【发布时间】:2021-01-07 01:03:08
【问题描述】:
通常当您使用 discord.py 模块创建命令时,您会执行以下操作:
@commands.command(name="my_command", pass_context=True, aliases=["mc"])
def my_command(ctx):
#Do some command action here
我希望能够使用我的 Discord 机器人来调节命令,以便命令只能在指定频道中使用,例如“my_command”只能在#general中使用。
获取命令名称的一种简单方法是执行以下操作:
def get_command_name(message, prefix):
command = message.split()[0].strip(prefix)
如果我可以使用message.command_used 之类的东西来获取命令会更好,但我检查了文档,似乎没有类似的东西。有没有办法从context 获取使用的命令,而不是从字符串操作中获取命令?
【问题讨论】:
标签: python python-3.x discord.py-rewrite