sir-lancebot
sir-lancebot copied to clipboard
Hardcoded prefixes in command help texts.
Description & Reasoning
In a few commands like hacktoberissues
, we've hardcoded .
as the prefix which won't make sense if a user is using a different prefix for the bot.
Expected Behaviour
The correct prefix should be displayed, by fetching the correct prefix through the constants module. Or perhaps we should re-word those help texts and remove the command invocation examples.
Would you like to implement a fix?
- [] I'd like to implement the bug fix
- [x] Anyone can implement the bug fix
I'm not entirely sure if there's a way to inject stuff into a help docstring, although that would be nice.
If we could use {prefix}
in the help text, and format it separately, that would work...
Perhaps an implementation in the bot.add_cog method which would format all of the function's docstrings.
simplified:
for func in cog.commands:
func.__doc__ = func.__doc__.format(prefix=self.prefix)
This would also allow adding other values too... hmmmm. If done in one way, could potentially add channels links in the docstrings.
Tried something personally, I kind of like this, but obviously shouldn't use this in a production environment, although all of the docstrings are controlled.
Once again, this is not likely the proper iterator, but meh
# bot.add_cog
# iterates through all of the commands of the cog and formats their docstrings
# this might need to be elsewhere or work differently, not sure
for func in cog.commands:
func.__doc__ = eval('f"""' + func.__doc__ + '"""',func.__globals__)
I don't think it's worth it, there are like 6 commands which provide command invocation examples, and they can easily be reworded.
Yeah, it was still an idea, probably not worth it, but an idea nonetheless