fix(tweety): remove theme args since buttons work

Simplifies the tweety command by removing the 'verified' and 'theme' arguments from command signatures and related logic. Defaults for these options are now set internally, and toggling is handled via UI elements instead of command parameters.
This commit is contained in:
neoarz
2025-10-07 21:29:42 -04:00
parent 70af8e24b2
commit 7419ec5f59
2 changed files with 11 additions and 35 deletions

View File

@@ -35,22 +35,8 @@ class Media(commands.GroupCog, name="media"):
content_without_mention = content.replace(f'<@{self.bot.user.id}>', '').replace(f'<@!{self.bot.user.id}>', '').strip() content_without_mention = content.replace(f'<@{self.bot.user.id}>', '').replace(f'<@!{self.bot.user.id}>', '').strip()
if 'tweety' in content_without_mention: if 'tweety' in content_without_mention:
parts = content_without_mention.split()
verified = "false"
theme = "light"
for i, part in enumerate(parts):
if part == 'tweety':
if i + 1 < len(parts):
if parts[i + 1] in ['verified', 'true', 'yes']:
verified = "true"
if 'dark' in parts or 'night' in parts:
theme = "dark"
break
ctx = await self.bot.get_context(message) ctx = await self.bot.get_context(message)
await self.tweety(ctx)
await self.tweety(ctx, verified=verified, theme=theme)
@commands.group(name="media", invoke_without_command=True) @commands.group(name="media", invoke_without_command=True)
async def media_group(self, context: Context): async def media_group(self, context: Context):
@@ -74,7 +60,7 @@ class Media(commands.GroupCog, name="media"):
await self.img2gif(context, attachment=kwargs.get('attachment')) await self.img2gif(context, attachment=kwargs.get('attachment'))
return return
if name == "tweety": if name == "tweety":
await self.tweety(context, verified=kwargs.get('verified', "false"), theme=kwargs.get('theme', "light")) await self.tweety(context)
return return
await context.send(f"Unknown media command: {name}") await context.send(f"Unknown media command: {name}")
@@ -91,8 +77,8 @@ class Media(commands.GroupCog, name="media"):
await self._invoke_hybrid(context, "img2gif", attachment=attachment) await self._invoke_hybrid(context, "img2gif", attachment=attachment)
@media_group.command(name="tweety") @media_group.command(name="tweety")
async def media_group_tweety(self, context: Context, verified: str = "false", theme: str = "light"): async def media_group_tweety(self, context: Context):
await self._invoke_hybrid(context, "tweety", verified=verified, theme=theme) await self._invoke_hybrid(context, "tweety")
@commands.check(_require_group_prefix) @commands.check(_require_group_prefix)
@commands.hybrid_command( @commands.hybrid_command(
@@ -123,8 +109,8 @@ class Media(commands.GroupCog, name="media"):
name="tweety", name="tweety",
description="Convert a replied message to a tweet image.", description="Convert a replied message to a tweet image.",
) )
async def tweety(self, context, verified: str = "false", theme: str = "light"): async def tweety(self, context):
return await tweety_command()(self, context, verified=verified, theme=theme) return await tweety_command()(self, context)
async def setup(bot) -> None: async def setup(bot) -> None:
cog = Media(bot) cog = Media(bot)

View File

@@ -151,20 +151,8 @@ def tweety_command():
name="tweety", name="tweety",
description="Convert a replied message to a tweet image." description="Convert a replied message to a tweet image."
) )
@app_commands.describe(
verified="Add a verified badge to the tweet",
theme="Choose the theme for the tweet"
)
@app_commands.choices(verified=[
app_commands.Choice(name="No", value="false"),
app_commands.Choice(name="Yes", value="true")
])
@app_commands.choices(theme=[
app_commands.Choice(name="Light", value="light"),
app_commands.Choice(name="Dark", value="dark")
])
@commands.cooldown(1, 10, commands.BucketType.user) @commands.cooldown(1, 10, commands.BucketType.user)
async def tweety(self, context, verified: Optional[str] = "false", theme: Optional[str] = "light"): async def tweety(self, context):
interaction = getattr(context, "interaction", None) interaction = getattr(context, "interaction", None)
if interaction is not None: if interaction is not None:
try: try:
@@ -184,8 +172,10 @@ def tweety_command():
except Exception: except Exception:
pass pass
return return
verified_bool = verified == "true"
theme_bool = theme == "dark" # Default to light mode, non-verified (buttons will allow toggling)
verified_bool = False
theme_bool = False
if not context.message.reference or not context.message.reference.message_id: if not context.message.reference or not context.message.reference.message_id:
embed = discord.Embed( embed = discord.Embed(