Skip to content

Commit 4940db7

Browse files
Merge pull request #65 from LewisProjects/development
hot fix
2 parents 351c524 + 3114a9a commit 4940db7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+492
-1805
lines changed

cogs/AI.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import base64
2-
import time
32
from io import BytesIO
4-
3+
import time
54
import disnake
65
from disnake.ext import commands
7-
86
from utils.bot import OGIROID
97

108

@@ -15,19 +13,11 @@ def __init__(self, bot: OGIROID):
1513
@commands.slash_command(description="Generates ai art")
1614
async def ai_art(self, inter: disnake.ApplicationCommandInteraction, text):
1715
ETA = int(time.time() + 60)
18-
await inter.send(
19-
f"Go grab a coffee this may take a while... ETA: <t:{ETA}:R>",
20-
ephemeral=True,
21-
)
22-
response = await self.bot.session.post(
23-
"https://backend.craiyon.com/generate", json={"prompt": text}
24-
)
16+
await inter.send(f"Go grab a coffee this may take a while... ETA: <t:{ETA}:R>", ephemeral=True)
17+
response = await self.bot.session.post("https://backend.craiyon.com/generate", json={"prompt": text})
2518
r = await response.json()
2619
raw_images = r["images"]
27-
images = [
28-
disnake.File(BytesIO(base64.decodebytes(i.encode("utf-8"))), "image.png")
29-
for i in raw_images
30-
]
20+
images = [disnake.File(BytesIO(base64.decodebytes(i.encode("utf-8"))), "image.png") for i in raw_images]
3121

3222
await inter.edit_original_response(files=images, content="Here you go!")
3323

cogs/Animals.py

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@ async def cat(self, inter):
2626
color=0xFFFFFF,
2727
)
2828
embed.set_image(url=data["image"])
29-
embed.set_footer(
30-
text=f"Command issued by: {inter.author.name}",
31-
icon_url=inter.author.display_avatar,
32-
)
29+
embed.set_footer(text=f"Command issued by: {inter.author.name}", icon_url=inter.author.display_avatar)
3330
await inter.response.send_message(f"**Fun Fact: **" + data["fact"], embed=embed)
3431

3532
@animal.sub_command(name="dog", description="Get a random dog picture")
@@ -43,10 +40,7 @@ async def dog(self, inter):
4340
color=0xFFFFFF,
4441
)
4542
embed.set_image(url=data["image"])
46-
embed.set_footer(
47-
text=f"Command issued by: {inter.author.name}",
48-
icon_url=inter.author.display_avatar,
49-
)
43+
embed.set_footer(text=f"Command issued by: {inter.author.name}", icon_url=inter.author.display_avatar)
5044
await inter.response.send_message("**Fun Fact: **" + data["fact"], embed=embed)
5145

5246
@animal.sub_command(name="bird", description="Get a random bird picture")
@@ -60,10 +54,7 @@ async def bird(self, inter):
6054
color=0xFFFFFF,
6155
)
6256
embed.set_image(url=data["image"])
63-
embed.set_footer(
64-
text=f"Command issued by: {inter.author.name}",
65-
icon_url=inter.author.display_avatar,
66-
)
57+
embed.set_footer(text=f"Command issued by: {inter.author.name}", icon_url=inter.author.display_avatar)
6758
await inter.response.send_message("**Fun Fact: **" + data["fact"], embed=embed)
6859

6960
@animal.sub_command(name="fox", description="Get a random fox picture")
@@ -77,10 +68,7 @@ async def fox(self, inter):
7768
color=0xFFFFFF,
7869
)
7970
embed.set_image(url=data["image"])
80-
embed.set_footer(
81-
text=f"Command issued by: {inter.author.name}",
82-
icon_url=inter.author.display_avatar,
83-
)
71+
embed.set_footer(text=f"Command issued by: {inter.author.name}", icon_url=inter.author.display_avatar)
8472
await inter.response.send_message("**Fun Fact: **" + data["fact"], embed=embed)
8573

8674
@animal.sub_command(name="panda", description="Get a random panda picture")
@@ -94,10 +82,7 @@ async def panda(self, inter):
9482
color=0xFFFFFF,
9583
)
9684
embed.set_image(url=data["image"])
97-
embed.set_footer(
98-
text=f"Command issued by: {inter.author.name}",
99-
icon_url=inter.author.display_avatar,
100-
)
85+
embed.set_footer(text=f"Command issued by: {inter.author.name}", icon_url=inter.author.display_avatar)
10186
await inter.response.send_message("**Fun Fact: **" + data["fact"], embed=embed)
10287

10388
@animal.sub_command(name="koala", description="Get a random cat picture")
@@ -111,10 +96,7 @@ async def koala(self, inter):
11196
color=0xFFFFFF,
11297
)
11398
embed.set_image(url=data["image"])
114-
embed.set_footer(
115-
text=f"Command issued by: {inter.author.name}",
116-
icon_url=inter.author.display_avatar,
117-
)
99+
embed.set_footer(text=f"Command issued by: {inter.author.name}", icon_url=inter.author.display_avatar)
118100
await inter.response.send_message("**Fun Fact: **" + data["fact"], embed=embed)
119101

120102

cogs/Birthdays.py

Lines changed: 17 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import datetime
2-
import datetime as dt
3-
import random
42

53
import disnake
4+
import datetime as dt
65
from disnake.ext import commands, tasks
6+
import random
77

8-
from utils.CONSTANTS import months, congrats_messages
98
from utils.DBhandlers import BirthdayHandler
10-
from utils.bot import OGIROID
119
from utils.exceptions import UserAlreadyExists, UserNotFound
1210
from utils.shortcuts import QuickEmb, sucEmb, errorEmb
11+
from utils.CONSTANTS import months, congrats_messages
12+
from utils.bot import OGIROID
1313

1414

1515
class Birthday(commands.Cog):
@@ -30,18 +30,11 @@ def cog_unload(self):
3030
async def birthday(self, inter: disnake.ApplicationCommandInteraction):
3131
pass
3232

33-
@birthday.sub_command(
34-
name="set", description="Set your birthday. Cant be removed without Staff."
35-
)
33+
@birthday.sub_command(name="set", description="Set your birthday. Cant be removed without Staff.")
3634
async def set(
3735
self,
3836
inter,
39-
day: int = commands.Param(
40-
name="day",
41-
ge=1,
42-
le=31,
43-
description="The day of your birthday. Select carefully.",
44-
),
37+
day: int = commands.Param(name="day", ge=1, le=31, description="The day of your birthday. Select carefully."),
4538
month: str = commands.Param(
4639
name="month",
4740
description="The month of your birthday. Select carefully.",
@@ -62,23 +55,17 @@ async def set(
6255
await sucEmb(inter, f"Your birthday has been set to {birth_date}")
6356

6457
@commands.has_permissions(manage_roles=True)
65-
@birthday.sub_command(
66-
name="edit", description="Edit a users birthday. Can only be done by Staff."
67-
)
58+
@birthday.sub_command(name="edit", description="Edit a users birthday. Can only be done by Staff.")
6859
async def edit(
6960
self,
7061
inter,
71-
day: int = commands.Param(
72-
name="day", ge=1, le=31, description="The day of the birthday."
73-
),
62+
day: int = commands.Param(name="day", ge=1, le=31, description="The day of the birthday."),
7463
month: str = commands.Param(
7564
name="month",
7665
description="The month of the birthday.",
7766
choices=months,
7867
),
79-
user: disnake.User = commands.Param(
80-
name="user", description="User to edit the birthday of."
81-
),
68+
user: disnake.User = commands.Param(name="user", description="User to edit the birthday of."),
8269
):
8370
try:
8471
await self.birthday.update_user(user.id, f"{day}/{month}")
@@ -87,15 +74,11 @@ async def edit(
8774
return await errorEmb(inter, "The User doesn't have a birthday set")
8875

8976
@commands.has_permissions(manage_roles=True)
90-
@birthday.sub_command(
91-
name="remove", description="Remove a birthday. Can only be done by Staff."
92-
)
77+
@birthday.sub_command(name="remove", description="Remove a birthday. Can only be done by Staff.")
9378
async def remove(
9479
self,
9580
inter: disnake.ApplicationCommandInteraction,
96-
user: disnake.User = commands.Param(
97-
name="user", description="Removes the birthday of this user"
98-
),
81+
user: disnake.User = commands.Param(name="user", description="Removes the birthday of this user"),
9982
):
10083
try:
10184
await self.birthday.delete_user(user.id)
@@ -105,9 +88,7 @@ async def remove(
10588
await sucEmb(inter, "The birthday has been removed")
10689

10790
@birthday.sub_command(name="get", description="Get the birthday of a user")
108-
async def get(
109-
self, inter, user: disnake.User = commands.Param(name="user", default=None)
110-
):
91+
async def get(self, inter, user: disnake.User = commands.Param(name="user", default=None)):
11192
if user is None:
11293
user = inter.author
11394
else:
@@ -117,13 +98,9 @@ async def get(
11798
if birthday is None:
11899
return await errorEmb(inter, "This user doesn't have a birthday set")
119100

120-
next_birthday = datetime.datetime.strptime(
121-
birthday.birthday + f"/{dt.datetime.now().year}", "%d/%m/%Y"
122-
)
101+
next_birthday = datetime.datetime.strptime(birthday.birthday + f"/{dt.datetime.now().year}", "%d/%m/%Y")
123102
if next_birthday < datetime.datetime.now():
124-
next_birthday = datetime.datetime.strptime(
125-
birthday.birthday + f"/{dt.datetime.now().year + 1}", "%d/%m/%Y"
126-
)
103+
next_birthday = datetime.datetime.strptime(birthday.birthday + f"/{dt.datetime.now().year + 1}", "%d/%m/%Y")
127104
await QuickEmb(
128105
inter,
129106
f"{user.mention}'s birthday is in {(next_birthday - datetime.datetime.now()).days} Days."
@@ -151,18 +128,11 @@ async def birthday_check(self):
151128
# if the birthday is today, congratulate the user
152129
if user.birthday == today:
153130
await member.add_roles(guild.get_role(self.bot.config.roles.birthday))
154-
congrats_msg = await channel.send(
155-
f"{random.choice(congrats_messages)} {member.mention}! 🎂"
156-
)
131+
congrats_msg = await channel.send(f"{random.choice(congrats_messages)} {member.mention}! 🎂")
157132
await congrats_msg.add_reaction("🥳")
158133
# If the birthday isn't today and the user still has the birthday role, remove it
159-
elif (
160-
user.birthday != today
161-
and member.get_role(self.bot.config.roles.birthday) is not None
162-
):
163-
await member.remove_roles(
164-
guild.get_role(self.bot.config.roles.birthday)
165-
)
134+
elif user.birthday != today and member.get_role(self.bot.config.roles.birthday) is not None:
135+
await member.remove_roles(guild.get_role(self.bot.config.roles.birthday))
166136

167137

168138
def setup(bot):

cogs/Blacklist.py

Lines changed: 15 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -64,40 +64,28 @@ async def blacklist_info(self, inter, user: Member):
6464
if not await self.blacklist.blacklisted(user.id):
6565
return await errorEmb(inter, f"{user.mention} is not in the blacklist")
6666
bl_user = await self.blacklist.get_user(user.id)
67-
embed = Embed(
68-
title=f"Blacklisted user: {user.name}",
69-
color=disnake.Color.random(seed=user.name),
70-
)
67+
embed = Embed(title=f"Blacklisted user: {user.name}", color=disnake.Color.random(seed=user.name))
7168
embed.add_field(name="Reason", value=bl_user.reason, inline=False)
7269
embed.add_field(name="Expires", value=bl_user.get_expiry, inline=False)
7370
embed.add_field(name="Bot", value=bl_user.bot)
7471
embed.add_field(name="Tickets", value=bl_user.tickets)
7572
embed.add_field(name="Tags", value=bl_user.tags)
7673
await inter.send(embed=embed)
7774

78-
@blacklist.sub_command_group(
79-
name="edit", description="Edit a user in the blacklist"
80-
)
75+
@blacklist.sub_command_group(name="edit", description="Edit a user in the blacklist")
8176
async def edit(self, inter):
8277
pass
8378

8479
@commands.has_permissions(manage_messages=True)
85-
@edit.sub_command(
86-
name="flags", description="Edit the user's blacklist flags in the blacklist"
87-
)
80+
@edit.sub_command(name="flags", description="Edit the user's blacklist flags in the blacklist")
8881
async def flags(self, inter, user: Member, bot: bool, tickets: bool, tags: bool):
8982
if not await self.blacklist.blacklisted(user.id):
9083
return await errorEmb(inter, f"{user.mention} is not in the blacklist")
9184
await self.blacklist.edit_flags(user.id, bot, tickets, tags)
92-
await sucEmb(
93-
inter,
94-
f"Edited {user.mention}'s blacklist flags to\nBot: {bot}, Tickets: {tickets}, Tags: {tags}",
95-
)
85+
await sucEmb(inter, f"Edited {user.mention}'s blacklist flags to\nBot: {bot}, Tickets: {tickets}, Tags: {tags}")
9686

9787
@commands.has_permissions(manage_messages=True)
98-
@edit.sub_command(
99-
name="reason", description="Edit the user's blacklist reason in the blacklist"
100-
)
88+
@edit.sub_command(name="reason", description="Edit the user's blacklist reason in the blacklist")
10189
async def reason(self, inter, user: Member, reason: str):
10290
if not await self.blacklist.blacklisted(user.id):
10391
return await errorEmb(inter, f"{user.mention} is not in the blacklist")
@@ -108,43 +96,29 @@ async def reason(self, inter, user: Member, reason: str):
10896
)
10997

11098
@commands.has_permissions(manage_messages=True)
111-
@edit.sub_command(
112-
name="expiry", description="Edit the user's blacklist expiry in the blacklist"
113-
)
99+
@edit.sub_command(name="expiry", description="Edit the user's blacklist expiry in the blacklist")
114100
async def expiry(self, inter, user: Member, expires: str):
115101
if not await self.blacklist.blacklisted(user.id):
116102
return await errorEmb(inter, f"{user.mention} is not in the blacklist")
117103
expiry = int((await timeconversions.convert(expires)).dt.timestamp())
118104
await self.blacklist.edit_expiry(user.id, expiry)
119-
await sucEmb(
120-
inter,
121-
f"Edited the expiry of {user.mention}'s blacklist to expire {get_expiry(expiry)}",
122-
)
105+
await sucEmb(inter, f"Edited the expiry of {user.mention}'s blacklist to expire {get_expiry(expiry)}")
123106
await self.check_user_removal(await self.blacklist.get_user(user.id))
124107

125108
@commands.has_permissions(manage_messages=True)
126-
@blacklist.sub_command(
127-
name="remove", description="Remove a user from the blacklist"
128-
)
109+
@blacklist.sub_command(name="remove", description="Remove a user from the blacklist")
129110
async def remove(self, inter, user: Member):
130111
if not await self.blacklist.blacklisted(user.id):
131112
return await errorEmb(inter, f"{user.mention} is not in the blacklist")
132113
await self.blacklist.remove(user.id)
133-
await sucEmb(
134-
inter, f"{user.mention} has been removed from blacklist", ephemeral=False
135-
)
114+
await sucEmb(inter, f"{user.mention} has been removed from blacklist", ephemeral=False)
136115

137116
@commands.has_permissions(manage_messages=True)
138117
@blacklist.sub_command(
139118
name="add",
140119
description="Add a user to the blacklist",
141120
options=[
142-
Option(
143-
"user",
144-
description="User to blacklist",
145-
type=OptionType.user,
146-
required=True,
147-
),
121+
Option("user", description="User to blacklist", type=OptionType.user, required=True),
148122
Option(
149123
"bot",
150124
description="Whether to blacklist the user from using the entire bot",
@@ -169,29 +143,12 @@ async def remove(self, inter, user: Member):
169143
type=OptionType.string,
170144
required=False,
171145
),
172-
Option(
173-
"reason",
174-
description="Reason for blacklisting the user",
175-
type=OptionType.string,
176-
required=False,
177-
),
146+
Option("reason", description="Reason for blacklisting the user", type=OptionType.string, required=False),
178147
],
179148
)
180-
async def blacklist_add(
181-
self,
182-
inter,
183-
user,
184-
bot,
185-
tickets,
186-
tags,
187-
reason="No Reason Specified",
188-
expires="never",
189-
):
149+
async def blacklist_add(self, inter, user, bot, tickets, tags, reason="No Reason Specified", expires="never"):
190150
if not any((bot, tickets, tags)):
191-
return await errorEmb(
192-
inter,
193-
"You can't blacklist a user without specifying either bot, tickets and/or tags",
194-
)
151+
return await errorEmb(inter, "You can't blacklist a user without specifying either bot, tickets and/or tags")
195152
elif len(reason) > 900:
196153
return await errorEmb(inter, "Reason must be under 900 chars")
197154
elif user.id == inter.author.id:
@@ -251,16 +208,11 @@ async def blacklist_list(self, inter):
251208
emb.description = f"Expires: {blacklist_list.get_expiry}\nReason: {blacklist_list.reason}\n"
252209
blacklist_embs.append(emb)
253210

254-
blacklist_embs.append(
255-
Embed(color=self.bot.config.colors.invis, description="The end ;D")
256-
)
211+
blacklist_embs.append(Embed(color=self.bot.config.colors.invis, description="The end ;D"))
257212
start_emb = Embed(title="Blacklist", color=self.bot.config.colors.invis)
258213
start_emb.description = f"There are currently {blacklist_count:,d} blacklisted user{'s' if blacklist_count > 1 else ''}, use the arrows below to navigate through them"
259214
blacklist_embs.insert(0, start_emb)
260-
await inter.send(
261-
embed=blacklist_embs[0],
262-
view=CreatePaginator(blacklist_embs, inter.author.id),
263-
)
215+
await inter.send(embed=blacklist_embs[0], view=CreatePaginator(blacklist_embs, inter.author.id))
264216

265217

266218
def setup(bot):

0 commit comments

Comments
 (0)