简体   繁体   English

Discord.py 重写踢/禁止命令

[英]Discord.py rewrite kick/ban commands

So, I've been learning how to make a discord bot lately and i want to make a kick/ban command.所以,我最近一直在学习如何制作一个不和谐的机器人,我想制作一个踢/禁止命令。 The code i have for them hasn't been working and all it does is sit there and do nothing.我为他们准备的代码一直没有工作,它所做的只是坐在那里什么也不做。 Its been really annoying.它真的很烦人。 I can't really do much on it everyday because of school and then a half hour drive home whiile doing thing while im still in town but this is the code:由于学校的原因,我每天都不能做太多事情,然后在我还在城里的时候开车回家半小时,但这是代码:

@client.command()
async def kick(ctx, member: discord.Member,*,reason=None):
  await member.kick(reason=reason)

@client.command()
async def ban(ctx, member: discord.Member,*,reason=None):
  await member.ban(reason=reason)

If the role of the user that you're trying to kick is higher than the role of the bot, then the bot cannot kick that user.如果您尝试踢的用户的角色高于机器人的角色,则机器人无法踢该用户。 Try putting the bot's role at the top of the roles, and give it administrator privileges.尝试将机器人的角色放在角色的顶部,并为其授予管理员权限。 Also, try using @commands.has_permissions() or @commands.has_roles() to avoid unauthorized users from kicking and banning random people另外,尝试使用@commands.has_permissions() 或@commands.has_roles() 来避免未经授权的用户踢和禁止随机人

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM