async def allcommands(self, ctx): '''All the commands''' # TODO: Fix/Deprecate?, all_commands alias formatter = commands.HelpFormatter(show_check_failure=True, show_hidden=True) formatter.format_help_for(ctx, self.bot) _commands = formatter.filter_command_list() _allcommands = "" for name, _command in _commands: _allcommands += name + ' ' await self.bot.whisper(_allcommands[:-1])
async def _help(self, ctx, command: str = None): """Gets help for a single command, or an entire category.""" formatter = commands.HelpFormatter(show_check_failure=True) if command is None: await ctx.send("\n".join(await formatter.format_help_for(ctx, self.bot))) else: thing = self.bot.get_cog(command) or self.bot.get_command(command) if thing is None: await ctx.send(f"Command or category {command} not found.") else: await ctx.send("\n".join(await formatter.format_help_for(ctx, thing)))
async def send_help(self) -> List[discord.Message]: """Send the command help message. Returns ------- `list` of `discord.Message` A list of help messages which were sent to the user. """ command = self.invoked_subcommand or self.command embed_wanted = await self.bot.embed_requested( self.channel, self.author, command=self.bot.get_command("help")) if self.guild and not self.channel.permissions_for( self.guild.me).embed_links: embed_wanted = False ret = [] destination = self if embed_wanted: embeds = await self.bot.formatter.format_help_for(self, command) for embed in embeds: try: m = await destination.send(embed=embed) except discord.HTTPException: destination = self.author m = await destination.send(embed=embed) ret.append(m) else: f = commands.HelpFormatter() msgs = await f.format_help_for(self, command) for msg in msgs: try: m = await destination.send(msg) except discord.HTTPException: destination = self.author m = await destination.send(msg) ret.append(m) return ret
def teardown(bot): bot.formatter = commands.HelpFormatter()
msg = f":x: **You can't do that here.**\nPlease do this in {error.channel.mention}" else: msg = "You can't use that command in this server." await ctx.send(msg, delete_after=10) elif isinstance(error, commands.CommandNotFound): pass else: exc = getattr(error, 'original', error) msg = f'Error with message\n{ctx.message.content}' tb = ''.join( traceback.format_exception(type(exc), exc, exc.__traceback__)) print('\n'.join((msg, tb))) await ctx.send(str(exc)) formatter = commands.HelpFormatter(show_check_failure=True) initial_extensions = [ f'cogs.{ext}' for ext in ('main', 'utility', 'points', 'exp', 'roles', 'help', 'giveaway') ] description = 'Survivor Bot - Created by MadWookie & sgtlaggy.' bot = SurvivorBot(command_prefix=['!'], description=description, formatter=formatter, request_offline_members=True) bot.ready = False bot.db_pool = bot.loop.run_until_complete( asyncpg.create_pool(config.dsn, init=set_codecs))