discord bot python 中的语法无效
Invalid syntax in discord bot python
我在 python 中制作了一个 discord 机器人,它运行良好。但是现在我想实现一个坏词过滤器。如果他或她说了脏话,机器人会警告他或她。我也希望它被嵌入。错误在最后一行(即 await message.channel.send(embed=embedwarn)。它说语法无效,但我找不到它。
#bad words for the bot to detect
bad_words = ["Word1", "Word2"]
#send person a warning message
@bot.event
async def on_message(message):
if message.author == bot.user:
return
if any(word in message.content.lower() for word in bad_words):
embedwarn=discord.Embed(title="Warning", description=f"Server: {member.name} \nReason: bad word")
await message.channel.send(embed=embedwarn)
这部分代码没有正确缩进。
if any(word in message.content.lower() for word in bad_words):
embedwarn=discord.Embed(title="Warning", description=f"Server: {member.name} \nReason: bad word")
await message.channel.send(embed=embedwarn)
我在 python 中制作了一个 discord 机器人,它运行良好。但是现在我想实现一个坏词过滤器。如果他或她说了脏话,机器人会警告他或她。我也希望它被嵌入。错误在最后一行(即 await message.channel.send(embed=embedwarn)。它说语法无效,但我找不到它。
#bad words for the bot to detect
bad_words = ["Word1", "Word2"]
#send person a warning message
@bot.event
async def on_message(message):
if message.author == bot.user:
return
if any(word in message.content.lower() for word in bad_words):
embedwarn=discord.Embed(title="Warning", description=f"Server: {member.name} \nReason: bad word")
await message.channel.send(embed=embedwarn)
这部分代码没有正确缩进。
if any(word in message.content.lower() for word in bad_words):
embedwarn=discord.Embed(title="Warning", description=f"Server: {member.name} \nReason: bad word")
await message.channel.send(embed=embedwarn)