本文介紹了是一種對命令使用前綴和 ping 的方法嗎?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我決定創建一個更有幫助的機器人,并且我想允許以兩種方式激活命令:x.
是默認前綴和 @xubot
,也就是 ping 機器人.
I've decided to create a much more helpful bot, and I would like to allow the commands to be activated in two ways: x.
which is the default prefix and @xubot
, aka pinging the bot.
我的命令是這樣設置的:
My commands are set out like this:
# sidenote: this is not an actual command ;)
pref = 'x.'
client = Bot(command_prefix=pref)
@client.command(name="example",
pass_ctx=True)
async def example(ctx, type=""):
# the "type" parameter is used so i can check if it is "help" and display an embed
await ctx.send("Test!")
但是,我只能激活帶有前綴 x.
However, I can only activate the commands with my prefix, x.
我希望 @xubot example
以及 x.example
運行命令.有沒有辦法做到這一點?
I would like for @xubot example
to run the command, as well as x.example
. Is there a way to achieve this?
推薦答案
通過commands.when_提到_or
用作您的前綴:
Pass the commands.when_mentioned_or
function as your prefix:
from discord.ext.commands import Bot, when_mentioned_or
bot = Bot(command_prefix=when_mentioned_or("x."))
...
這篇關于是一種對命令使用前綴和 ping 的方法嗎?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!