-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplugin-dmsg.py
36 lines (30 loc) · 1.1 KB
/
plugin-dmsg.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
from xander_plugin import *
from traceback import format_exc
def onload():
help_menu_edit("!dmsg", "A command that deletes all of a user id's messages.")
log("Delete messages plugin loaded!")
user = None
def check(ctx):
global user
return ctx.author.id == user.id
async def onmessage(message):
global user
count = 0
print(message.guild.channels)
if message.content.startswith("!dmsg "):
user = message.guild.get_member(int(message.content[6:]))
if user:
for channel in message.guild.channels:
if not type(channel) is discord.CategoryChannel:
while True:
deleted = await channel.purge(check=check)
for msg in deleted:
count += 1
log(f"Deleted {count} messages so far")
if deleted == []:
break
await message.channel.send("Purged all messages from given user")
return False
return True
def onexit():
log("Delete messages plugin exit run.")