From 8d49b918a23f10bd001c3620d05f23b742f54487 Mon Sep 17 00:00:00 2001 From: snipe <72265661+notsniped@users.noreply.github.com> Date: Sun, 22 Jan 2023 12:46:17 +0530 Subject: [PATCH] Move special event commands to a separate cog file --- cogs/events.py | 33 +++++++++++++++++++++++++++++++++ main.py | 19 ------------------- 2 files changed, 33 insertions(+), 19 deletions(-) create mode 100644 cogs/events.py diff --git a/cogs/events.py b/cogs/events.py new file mode 100644 index 00000000..e29ca671 --- /dev/null +++ b/cogs/events.py @@ -0,0 +1,33 @@ +# Imports +import discord +from discord import option, ApplicationContext +from discord.ext import commands +from discord.commands import SlashCommandGroup + +# Add code for event database here + +# Commands +class SpecialEvents(commands.Cog): + def __init__(self, bot): + self.bot = bot + + special_event = SlashCommandGroup("event", "Commands related to any ongoing special in-game event.") + + @special_event.command( + name="leaderboard", + description="View the global leaderboard for the special in-game event." + ) + async def leaderboard(self, ctx: ApplicationContext): + ctx.respond("This event has been concluded! Come back to this command later for new events!", ephemeral=True) + + @special_event.command( + name="stats", + description="See your current stats in the special in-game event." + ) + @option(name="user", description="Who's event stats do you want to view?", type=discord.User, default=None) + async def stats(self, ctx: ApplicationContext, user: discord.User): + if user == None: user = ctx.author + ctx.respond("This event has been concluded! Come back to this command later for new events!", ephemeral=True) + +# Initialization +def setup(bot): bot.add_cog(SpecialEvents(bot)) diff --git a/main.py b/main.py index a55607db..6acfa929 100644 --- a/main.py +++ b/main.py @@ -430,25 +430,6 @@ async def profile(ctx: ApplicationContext, user: discord.User = None): # Maybe I should make a userdat system for collecting statistical data to process and display here, coming in a future update. await ctx.respond(embed=localembed) -# New Year's in-game Event Commands -special_event = client.create_group("event", "Commands related to any ongoing special in-game event.") - -@special_event.command( - name="leaderboard", - description="View the global leaderboard for the special in-game event." -) -async def leaderboard(ctx: ApplicationContext): - ctx.respond("This event has been concluded! Come back to this command later for new events!", ephemeral=True) - -@special_event.command( - name="stats", - description="See your current stats in the special in-game event." -) -@option(name="user", description="Who's event stats do you want to view?", type=discord.User, default=None) -async def stats(ctx: ApplicationContext, user: discord.User): - if user == None: user = ctx.author - ctx.respond("This event has been concluded! Come back to this command later for new events!", ephemeral=True) - # Initialization active_cogs = ["economy", "maths", "moderation", "reddit", "minigames", "automod", "isobank", "levelling", "fun"] i = 1