1
1
# Bot originally made by using NAFF
2
2
# Ported to i.py v5
3
3
# pip install -U discord-py-interactions
4
- bot_official_version = "4.0.0 dev "
4
+ bot_official_version = "4.0.0"
5
5
6
6
import interactions as inter
7
7
from interactions import (
26
26
Permissions ,
27
27
SlashCommandChoice ,
28
28
ButtonStyle ,
29
+ check ,
29
30
)
30
31
31
32
import asyncio
103
104
invite_cooldown = []
104
105
nameday_cooldown = []
105
106
107
+ with open ("data/namedays-extended.json" , encoding = "utf-8" ) as f :
108
+ namedays_ext = json .load (f )
106
109
107
110
# @listen()
108
111
# async def on_error():
111
114
112
115
delete_btn = Button (style = ButtonStyle .RED , custom_id = "delete" , emoji = "🗑️" )
113
116
114
- base = os .path .dirname ("templates/" )
115
- html = open (os .path .join (base , "index.html" ))
116
- soup = bs (html , ' html.parser' )
117
+ base = os .path .dirname ("templates/" )
118
+ html = open (os .path .join (base , "index.html" ))
119
+ soup = bs (html , " html.parser" )
117
120
118
121
# for i in range(len(epiccontribbutingppl)):
119
122
# url_links_contributors.append((bot.fetch_user(epiccontribbutingppl[i])).avatar.url)
128
131
</table>
129
132
"""
130
133
134
+
131
135
@listen ()
132
136
async def on_startup ():
133
-
134
137
print (f"{ bot .user } has connected to Discord!" )
135
138
# bot.load_extension("data.voice")
136
139
bot .load_extension ("data.ext1" ) # Load all games
@@ -139,21 +142,19 @@ async def on_startup():
139
142
bot .load_extension ("data.lichess" )
140
143
bot .load_extension ("data.welcome" )
141
144
142
- contr_icons = []
143
- contr_usernames = []
144
-
145
- lilhelp_icons = []
146
- lilhelp_usernames = []
145
+ # contr_icons = []
146
+ # contr_usernames = []
147
147
148
- for contributor in epiccontribbutingppl :
149
- contr_icons .append (bot .get_user (contributor ).avatar .url )
150
- contr_usernames .append (bot .get_user (contributor ).username )
151
-
152
- for lilhelper in lilhelpers :
153
- lilhelp_icons .append (bot .get_user (lilhelper ).avatar .url )
154
- lilhelp_usernames .append (bot .get_user (lilhelper ).username )
148
+ # lilhelp_icons = []
149
+ # lilhelp_usernames = []
155
150
151
+ # for contributor in epiccontribbutingppl:
152
+ # contr_icons.append(bot.get_user(contributor).avatar.url)
153
+ # contr_usernames.append(bot.get_user(contributor).username)
156
154
155
+ # for lilhelper in lilhelpers:
156
+ # lilhelp_icons.append(bot.get_user(lilhelper).avatar.url)
157
+ # lilhelp_usernames.append(bot.get_user(lilhelper).username)
157
158
158
159
# with open("index.html", "wb") as f:
159
160
# f.write(soup.prettify("utf-8"))
@@ -256,6 +257,7 @@ async def reload(ctx, cog=None):
256
257
else :
257
258
await ctx .respond (random .choice (notauthormessages ), ephemeral = True , components = [delete_btn ])
258
259
260
+
259
261
@slash_command (
260
262
name = "info" ,
261
263
description = "get info about the bot" ,
@@ -267,7 +269,7 @@ async def info(ctx):
267
269
timestamp = datetime .utcnow (),
268
270
color = Color .from_hex ("5e50d4" ),
269
271
thumbnail = "https://cdn.discordapp.com/attachments/983081269543993354/1041045309695987712/image.png" ,
270
- url = "https://larss-bot.onrender.com"
272
+ url = "https://larss-bot.onrender.com" ,
271
273
)
272
274
embed .set_footer (text = "Requested by " + str (ctx .author ), icon_url = ctx .author .avatar .url )
273
275
embed .add_field (
@@ -286,6 +288,10 @@ async def info(ctx):
286
288
name = "Last startup" ,
287
289
value = f"<t:{ int (str (now_unix )[:- 2 ])} :R>" ,
288
290
)
291
+ embed .add_field (
292
+ name = "Support the creator!" ,
293
+ value = "https://ko-fi.com/larssj" ,
294
+ )
289
295
290
296
btn1 = Button (label = "Contributors" , style = ButtonStyle .BLUE , emoji = "⭐" , custom_id = "contributors" )
291
297
btn2 = Button (
@@ -305,7 +311,7 @@ async def on_component(ctx: ComponentContext):
305
311
message_components = event .message .components
306
312
message_components [0 ].components [0 ].disabled = True
307
313
await event .message .edit (components = message_components )
308
-
314
+
309
315
embed = Embed (
310
316
title = "⭐ Contributors" ,
311
317
description = f"Awesome people who have helped to make Larss_Bot what it is today!" ,
@@ -339,7 +345,7 @@ async def on_component(ctx: ComponentContext):
339
345
message_components = event .message .components
340
346
message_components [0 ].components [1 ].disabled = True
341
347
await event .message .edit (components = message_components )
342
-
348
+
343
349
embed = Embed (
344
350
title = "Partner servers" ,
345
351
description = f"Press any of the buttons below to get invited to one of the partnered servers" ,
@@ -369,27 +375,23 @@ async def on_component(ctx: ComponentContext):
369
375
url = "https://discord.gg/w78rcjW8ck" ,
370
376
)
371
377
components : list [ActionRow ] = spread_to_rows (btn1 , btn2 , btn3 )
372
- components .append (ActionRow (delete_btn ))
378
+ components .append (ActionRow (delete_btn ))
373
379
374
380
await event .send (embed = embed , components = components )
375
- # if event.custom_id == "extendedlistshow":
376
- # if event.channel.id not in nameday_cooldown:
377
- # today = date.today().strftime("%m-%d")
378
- # embed = Embed(
379
- # title="Visi šodienas vārdi",
380
- # description="> " + "\n> ".join(namedays_ext[today]),
381
- # color=Color.from_rgb(255, 13, 13),
382
- # )
383
- # await event.send(embed=embed)
384
- # nameday_cooldown.append(event.channel.id)
385
- # await asyncio.sleep(15)
386
- # nameday_cooldown.remove(event.channel.id)
387
- # else:
388
- # # ephemeral not gonna work, once again
389
- # await event.send(
390
- # "Looks like someone already pressed the button. No need to do it again.",
391
- # ephemeral=True,
392
- # )
381
+ case "extendedlistshow" :
382
+ today = date .today ().strftime ("%m-%d" )
383
+ embed = Embed (
384
+ title = "Visi šodienas vārdi" ,
385
+ description = "> " + "\n > " .join (namedays_ext [today ]),
386
+ color = Color .from_rgb (255 , 13 , 13 ),
387
+ )
388
+
389
+ message_components = event .message .components
390
+ message_components [0 ].components [0 ].disabled = True
391
+ await event .message .edit (components = message_components )
392
+
393
+ await event .send (embed = embed , components = [delete_btn ])
394
+
393
395
case "delete" :
394
396
if (
395
397
event .message .interaction ._user_id == event .author .id
@@ -399,6 +401,7 @@ async def on_component(ctx: ComponentContext):
399
401
else :
400
402
await event .send ("Not your interaction." , ephemeral = True )
401
403
404
+
402
405
@slash_command (name = "ping" , description = "check the bots status" )
403
406
async def ping (ctx ):
404
407
message = await ctx .send (
@@ -430,7 +433,7 @@ async def ping(ctx):
430
433
)
431
434
async def randomise (ctx , min , max ):
432
435
try :
433
- #check if the numbers are floats
436
+ # check if the numbers are floats
434
437
try :
435
438
min = int (min )
436
439
max = int (max )
@@ -491,6 +494,7 @@ async def randomise(ctx, min, max):
491
494
492
495
# # await bot.process_commands(message)
493
496
497
+
494
498
@is_owner ()
495
499
@slash_command ("quit" , description = "Log off the bot" )
496
500
async def quit (ctx : InteractionContext ):
0 commit comments