【发布时间】:2021-01-29 11:31:50
【问题描述】:
@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?
这是完全相同的问题,但在他的情况下,这是我已经在我的代码中修复的 CaseSensitiveProblem
多个单词的第二个代码是:
bot = commands.Bot(command_prefix='!', case_insensitive=True)
@bot.command(aliases=['info', 'stats', 'status'])
async def about(self):
# your code here
我做到了,但出现了很多错误,导致机器人甚至无法运行(我将 PyCharm 与 discord.py 1.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
我能做些什么来解决它?
【问题讨论】:
-
if message.content.lower() in ("fase", "estagio", "missao", "sala") -
我忘记了“in”的存在,谢谢你帮了我很多。
标签: python discord.py