-
Notifications
You must be signed in to change notification settings - Fork 0
/
moderation.py
33 lines (20 loc) · 1.18 KB
/
moderation.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#At the start we import the modules
import discord #We import discord to make connection with discord API
from discord.ext import commands #We import commands from discord.ext in order to define commands
client = commands.Bot(command_prefix='!') #You can always change the ! to any prefix you want
#Moderation Commands:
@client.command() #Ban command
async def ban(ctx, member : discord.Member, *, reason=None): #Reason = None because if there is no reason given it doesn't show an error
await member.ban(reason=reason)
await ctx.send(f"Banned {member.mention}")
#Kick command is pretty much same as the ban command but here is the code:
@client.command() #Kick command
async def kick(ctx, member : discord.Member, *, reason=None):
await member.kick(reason=reason)
await ctx.send(f"Kicked {member.mention}")
#Warn command is one of the easiest moderation commands you can do!
@client.command() #Warn command
async def warn(ctx, member : discord.Member, *, reason=None):
await member.send(f"You have been warned in {ctx.guild.name} for : {reason}")
await ctx.send(f"Warned {member.mention} for : {reason}")
client.run('bot_token') #Replace "bot_token" with your bot's token