mirror of
https://github.com/TotalFreedomMC/TotalFreedomBot.git
synced 2025-07-13 01:04:09 +00:00
Add files via upload
This commit is contained in:
parent
102df63908
commit
fc4cc4e37a
10 changed files with 693 additions and 0 deletions
53
commands/help.py
Normal file
53
commands/help.py
Normal file
|
@ -0,0 +1,53 @@
|
|||
import math
|
||||
import discord
|
||||
|
||||
from discord.ext import commands
|
||||
from functions import get_avatar
|
||||
|
||||
class Help(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
self.bot.remove_command('help')
|
||||
|
||||
@commands.command(aliases=['h','?'])
|
||||
async def help(self, ctx, page=1):
|
||||
'Displays the help command'
|
||||
em = discord.Embed()
|
||||
em.title = 'Help Command'
|
||||
command_list = ''
|
||||
|
||||
cog_list = [c for c in self.bot.cogs.keys()]
|
||||
|
||||
page_count = math.ceil(len(cog_list) / 4)
|
||||
|
||||
page = int(page)
|
||||
if page > page_count or page<1:
|
||||
await ctx.send(f'Page number \'{page}\' not found.')
|
||||
return
|
||||
|
||||
cogs_needed = []
|
||||
for i in range(4):
|
||||
x = i + (int(page) - 1) * 4
|
||||
try:
|
||||
cogs_needed.append(cog_list[x])
|
||||
except IndexError:
|
||||
pass
|
||||
|
||||
for cog in cogs_needed:
|
||||
command_list = ''
|
||||
for command in self.bot.get_cog(cog).walk_commands():
|
||||
if command.hidden:
|
||||
continue
|
||||
if command.parent:
|
||||
continue
|
||||
|
||||
command_list += f'**tf!{command.name}** - {command.help}\n'
|
||||
command_list += '\n'
|
||||
|
||||
em.add_field(name=cog, value=command_list, inline=False)
|
||||
|
||||
em.set_footer(text=f'Requested by {ctx.message.author}', icon_url=get_avatar(ctx.message.author))
|
||||
await ctx.send(embed=em)
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(Help(bot))
|
Loading…
Add table
Add a link
Reference in a new issue