Python 这是一种对命令使用前缀和ping的方法吗?

Python 这是一种对命令使用前缀和ping的方法吗?,python,discord.py,discord.py-rewrite,Python,Discord.py,Discord.py Rewrite,我决定创建一个更有用的bot,我想让命令以两种方式激活:x.,这是默认前缀;@xubot,也就是ping bot 我的命令如下: #旁注:这不是实际的命令;) pref='x.' 客户端=Bot(命令前缀=pref) @client.command(name=“example”, 通过(ctx=True) 异步定义示例(ctx,type=”“): #使用“type”参数,以便我可以检查它是否为“help”,并显示一个嵌入 等待ctx.send(“测试!”) 但是,我只能使用前缀x激活命令。

我决定创建一个更有用的bot,我想让命令以两种方式激活:
x.
,这是默认前缀;
@xubot
,也就是ping bot

我的命令如下:


#旁注:这不是实际的命令;)
pref='x.'
客户端=Bot(命令前缀=pref)
@client.command(name=“example”,
通过(ctx=True)
异步定义示例(ctx,type=”“):
#使用“type”参数,以便我可以检查它是否为“help”,并显示一个嵌入
等待ctx.send(“测试!”)
但是,我只能使用前缀
x激活命令。

我想让
@xubot example
运行该命令,以及
x.example
。有没有办法做到这一点?

将函数作为前缀传递:

from discord.ext.commands import Bot, when_mentioned_or

bot = Bot(command_prefix=when_mentioned_or("x."))

...
将函数作为前缀传递:

from discord.ext.commands import Bot, when_mentioned_or

bot = Bot(command_prefix=when_mentioned_or("x."))

...