-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhello.py
More file actions
74 lines (54 loc) · 2.2 KB
/
Copy pathhello.py
File metadata and controls
74 lines (54 loc) · 2.2 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import discord
import asyncio
import sys
# INPUT
TOKEN = input("DISCORD TOKEN: ").strip().replace('"', '')
CHANNEL_ID = int(input("CHANNEL ID: ").strip())
MESSAGE_ID = int(input("MESSAGE ID: ").strip())
def log(msg):
print(f"> {msg}")
class MyClient(discord.Client):
def __init__(self, channel_id, message_id, *args, **kwargs):
super().__init__(*args, **kwargs)
self.channel_id = channel_id
self.message_id = message_id
async def on_ready(self):
log(f"LOGGED IN AS: {self.user}")
try:
log("FETCHING CHANNEL")
channel = self.get_channel(self.channel_id)
if not channel:
channel = await self.fetch_channel(self.channel_id)
log(f"CHANNEL: {channel.name}")
log("FETCHING MESSAGE..")
msg = await channel.fetch_message(self.message_id)
log(f"MESSAGE FOUND: {msg.content[:30]}...")
unique_users = set()
log("SCRAPPING REACTIONS..")
for reaction in msg.reactions:
emoji = reaction.emoji if isinstance(reaction.emoji, str) else reaction.emoji.name
log(f"EMOJI: {emoji}")
async for user in reaction.users(limit=None):
user_str = f"{user.name} | ID: {user.id}"
unique_users.add(user_str)
await asyncio.sleep(0.01)
filename = f"reactions_{self.message_id}.txt"
log(f"SAVING: {filename}")
with open(filename, "w", encoding="utf-8") as f:
f.write("-- MADE BY THENOTFUEL --\n")
f.write("https://github.com/facepunchh\n")
f.write("Discord: @face.punch\n")
f.write("=" * 30 + "\n")
for u in unique_users:
f.write(u + "\n")
log("DONE.")
log(f"TOTAL USERS: {len(unique_users)}")
except Exception as e:
log(f"ERROR: {e}")
await self.close()
client = MyClient(CHANNEL_ID, MESSAGE_ID)
try:
client.run(TOKEN, reconnect=False)
except KeyboardInterrupt:
log("EXITED BY USER")
sys.exit(0)