29 lines
1.0 KiB
Python
29 lines
1.0 KiB
Python
import logging
|
|
|
|
class VoiceChannelManager:
|
|
async def join_voice_channel(self, channel):
|
|
"""ボイスチャンネルに接続する"""
|
|
try:
|
|
await channel.connect()
|
|
except Exception as e:
|
|
logging.info(f"Failed to join voice channel: {e}")
|
|
raise
|
|
|
|
async def leave_voice_channel(self, guild, bot=None):
|
|
"""ボイスチャンネルから切断する"""
|
|
try:
|
|
if guild.voice_client is not None:
|
|
await guild.voice_client.disconnect()
|
|
if bot is not None:
|
|
bot.volume = 1.0
|
|
bot.reset_emotion()
|
|
except Exception as e:
|
|
logging.info(f"Failed to leave voice channel: {e}")
|
|
raise
|
|
|
|
def get_connected_channel(self, guild):
|
|
"""ボットが接続しているボイスチャンネルを取得する"""
|
|
if guild.voice_client and guild.voice_client.is_connected():
|
|
return guild.voice_client.channel
|
|
return None
|