feat(tts): new command

Co-authored-by: neoarz <tyrantneo740@gmail.com>
This commit is contained in:
se2crid
2025-10-15 06:35:19 +02:00
committed by GitHub
parent 14cb324e0e
commit 6a43c93637
5 changed files with 193 additions and 6 deletions

View File

@@ -7,6 +7,7 @@ from .download import download_command
from .mcquote import mcquote_command
from .img2gif import img2gif_command
from .tweety import tweety_command
from .tts import tts_command
def _require_group_prefix(context: Context) -> bool:
@@ -46,7 +47,7 @@ class Media(commands.GroupCog, name="media"):
color=0x7289DA
)
embed.set_author(name="Media", icon_url="https://yes.nighty.works/raw/y5SEZ9.webp")
embed.add_field(name="Available", value="download, mcquote, img2gif, tweety", inline=False)
embed.add_field(name="Available", value="download, mcquote, img2gif, tweety, tts", inline=False)
await context.send(embed=embed)
async def _invoke_hybrid(self, context: Context, name: str, *args, **kwargs):
@@ -62,6 +63,9 @@ class Media(commands.GroupCog, name="media"):
if name == "tweety":
await self.tweety(context)
return
if name == "tts":
await self.tts(context, text=kwargs.get('text'))
return
await context.send(f"Unknown media command: {name}")
@media_group.command(name="download")
@@ -80,6 +84,10 @@ class Media(commands.GroupCog, name="media"):
async def media_group_tweety(self, context: Context):
await self._invoke_hybrid(context, "tweety")
@media_group.command(name="tts")
async def media_group_tts(self, context: Context, *, text: str = None):
await self._invoke_hybrid(context, "tts", text=text)
@commands.check(_require_group_prefix)
@commands.hybrid_command(
name="download",
@@ -112,11 +120,20 @@ class Media(commands.GroupCog, name="media"):
async def tweety(self, context):
return await tweety_command()(self, context)
@commands.check(_require_group_prefix)
@commands.hybrid_command(
name="tts",
description="Convert text to speech using Google Text-to-Speech.",
)
async def tts(self, context, text: str = None):
return await tts_command()(context, text=text)
async def setup(bot) -> None:
cog = Media(bot)
await bot.add_cog(cog)
bot.logger.info("Loaded extension 'media.download'")
bot.logger.info("Loaded extension 'media.mcquote'")
bot.logger.info("Loaded extension 'media.img2gif'")
bot.logger.info("Loaded extension 'media.tweety'")
bot.logger.info("Loaded extension 'media.tts'")