async def get_list_embed(self, ctx, expanded=False): staff = is_staff(ctx) list_embed = Embed(title="Categories", bot=self.bot, user=ctx.author) list_embed.set_author(name=f"Use {ctx.prefix}help [Command/Category]") await list_embed.set_requested_by_footer() for name, cog in self.bot.cogs.items(): if name == "Admin" or name == "Help": continue if not cog.get_commands(): continue commands = [] for command in cog.get_commands(): if has_is_staff(command) and not staff: continue if hasattr(command, "commands") and expanded: sub_cmds = [command.name for command in command.commands if not has_is_staff(command) or staff] if sub_cmds: commands.append(f"`{command.name}` *({'*, *'.join(sub_cmds)})*") else: commands.append(f"`{command.name}`") else: commands.append(f"`{command.name}`") list_embed.add_field(name=name, value=", ".join(commands), inline=False) list_embed.add_field(name="Links", value="[Contribute](https://discord.gg/zqRsduD2JN) | [Vote](https://top.gg/bot/630106665387032576/vote) | [Invite the Bot to your server](https://discordapp.com/oauth2/authorize?client_id=630106665387032576&scope=bot%20applications.commands&permissions=8) | [Support Server](https://discord.gg/7fPv2uY2Tf) | [Todos](https://trello.com/b/2yBAtx82/skybot-rewrite) | [GitHub repo](https://github.com/Skybot-dev/Skybot-rewrite)", inline=False) return list_embed
async def help(self, ctx: commands.Context, *, arg=None): if arg is None or arg.lower() == "list": await ctx.invoke(self.list) return arg = arg.lower() staff = is_staff(ctx) command_names = [ command.name for command in self.bot.commands if str(command.cog) != "Admin" and str(command.cog) != "Help" and not has_is_staff(command) or staff ] for command in self.bot.commands: if str(command.cog) != "Admin" and str( command.cog) != "Help" and not has_is_staff( command) or staff: for alias in command.aliases: command_names.append(alias) if arg.split(" ")[0] in command_names: await ctx.invoke(self.show_command, arg=arg) return cog_names = [ cog.lower() for cog in self.bot.cogs if cog != "Admin" and cog != "Help" ] if arg in cog_names: await ctx.invoke(self.show_cog, arg=arg) return raise commands.BadArgument(message="Command or Category not found")
async def show_command(self, ctx, arg): if isinstance(arg, commands.Command): command = arg elif isinstance(arg, str): command = self.bot.get_command(arg) if has_is_staff(command) and not is_staff(ctx): raise commands.BadArgument(message="Command or Category not found") if command.parents: command_embed = Embed(title=f"{ctx.prefix}{' '.join([command.name.capitalize() for command in command.parents])} {command.name.capitalize()}", bot=self.bot, user=ctx.author) else: command_embed = Embed(title=f"{ctx.prefix}{command.name.capitalize()}", bot=self.bot, user=ctx.author) await command_embed.set_requested_by_footer() if command.description == "": description = "No Description." else: description = command.description if command.usage is None: usage = "No Usage." elif command.parents: usage = f"{ctx.prefix}{' '.join([command.name.capitalize() for command in command.parents])} {command.name.capitalize()} {command.usage}" else: usage = f"{ctx.prefix}{command.name.capitalize()} {command.usage}" if command.aliases == []: aliases = "No Aliases." else: aliases = str(command.aliases).replace("[", " ").replace("]", " ").replace("'", " ").replace(",", "\n") command_embed.add_field(name="Description", value=description, inline=False) command_embed.add_field(name="Usage", value=usage, inline=False) command_embed.add_field(name="Aliases", value=aliases, inline=False) await ctx.send(embed=command_embed)