【发布时间】:2022-01-26 21:08:17
【问题描述】:
所以我做了很多研究,找到了很多答案,但没有一个奏效。我试图让我的机器人按命令踢用户,但我不知道正确的语法。我们将不胜感激,谢谢。
intents = discord.Intents.all()
intents.members = True
bot = commands.Bot(command_prefix='#', intents=intents)
@bot.event
async def on_message(message):
if '#kick' in message.content.lower():
mod=discord.utils.get(message.author.guild.roles, name='Mod')
if mod in message.author.roles:
await message.channel.send('Who do you want to kick?')
try:
message=await bot.wait_for('message', check=lambda m: m.author==message.author and m.channel==message.channel, timeout=15)
except asyncio.TimeoutError:
await message.channel.send('Your victim got away')
else:
member2id=message.mentions[0].id
member2=await bot.fetch_user(member2id)
await member2.kick()
await message.channel.send(f'{message.content} was kicked')
else:
await message.channel.send('You dont have the permission to use that command')
bot.run('token')
【问题讨论】: