如何禁止提及(d.py)

时间:2018-02-03 19:24:22

标签: python discord discord.py

我有一个问题,我希望机器人能够错过提到的东西,并且我使用了这个:

    if message.content.lower().startswith((prefix) + 'ban'):
    user = client.get_mention
    client.ban(member=user)

(包含ctx的代码对我不起作用,因为我刚刚导入了这个:)

import discord
import asyncio
import random

我使用带变量的前缀:

(prefix) = '?'

1 个答案:

答案 0 :(得分:0)

You can use message.mentions:

@bot.event
async def on_message(message):
    if message.content.lower().startswith((prefix) + 'ban'):
        user = message.mentions[0]
        await bot.ban(user)

This works fine.