This repository has been archived by the owner on Aug 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.py
325 lines (300 loc) · 13.7 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
import requests, json, discord, datetime, asyncio, aiohttp
from discord.ext import commands
from discord.ext import tasks
from discord.utils import get
x = datetime.datetime.now()
with open('Saves/setup.json') as f:
config = json.load(f)
if config['api-key'] == 'Fortnite API Key Here (If Not Leave Default)':
apikey = False
else:
apikey = True
bot = commands.Bot(command_prefix=config['prefix'])
@bot.command()
async def aes(ctx):
r = requests.get('https://benbotfn.tk/api/v1/aes')
rr = r.json()
mainkey = rr['mainKey']
version = rr['version']
embed = discord.Embed(title=f"{version} Aes", description="")
embed.add_field(name='MainKey', value=f'``{mainkey}``', inline=False)
for sub_dict in rr['dynamicKeys']:
embed.add_field(name=sub_dict.split('FortniteGame/Content/Paks/')[1].strip().replace('"', ''), value=f"``{rr['dynamicKeys'][sub_dict]}``", inline=False)
embed.set_footer(text=f'{ctx.guild.name}', icon_url=f'{ctx.guild.icon_url}')
await ctx.send(embed=embed)
@bot.command()
async def bearer(ctx):
r = requests.get('https://api.nitestats.com/v1/epic/bearer')
rr = r.json()
accessToken = rr['accessToken']
lastUpdated = rr['lastUpdated']
embed = discord.Embed(title=f"Bearer Token", description="")
embed.add_field(name='Access Token', value=f'``{accessToken}``', inline=False)
embed.add_field(name='Last Updated', value=f"``{lastUpdated}``", inline=False)
embed.set_footer(text=f'Updated every 10 minutes - {ctx.guild.name}', icon_url=f'{ctx.guild.icon_url}')
await ctx.send(embed=embed)
@bot.command()
async def fltoken(ctx):
r = requests.get('https://api.nitestats.com/v1/epic/builds/fltoken')
rr = r.json()
version = rr['version']
fltoken = rr['fltoken']
embed = discord.Embed(title=f"FLToken", description="")
embed.add_field(name='Version', value=f'``{version}``', inline=False)
embed.add_field(name='FLToken', value=f"``{fltoken}``", inline=False)
embed.set_footer(text=f'Refreshes automatically in under 1sec when a new build releases - {ctx.guild.name}', icon_url=f'{ctx.guild.icon_url}')
await ctx.send(embed=embed)
@tasks.loop(seconds=30)
async def taskbrnews():
with open('Saves/brnews.json', 'r') as file:
old = json.load(file)
try:
async with aiohttp.ClientSession() as session:
async with session.get("https://api.peely.de/v1/br/news") as r:
response = await r.json()
if response != old:
channel = bot.get_channel(config['brnews-channel'])
embed=discord.Embed(
title='Br News',
)
embed.set_image(url=response['data']['image'])
await channel.send(embed=embed)
with open('Saves/brnews.json', 'w') as file:
json.dump(response, file, indent=3)
except Exception as e:
print("ERROR! Woah that wasn't supposed to happen " + e)
pass
@tasks.loop(seconds=30)
async def taskcrnews():
with open('Saves/crnews.json', 'r') as file:
old = json.load(file)
try:
async with aiohttp.ClientSession() as session:
async with session.get("https://api.peely.de/v1/creative/news") as r:
response = await r.json()
if response != old:
channel = bot.get_channel(config['crnews-channel'])
embed=discord.Embed(
title='Creative News',
)
embed.set_image(url=response['data']['image'])
await channel.send(embed=embed)
with open('Saves/crnews.json', 'w') as file:
json.dump(response, file, indent=3)
except Exception as e:
print("ERROR! Woah that wasn't supposed to happen " + e)
pass
@tasks.loop(seconds=30)
async def taskstwnews():
with open('Saves/stwnews.json', 'r') as file:
old = json.load(file)
try:
async with aiohttp.ClientSession() as session:
async with session.get("https://api.peely.de/v1/stw/news") as r:
response = await r.json()
if response != old:
channel = bot.get_channel(config['stwnews-channel'])
embed=discord.Embed(
title='Stw News',
)
embed.set_image(url=response['data']['image'])
await channel.send(embed=embed)
with open('Saves/stwnews.json', 'w') as file:
json.dump(response, file, indent=3)
except Exception as e:
print("ERROR! Woah that wasn't supposed to happen " + e)
pass
@tasks.loop(seconds=30)
async def autobuild():
with open('Saves/build.json', 'r') as file:
old = json.load(file)
async with aiohttp.ClientSession() as session:
async with session.get("https://benbotfn.tk/api/v1/status") as statuss:
status = await statuss.json()
if status != old:
await bot.change_presence(activity=discord.Game(name=f"{status['currentFortniteVersion']}"))
async with session.get("https://benbotfn.tk/api/v1/aes") as response:
response = await response.json()
with open('Saves/build.json', 'r') as file:
newBuild = json.load(file)
embed=discord.Embed(
title="Fortnite Static Key Update Detected",
color=0xff0a0a
)
channel = bot.get_channel(config["build-channel"])
embed.add_field(name=f"Build", value=f"{response['version']}", inline=False)
embed.add_field(name=f"CDN", value=f"{newBuild['currentCdnVersion']}", inline=False)
embed.add_field(name="AES", value=f"{response['mainKey']}", inline=False)
embed.add_field(name="Total PAK Count", value=f"{newBuild['totalPakCount']}", inline=False)
embed.add_field(name="Dynamic PAK Count", value=f"{newBuild['dynamicPakCount']}", inline=False)
await channel.send(embed=embed)
file.close()
with open('Saves/build.json', 'w') as file:
json.dump(status, file, indent=3)
@tasks.loop(seconds=30)
async def autofltoken():
with open('Saves/fltoken.json', 'r') as file:
old = json.load(file)
async with aiohttp.ClientSession() as session:
async with session.get("https://api.nitestats.com/v1/epic/builds/fltoken") as statuss:
status = await statuss.json()
if status != old:
async with session.get("https://api.nitestats.com/v1/epic/builds/fltoken") as response:
response = await response.json()
embed=discord.Embed(
title="Fortnite FLToken Updated",
color=0xff0a0a
)
channel = bot.get_channel(config["build-channel"])
embed.add_field(name=f"Build", value=f"{response['version']}", inline=False)
embed.add_field(name="FLToken", value=f"{response['fltoken']}", inline=False)
await channel.send(embed=embed)
with open('Saves/fltoken.json', 'w') as file:
json.dump(status, file, indent=3)
@tasks.loop(seconds=30)
async def autobg():
with open('Saves/bg.json', 'r') as file:
old = json.load(file)
async with aiohttp.ClientSession() as session:
async with session.get("http://www.fortniteapi.net/v1/game/backgrounds") as statuss:
status = await statuss.json()
if status != old:
async with session.get("http://www.fortniteapi.net/v1/game/backgrounds") as response:
response = await response.json()
embed=discord.Embed(
title="Fortnite Dynamic Backgrounds Updated",
color=0xff0a0a
)
channel = bot.get_channel(config["build-channel"])
embed.add_field(name=f"Stage", value=f"{response['backgrounds'][0]['stage']}", inline=False)
embed.add_field(name="Type", value=f"{response['backgrounds'][0]['_type']}", inline=False)
embed.add_field(name="Key", value=f"{response['backgrounds'][0]['key']}", inline=False)
embed.add_field(name=f"Stage", value=f"{response['backgrounds'][1]['stage']}", inline=False)
embed.add_field(name="Type", value=f"{response['backgrounds'][1]['_type']}", inline=False)
embed.add_field(name="Key", value=f"{response['backgrounds'][1]['key']}", inline=False)
await channel.send(embed=embed)
with open('Saves/bg.json', 'w') as file:
json.dump(status, file, indent=3)
@tasks.loop(seconds=30)
async def autobrshop():
with open('Saves/shop.json', 'r') as file:
old = json.load(file)
try:
async with aiohttp.ClientSession() as session:
async with session.get("https://api.peely.de/v1/shop") as r:
response = await r.json()
if response != old:
channel = bot.get_channel(config['shop-channel'])
embed=discord.Embed(
title='Br Shop',
)
embed.set_image(url=response['uniqueurl'])
await channel.send(embed=embed)
with open('Saves/shop.json', 'w') as file:
json.dump(response, file, indent=3)
except Exception as e:
print("ERROR! Woah that wasn't supposed to happen " + str(e))
pass
@bot.event
async def on_ready():
print('Bot Ready/Logged In')
status=requests.get(
'https://benbotfn.tk/api/v1/status'
).json()
await bot.change_presence(activity=discord.Game(name=f"{status['currentFortniteVersion']}"))
taskbrnews.start()
taskcrnews.start()
taskstwnews.start()
autobuild.start()
autobrshop.start()
autofltoken.start()
autobg.start()
@bot.command()
async def stats(ctx, arg):
r = requests.get(f'https://fortnite-api.com/v1/stats/br/v2?name={arg}&image=all')
rr = r.json()
embed=discord.Embed()
embed.set_image(url=f"{rr['data']['image']}")
await ctx.send(embed=embed)
@bot.command()
async def brnews(ctx):
response=requests.get(
'https://fortnite-api.com/v2/news/br'
).json()
embed=discord.Embed(
title='Br News'
)
embed.set_image(
url=response['data']['image']
)
await ctx.send(embed=embed)
@bot.command()
async def creativenews(ctx):
response=requests.get(
'https://fortnite-api.com/v2/news/creative'
).json()
embed=discord.Embed(
title='Creative News'
)
embed.set_image(
url=response['data']['image']
)
await ctx.send(embed=embed)
@bot.command()
async def stwnews(ctx):
response=requests.get(
'https://api.peely.de/v1/stw/news'
).json()
embed=discord.Embed(
title='Save The World News'
)
embed.set_image(
url=response['data']['image']
)
await ctx.send(embed=embed)
@bot.command()
async def search(ctx):
#cosname = cosnamee.replace(' ', '+')
cosname = ctx.message.content.replace('>search ', '').replace(' ', '+')
r = requests.get(f'https://fortnite-api.com/v2/cosmetics/br/search/all?name={cosname}')
rr = r.json()
if rr['status'] == 200:
for sub_dict in rr['data']:
embed = discord.Embed(color=0x0d95fd)
embed.add_field(name='Name', value=f"``{sub_dict['name']}``", inline=False)
embed.add_field(name='ID', value=f"``{sub_dict['id']}``", inline=False)
embed.add_field(name='Description', value=f"``{sub_dict['description']}``", inline=False)
embed.add_field(name='Type', value=f"``{sub_dict['type']['value']}``", inline=False)
embed.add_field(name='Display Type', value=f"``{sub_dict['type']['displayValue']}``", inline=False)
embed.add_field(name='Backend Value', value=f"``{sub_dict['type']['backendValue']}``", inline=False)
embed.add_field(name='Rarity', value=f"``{sub_dict['rarity']['value']}``", inline=False)
embed.add_field(name='Backend Rarity', value=f"``{sub_dict['rarity']['backendValue']}``", inline=False)
embed.add_field(name='Series', value=f"``{sub_dict['series']}``", inline=False)
embed.add_field(name='Shop History', value=f"``{sub_dict['shopHistory']}``", inline=False)
if sub_dict['introduction'] == None:
pass
else:
embed.add_field(name='Introduction', value=f"``{sub_dict['introduction']['text']}``", inline=False)
embed.add_field(name='Display Asset Path', value=f"``{sub_dict['displayAssetPath']}``", inline=False)
embed.add_field(name='Definition Path', value=f"``{sub_dict['definitionPath']}``", inline=False)
embed.set_thumbnail(url=f"https://fortnite-api.com/images/cosmetics/br/{sub_dict['id'].lower()}/icon.png")
embed.set_footer(text=f"{bot.user.name} | uwu")
message = await ctx.send(embed=embed)
else:
embed = discord.Embed(color=0xff0f0f)
embed.add_field(name='Error', value=f"``{rr['error']}``", inline=False)
embed.set_footer(text=f"{bot.user.name} | uwu")
message = await ctx.send(embed=embed)
await asyncio.sleep(60)
await message.delete()
@bot.command()
async def brshop(ctx, aliases=['shop', 'itemshop']):
response=requests.get('https://api.peely.de/v1/shop').json()
embed=discord.Embed(
title=response['time']
)
embed.set_image(
url=response['uniqueurl']
)
await ctx.send(embed=embed)
bot.run(config["token"], reconnect=True)