fix: hopefully fixed the cog not loading

This commit is contained in:
Seaswimmer 2023-08-08 10:26:37 -04:00
parent 524bf59df5
commit c22ad4e506
No known key found for this signature in database
GPG key ID: 5019678FD9CF50D8

View file

@ -1,3 +1,4 @@
import re
import subprocess
from datetime import datetime
import discord
@ -88,13 +89,26 @@ class Galaxy(commands.Cog):
coco = app_commands.Group(name='coco', guild_only=True, description="This group handles the autoreact functionality.")
def extract_id(input_string):
match = re.search(r'(?<=:)\d+(?=>)', input_string)
if match:
return match.group()
else:
return input_string
@coco.command(name="emoji")
@app_commands.describe(emoji="Which emoji are you setting Coco to use?")
async def coco_emoji(self, interaction: discord.Interaction, emoji: discord.Emoji = None):
async def coco_emoji(self, interaction: discord.Interaction, emoji: str = None):
"""Sets Coco's emoji."""
if emoji:
await self.config.guild(interaction.guild).cocoemoji.set(emoji.id)
embed=discord.Embed(color=await self.bot.get_embed_color(None), description=f"Coco's emoji has been set to {emoji} ({emoji.id}).")
emoji_id = self.extract_id(emoji)
try:
emoji_obj = interaction.guild.fetch_emoji(emoji_id)
except discord.NotFound or discord.HTTPException as error:
await interaction.response.send_message(content="You're trying to set the coco emoji to an emoji I don't have access to!", ephemeral=True)
return
await self.config.guild(interaction.guild).cocoemoji.set(emoji_obj.id)
embed=discord.Embed(color=await self.bot.get_embed_color(None), description=f"Coco's emoji has been set to {emoji_obj} ({emoji_obj.id}).")
await interaction.response.send_message(embed=embed)
else:
await self.config.guild(interaction.guild).cocoemoji.set(1028535684757209118)