Rapptz / discord.py

An API wrapper for Discord written in Python.
http://discordpy.rtfd.org/en/latest
MIT License
14.77k stars 3.75k forks source link

How to make case insensitive commands #1188

Closed bencerwn closed 6 years ago

bencerwn commented 6 years ago

I'm new to discord.py and have looked through the documentation, but I can't seem to figure out how to use the case_insensitive option. I know that there has already been a post on this, about a year ago, but as I've said, I found a "case_insensitive option" for commands in the API Reference -> Bot section and just can't get it to work. So far I've tried this:

from discord.ext import commands

bot = commands.Bot(command_prefix="!", case_insensitive=True)

Any help would be appreciated.

Vexs commented 6 years ago

Either you're using the async branch, which does not support case insensitive commands (although a number of hacks exist to get it to work), or you're using the rewrite branch and haven't updated it- case_insensitive was added rather recently.

Also possible is you're making some other error that can't be seen here; but that would be an issue with your code and not what you've presented.

bencerwn commented 6 years ago

How do I use the rewrite branch?

revsuine commented 6 years ago

@SlenderDoge RTFM: https://discordpy.readthedocs.io/en/rewrite/

Vexs commented 6 years ago

.....actually no. The docs for rewrite don't tell you how to install it because they're assuming it's already been released to pip. If you want to use the rewrite branch, it's mandatory that you be on the discord.py server (invite), as breaking changes are announced there and you're expected to keep up. It's also a massive breaking change so all d.py-related code will break, and need porting.

JennyDiscord commented 6 years ago

import discord from discord.ext import commands from discord.ext.commands import Bot

johann-lau commented 3 years ago
@bot.event
async def on_message(message):
  partitioned = message.partition(" ")
  await bot.process_commands(partitioned[0].lower()+" "+partitioned[2])