From bb92b04b78aa1ff614c525460dfabce35cdc3c8c Mon Sep 17 00:00:00 2001 From: whats2000 <60466660+whats2000@users.noreply.github.com> Date: Fri, 31 Jan 2025 16:39:46 +0800 Subject: [PATCH] =?UTF-8?q?Add:=20=E6=96=B0=E5=A2=9E=20slash=20command=20?= =?UTF-8?q?=E4=BE=86=E5=95=9F=E7=94=A8=E8=87=AA=E5=8B=95=E8=BD=89=E8=AA=9E?= =?UTF-8?q?=E9=9F=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bot/commands/tts_commands.py | 26 ++++++++++++++++++++++++++ data/user_settings.json | 3 ++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/bot/commands/tts_commands.py b/bot/commands/tts_commands.py index 59f3b97..3b28d2f 100644 --- a/bot/commands/tts_commands.py +++ b/bot/commands/tts_commands.py @@ -170,6 +170,32 @@ def after_playing(error): ) await inter.edit_original_response(embed=embed) + @commands.slash_command( + name="tts_start", + guild_ids=[GUILD_ID], + description="啟用文字轉語音功能" + ) + async def tts_start(self, inter: disnake.ApplicationCommandInteraction): + user_id = inter.author.id + settings = user_settings.get_user_settings(user_id) + settings["tts_enabled"] = True + user_settings.set_user_settings(user_id, settings) + await inter.response.send_message(f"TTS 已啟用,針對用戶:{inter.author.name}", ephemeral=True) + logger.info(f"TTS enabled for user: {inter.author.name}") + + @commands.slash_command( + name="tts_stop", + guild_ids=[GUILD_ID], + description="禁用文字轉語音功能" + ) + async def tts_stop(self, inter: disnake.ApplicationCommandInteraction): + user_id = inter.author.id + settings = user_settings.get_user_settings(user_id) + settings["tts_enabled"] = False + user_settings.set_user_settings(user_id, settings) + await inter.response.send_message(f"TTS 已禁用,針對用戶:{inter.author.name}", ephemeral=True) + logger.info(f"TTS disabled for user: {inter.author.name}") + def setup(bot: commands.Bot): bot.add_cog(TTSCommands(bot)) diff --git a/data/user_settings.json b/data/user_settings.json index da1b111..47dc5a5 100644 --- a/data/user_settings.json +++ b/data/user_settings.json @@ -32,7 +32,8 @@ }, "880316234455982121": { "selected_sample": "\u937e\u96e2", - "game_id": "Eric_Yang" + "game_id": "Eric_Yang", + "tts_enabled": true }, "574515974573785098": { "selected_sample": "\u80e1\u6843"