@client.command
@commands.has_permissions(kick_members=True)
async def kick(ctx, member: discord.Member, *, reason = None):
await member.kick(reason=reason)
await ctx.send(f'{member} Has been kicked')
I have my on_command_error
event,
@kick.error
async def on_kick_error(ctx, error):
if isinstance(error, commands.MissingRequiredArgument):
await ctx.send('Please specify an user')
elif isinstance(error, commands.CheckFailure):
await ctx.send('You do not have a perms to do that!')
else:
await ctx.send('There is some error')
and then i got error messages in discord
discord.py version 1.5
@commands.has_permissions(kick_members=True)
@client.command()
async def kick(ctx, user: discord.Member, *, reason="No reason provided"):
await user.kick(reason=reason)
kick = discord.Embed(title=f":boot: Kicked {user.name}!", description=f"Reason: {reason}\nBy: {ctx.author.mention}")
await ctx.message.delete()
await ctx.channel.send(embed=kick)
await user.send(embed=kick)
Does this work?
@client.command()
@commands.has_permissions(kick_members=True)
async def kick(ctx, member: typing.Optional[discord.Member], arg = None):
if arg == None:
await ctx.send("Kicked " + member.mention + ".")
else:
await ctx.send("Kicked " + member.mention + " for " + arg + ".")
await ctx.guild.kick(member)
This should work.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.