feat: made coco an actual slash command

This commit is contained in:
Seaswimmer 2023-08-08 10:17:45 -04:00
parent 41e3c3f278
commit 2928c5f89f
No known key found for this signature in database
GPG key ID: 5019678FD9CF50D8

View file

@ -77,44 +77,46 @@ class Galaxy(commands.Cog):
return return
await message.add_reaction(emoji) await message.add_reaction(emoji)
@commands.group(autohelp=False, invoke_without_command=True) @commands.command(name='coco')
@commands.guild_only() @commands.guild_only()
async def coco(self, ctx): async def coco_list(self, ctx: commands.Context):
"""Checks who Coco is currently set to.""" """Checks who Coco is currently set to."""
emoji = self.bot.get_emoji(await self.config.guild(ctx.guild).cocoemoji()) emoji = self.bot.get_emoji(await self.config.guild(ctx.guild).cocoemoji())
cocotarget = await self.config.guild(ctx.guild).cocotarget() cocotarget = await self.config.guild(ctx.guild).cocotarget()
embed = discord.Embed(color=await self.bot.get_embed_color(None), description=f"Coco is currently set to <@{cocotarget}> ({cocotarget}).\nCoco's emoji is currently set to {emoji} ({await self.config.guild(ctx.guild).cocoemoji()}).") embed = discord.Embed(color=await self.bot.get_embed_color(None), description=f"Coco is currently set to <@{cocotarget}> ({cocotarget}).\nCoco's emoji is currently set to {emoji} ({await self.config.guild(ctx.guild).cocoemoji()}).")
await ctx.send(embed=embed) await ctx.send(embed=embed)
coco = app_commands.Group(name='coco', guild_only=True)
@coco.command(name="emoji") @coco.command(name="emoji")
async def coco_emoji(self, ctx, emoji: discord.Emoji = None): async def coco_emoji(self, interaction: discord.Interaction, emoji: discord.Emoji = None):
"""Sets Coco's emoji.""" """Sets Coco's emoji."""
if emoji: if emoji:
await self.config.guild(ctx.guild).cocoemoji.set(emoji.id) 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}).") embed=discord.Embed(color=await self.bot.get_embed_color(None), description=f"Coco's emoji has been set to {emoji} ({emoji.id}).")
await ctx.send(embed=embed) await interaction.response.send_message(embed=embed)
else: else:
await self.config.guild(ctx.guild).cocoemoji.set(1028535684757209118) await self.config.guild(interaction.guild).cocoemoji.set(1028535684757209118)
emoji = self.bot.get_emoji(1028535684757209118) emoji = self.bot.get_emoji(1028535684757209118)
embed=discord.Embed(color=await self.bot.get_embed_color(None), description=f"Coco's emoji has been set to {emoji} (1028535684757209118).") embed=discord.Embed(color=await self.bot.get_embed_color(None), description=f"Coco's emoji has been set to {emoji} (1028535684757209118).")
await ctx.send(embed=embed) await interaction.response.send_message(embed=embed)
@coco.command(name="set") @coco.command(name="set")
async def coco_set(self, ctx, member: discord.Member): async def coco_set(self, interaction: discord.Interaction, member: discord.Member):
"""Sets Coco's target.""" """Sets Coco's target."""
if member: if member:
await self.config.guild(ctx.guild).cocotarget.set(member.id) await self.config.guild(interaction.guild).cocotarget.set(member.id)
embed=discord.Embed(color=await self.bot.get_embed_color(None), description=f"Coco has been set to {member.mention} ({member.id}).") embed=discord.Embed(color=await self.bot.get_embed_color(None), description=f"Coco has been set to {member.mention} ({member.id}).")
await ctx.send(embed=embed) await interaction.response.send_message(embed=embed)
else: else:
await ctx.send(content="That is not a valid argument!") await interaction.response.send_message(content="That is not a valid argument!", ephemeral=True)
@coco.command(name="reset") @coco.command(name="reset")
async def coco_reset(self, ctx): async def coco_reset(self, interaction: discord.Interaction):
"""Resets Coco's target.""" """Resets Coco's target."""
await self.config.guild(ctx.guild).cocotarget.set(0) await self.config.guild(interaction.guild).cocotarget.set(0)
embed=discord.Embed(color=await self.bot.get_embed_color(None), description=f"Coco has been reset.") embed=discord.Embed(color=await self.bot.get_embed_color(None), description=f"Coco has been reset.")
await ctx.send(embed=embed) await interaction.response.send_message(embed=embed)
@commands.command() @commands.command()
async def unix(self, ctx): async def unix(self, ctx):