我已经尝试过了,但是没有用(我在错误行上做了标记),希望您能对我有所帮助
@bot.event
async def on_message(message):
if 'https://' in message.content.lower():
if(message.channel.name.startswith("ticket")):
print("")
else:
>>>>>>if(has_permissions(manage_messages = True))
print("")
else:
await message.delete()
embed = discord.Embed(title=f'Message Deleted',description=f'**User** : ``{str(message.author)}``\n**Reason** : ``Url/Link detected in the Message``', color=0xFF0000 )
await message.channel.send(embed=embed)
答案 0 :(得分:2)
您有缩进错误(您必须在第一个else
之后添加一个缩进):
@bot.event
async def on_message(message):
if 'https://' in message.content.lower():
if(message.channel.name.startswith("ticket")):
print("")
else:
if(has_permissions(manage_messages = True))
print("")
else:
await message.delete()
embed = discord.Embed(title=f'Message Deleted',description=f'**User** : ``{str(message.author)}``\n**Reason** : ``Url/Link detected in the Message``', color=0xFF0000 )
await message.channel.send(embed=embed)
要检查代码的权限,可以使用Member.guild_permissions
:
if ctx.author.guild_permissions.manage_messages:
print('You have permission')