Usually when you create a command with the discord.py module, you do something like this:
@commands.command(name="my_command", pass_context=True, aliases=["mc"])
def my_command(ctx):
#Do some command action here
I want to be able to use my Discord bot to moderate commands so that commands can only be used in designated channels, e.g. "my_command" can only be used in #general.
One easy way to get the command name would be to do something like this:
def get_command_name(message, prefix):
command = message.split()[0].strip(prefix)
It would be nicer if I could used something like message.command_used
to get the command, but I checked the documentation and there doesn't seem to be anything like that. Is there a way to get the command used from context
rather than getting the command from string manipulation?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…