Skip to content

Commit 95fdc4a

Browse files
authored
Merge pull request #22 from HeDeAnTheonlyone/main
added command to change guild icon, moved same resolve code to one place
2 parents 97f5040 + 1015d40 commit 95fdc4a

File tree

14 files changed

+39
-15
lines changed

14 files changed

+39
-15
lines changed

index.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from utils.stats import update
1010

1111

12+
1213
# Setup bot
1314
bot = commands.InteractionBot(
1415
test_guilds=[variables.guild],
@@ -48,6 +49,8 @@
4849
bot.add_cog(MembersCommand(bot))
4950
from modules.utilities.commands.help import HelpCommand
5051
bot.add_cog(HelpCommand(bot))
52+
from modules.utilities.commands.icon import IconCommand
53+
bot.add_cog(IconCommand(bot))
5154
from modules.utilities.message_commands.view import ViewFileCommand
5255
bot.add_cog(ViewFileCommand(bot))
5356

modules/events/button_click.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,7 @@ async def on_button_click(self, inter: disnake.MessageInteraction):
1616
if inter.component.custom_id == "resolve_question_button":
1717
role = inter.guild.get_role(variables.helper)
1818
if (inter.channel.owner_id == inter.user.id) or (role in inter.user.roles):
19-
if len(inter.channel.applied_tags) == 5:
20-
await inter.response.send_message("This post has too many tags and the resolved tag cannot be applied. Please remove the least important one to properly resolve it.")
21-
else:
22-
await inter.response.send_message("Done.")
23-
await inter.delete_original_message()
24-
await resolve_thread(inter.channel,inter.author)
19+
await resolve_thread(inter.channel, inter.response, inter.author)
2520
else:
2621
await inter.response.send_message(
2722
embed=disnake.Embed(

modules/help_channels/commands/resolve.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,7 @@ async def resolve(self, inter: disnake.ApplicationCommandInteraction):
2121
return False
2222

2323
if (inter.channel.owner_id == inter.author.id) or (role in inter.author.roles) and channel in variables.help_channels:
24-
if len(inter.channel.applied_tags) == 5:
25-
await inter.response.send_message("This post has too many tags and the resolved tag cannot be applied. Please remove the least important one to properly resolve it.")
26-
else:
27-
await inter.response.send_message("Done.")
28-
await inter.delete_original_message()
29-
await resolve_thread(inter.channel,inter.author)
24+
await resolve_thread(inter.channel, inter.response, inter.author)
3025
else:
3126
await inter.response.send_message("You aren't allowed to do this here.", ephemeral=True)
3227
Log.info(f"{inter.author.name} tried to resolve a thread which wasn't theirs")

modules/utilities/commands/icon.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import os
2+
import disnake
3+
from disnake.ext import commands
4+
5+
ICONS = list(map(lambda s: s.removesuffix(".gif"),os.listdir(os.path.join(os.getcwd(), "static", "icons"))))
6+
7+
class IconCommand(commands.Cog):
8+
def __init__(self, bot):
9+
self.bot = bot
10+
11+
@commands.slash_command(name="icon", description="Changes the icon of the server.")
12+
async def icon(
13+
self,
14+
inter: disnake.ApplicationCommandInteraction,
15+
icon_type: str = commands.Param(
16+
default="Normal",
17+
choices=ICONS
18+
)
19+
):
20+
try:
21+
with open(os.path.join(os.getcwd(), "static", "icons", f"{icon_type}.gif"), "rb") as image_file:
22+
icon_data = image_file.read()
23+
24+
await inter.guild.edit(icon=icon_data)
25+
await inter.send("Guild icon updated.", ephemeral=True)
26+
except Exception as e:
27+
await inter.send(f"Updating guild icon failed: {e}", ephemeral=True)
28+
3.93 MB
Loading
4.3 MB
Loading
4.74 MB
Loading
4.97 MB
Loading

static/icons/Halloween.gif

967 KB
Loading

static/icons/New Years.gif

4.92 MB
Loading

0 commit comments

Comments
 (0)