Advertisement
Akuba

cmd_summon

Aug 7th, 2016
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.08 KB | None | 0 0
  1.  
  2.     async def cmd_summon(self, channel, author, voice_channel):
  3.         """
  4.        Usage:
  5.            {command_prefix}summon
  6.  
  7.        Call the bot to the summoner's voice channel.
  8.        """
  9.  
  10.         if not author.voice_channel:
  11.             raise exceptions.CommandError('You are not in a voice channel!')
  12.  
  13.         """voice_client = self.the_voice_clients.get(channel.server.id, None)
  14.        if voice_client and voice_client.channel.server == author.voice_channel.server:
  15.            await self.move_voice_client(author.voice_channel)
  16.            return"""
  17.         # can this be exploided? - no
  18.         self.serverVoice = await self.join_voice_channel(author.voice_channel)
  19.         player = self.serverVoice.create_ffmpeg_player('./samples/welcome.wav')
  20.         player.volume = self.config.default_volume
  21.         # Set the default volume or rip ears
  22.         player.start()
  23.         # move to _verify_vc_perms?
  24.         chperms = author.voice_channel.permissions_for(author.voice_channel.server.me)
  25.  
  26.         if not chperms.connect:
  27.             self.safe_print("Cannot join channel \"%s\", no permission." % author.voice_channel.name)
  28.             return Response(
  29.                 "```Cannot join channel \"%s\", no permission.```" % author.voice_channel.name,
  30.                 delete_after=25
  31.             )
  32.  
  33.         elif not chperms.speak:
  34.             self.safe_print("Will not join channel \"%s\", no permission to speak." % author.voice_channel.name)
  35.             return Response(
  36.                 "```Will not join channel \"%s\", no permission to speak.```" % author.voice_channel.name,
  37.                 delete_after=25
  38.             )
  39.        
  40.         await asyncio.sleep(4)
  41.         # the intro is a bit longer then 3 seconds
  42.         if self.serverVoice is not None:
  43.             await self.serverVoice.disconnect()
  44.             self.serverVoice = None
  45.         player = await self.get_player(author.voice_channel, create=True)
  46.         if player.is_stopped:
  47.             player.play()
  48.  
  49.         if self.config.auto_playlist:
  50.             await self.on_player_finished_playing(player)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement