def joinVC(self, toJoin, channel=None):
'''
Joins a given voice channel.
Will join the VC of a member if a member is passed.
'''
if channel == None:
channel = self.lastChannel
# Join a channel if specified
if type(toJoin) == Channel:
loadedVC = self.sparcli.join_voice_channel(toJoin)
self.voiceClient = loadedVC
return loadedVC
# No channel specified, join the user's VC
memberVC = toJoin.voice.voice_channel
if memberVC == None:
await self.sparcli.send_message(channel, 'You aren\'t currently in a voice channel.')
return False
# Join the member's VC
try:
# Try to join
loadedVC = await self.sparcli.join_voice_channel(memberVC)
self.voiceClient = loadedVC
return loadedVC
except ClientException:
# You're already in it
loadedVC = self.sparcli.voice_client_in(toJoin.server)
self.voiceClient = loadedVC
return loadedVC
else:
# You can't join it
await self.sparcli.send_message(channel, 'I am unable to join that voice channel.')
return False
评论列表
文章目录