-
Notifications
You must be signed in to change notification settings - Fork 83
/
Main.py
422 lines (393 loc) · 17.1 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
import json
import re
import requests
from time import sleep
import colorama
import datetime
import discord
import os
from colorama import Fore
from playsound import playsound
from discord.ext import commands
#
# CONFIG INPUT
#
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")
airdrop_sniper = config.get("airdrop_sniper")
webhooknotification = config.get("webhook_notification")
sound_notification = config.get("sound_notification")
webhook = config.get("webhook")
botlist = config.get("bot_list")
altlist = config.get("alt_list")
#
# END OF CONFIG INPUT
#
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 = " "
print(
f"""{Fore.RESET}
{Fore.GREEN}╔═╗ ╔╗╔ ╦ ╦═╗ ╦═╗ ╦═╗
{Fore.LIGHTBLACK_EX}╚═╗ ║║║ ║ ╠═╝ ╠╣ ╠╦╝
{Fore.WHITE}╚═╝ ╝╚╝ ╩ ╩ ╩═╝ ╩╚═
{Fore.WHITE}Connected User - {Fore.GREEN}{Sniper.user.name}#{Sniper.user.discriminator}
{Fore.WHITE}Nitro Sniper - {Fore.GREEN}{nitro_sniper} {onaltt}
{Fore.WHITE}Giveaway Sniper - {Fore.GREEN}{giveaway_sniper} {ddelay}
"""
+ Fore.RESET
)
colorama.init()
Sniper = commands.Bot(description="Discord Sniper", command_prefix="", self_bot=True)
def Clear():
print("\n" * 100)
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 Redeem Token!"
+ Fore.RESET
)
exit()
if rtoken == "your-token":
Clear()
print(
f"\n\n{Fore.RED}Error {Fore.WHITE}You didn't 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 didn't put your token in the config.json file"
+ Fore.RESET
)
exit()
else:
token = config.get("token")
try:
Sniper.run(token, reconnect=True)
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(elapsed):
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} Elapsed: {Fore.WHITE}{elapsed}s" + 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
)
time = datetime.datetime.now().strftime("%H:%M")
if (
"discord.gift/" in message.content
or "discord.com/gifts/" in message.content
or "discordapp.com/gifts/" in message.content
):
if nitro_sniper:
start = datetime.datetime.now()
if "discord.gift/" in message.content:
code = re.findall("discord[.]gift/(\w+)", message.content)
if "discordapp.com/gifts/" in message.content:
code = re.findall("discordapp[.]com/gifts/(\w+)", message.content)
if "discord.com/gifts/" in message.content:
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:
if sound_notification == True:
try:
playsound("./sounds/success.wav")
except:
pass
print(
""
f"\n{Fore.GREEN}{time} - Nitro Successfuly Claimed!"
+ Fore.RESET
)
NitroInfo(elapsed, code)
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": f"Sniper | {Sniper.user.name}#{Sniper.user.discriminator}",
"avatar_url": str(Sniper.user.avatar_url),
}
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
# Don't react to all messages
# Don't react to DMs
if message.content or message.embeds and message.guild:
if giveaway_sniper:
if (
message.author.id in botlist
and not (
f"@{Sniper.user.id}" in message.content
or f"<@{Sniper.user.id}>" in message.content
)
and not (
"Giveaway ended" in message.content
or "Congratulations" in message.content
)
):
start = datetime.datetime.now()
try:
if not edelay:
await message.add_reaction("🎉")
elapsed = datetime.datetime.now() - start
elapsed = f"{elapsed.seconds}.{elapsed.microseconds}"
except discord.errors.Forbidden:
print(
""
f"\n{Fore.RED}{time} - Couldn't React to Giveaway" + Fore.RESET
)
GiveawayInfo(elapsed)
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(elapsed)
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} - Couldn't React to Giveaway" + Fore.RESET
)
GiveawayInfo(elapsed)
if webhooknotification:
if message.content and message.embeds:
message_content = (
"`"
+ message.content.replace("`", "").replace("\\", "")[:500]
+ "`"
+ "\n"
+ "***Message Embed***: "
+ "`"
+ str(message.embeds[0].title)
+ "\n"
+ str(message.embeds[0].description)
.replace("`", "")
.replace("\\", "")[:500]
+ "`"
)
elif message.embeds and not message.content:
message_content = (
"Empty Message\n"
+ "***Message Embed***: "
+ "`"
+ str(message.embeds[0].title)
+ "\n"
+ str(message.embeds[0].description)
.replace("`", "")
.replace("\\", "")[:500]
+ "`"
)
elif message.content and not message.embeds:
message_content = (
"`"
+ message.content.replace("`", "").replace("\\", "")[:500]
+ "`"
)
else:
message_content = "No content"
data = {
"embeds": [
{
"title": "Giveaway Joined!",
"description": f"**Message content**:\n {message_content}\n**Giveaway Server**: `{message.guild}`\n**Channel**: `#{message.channel}`\n**Bot**: `{message.author.name}`",
"url": message.jump_url,
"color": 3407667,
}
],
"username": f"Sniper | {Sniper.user.name}#{Sniper.user.discriminator}",
"avatar_url": str(Sniper.user.avatar_url),
}
requests.post(webhook, json=data)
else:
return
if (
f"@{Sniper.user.id}" in message.content
or f"<@{Sniper.user.id}>" in message.content
):
if giveaway_sniper:
if message.author.id in botlist:
print("" f"\n{Fore.GREEN}{time} - Giveaway Won" + Fore.RESET)
elapsed = "-"
GiveawayInfo(elapsed)
if webhooknotification:
if message.content and message.embeds:
message_content = (
"`"
+ message.content.replace("`", "").replace("\\", "")[:500]
+ "`"
+ "\n"
+ "***Message Embed***: "
+ "`"
+ str(message.embeds[0].title)
+ "\n"
+ str(message.embeds[0].description)
.replace("`", "")
.replace("\\", "")[:500]
+ "`"
)
elif message.embeds and not message.content:
message_content = (
"Empty Message\n"
+ "***Message Embed***: "
+ "`"
+ str(message.embeds[0].title)
+ "\n"
+ str(message.embeds[0].description)
.replace("`", "")
.replace("\\", "")[:500]
+ "`"
)
elif message.content and not message.embeds:
message_content = (
"`"
+ message.content.replace("`", "").replace("\\", "")[:500]
+ "`"
)
else:
message_content = "No content"
data = {
"embeds": [
{
"title": "Giveaway Won!",
"description": f"**Message content**:\n {message_content}\n**Giveaway Server**: `{message.guild}`\n**Channel**: `#{message.channel}`",
"url": message.jump_url,
"color": 16732345,
}
],
"username": f"Sniper | {Sniper.user.name}#{Sniper.user.discriminator}",
"avatar_url": str(Sniper.user.avatar_url),
}
requests.post(webhook, json=data)
else:
return
await Sniper.process_commands(message)
@Sniper.event
async def on_connect():
Clear()
codestart()
Init()