sir-lancebot icon indicating copy to clipboard operation
sir-lancebot copied to clipboard

Hardcoded prefixes in command help texts.

Open Qwerty-133 opened this issue 3 years ago • 4 comments

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

Qwerty-133 avatar Nov 06 '21 09:11 Qwerty-133

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.

onerandomusername avatar Dec 02 '21 03:12 onerandomusername

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__)

onerandomusername avatar Dec 02 '21 03:12 onerandomusername

I don't think it's worth it, there are like 6 commands which provide command invocation examples, and they can easily be reworded.

Qwerty-133 avatar Dec 02 '21 04:12 Qwerty-133

Yeah, it was still an idea, probably not worth it, but an idea nonetheless

onerandomusername avatar Dec 02 '21 05:12 onerandomusername