This commit is contained in:
End 2026-03-19 08:44:23 -07:00
parent 80ba304043
commit 026d0d94ea
No known key found for this signature in database

13
bot.py
View file

@ -26,7 +26,6 @@ with open("config.json", "r", encoding="utf-8") as f:
with open("voices.json", "r", encoding="utf-8") as f:
voices_data = json.load(f)
data directory (set this in your deployment environment, e.g. Coolify)
DATA_DIR = os.getenv("DATA_DIR", "/app/data")
Path(DATA_DIR).mkdir(parents=True, exist_ok=True)
@ -181,8 +180,7 @@ async def enqueue(
guild: discord.Guild, member: discord.Member, text: str, voice_id: str
):
q = tts_queues.setdefault(guild.id, asyncio.Queue())
await q.put((text
, voice_id, member))
await q.put((text, voice_id, member))
if q.qsize() == 1:
asyncio.create_task(queue_worker(guild))
@ -233,7 +231,9 @@ async def queue_worker(guild: discord.Guild):
except Exception as e:
logger.error(f"Playback error: {e}")
try:
await member.send("Failed to play audio. Check that ffmpeg is installed.")
await member.send(
"Failed to play audio. Check that ffmpeg is installed."
)
except Exception:
pass
@ -271,7 +271,9 @@ async def on_message(message: discord.Message):
if not message.author.voice or not message.author.voice.channel:
try:
await message.reply("You need to be in a voice channel.", mention_author=False)
await message.reply(
"You need to be in a voice channel.", mention_author=False
)
except Exception:
pass
return
@ -521,7 +523,6 @@ async def tts_enable(interaction: discord.Interaction):
)
return
enabled = tts_enabled.setdefault(interaction.guild_id, set())
if interaction.user.id in enabled:
await interaction.response.send_message(