Discord.py: Add an option to make commands case insensitive

Created on 29 Jan 2017  路  7Comments  路  Source: Rapptz/discord.py

All my commands are lower case right now, but some people on the guilds it's on are used to commands starting with an upper case character, so it would be useful if I could make my bot ignore case (for the command names, not the arguments), preferably globally. I think this should be quite simple to implement, but doing it with an override in my own bot would mean duplicating ~50 lines of code.

Most helpful comment

I won't add this natively. However in the rewrite supporting this is simple from the user end:

async def on_message(self, message):
  ctx = await self.get_context(message)
  if ctx.prefix is not None:
    ctx.command = self.commands.get(ctx.invoked_with.lower())
    await self.invoke(ctx)

I just don't care enough to add since it's 1) wrong to do so, 2) performance penalty when 99% don't need it.

All 7 comments

I'm not implementing this (or ever plan to). Case insensitivity only makes sense in English, which is a common language admittedly but the library does not assume to be English only in its interfaces.

Outside of that, I don't like the idea of case insensitive commands since it's just a way to give users a lazy way out.

I'm not implementing this (or ever plan to). Case insensitivity only makes sense in English, which is a common language admittedly but the library does not assume to be English only in its interfaces.

Would this be a problem if it was an option, like the command prefix?

Outside of that, I don't like the idea of case insensitive commands since it's just a way to give users a lazy way out.

Haha, ok. Makes sense.

You could, instead of using the command handler in d.py, write your own to call from on_message and make it case insensitive there. So it's not impossible.

@Soliel Yes, that's exactly what I'm planning on doing. It's not a big issue, I just thought it would be worth seeing if it could be implemented here to avoid some code duplication and possible future compatibility issues. Thanks for the suggestion though!

Since @Rapptz has stated they have no intentions of implementing this, I suppose I should close this issue. If not, feel free to re-open.

I won't add this natively. However in the rewrite supporting this is simple from the user end:

async def on_message(self, message):
  ctx = await self.get_context(message)
  if ctx.prefix is not None:
    ctx.command = self.commands.get(ctx.invoked_with.lower())
    await self.invoke(ctx)

I just don't care enough to add since it's 1) wrong to do so, 2) performance penalty when 99% don't need it.

Ok, thanks!

how do we implement this code?
edit: Why did this get, loads of Thumbs Down?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jzburda picture jzburda  路  3Comments

Yolotroll101 picture Yolotroll101  路  3Comments

superloach picture superloach  路  3Comments

Spyder-exe picture Spyder-exe  路  3Comments

ghost picture ghost  路  3Comments