简体   繁体   English

如何使 discord 机器人接受多个前缀

[英]How to make a discord bot accept multiple prefixes

I am making a bot with multiple commands and for the sake of relevancy I want one command to be used with a + prefix and another one to be used with a !我正在制作一个带有多个命令的机器人,为了相关性,我希望一个命令与+前缀一起使用,另一个与! prefix.字首。

I have a config file with a dictionary that I imported so I could use those to define my prefix.我有一个配置文件,其中包含我导入的字典,因此我可以使用它们来定义我的前缀。

Here is what my prefix bot thing is:这是我的前缀机器人:

bot = commands.Bot(command_prefix=BOT['DEFAULT_PREFIX'])

I tried making another prefix in the config file so it has two of them:我尝试在配置文件中添加另一个前缀,所以它有两个:

'DEFAULT_PREFIX': '+',
'SPECIAL_PREFIX': '!',

I could add a second variable such as client = command.Bot... but I already tried that and the default prefix ( + ) worked fine being used in my cogs.py but the special prefix ( ! ) didn't work with my report command.我可以添加第二个变量,例如 client = command.Bot... 但我已经尝试过了,默认前缀 ( + ) 在我的 cogs.py 中使用得很好,但特殊前缀 ( ! ) 不适用于我的report命令。

Is it possible to somehow have two available prefixes for commands to use?是否有可能以某种方式有两个可用的前缀供命令使用? Or even better , to assign a custom prefix to one decorator?或者更好的是,为一个装饰器分配一个自定义前缀? (I have tried doing bot.command(command_prefix='!') but had no luck). (我试过做bot.command(command_prefix='!')但没有运气)。

Thanks!谢谢!

bot = commands.Bot(command_prefix=['first prefix','second prefix'])

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当我使用函数获取前缀时,如何让我的 Discord 机器人同时响应自定义前缀和提及? - How to make my Discord bot respond to both custom prefixes and mentions when I use a function to get the prefix? Discord.py 如何让机器人回复多条消息 - Discord.py how to make bot reply to multiple messages 如何使 discord 机器人响应其他消息中的不同(多个)关键字? - How to make the discord bot respond different (multiple) keywords in the others message? 如何使 Discord 机器人异步等待对多条消息的反应? - How to Make a Discord Bot Asynchronously Wait for Reactions on Multiple Messages? 如何制作一个 Discord Bot 可以接受来自 Python 的 arguments 的什么消息发送给谁并能够关闭自己? - How to make a Discord Bot that can accept arguments from Python of what message to send to who and be able to close itself? 如何让一个机器人在不同的服务器上工作并具有不同的前缀? - How to make one bot work on different servers and have different prefixes? 如何制作 discord.py 自定义前缀系统? - How to make discord.py custom prefixes system? 如何让 discord 机器人使用其他 discord 机器人命令? - How to make a discord bot use other discord bot commands? 在多个通道中制作 discord 机器人类型 - Make a discord bot type in multiple channels 在 discord.py 中为 discord 机器人设置有效前缀 - Setting valid prefixes for the discord bot in discord.py
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM