diff --git a/src/discord/bot.py b/src/discord/bot.py index d1441ec..a9b834e 100644 --- a/src/discord/bot.py +++ b/src/discord/bot.py @@ -39,6 +39,8 @@ async def on_ready(self): await self.bot.load_extension('src.discord.cogs.tasks') # Load commands here + logger.info('Loading Trakt cog') + await self.bot.load_extension('src.discord.cogs.trakt') ## Post an single embed to a channel async def dispatch_embed(self, channel_id, embed): diff --git a/src/discord/cogs/tasks.py b/src/discord/cogs/tasks.py index 26987ab..4ed80a2 100644 --- a/src/discord/cogs/tasks.py +++ b/src/discord/cogs/tasks.py @@ -114,5 +114,5 @@ async def before_weekly_task(self): await asyncio.sleep(sleep_duration) # Sleep until the next run time async def setup(bot): - logger.info('Cogs have been loaded') + logger.info('Tasks cogs have been loaded') await bot.add_cog(TasksCog(bot)) \ No newline at end of file diff --git a/src/discord/cogs/trakt.py b/src/discord/cogs/trakt.py new file mode 100644 index 0000000..5d71d28 --- /dev/null +++ b/src/discord/cogs/trakt.py @@ -0,0 +1,27 @@ +import discord +from discord.ext import commands +from src.trakt.global_weekly import create_weekly_global_embed +from utils.custom_logger import logger + + +class TraktCog(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.command(name="trakt") + async def trakt(self, ctx): + """Fetches and displays the weekly global Trakt stats manually.""" + try: + logger.info("!trakt command invoked") + embed_data = create_weekly_global_embed() + for embed in embed_data["embeds"]: + await ctx.send(embed=discord.Embed.from_dict(embed)) + except Exception as e: + logger.error(f"Error processing !trakt command: {e}") + await ctx.send("An error occurred while fetching Trakt data.") + + +async def setup(bot): + """Setup function to add the cog to the bot.""" + logger.info('Trakt cog have been loaded') + await bot.add_cog(TraktCog(bot)) \ No newline at end of file