@client.event
async def on_message(message):
if message.content == "fase":
channel = (mychannel)
await message.channel.send("Fase 1")
我正在尝试使message.content检测多个单词并发送相同的message.channel.send 我试过了
if message.content.lower() == "fase", "estagio", "missao", "sala":
if message.content.lower() == ("fase", "estagio", "missao", "sala"):
if message.content.lower() == "fase" or "estagio" or "missao" or "sala":
if message.content.lower() == ("fase" or "estagio" or "missao" or "sala"):
我读了这篇文章:How do I allow for multiple possible responses in a discord.py command?
这是同样的问题,但在他的情况下,这是一个案例敏感的问题,我已经在我的代码中修复
多个单词的第二个代码是:
bot = commands.Bot(command_prefix='!', case_insensitive=True)
@bot.command(aliases=['info', 'stats', 'status'])
async def about(self):
# your code here
我这样做了,并且得到了很多错误,使bot甚至无法运行(我使用PyCharm与discord.py1.4.1和python 3.6配合使用):
#import and token things up here
bot = commands.Bot(command_prefix='i.')
@bot.command(aliases=['fase', 'estagio', 'missao', 'sala']) #'@' or 'def' expected
async def flame(self): #Unexpected indent // Unresolved reference 'self'
if message.content(self): #Unresolved reference 'message'
await message.send("Fase 1") #Unresolved reference 'message' // Statement expected, found Py:DEDENT
我能做些什么来修复它
下面是如何使用^{} 扩展名:
每个命令都有以下共同点:
bot.command()
装饰器创建的李>ctx
(第一个参数)将是一个^{然后,
ctx
允许您使用一些快捷方式:message.channel.send()
变成ctx.send()
message.author
变成ctx.author
message.channel
变成ctx.channel
命令参数也更易于使用:
相关问题 更多 >
编程相关推荐