Skip to content

Instantly share code, notes, and snippets.

@lpkeates
Forked from That-Kidd/helpcommand.py
Last active October 31, 2020 16:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lpkeates/2776f29664f99b5320df6da50e8fe5e0 to your computer and use it in GitHub Desktop.
Save lpkeates/2776f29664f99b5320df6da50e8fe5e0 to your computer and use it in GitHub Desktop.
A kinda advanced custom "help" command for your Discord.py Rewrite bots!
"""This custom help command is a perfect replacement for the default one on any Discord Bot written in Discord.py Rewrite!
However, you must put "bot.remove_command('help')" in your bot, and the command must be in a cog for it to work.
Written by Jared Newsom (AKA Jared M.F.), edited by Leon Peter Keates (AKA Leon P.K.)"""
@commands.command()
@commands.has_permissions(add_reactions=True, embed_links=True)
async def help(self,ctx,*cog):
"""Gets all cogs and commands of mine."""
try:
if not cog:
halp=discord.Embed(title='Cog Listing and Uncatergorized Commands', description='Use `m!help *cog*` to find out more about them!\n(BTW, the Cog Name Must Be in Title Case, Just Like this Sentence.)')
cogs_desc = ''
for x in self.bot.cogs:
cogs_desc += ('{} - {}'.format(x,self.bot.cogs[x].__doc__)+'\n')
halp.add_field(name='Cogs',value=cogs_desc[0:len(cogs_desc)-1],inline=False)
cmds_desc = ''
for y in self.bot.walk_commands():
if not y.cog_name and not y.hidden:
cmds_desc += ('{} - {}'.format(y.name,y.help)+'\n')
halp.add_field(name='Uncatergorized Commands',value=cmds_desc[0:len(cmds_desc)-1],inline=False)
await ctx.message.add_reaction(emoji='✉')
await ctx.message.author.send('',embed=halp)
else:
if len(cog) > 1:
halp = discord.Embed(title='Error!',description='That is way too many cogs!',color=discord.Color.red())
await ctx.message.author.send('',embed=halp)
else:
found = False
for x in self.bot.cogs:
for y in cog:
if x == y:
halp=discord.Embed(title=cog[0]+' Command Listing',description=self.bot.cogs[cog[0]].__doc__)
for c in self.bot.get_cog(y).get_commands():
if not c.hidden:
halp.add_field(name=c.name,value=c.help,inline=False)
found = True
if not found:
halp = discord.Embed(title='Error!',description='How do you even use "'+cog[0]+'"?',color=discord.Color.red())
else:
await ctx.message.add_reaction(emoji='✉')
await ctx.message.author.send('',embed=halp)
except:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment