Skip to content

Commit

Permalink
Move stats commands to command group
Browse files Browse the repository at this point in the history
  • Loading branch information
raccube committed Aug 13, 2024
1 parent 8923ae6 commit fc1c67f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
13 changes: 11 additions & 2 deletions src/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@
import discord
from discord import app_commands

from src.commands.stats import SubscribedMessage, stats, stats_subscribe, load_subscribed_messages, SUBSCRIBE_MSG_FILE
from src.commands.stats import (
SubscribedMessage,
stats_subscribe,
load_subscribed_messages,
SUBSCRIBE_MSG_FILE,
Stats,
post_stats,
)
from src.constants import (
SPECIAL_ROLE,
VERIFIED_ROLE,
Expand Down Expand Up @@ -57,8 +64,10 @@ def __init__(
team.add_command(create_voice)
team.add_command(create_team_channel)
self.tree.add_command(team, guild=self.guild)
stats = Stats()
stats.add_command(post_stats)
stats.add_command(stats_subscribe)
self.tree.add_command(stats, guild=self.guild)
self.tree.add_command(stats_subscribe, guild=self.guild)
self.tree.add_command(join, guild=self.guild)
load_subscribed_messages(self)

Expand Down
12 changes: 9 additions & 3 deletions src/commands/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,20 @@ def __eq__(self, comp: object) -> bool:
)


@app_commands.command()
@app_commands.guild_only()
@app_commands.default_permissions()
class Stats(app_commands.Group):
pass


@app_commands.command(name='post')
@app_commands.describe(
members='Display the number of members in each team',
warnings='Display warnings about missing supervisors and empty teams',
stats='Display statistics about the teams',
)
@app_commands.checks.has_role(VOLUNTEER_ROLE)
async def stats(
async def post_stats(
ctx: discord.interactions.Interaction["BotClient"],
members: bool = False,
warnings: bool = False,
Expand All @@ -66,7 +72,7 @@ async def stats(
await send_response(ctx, message)


@discord.app_commands.command() # type:ignore[arg-type]
@discord.app_commands.command(name='subscribe') # type:ignore[arg-type]
@app_commands.describe(
members='Display the number of members in each team',
warnings='Display warnings about missing supervisors and empty teams',
Expand Down

0 comments on commit fc1c67f

Please sign in to comment.