aboutsummaryrefslogtreecommitdiffstats
path: root/bot
diff options
context:
space:
mode:
Diffstat (limited to 'bot')
-rw-r--r--bot/__init__.py4
-rw-r--r--bot/__main__.py10
-rw-r--r--bot/cogs/__init__.py0
-rw-r--r--bot/cogs/evergreen/__init__.py0
-rw-r--r--bot/cogs/evergreen/uptime.py33
-rw-r--r--bot/cogs/hacktober/__init__.py0
-rw-r--r--bot/cogs/hacktober/hacktoberstats.py (renamed from bot/cogs/hacktoberstats.py)0
-rw-r--r--bot/cogs/hacktober/halloween_facts.py (renamed from bot/cogs/halloween_facts.py)0
-rw-r--r--bot/cogs/hacktober/halloweenify.py (renamed from bot/cogs/halloweenify.py)0
-rw-r--r--bot/cogs/hacktober/movie.py (renamed from bot/cogs/movie.py)0
-rw-r--r--bot/cogs/hacktober/spookyreact.py (renamed from bot/cogs/spookyreact.py)0
11 files changed, 40 insertions, 7 deletions
diff --git a/bot/__init__.py b/bot/__init__.py
index c411deb6..6b3a2a6f 100644
--- a/bot/__init__.py
+++ b/bot/__init__.py
@@ -2,6 +2,10 @@ import logging.handlers
import os
from pathlib import Path
+import arrow
+
+# start datetime
+start_time = arrow.utcnow()
# set up logging
log_dir = Path("bot", "log")
diff --git a/bot/__main__.py b/bot/__main__.py
index ccd69b0b..64f8fdc0 100644
--- a/bot/__main__.py
+++ b/bot/__main__.py
@@ -17,23 +17,19 @@ else:
ghost_unicode = "\N{GHOST}"
bot = commands.Bot(command_prefix=commands.when_mentioned_or(".", f"{ghost_unicode} ", ghost_unicode))
-log.info('Start loading extensions from ./bot/cogs/')
+log.info('Start loading extensions from ./bot/cogs/evergreen/')
if __name__ == '__main__':
# Scan for files in the /cogs/ directory and make a list of the file names.
- cogs = [file.stem for file in Path('bot', 'cogs').glob('*.py')]
+ cogs = [file.stem for file in Path('bot', 'cogs', 'evergreen').glob('*.py') if not file.stem.startswith("__")]
for extension in cogs:
try:
- bot.load_extension(f'bot.cogs.{extension}')
+ bot.load_extension(f'bot.cogs.evergreen.{extension}')
log.info(f'Successfully loaded extension: {extension}')
except Exception as e:
log.error(f'Failed to load extension {extension}: {repr(e)} {format_exc()}')
- # print(f'Failed to load extension {extension}.', file=stderr)
- # print_exc()
-log.info(f'Spooky Launch Sequence Initiated...')
bot.run(HACKTOBERBOT_TOKEN)
-log.info(f'HackBot has been slain!')
diff --git a/bot/cogs/__init__.py b/bot/cogs/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/bot/cogs/__init__.py
diff --git a/bot/cogs/evergreen/__init__.py b/bot/cogs/evergreen/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/bot/cogs/evergreen/__init__.py
diff --git a/bot/cogs/evergreen/uptime.py b/bot/cogs/evergreen/uptime.py
new file mode 100644
index 00000000..ec4a3083
--- /dev/null
+++ b/bot/cogs/evergreen/uptime.py
@@ -0,0 +1,33 @@
+import arrow
+from dateutil.relativedelta import relativedelta
+from discord.ext import commands
+
+from bot import start_time
+
+
+class Uptime:
+ """
+ A cog for posting the bots uptime.
+ """
+
+ def __init__(self, bot):
+ self.bot = bot
+
+ @commands.command(name='uptime')
+ async def uptime(self, ctx):
+ """
+ Returns the uptime of the bot.
+ """
+ difference = relativedelta(start_time - arrow.utcnow())
+ uptime_string = start_time.shift(
+ seconds=-difference.seconds,
+ minutes=-difference.minutes,
+ hours=-difference.hours,
+ days=-difference.days
+ ).humanize()
+ await ctx.send(f"I started up {uptime_string}.")
+
+
+# Required in order to load the cog, use the class name in the add_cog function.
+def setup(bot):
+ bot.add_cog(Uptime(bot))
diff --git a/bot/cogs/hacktober/__init__.py b/bot/cogs/hacktober/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/bot/cogs/hacktober/__init__.py
diff --git a/bot/cogs/hacktoberstats.py b/bot/cogs/hacktober/hacktoberstats.py
index 0ccb41c1..0ccb41c1 100644
--- a/bot/cogs/hacktoberstats.py
+++ b/bot/cogs/hacktober/hacktoberstats.py
diff --git a/bot/cogs/halloween_facts.py b/bot/cogs/hacktober/halloween_facts.py
index e97c80d2..e97c80d2 100644
--- a/bot/cogs/halloween_facts.py
+++ b/bot/cogs/hacktober/halloween_facts.py
diff --git a/bot/cogs/halloweenify.py b/bot/cogs/hacktober/halloweenify.py
index a5fe45ef..a5fe45ef 100644
--- a/bot/cogs/halloweenify.py
+++ b/bot/cogs/hacktober/halloweenify.py
diff --git a/bot/cogs/movie.py b/bot/cogs/hacktober/movie.py
index 925f813f..925f813f 100644
--- a/bot/cogs/movie.py
+++ b/bot/cogs/hacktober/movie.py
diff --git a/bot/cogs/spookyreact.py b/bot/cogs/hacktober/spookyreact.py
index 9146b797..9146b797 100644
--- a/bot/cogs/spookyreact.py
+++ b/bot/cogs/hacktober/spookyreact.py