CasuallyCalm / discord-pretty-help

An embed version of the built in help command for discord.py
MIT License
127 stars 32 forks source link

Not every cog shows in the command #5

Closed lpkeates closed 4 years ago

lpkeates commented 4 years ago

I can't seem to see every single cog my bot has in the help command.

I have 3 cogs, but its showing all except 1 all of a sudden.

Code for the missing cog:

``import discord from discord.ext import commands

class Moderation(commands.Cog):
def init(self, bot): self.bot = bot

@commands.command(name="ban")
@commands.has_guild_permissions(ban_members=True)
@commands.bot_has_guild_permissions(ban_members=True)
async def ban(self, ctx, member: discord.Member, reason):
    """
    Bans a user
    """
    if member.top_role > ctx.author.top_role:
        embed = discord.Embed(title="Nice try! You can't ban a higher up role.")
        await ctx.send(embed=embed)
    elif member == ctx.author:
        embed = discord.Embed(title=":x: You cannot ban yourself! If you are feeling/having suicidal/self-harm thoughts, visit https://en.wikipedia.org/wiki/List_of_suicide_crisis_lines")
        await ctx.send(embed=embed)

    await member.ban()
    embed = discord.Embed(title=f":white_check_mark: {member} was banned; {reason}.")
    await ctx.send(embed=embed)
    channel = await member.create_dm()
    await channel.send(f'You were banned in {ctx.guild.name} for {reason}.')

@commands.command(name="unban")
@commands.has_guild_permissions(ban_members=True)
@commands.bot_has_guild_permissions(ban_members=True)
async def unban(self, ctx, member: discord.Member, reason):
    """
    Unbans a user
    """
    banned_users = await ctx.guild.bans()
    member_name, member_discriminator = member.split('#')
    for ban_entry in banned_users:
        member = ban_entry.member

    if (member_name, member_discriminator) == (member_name, member_discriminator):
        await member.unban()
        embed = discord.Embed(title=f"{member} was unbanned; {reason}")
        await ctx.send(embed=embed)
    elif member == None:
        embed = discord.Embed(title=":x: You need to sepcify a user!")
        await ctx.send(embed=embed)  

    embed = discord.Embed(title=f"{member} is not banned.")
    await ctx.send(embed=embed)
    channel = await member.create_dm()
    await channel.send(f'You were unbanned in {ctx.guild.name} for {reason}.')

@commands.command(name="mute")
@commands.has_guild_permissions(manage_roles=True)
@commands.bot_has_guild_permissions(manage_roles=True)
async def mute(self, ctx, member: discord.Member, reason):
    """
    Mutes a user
    """
    if member.top_role > ctx.author.top_role:
        embed = discord.Embed(title="Nice try! You can't mute a higher up role.")
        await ctx.send(embed=embed)
    elif member == ctx.author:
        embed = discord.Embed(title=":x: You cannot mute yourself! If you are feeling/having suicidal/self-harm thoughts, visit https://en.wikipedia.org/wiki/List_of_suicide_crisis_lines")
        await ctx.send(embed=embed)       
    elif not discord.utils.get(name="Muted", permissions=discord.Permissions(send_messages=True, manage_messages=False)):
        await ctx.create_role(name="Muted", permissions=discord.Permissions(send_messages=True, manage_messages=False))
        await ctx.add_roles(name="Muted", reason="Muted")

    channel = await member.create_dm()
    await channel.send(f'You were muted in {ctx.guild.name} for {reason}.')

@commands.command(name="unmute")
@commands.has_guild_permissions(manage_roles=True)
@commands.bot_has_guild_permissions(manage_roles=True)
async def unmute(self, ctx, member: discord.Member, reason):
    """
    Unmutes a user
    """
    if member.top_role > ctx.author.top_role:
        embed = discord.Embed(title="Nice try! You can't mute a higher up role.")
        await ctx.send(embed=embed)
    elif member == ctx.author:
        embed = discord.Embed(title=":x: You cannot mute yourself! If you are feeling/having suicidal/self-harm thoughts, visit https://en.wikipedia.org/wiki/List_of_suicide_crisis_lines")
        await ctx.send(embed=embed)       
    elif not discord.utils.get(name="Muted", permissions=discord.Permissions(send_messages=True, manage_messages=False)):
        await ctx.create_role(name="Muted", permissions=discord.Permissions(send_messages=True, manage_messages=False))
        await ctx.remove_roles(name="Muted", reason="Unmuted")

    channel = await member.create_dm()
    await channel.send(f'You were unmuted in {ctx.guild.name} for {reason}.')

@commands.command(name="kick")
@commands.has_permissions(kick_members=True)
@commands.bot_has_guild_permissions(kick_members=True)
async def kick(self, ctx, member: discord.Member, reason):
    """
    Kicks a user
    """
    if member.top_role > ctx.author.top_role:
        embed = discord.Embed(title="Nice try! You can't kick a higher up role.")
        await ctx.send(embed=embed) 
    elif member == ctx.author:
        embed = discord.Embed(title=":x: You cannot kick yourself! If you are feeling/having suicidal/self-harm thoughts, visit https://en.wikipedia.org/wiki/List_of_suicide_crisis_lines")
        await ctx.send(embed=embed)

    await member.kick()
    embed = discord.Embed(title=f":white_check_mark: {member} was kicked; {reason}.")
    await ctx.send(embed=embed)
    channel = await member.create_dm()
    await channel.send(f'You were kicked in {ctx.guild.name} for {reason}.')

@commands.command(name="warn")
@commands.has_permissions(manage_messages=True)
async def warn(self, ctx, member: discord.Member, reason):
    """
    Warns a user
    """
    if member.top_role > ctx.author.top_role:
        embed = discord.Embed(title="Nice try! You can't warn a higher up role.")
        return await ctx.send(embed=embed) 
    elif member == ctx.author:
        embed = discord.Embed(title=":x: You cannot warn yourself! If you are feeling/having suicidal/self-harm thoughts, visit https://en.wikipedia.org/wiki/List_of_suicide_crisis_lines")
        return await ctx.send(embed=embed)
    await ctx.channel.send(f"{member} was warned; {reason}.")
    try:
      await member.send(f'You were warned in {ctx.guild.name} for {reason}.')
    except:
      return

@commands.Cog.listener()
async def on_command_error(self, ctx, exc):

    if hasattr(ctx.command, 'on_error'):
        return

    if isinstance(exc, commands.CommandNotFound):
        return
    if isinstance(exc, commands.NotOwner):
        return await ctx.send("This command is locked to my owner only.")
    if isinstance(exc, commands.CommandInvokeError):
        ctx.command.reset_cooldown(ctx)
        exc = exc.original
    if isinstance(exc, commands.BadArgument):
        cleaned = discord.utils.escape_mentions(str(exc))
        return await ctx.send(cleaned)
    if isinstance(exc, commands.MissingPermissions):
        perms = "`" + '`, `'.join(exc.missing_perms) + "`" 
        return await ctx.send(f"You're missing {perms} permissions")
    if isinstance(exc, commands.BotMissingPermissions):
        perms = "`" + '`, `'.join(exc.missing_perms) + "`" 
        return await ctx.send(f"I'm missing {perms} permissions")
    if isinstance(exc, commands.CheckFailure):
        return
    if isinstance(exc, commands.TooManyArguments):
        if isinstance(ctx.command, commands.Group):
            return
    if isinstance(exc, commands.MissingRequiredArgument):
        await ctx.send(f"You're missing required argument **{(exc.param.name)}**")
        return

def setup(bot): bot.add_cog(Moderation(bot))`

Code 2 (non-missing cog): `import discord from discord.ext import commands import discordlists

class Owner(commands.Cog): def init(self, bot): self.bot = bot self.api = discordlists.Client(self.bot) # Create a Client instance self.api.set_auth("discordbotlist.com", "CENSORED") self.api.set_auth("discord.boats", "CENSORED") self.api.set_auth("discordextremelist.xyz", "CENSORED") self.api.set_auth("bladebotlist.xyz", "CENSORED") self.api.set_auth("discord.bots.gg", "CENSORED") self.api.set_auth("botsfordiscord.com", "CENSORED") self.api.set_auth("disforge.com", "CENSORED") self.api.set_auth("discordbotlist.cleverapps.io", "CENSORED") self.api.start_loop() # Posts the server count automatically every 30 minutes

@commands.command(name="post", pass_context=True)
async def post(self, ctx: commands.Context):
    """
    Manually posts guild count using discordlists.py (BotBlock)
    """
    if ctx.message.author.id =='541872670371741697':
        try:
            result = await self.api.post_count()
        except Exception as e:
            await ctx.send("Request failed: `{}`".format(e))
        await ctx.send("Successfully manually posted server count ({:,}) to {:,} lists."
                        "\nFailed to post server count to {:,} lists.".format(self.api.server_count,
                                                                            len(result["success"].keys()),
                                                                            len(result["failure"].keys())))
        return

def setup(bot): bot.add_cog(Owner(bot))`

Code 3 (not a missing cog as well):

`import discord from discord.ext import commands from datetime import datetime import traceback import sys

class Misc(commands.Cog):
def init(self, bot): self.bot = bot

@commands.Cog.listener()
async def on_command_error(self, ctx, error):
    """The event triggered when an error is raised while invoking a command.
    Parameters
    ------------
    ctx: commands.Context
        The context used for command invocation.
    error: commands.CommandError
        The Exception raised.
    """

    # This prevents any commands with local handlers being handled here in on_command_error.
    if hasattr(ctx.command, 'on_error'):
        return

    # This prevents any cogs with an overwritten cog_command_error being handled here.
    cog = ctx.cog
    if cog:
        if cog._get_overridden_method(cog.cog_command_error) is not None:
            return

    ignored = (commands.CommandNotFound, )

    # Allows us to check for original exceptions raised and sent to CommandInvokeError.
    # If nothing is found. We keep the exception passed to on_command_error.
    error = getattr(error, 'original', error)

    # Anything in ignored will return and prevent anything happening.
    if isinstance(error, ignored):
        return

    if isinstance(error, commands.DisabledCommand):
        await ctx.send(f'{ctx.command} has been disabled.')

    elif isinstance(error, commands.NoPrivateMessage):
        try:
            await ctx.author.send(f'{ctx.command} can not be used in Private Messages.')
        except discord.HTTPException:
            pass

    # For this error example we check to see where it came from...
    elif isinstance(error, commands.BadArgument):
        if ctx.command.qualified_name == 'tag list':  # Check if the command being invoked is 'tag list'
            await ctx.send('I could not find that member. Please try again.')

    else:
        # All other Errors not returned come here. And we can just print the default TraceBack.
        print('Ignoring exception in command {}:'.format(ctx.command), file=sys.stderr)
        traceback.print_exception(type(error), error, error.__traceback__, file=sys.stderr)

@commands.command(name="botinfo", aliases=['bi'])
async def botinfo(self, ctx):
    """
    Shows info on the bot
    """
    embed=discord.Embed(title="About Moderatus", description="Here is my info")
    embed.set_thumbnail(url="https://cdn.discordapp.com/avatars/734822514894831639/bde485834ec5b3351356f045b4dc9655.png?size=128")
    embed.add_field(name="Prefix:", value="`m1/m!`", inline=True)
    embed.add_field(name="Developer:", value="`MrCatLover#7894`", inline=True)
    embed.add_field(name="Library:", value="`discord.py`", inline=True)
    embed.add_field(name="Servers:", value=f"`{len(self.bot.guilds)}`", inline=True)
    embed.add_field(name="Version:", value="`v1.0.3`", inline=True)
    embed.add_field(name="Users:", value=f"`{len(self.bot.users)}`", inline=True)
    embed.add_field(name="Support:", value=":star: [Here](https://discord.gg/EyKqRNT)", inline=True)
    embed.add_field(name="Invite:", value=":robot: [Invite](https://discord.com/oauth2/authorize?client_id=734822514894831639&permissions=2134240759&scope=bot)", inline=True) 
    embed.add_field(name="Vote:", value=":white_check_mark: [Vote](https://discord.ly/moderatus/upvote)", inline=True)
    embed.set_footer(text=f"Requested by {ctx.author} | Today at {datetime.astimezone(tz='Europe/London').strftime('%H:%M')}", icon_url=f"{ctx.author.avatar_url}")
    await ctx.send(embed=embed)

@commands.command(name="avatar", aliases=['pfp, av, profilepic'])
async def avatar(self, ctx, User: discord.Member):
    """
    Shows the user's profile pic
    """
    embed=discord.Embed(title="User's Profile pic", description="Here is the user's profile pic you requested...")
    embed.set_thumbnail(url=f"{User.avatar_url}")
    await ctx.send(embed=embed)

@commands.command(name="ping")
async def ping(self, ctx):
    """
    Shows the bot's ping
    """
    embed=discord.Embed(title="Pong!", description=f'{ctx.bot.latency * 100}ms')
    await ctx.send(embed=embed)

@commands.command(name="serverinfo", aliases=['si'])
async def serverinfo(self, ctx): 
    """
    Shows info on the server
    """
    embed=discord.Embed(title=f"About {ctx.guild.name}", description=f"Here is {ctx.guild.name}('s) info")
    embed.set_thumbnail(url=f'{ctx.guild.icon_url}')
    embed.add_field(name="Boosts:", value=f"`{ctx.guild.premium_subscription_count}`", inline=True)
    embed.add_field(name="Owner:", value=f"`{ctx.guild.owner}`", inline=True)            
    embed.add_field(name="Boost tier:", value=f"`{ctx.guild.premium_tier}`", inline=True)
    embed.add_field(name="Users:", value=f"`{len(ctx.guild.members)}`", inline=True)
    embed.add_field(name="Channels:", value=f"`{len(ctx.guild.channels)}`", inline=True)
    embed.add_field(name="Roles:", value=f"`{len(ctx.guild.roles)}`", inline=True)
    embed.set_footer(text=f"Requested by {ctx.author} | Today at {datetime.astimezone(tz='Europe/London').strftime('%H:%M')}", icon_url=f"{ctx.author.avatar_url}")
    await ctx.send(embed=embed)

@commands.command(name="privacy")
async def privacy(self, ctx):
    """
    (Required under Discord ToS)
    """
    embed=discord.Embed(title="Moderatus' Privacy Policy", description="Correct at 15/08/2020 British Summer Time")
    embed.set_thumbnail(url='https://cdn.discordapp.com/attachments/744111535638446121/744112274364432454/Privacy.png')
    embed.add_field(name="**What data do we collect?**", value="We do not collect nor share any data.", inline=False)
    embed.add_field(name="**What happens if I have a problem?**", value="If you have questions regarding your privacy, this privacy policy or this bot in general you may contact me using one of the forms of contact listed below;", inline=False) 
    embed.add_field(name="• Email -", value="`realuprising2005@gmail.com`", inline=False)
    embed.add_field(name="• Discord -", value="`MrCatLover#7894 (541872670371741697)`", inline=False)
    await ctx.send(embed=embed)

@commands.command(name="vote", aliases=['upvote'])
async def vote(self, ctx):
    """
    Vote for Moderatus
    """
    embed=discord.Embed(title="Vote for moderatus!", description="Here are the current vote links.")
    embed.add_field(name="Vote every 12 hours", value="[Discord Labs](https://bots.discordlabs.org/bot/734822514894831639), [DiscordBoats](https://discord.boats/bot/734822514894831639/vote)", inline=False)
    embed.add_field(name="Vote every 24 hours", value="[DBL](https://discord.ly/moderatus/upvote), [BotlistSpace](https://botlist.space/bot/734822514894831639/upvote)", inline=False)
    embed.add_field(name="Vote at any time", value="[BBL](https://bladebotlist.xyz/bot/734822514894831639)", inline=False)
    await ctx.send(embed=embed)

@commands.command(name="invite", aliases=['inv'])
async def invite(self, ctx):
    """
    Invite Moderatus to your server
    """
    embed=discord.Embed(title="Invite Moderatus!", description="Doitdoitdoitdoitdoitdoit")
    embed.add_field(name="Here:", value="[Doitdoitdoitdoitdoitdoit](https://discord.com/oauth2/authorize?client_id=734822514894831639&permissions=2134240759&scope=bot)", inline=False)
    await ctx.send(embed=embed)

@commands.command(name="support", aliases=['sup', 'server'])
async def support(self, ctx):
    """
    Support server invite
    """
    await ctx.send("https://discord.gg/EyKqRNT")

def setup(bot): bot.add_cog(Misc(bot))``

CasuallyCalm commented 4 years ago

Not sure because your cogs work for me phelp

Can you use commands from the cog that's not working? It might not be loading correctly.

lpkeates commented 4 years ago

Not sure because your cogs work for me phelp

Can you use commands from the cog that's not working? It might not be loading correctly.

Yes, I can use the commands. Its just they won't show for me :/

lpkeates commented 4 years ago

It works now, its just the ban/unban commands won't show up. Trial and error lol

CircuitSacul commented 4 years ago

@MrMudkip Commands won't show up if you don't have permission to run them, and if there are no commands in a category that you can run, the category just won't show up.