From 22f46d675035e8708d72f317cf6fdf6618e48657 Mon Sep 17 00:00:00 2001 From: Sengolda <79252176+Sengolda@users.noreply.github.com> Date: Tue, 11 May 2021 18:26:20 +0530 Subject: [PATCH 1/2] Update example-bot.py --- python/discord.py/example-bot.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/python/discord.py/example-bot.py b/python/discord.py/example-bot.py index ee85772..1876a78 100644 --- a/python/discord.py/example-bot.py +++ b/python/discord.py/example-bot.py @@ -33,9 +33,20 @@ async def _purge(ctx, *, amount=1): # set a default amount, which is 1 description=f"Purged {amount} messages!") await ctx.send(embed=embed) +@commands.command(name="kick", aliases=['k']) +@commands.has_permissions(kick_members=True) # This will check the permissions the person that is trying to kick the member has (You can change this to any perm to want but make sure it has the =True at the end) +async def _kick(ctx, member:discord.Member=None,*, reason=None): + """ + A command that kicks members + """ + await member.kick(reason=reason) # This is the line that kicks the member + embed = discord.Embed(title="Done!", description=f"{member.mention} has been kicked for {reason} !") + await ctx.send(embed=embed) + await member.send(embed=embed) # This will send the member a message in their dms (direct messages). bot.add_command(_ping) bot.add_command(_purge) +bot.add_command(_kick) # you can uncomment the line below if you have the api-cog-example cog already From 4d07f14f9eb0e1ccd55040ab1a2477f077df7bbd Mon Sep 17 00:00:00 2001 From: BobDotCom <71356958+BobDotCom@users.noreply.github.com> Date: Tue, 11 May 2021 11:41:03 -0500 Subject: [PATCH 2/2] Update example-bot.py --- python/discord.py/example-bot.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/python/discord.py/example-bot.py b/python/discord.py/example-bot.py index 1876a78..eecd649 100644 --- a/python/discord.py/example-bot.py +++ b/python/discord.py/example-bot.py @@ -24,6 +24,8 @@ async def _ping(ctx): @commands.command(name="purge", aliases=['clear']) +@commands.has_permissions(manage_messages=True) # check for the correct perms +@commands.bot_has_permissions(manage_messages=True) async def _purge(ctx, *, amount=1): # set a default amount, which is 1 """ A command that clears messages @@ -33,16 +35,21 @@ async def _purge(ctx, *, amount=1): # set a default amount, which is 1 description=f"Purged {amount} messages!") await ctx.send(embed=embed) + @commands.command(name="kick", aliases=['k']) -@commands.has_permissions(kick_members=True) # This will check the permissions the person that is trying to kick the member has (You can change this to any perm to want but make sure it has the =True at the end) +@commands.has_guild_permissions(kick_members=True) # check for the correct perms +@commands.bot_has_guild_permissions(kick_members=True) async def _kick(ctx, member:discord.Member=None,*, reason=None): """ A command that kicks members """ - await member.kick(reason=reason) # This is the line that kicks the member - embed = discord.Embed(title="Done!", description=f"{member.mention} has been kicked for {reason} !") + await member.send(f'You have been kicked from **{server.name}** for `{reason}`') + await member.kick(reason=reason) # This is the line that kicks the member + embed = discord.Embed( + title="Kicked Member", + description=f"{member.mention} has been kicked for `{reason}`") await ctx.send(embed=embed) - await member.send(embed=embed) # This will send the member a message in their dms (direct messages). + bot.add_command(_ping) bot.add_command(_purge)