From c3bf12331c8b58b2d9936b2cfeb4dac4f7d947cb Mon Sep 17 00:00:00 2001 From: Matt Compton Date: Mon, 31 Jan 2022 16:27:15 +0000 Subject: [PATCH] Update requirements.txt, bot.py, cogs/task.py --- bot.py | 37 +++++++++++++++++++++++++++++++++---- task.py => cogs/task.py | 0 requirements.txt | 3 ++- 3 files changed, 35 insertions(+), 5 deletions(-) rename task.py => cogs/task.py (100%) diff --git a/bot.py b/bot.py index d6932f0..e3adb68 100644 --- a/bot.py +++ b/bot.py @@ -1,11 +1,27 @@ -import discord,os +# Stdlib +import os + +# Pip +import discord from discord.ext import commands +from pretty_help import DefaultMenu, PrettyHelp +# Custom from task import Packages -bot = commands.Bot(";") -bot.add_cog(Packages(bot)) +intents = discord.Intents.default() +intents.members = True + +bot = commands.Bot( + command_prefix=commands.when_mentioned_or(";"), + description="Bang rocks together make package tracker bot", + intents=intents +) +helpmenu = DefaultMenu("◀️", "▶️", "❌") +bot.help_command = PrettyHelp( + no_category="Commands", navigation=helpmenu, color=discord.Colour.blurple() +) @bot.command() async def distrohop(ctx, *, count=None): @@ -21,9 +37,22 @@ async def distrohop(ctx, *, count=None): f.write(str(distrohops)) await ctx.send("Miku distrohops: " + str(distrohops)) +@bot.event +async def on_ready(): + chan = await bot.get_channel(842491569176051712) + cogs_dir = "cogs" + for extension in [ + f.replace(".py", "") for f in os.listdir(cogs_dir) if os.isfile(join(cogs_dir, f)) + ]: + try: + bot.load_extension(cogs_dir + "." + extension) + except (Exception) as e: + await chan.send(f"Failed to load extension {extension}.") + await chan.send("Started/restarted at: `" + getstamp() + "`") + if not os.path.exists(os.environ["HOME"] + "/.cavetoken"): print("No token found") exit() else: token = open(os.environ["HOME"] + "/.cavetoken", "r").read() - bot.run(token) \ No newline at end of file + bot.run(token) diff --git a/task.py b/cogs/task.py similarity index 100% rename from task.py rename to cogs/task.py diff --git a/requirements.txt b/requirements.txt index 1fe7dd3..f59d5ba 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ feedparser -py-cord \ No newline at end of file +py-cord +discord-pretty-help