summaryrefslogtreecommitdiff
path: root/cogs/Help.py
diff options
context:
space:
mode:
authorlexicade <jasonnlelong@gmail.com>2023-01-27 21:06:30 +0000
committerlexicade <jasonnlelong@gmail.com>2023-01-27 21:06:30 +0000
commit52801b4de1d63cd01191acf7fcee137977140ec0 (patch)
tree08271a1f1e3e8060486b6651c67c9934867c648e /cogs/Help.py
parent8df873808c86805624851356f5dea76ec621de23 (diff)
Project initHEADmain
Diffstat (limited to 'cogs/Help.py')
-rw-r--r--cogs/Help.py61
1 files changed, 61 insertions, 0 deletions
diff --git a/cogs/Help.py b/cogs/Help.py
new file mode 100644
index 0000000..2a79784
--- /dev/null
+++ b/cogs/Help.py
@@ -0,0 +1,61 @@
+from discord.ext import commands
+import discord
+import importlib
+import utils
+import itertools
+import math
+importlib.reload(utils)
+
+
+class Help(commands.Cog):
+ def __init__(self, bot):
+ self.bot = bot
+ "https://api.openweathermap.org/data/2.5/weather?q=jersey&appid=d83a0ac0ba2d9d59007724f54bd4f960"
+
+ @commands.command(usage="!help", aliases=['commands'], application_command_meta=commands.ApplicationCommandMeta(options=[]))
+ async def help(self, ctx):
+ """Shows this help message."""
+ str_cmds = ""
+ cmds = {}
+
+ # Reorder list
+ cmds_set = self.bot.commands
+
+ for cmd in cmds_set:
+ if not cmd.hidden:
+ cmds[cmd.name] = {"help": cmd.help}
+
+ cmds = dict(sorted(cmds.items(), key=lambda x: x[0].lower()))
+ await pagify(self, cmds, 5, 2)
+ for cmd in cmds:
+ str_cmds = f"{str_cmds}\n•**{cmd}** - {cmds[cmd]['help']}"
+
+ emb = await utils.embed(ctx, "Help commands", str_cmds)
+ await ctx.send(embed=emb)
+
+
+async def pagify(self, input, items_per_page, page_wanted=1):
+ total_items = len(input)
+ # total items = 25
+ pages = 1
+
+ if total_items > items_per_page:
+ pages = int(math.floor(total_items / items_per_page))
+
+ return_list = []
+ for i, item in enumerate(input):
+ if int(math.floor(i / pages)) == page_wanted:
+ return_list.append({item: input[item]["help"]})
+
+ print(return_list)
+ return return_list
+
+
+def setup(bot):
+ print("INFO: Loading [Help]... ", end="")
+ bot.add_cog(Help(bot))
+ print("Done!")
+
+
+def teardown(bot):
+ print("INFO: Unloading [Help]")