forked from dfrnoch/discord-sniper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.py
428 lines (423 loc) · 20.9 KB
/
Main.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
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
import json
import re
import requests
from time import sleep
import colorama
import ctypes
import datetime
import discord
import os
import pyPrivnote as pn
from colorama import Fore
from discord.ext import (
commands
)
from win10toast import ToastNotifier
toaster = ToastNotifier()
with open('config.json') as f:
config = json.load(f)
onalt = config.get("on-alt")
token = config.get('token')
rtoken = config.get("reedem-token")
edelay = config.get("delay-enabled")
delay = config.get("delay")
giveaway_sniper = config.get('giveaway_sniper')
slotbot_sniper = config.get('slotbot_sniper')
nitro_sniper = config.get('nitro_sniper')
privnote_sniper = config.get('privnote_sniper')
notification = config.get('notification')
webhooknotification = config.get('webhook-notification')
webhook = config.get('webhook')
sname = ""
stag = ""
if os.path.isfile('tried-nitro-codes.txt'):
with open("tried-nitro-codes.txt", "r") as fp:
usedcodes = json.load(fp)
else:
usedcodes = []
def codestart():
global sname, stag
if onalt:
headers = {
'Authorization': rtoken,
'Content-Type': 'application/json'
}
res = requests.get('https://canary.discordapp.com/api/v6/users/@me', headers=headers)
res = res.json()
sname = res['username']
stag = res['discriminator']
if onalt:
onaltt = " "
else:
if sname != "":
onaltt = f"{Fore.LIGHTBLACK_EX}({sname}#{stag})"
else:
onaltt = " "
if edelay:
ddelay = f"{Fore.LIGHTBLACK_EX}({delay} seconds)"
else:
ddelay = " "
if giveaway_sniper:
giveaway = "Active"
else:
giveaway = "Disabled"
if nitro_sniper:
nitro = "Active"
else:
nitro = "Disabled"
if notification:
notify = "Active"
else:
notify = "Disabled"
if privnote_sniper:
privnote = "Active"
else:
privnote = "Disabled"
print(f'''{Fore.RESET}
{Fore.GREEN}╔═╗ ╔╗╔ ╦ ╦═╗ ╦═╗ ╦═╗
{Fore.LIGHTBLACK_EX}╚═╗ ║║║ ║ ╠═╝ ╠╣ ╠╦╝
{Fore.WHITE}╚═╝ ╝╚╝ ╩ ╩ ╩═╝ ╩╚═
{Fore.WHITE}Logged User - {Fore.GREEN}{Sniper.user.name}#{Sniper.user.discriminator}
{Fore.WHITE}Nitro Sniper - {Fore.GREEN}{nitro} {onaltt}
{Fore.WHITE}Giveaway Sniper - {Fore.GREEN}{giveaway} {ddelay}
{Fore.WHITE}Privnote Sniper - {Fore.GREEN}{privnote}
{Fore.WHITE}Notification - {Fore.GREEN}{notify}
''' + Fore.RESET)
colorama.init()
Sniper = commands.Bot(
description='Discord Sniper',
command_prefix="",
self_bot=True
)
def Clear():
os.system('cls')
Clear()
def Init():
if onalt:
if config.get('token') == config.get('reedem-token'):
Clear()
print(f"\n\n{Fore.RED}Error {Fore.WHITE}Alt token connot be same as Reedem Token!" + Fore.RESET)
exit()
if rtoken == "token-here":
Clear()
print(f"\n\n{Fore.RED}Error {Fore.WHITE}You didnt put your alt token in the config.json file" + Fore.RESET)
exit()
else:
headers = {
'Authorization': rtoken,
'Content-Type': 'application/json'
}
r = requests.get('https://canary.discordapp.com/api/v6/users/@me', headers=headers)
if r.status_code == 200:
pass
else:
print(f"\n\n{Fore.RED}Error {Fore.WHITE}Alt Token is invalid" + Fore.RESET)
exit()
if config.get('token') == "token-here":
Clear()
print(f"\n\n{Fore.RED}Error {Fore.WHITE}You didnt put your token in the config.json file" + Fore.RESET)
exit()
else:
token = config.get('token')
try:
Sniper.run(token, bot=False, reconnect=True)
os.system(f'title Discord Sniper')
except discord.errors.LoginFailure:
print(f"\n\n{Fore.RED}Error {Fore.WHITE}Token is invalid" + Fore.RESET)
exit()
@Sniper.event
async def on_command_error(ctx, error):
error_str = str(error)
error = getattr(error, 'original', error)
if isinstance(error, commands.CommandNotFound):
return
elif isinstance(error, discord.errors.Forbidden):
print(f"{Fore.RED}Error: {Fore.WHITE}Discord error: {error}" + Fore.RESET)
else:
print(f"{Fore.RED}Error: {Fore.WHITE}{error_str}" + Fore.RESET)
@Sniper.event
async def on_message(message):
global note_text
def GiveawayInfo():
print(
f"{Fore.LIGHTBLACK_EX} Server: {Fore.WHITE}{message.guild}"
f"\n{Fore.LIGHTBLACK_EX} Channel: {Fore.WHITE}{message.channel}"
+ Fore.RESET)
def GiveawayDelayInfo():
print(
f"{Fore.LIGHTBLACK_EX} Server: {Fore.WHITE}{message.guild}"
f"\n{Fore.LIGHTBLACK_EX} Channel: {Fore.WHITE}{message.channel}"
f"\n{Fore.LIGHTBLACK_EX} Delay: {Fore.WHITE}{delay} seconds"
+ Fore.RESET)
def NitroInfo(elapsed, code):
print(
f"{Fore.LIGHTBLACK_EX} Server: {Fore.WHITE}{message.guild}"
f"\n{Fore.LIGHTBLACK_EX} Channel: {Fore.WHITE}{message.channel}"
f"\n{Fore.LIGHTBLACK_EX} Author: {Fore.WHITE}{message.author}"
f"\n{Fore.LIGHTBLACK_EX} Author ID: {Fore.WHITE}{message.author.id}"
f"\n{Fore.LIGHTBLACK_EX} Elapsed: {Fore.WHITE}{elapsed}s"
f"\n{Fore.LIGHTBLACK_EX} Code: {Fore.WHITE}{code}"
+ Fore.RESET)
def PrivnoteInfo(elapsed, code):
print(
f"\n{Fore.LIGHTBLACK_EX} Server: {Fore.WHITE}{message.guild}"
f"\n{Fore.LIGHTBLACK_EX} Channel: {Fore.WHITE}{message.channel}"
f"\n{Fore.LIGHTBLACK_EX} Elapsed: {Fore.WHITE}{elapsed}s"
f"\n{Fore.LIGHTBLACK_EX} Content: {Fore.WHITE}Privnote content is saved in Privnote/{code}.txt"
+ Fore.RESET)
time = datetime.datetime.now().strftime("%H:%M")
if 'discord.gift/' in message.content:
if nitro_sniper:
start = datetime.datetime.now()
code = re.findall("discord[.]gift/(\w+)", message.content)
for code in code:
if len(code) == 16 or len(code) == 24:
if code not in usedcodes:
usedcodes.append(code)
with open("tried-nitro-codes.txt", "w") as fp:
json.dump(usedcodes, fp)
if onalt:
headers = {'Authorization': rtoken}
else:
headers = {'Authorization': token}
r = requests.post(
f'https://discordapp.com/api/v6/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.RED}{time} - Nitro is Already Redeemed" + Fore.RESET)
NitroInfo(elapsed, code)
elif 'subscription_plan' in r:
print(""
f"\n{Fore.GREEN}{time} - Nitro Successfuly Claimed!" + Fore.RESET)
NitroInfo(elapsed, code)
if notification:
toaster.show_toast("Sniper",
"Nitro Claimed! Look into console",
icon_path="./drop.ico",
duration=7)
if webhooknotification:
data = {
"embeds": [{
"title": "Successfully Sniped Nitro Gift!",
"description": f"Congratulations, good job! You can view your Nitro Gifts in your inventory.\n\nNitro Gift Server:\n{message.guild}\n\nNitro Gift Sender:\n{message.author}\n\nNitro Gift Code:\n{code}",
"url": "https://github.com/lnxcz/discord-sniper",
"color": 16732345,
"footer": {
"text": "lnxcz's sniper"
},
"image": {
"url": "https://i.imgur.com/9QVtF0t.png"
}
}],
"username": "Nitro",
"avatar_url": "https://i.imgur.com/44N46up.gif"
}
requests.post(webhook, json=data)
elif 'Unknown Gift Code' in r:
print(""
f"\n{Fore.YELLOW}{time} - Unknown Nitro Gift Code" + Fore.RESET)
NitroInfo(elapsed, code)
else:
return
if 'discord.com/gifts/' in message.content:
if nitro_sniper:
start = datetime.datetime.now()
code = re.findall("discord[.]com/gifts/(\w+)", message.content)
for code in code:
if len(code) == 16 or len(code) == 24:
if code not in usedcodes:
usedcodes.append(code)
with open("tried-nitro-codes.txt", "w") as fp:
json.dump(usedcodes, fp)
if onalt:
headers = {'Authorization': rtoken}
else:
headers = {'Authorization': token}
r = requests.post(
f'https://discordapp.com/api/v6/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.RED}{time} - Nitro is Already Redeemed" + Fore.RESET)
NitroInfo(elapsed, code)
elif 'subscription_plan' in r:
print(""
f"\n{Fore.GREEN}{time} - Nitro Successfuly Claimed!" + Fore.RESET)
NitroInfo(elapsed, code)
if notification:
toaster.show_toast("Sniper",
"Nitro Claimed! Look into console",
icon_path="./drop.ico",
duration=7)
if webhooknotification:
data = {
"embeds": [{
"title": "Successfully Sniped Nitro Gift!",
"description": f"Congratulations, good job! You can view your Nitro Gifts in your inventory.\n\nNitro Gift Server:\n{message.guild}\n\nNitro Gift Sender:\n{message.author}\n\nNitro Gift Code:\n{code}",
"url": "https://github.com/lnxcz/discord-sniper",
"color": 16732345,
"footer": {
"text": "lnxcz's sniper"
},
"image": {
"url": "https://i.imgur.com/9QVtF0t.png"
}
}],
"username": "Nitro",
"avatar_url": "https://i.imgur.com/44N46up.gif"
}
requests.post(webhook, json=data)
elif 'Unknown Gift Code' in r:
print(""
f"\n{Fore.YELLOW}{time} - Unknown Nitro Gift Code" + Fore.RESET)
NitroInfo(elapsed, code)
else:
return
if 'discordapp.com/gifts/' in message.content:
if nitro_sniper:
start = datetime.datetime.now()
code = re.findall("discordapp[.]com/gifts/(\w+)", message.content)
for code in code:
if len(code) == 16 or len(code) == 24:
if code not in usedcodes:
usedcodes.append(code)
with open("tried-nitro-codes.txt", "w") as fp:
json.dump(usedcodes, fp)
if onalt:
headers = {'Authorization': rtoken}
else:
headers = {'Authorization': token}
r = requests.post(
f'https://discordapp.com/api/v6/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.RED}{time} - Nitro is Already Redeemed" + Fore.RESET)
NitroInfo(elapsed, code)
elif 'subscription_plan' in r:
print(""
f"\n{Fore.GREEN}{time} - Nitro Successfuly Claimed!" + Fore.RESET)
NitroInfo(elapsed, code)
if notification:
toaster.show_toast("Sniper",
"Nitro Claimed! Look into console",
icon_path="./drop.ico",
duration=7)
if webhooknotification:
data = {
"embeds": [{
"title": "Successfully Sniped Nitro Gift!",
"description": f"Congratulations, good job! You can view your Nitro Gifts in your inventory.\n\nNitro Gift Server:\n{message.guild}\n\nNitro Gift Sender:\n{message.author}\n\nNitro Gift Code:\n{code}",
"url": "https://github.com/lnxcz/discord-sniper",
"color": 16732345,
"footer": {
"text": "lnxcz's sniper"
},
"image": {
"url": "https://i.imgur.com/9QVtF0t.png"
}
}],
"username": "Nitro",
"avatar_url": "https://i.imgur.com/44N46up.gif"
}
requests.post(webhook, json=data)
elif 'Unknown Gift Code' in r:
print(""
f"\n{Fore.YELLOW}{time} - Unknown Nitro Gift Code" + Fore.RESET)
NitroInfo(elapsed, code)
else:
return
if 'GIVEAWAY' in message.content:
if giveaway_sniper:
if message.author.id == 294882584201003009 or message.author.id == 673918978178940951 or message.author.id == 582537632991543307 or message.author.id == 649604306596528138:
try:
if not edelay:
await message.add_reaction("🎉")
except discord.errors.Forbidden:
print(""
f"\n{Fore.RED}{time} - Couldnt React to Giveaway" + Fore.RESET)
GiveawayInfo()
if edelay:
print(""
f"\n{Fore.GREEN}{time} - Giveaway Found!" + Fore.RESET)
GiveawayDelayInfo()
else:
print(""
f"\n{Fore.GREEN}{time} - Giveaway Sniped" + Fore.RESET)
GiveawayInfo()
if notification:
if edelay:
toaster.show_toast("Sniper",
f"Sniping Giveaway in {delay}s. Look into console",
icon_path="./drop.ico",
duration=7)
else:
toaster.show_toast("Sniper",
"Giveaway Sniped! Look into console",
icon_path="./drop.ico",
duration=7)
try:
if edelay:
sleep(delay)
await message.add_reaction("🎉")
print("")
print(f"{Fore.GREEN}Giveaway Sniped with delay {delay} seconds!")
except discord.errors.Forbidden:
print(""
f"\n{Fore.RED}{time} - Couldnt React to Giveaway" + Fore.RESET)
GiveawayInfo()
else:
return
if f'Congratulations <@{Sniper.user.id}>' in message.content or f'<@{Sniper.user.id}> won' in message.content:
if giveaway_sniper:
if message.author.id == 294882584201003009 or message.author.id == 673918978178940951 or message.author.id == 582537632991543307 or message.author.id == 396464677032427530 or message.author.id == 649604306596528138:
print(""
f"\n{Fore.GREEN}{time} - Giveaway Won" + Fore.RESET)
GiveawayInfo()
if notification:
toaster.show_toast("Sniper",
"Giveaway Won! Look into console",
icon_path="./drop.ico",
duration=7)
else:
return
if 'privnote.com' in message.content:
if privnote_sniper:
start = datetime.datetime.now()
code = re.findall('privnote.com/(\S*)', message.content)
for code in code:
link = 'https://privnote.com/' + code
try:
note_text = pn.read_note(link)
except Exception as e:
print(e)
with open(f'Privnote/{code}.txt', 'a+') as data:
print(f"\n{Fore.GREEN}{time} - Privnote Sniped" + Fore.RESET)
elapsed = datetime.datetime.now() - start
elapsed = f'{elapsed.seconds}.{elapsed.microseconds}'
PrivnoteInfo(elapsed, code)
data.write(note_text)
if notification:
toaster.show_toast("Sniper",
"Privnote sniped! Look into console",
icon_path="./drop.ico",
duration=7)
else:
return
await Sniper.process_commands(message)
@Sniper.event
async def on_connect():
Clear()
codestart()
ctypes.windll.kernel32.SetConsoleTitleW(f'Discord Sniper - User: {Sniper.user.name} - Made by LnX')
Init()