-
Notifications
You must be signed in to change notification settings - Fork 2
/
modtools.py
78 lines (64 loc) · 2.71 KB
/
modtools.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
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import discord
import asyncio
import checks
async def purge(message, client):
while True:
await client.send_typing(message.channel)
if not checks.has_msg(message):
await client.send_message(message.channel, 'You need the "Manage Messages" permission to call this command.')
break
parse = message.content.split()
try:
name = parse[1]
except IndexError:
await client.send_message(message.channel, 'No name specified')
break
user = discord.utils.find(lambda o: o.display_name.lower() == name, message.channel.server.members)
def is_usr(message):
return message.author == user
try:
param = int(parse[2])
except IndexError:
param = 100
deleted = await client.purge_from(message.channel, limit=param, check=is_usr)
await client.send_message(message.channel, 'Done deleting {0} messages by {1}.'.format(len(deleted),user.display_name))
break
async def mvmembers(message, client):
while True:
await client.send_typing(message.channel)
if not checks.has_move(message):
await client.send_message(message.channel, 'You need the "Move Members" permission to call this command.')
break
usr_error = 'Please provide users to move.'
if '"' in message.content:
parse = message.content.split('"')
for i in range(0, len(parse)):
parse[i] = parse[i].strip()
cname = parse[1]
if parse[2] != '':
members = parse[2].split(';')
else:
await client.send_message(message.channel, usr_error)
break
else:
parse = message.content.split()
try:
cname = parse[1]
except IndexError:
await client.send_message(message.channel, 'Please provide a name for the channel to move to.')
break
try:
members = parse[2].split(';')
except IndexError:
await client.send_message(message.channel, usr_error)
break
channel = discord.utils.get(message.server.channels, name=cname, type=discord.ChannelType.voice)
if channel != None:
for member in members:
user = discord.utils.find(lambda o: member.lower() in o.display_name.lower(), message.channel.server.members)
await client.move_member(user, channel)
else:
await client.send_message(message.channel, 'Channel not found.')
break
await client.send_message(message.channel, 'Successfully moved users.')
break