我正在尝试创建一个on_message事件,如果提到管理员,它将删除该消息,然后告诉他们他们不能这样做。这是我的代码
@bot.event
async def on_message(message):
admin_id = "<@496186362886619138>"
if admin_id in message.content:
await message.delete()
await message.channel.send("You can't do that")
await bot.process_commands(message)
答案 0 :(得分:2)
再看一下文档,发现mentioned_in()
和Client.fetch_user()
。
我的最终代码如下:
@bot.event
async def on_message(message):
# DELETE ADMIN MENTION
user = await bot.fetch_user(496186362886619138)
if user.mentioned_in(message):
await message.delete()
await message.channel.send("You can't do that")
await bot.process_commands(message)