Skip to content
Open
Changes from all commits
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
18 changes: 18 additions & 0 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 @@ -34,8 +36,24 @@ async def _purge(ctx, *, amount=1): # set a default amount, which is 1
await ctx.send(embed=embed)


@commands.command(name="kick", aliases=['k'])
@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.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)


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
Expand Down