You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import logging
import asyncio
import os
import discord
from astrbot.api.event import AstrMessageEvent
from astrbot.api.star import Context
logging.getLogger("discord.voice_client").setLevel(logging.DEBUG)
logging.getLogger("discord.gateway").setLevel(logging.DEBUG)
class DiscordMusicHandler:
def __init__(self, context: Context):
self.voice_clients = {}
async def join_voice(self, event: AstrMessageEvent):
"""Command: /join - Connects the bot to your current voice channel"""
msg = getattr(event.message_obj, "raw_message", None)
if not msg or not msg.guild or not msg.author.voice:
return "Unable to retrieve channel information or the user is not in a voice channel."
target_channel = msg.author.voice.channel
guild = msg.guild
# Disconnect from any existing voice connection in the guild
if guild.voice_client:
try:
await guild.voice_client.disconnect(force=True)
except Exception:
pass
try:
vc = await target_channel.connect(timeout=5.0, reconnect=True)
self.voice_clients[guild.id] = vc
logging.info(f"Connected: {vc.is_connected()}")
return f"Successfully joined: {target_channel.name}"
except Exception as e:
return f"Connection failed: {type(e).__name__} - {str(e)}"
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
好像基本没有discord相关的插件。
我用ai随便乱生成了一个插件,每次输入指令让bot进语音都会在进去十几秒后弹出来,bot的状态也是说它有困难连接语音。
这是那个乱生成的插件的一部分,有没有大佬知道问题在哪或者能推荐可以用的discord插件:
Beta Was this translation helpful? Give feedback.
All reactions