fix: hopefully fixed the cog not loading
This commit is contained in:
parent
524bf59df5
commit
c22ad4e506
1 changed files with 17 additions and 3 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import discord
|
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.")
|
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")
|
@coco.command(name="emoji")
|
||||||
@app_commands.describe(emoji="Which emoji are you setting Coco to use?")
|
@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."""
|
"""Sets Coco's emoji."""
|
||||||
if emoji:
|
if emoji:
|
||||||
await self.config.guild(interaction.guild).cocoemoji.set(emoji.id)
|
emoji_id = self.extract_id(emoji)
|
||||||
embed=discord.Embed(color=await self.bot.get_embed_color(None), description=f"Coco's emoji has been set to {emoji} ({emoji.id}).")
|
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)
|
await interaction.response.send_message(embed=embed)
|
||||||
else:
|
else:
|
||||||
await self.config.guild(interaction.guild).cocoemoji.set(1028535684757209118)
|
await self.config.guild(interaction.guild).cocoemoji.set(1028535684757209118)
|
||||||
|
|
Loading…
Reference in a new issue