Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Update example-bot.py
  • Loading branch information
BobDotCom authored May 11, 2021
commit 4d07f14f9eb0e1ccd55040ab1a2477f077df7bbd
15 changes: 11 additions & 4 deletions python/discord.py/example-bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down