async def summon(self, ctx, channel: discord.VoiceChannel = None): """Summons the bot to the voice channel you are currently in You can specify the specific voice channel that you would like to connect to. If no channel is specified, it will connect to whatever channel you are currently in. **Example:** `{cmdpfx}summon General`""" if not channel: if not ctx.message.guild: raise UserError("You have to say that in a server") if not ctx.message.author.voice: raise UserError("You are not currently in a voice channel") channel = ctx.message.author.voice.channel if channel.guild != ctx.message.guild: raise UserError( "You are not currently in a voice channel on this server/guild" ) audio = self.bot.get_cog("Audio") if not audio: raise UserError("You must have the Audio cog enabled to do this") try: await audio.connect_voice(channel) botdata.guildinfo(channel.guild.id).voicechannel = channel.id except asyncio.TimeoutError: cmdpfx = botdata.command_prefix(ctx) raise UserError( f"There was a timeout when attempting to do the `{cmdpfx}summon`" ) await ctx.message.add_reaction("✅")
async def remoteresummon(self, ctx, guild_id : int): """Re-summons the bot for the given guild This command is useful if you are having issues with mangobyte not being responsive""" audio = self.bot.get_cog("Audio") if not audio: raise UserError("You must have the Audio cog enabled to do this") guild = self.bot.get_guild(guild_id) if guild is None: raise UserError(f"guild '{guild_id}' not found") guildinfo = botdata.guildinfo(guild_id) channel = None if guild.me.voice: channel = guild.me.voice.channel elif guildinfo.voicechannel is not None: channel = self.bot.get_channel(guildinfo.voicechannel) else: raise UserError("I'm not sure where you want me to resummon to. I'm not in any channel currently.") await audio.disconnect(guild) await asyncio.sleep(1) try: await audio.connect_voice(channel) guildinfo.voicechannel = channel.id except asyncio.TimeoutError: cmdpfx = botdata.command_prefix(ctx) raise UserError(f"There was a timeout when attempting to do the `{cmdpfx}summon`") await ctx.message.add_reaction("✅")
async def resummon(self, ctx): """Re-summons the bot to the voice channel This command is useful if you are having issues with mangobyte not being responsive""" audio = self.bot.get_cog("Audio") if not audio: raise UserError("You must have the Audio cog enabled to do this") if not ctx.message.guild: raise UserError("You have to be in a server to use this command") guildinfo = botdata.guildinfo(ctx.message.guild.id) save_channel = False channel = None if ctx.message.guild.me.voice: channel = ctx.message.guild.me.voice.channel elif ctx.message.author.voice: channel = ctx.message.author.voice.channel elif guildinfo.voicechannel is not None: channel = self.bot.get_channel(guildinfo.voicechannel) else: raise UserError("I'm not sure where you want me to resummon to. I'm not in any channel currently.") await audio.disconnect(ctx.message.guild) await asyncio.sleep(1) try: await audio.connect_voice(channel) guildinfo.voicechannel = channel.id except asyncio.TimeoutError: cmdpfx = botdata.command_prefix(ctx) raise UserError(f"There was a timeout when attempting to do the `{cmdpfx}summon`") await ctx.message.add_reaction("✅")
def fill_template(self, text): text = re.sub("\{config_help\}", get_config_help(GuildInfo.variables, "config"), text) text = re.sub("\{userconfig_help\}", get_config_help(UserInfo.variables, "userconfig"), text) text = re.sub("\{cmdpfx\}", botdata.command_prefix(self.context), text) text = re.sub("\n`", u"\n\u200b`", text) return text
def cmdpfx(self, ctx): return botdata.command_prefix(ctx)
def get_command_signature(self, command): return '%s%s %s' % (botdata.command_prefix(self.context), command.qualified_name, command.signature)