Skip to content

Commit

Permalink
Add: 新增 slash command 來啟用自動轉語音
Browse files Browse the repository at this point in the history
  • Loading branch information
whats2000 committed Jan 31, 2025
1 parent 0e17c81 commit bb92b04
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
26 changes: 26 additions & 0 deletions bot/commands/tts_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
3 changes: 2 additions & 1 deletion data/user_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit bb92b04

Please sign in to comment.