[feat]: Commands to group

This commit is contained in:
Sweetbread 2023-05-18 22:54:43 +03:00
parent f858ae49bf
commit e963c5ca86
2 changed files with 12 additions and 9 deletions

View File

@ -53,7 +53,7 @@ class Economic(commands.Cog, name="Экономика"):
async def on_message(self, message):
if not message.author.bot and message.guild is not None and not message.content.startswith(tuple(await self.bot.command_prefix(self.bot, message))):
data = await db.members.find_one({"id": message.author.id})
flood_channels = await db.guild_settings.find_one({"id": message.guild.id})
flood_channels = await db.guild_settings.find_one({"id": message.guild.id, 'type': 'general'})
if flood_channels is None:
flood_channels = []
else:
@ -243,7 +243,10 @@ class Economic(commands.Cog, name="Экономика"):
})
logger.debug(m["guild_stat"][str(guild.id)]["exp"])
@app_commands.command(description="View balance and level")
stat_gr = app_commands.Group(name="statistic", description="Some statistic")
@stat_gr.command(description="View balance and level")
async def rank(self, inter: discord.Interaction, user: discord.Member = None):
if user is None: user = inter.user
@ -325,7 +328,7 @@ class Economic(commands.Cog, name="Экономика"):
color=color)
await inter.response.send_message(embed=e)
@app_commands.command(description="Top members of the guild")
@stat_gr.command(description="Top members of the guild")
@app_commands.describe(category='Category')
@app_commands.choices(category=[
Choice(name='Balance', value="Баланс"),
@ -401,7 +404,7 @@ class Economic(commands.Cog, name="Экономика"):
await inter.response.send_message(embed=e)
@app_commands.command(description="Comparison of exp with other members")
@stat_gr.command(description="Comparison of exp with other members")
@app_commands.choices(period=[
Choice(name='Per the entire period', value=-1),
Choice(name='Per month', value=24*30),
@ -477,8 +480,7 @@ class Economic(commands.Cog, name="Экономика"):
await inter.response.send_message(file=discord.File(f))
remove(f'tmp/{inter.id}.png')
@app_commands.command()
@stat_gr.command()
@app_commands.choices(period=[
Choice(name='Per the entire period', value=-1),
Choice(name='Per month', value=24*30),

View File

@ -6,7 +6,6 @@ import asyncio
from loguru import logger
from json import dumps
from discord import app_commands
from discord.ext import commands
from dataclasses import dataclass
from bot import db
@ -31,8 +30,10 @@ class Channel:
# skip_policy: Enum "everyone"
class Music(commands.Cog, name="Музыка"):
@app_commands.guild_only()
class Music(app_commands.Group, name="music"):
def __init__(self, bot):
super().__init__()
self.bot = bot
self.queue: dict[int, Channel] = {}
@ -167,4 +168,4 @@ class Music(commands.Cog, name="Музыка"):
async def setup(bot):
await bot.add_cog(Music(bot))
bot.tree.add_command(Music(bot))