-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDiscordMod.py
More file actions
58 lines (46 loc) · 1.79 KB
/
DiscordMod.py
File metadata and controls
58 lines (46 loc) · 1.79 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import discord
from discord.ext import commands
client = commands.Bot(command_prefix='!')
@client.event
async def on_ready():
print('Bot is ready.')
@client.command()
async def kick(ctx, member : discord.Member, *, reason=None):
await member.kick(reason=reason)
await ctx.send(f'{member} has been kicked.')
@client.command()
async def ban(ctx, member : discord.Member, *, reason=None):
await member.ban(reason=reason)
await ctx.send(f'{member} has been banned.')
@client.command()
async def unban(ctx, *, member):
banned_users = await ctx.guild.bans()
member_name, member_discriminator = member.split('#')
for ban_entry in banned_users:
user = ban_entry.user
if (user.name, user.discriminator) == (member_name, member_discriminator):
await ctx.guild.unban(user)
await ctx.send(f'{user.mention} has been unbanned.')
return
@client.command()
async def mute(ctx, member : discord.Member):
muted_role = ctx.guild.get_role(ROLE_ID_HERE)
await member.add_roles(muted_role)
await ctx.send(f'{member.mention} has been muted.')
@client.command()
async def unmute(ctx, member : discord.Member):
muted_role = ctx.guild.get_role(ROLE_ID_HERE)
await member.remove_roles(muted_role)
await ctx.send(f'{member.mention} has been unmuted.')
@client.command()
async def clear(ctx, amount=5):
await ctx.channel.purge(limit=amount)
@client.command()
async def tempmute(ctx, member : discord.Member, time, *, reason=None):
muted_role = ctx.guild.get_role(ROLE_ID_HERE)
await member.add_roles(muted_role)
await ctx.send(f'{member.mention} has been muted for {time}.')
await asyncio.sleep(time)
await member.remove_roles(muted_role)
await ctx.send(f'{member.mention} has been unmuted.')
client.run('TOKEN_HERE')