def vsetup(self, author):
"""Creates the voice client
Args:
author (discord.Member): The user that the voice ui will seek
"""
if self.vready:
logger.warning("Attempt to init voice when already initialised")
return
if self.state != 'starting':
logger.error("Attempt to init from wrong state ('{}'), must be 'starting'.".format(self.state))
return
self.logger.debug("Setting up voice")
# Create voice client
self.vchannel = author.voice.voice_channel
if self.vchannel:
self.statuslog.info("Connecting to voice")
try:
self.vclient = await client.join_voice_channel(self.vchannel)
except discord.ClientException as e:
logger.exception(e)
self.statuslog.warning("I'm already connected to a voice channel.")
return
except discord.opus.OpusNotLoaded as e:
logger.exception(e)
logger.error("Could not load Opus. This is an error with your FFmpeg setup.")
self.statuslog.error("Could not load Opus.")
return
except discord.DiscordException as e:
logger.exception(e)
self.statuslog.error("I couldn't connect to the voice channel. Check my permissions.")
return
except Exception as e:
self.statuslog.error("Internal error connecting to voice, disconnecting.")
logger.error("Error connecting to voice {}".format(e))
return
else:
self.statuslog.error("You're not connected to a voice channel.")
return
self.vready = True
评论列表
文章目录