嘿,我尝试了这个,但是它没有用,机器人仍然在任何频道idk中都回答了,为什么如果可以的话请帮助我会很棒
@bot.event
async def on_message(message):
if 'hey' in message.content.lower():
if 'i' in message.content.lower():
message.channel.name.startswith("ticket")
embed = discord.Embed(title=f'test',description=f'**test** : ``test``', color=0x001fff )
await message.channel.send(embed=embed)
if 'test' in message.content.lower():
message.channel.name.startswith("ticket")
embed = discord.Embed(title=f'test',description=f'**test** : ``hi``', color=0x001fff )
await message.channel.send(embed=embed)
这是我的命令
答案 0 :(得分:0)
您在if语句外使用了message.channel.name.startswith("ticket")
。这不会做任何事情。
用if(message.channel.name.startswith("ticket")):
替换实际上会检查频道名称是否以“票证”开头。并且您需要缩进应执行的代码。在下面您可以看到我已经为您修复了代码。
@bot.event
async def on_message(message):
if 'hey' in message.content.lower():
if 'i' in message.content.lower():
if(message.channel.name.startswith("ticket")): #This line
embed = discord.Embed(title=f'test',description=f'**test** : ``test``', color=0x001fff )
await message.channel.send(embed=embed)
if 'test' in message.content.lower():
message.channel.name.startswith("ticket")
embed = discord.Embed(title=f'test',description=f'**test** : ``hi``', color=0x001fff )
await message.channel.send(embed=embed)