# Path: dozer/cogs/info.py
# class Info(Cog):
#     async def slash_member(self, ctx: SlashContext, member: discord.Member = None):
#     async def member(self, ctx, *, member: discord.Member = None):
#     def _format_activities(activities: typing.Sequence[discord.Activity]) -> typing.List[str]:
#         def format_activity(activity: discord.Activity) -> str:
#     def pluralize(values: typing.List[str]) -> str:
#     async def slash_role(self, ctx: SlashContext, role: discord.Role):
#     async def role(self, ctx, role: discord.Role):
#     async def slash_rolemember(self, ctx: SlashContext, role: discord.Role):
#     async def rolemembers(self, ctx, role: discord.Role):
#     async def slash_guild(self, ctx: SlashContext):
#     async def guild(self, ctx):
# def setup(bot):


import json
import discord
from aiotba.http import AioTBAError
from discord.ext.commands import BadArgument, guild_only, has_permissions
from discord_slash import cog_ext, SlashContext
from ._utils import *
from .info import blurple
from .. import db
    `{prefix}onteam type team_number` - Returns a list of users associated with a given team type and number
    """

    @onteam.command()
    @guild_only()
    async def top(self, ctx):
        """Show the top 10 teams by number of members in this guild."""
        users = [mem.id for mem in ctx.guild.members]
        counts = await TeamNumbers.top10(users)
        embed = discord.Embed(title=f'Top teams in {ctx.guild.name}', color=discord.Color.blue())
        embed.description = '\n'.join(
            f'{type_.upper()} team {num} ({count} member{"s" if count > 1 else ""})' for (type_, num, count) in counts)
        await ctx.send(embed=embed)

    top.example_usage = """
    `{prefix}onteam top` - List the 10 teams with the most members in this guild
    """

    @command()
    @guild_only()
    @has_permissions(manage_guild=True)
    async def toggleautoteam(self, ctx):
        """Toggles automatic adding of team association to member nicknames"""
        settings = await AutoAssociation.get_by(guild_id=ctx.guild.id)
        enabled = settings[0].team_on_join if settings else True
        new_settings = AutoAssociation(
            guild_id=ctx.guild.id,
            team_on_join=not enabled
        )
        await new_settings.update_or_add()

# Path: dozer/cogs/info.py
# class Info(Cog):
#     async def slash_member(self, ctx: SlashContext, member: discord.Member = None):
#     async def member(self, ctx, *, member: discord.Member = None):
#     def _format_activities(activities: typing.Sequence[discord.Activity]) -> typing.List[str]:
#         def format_activity(activity: discord.Activity) -> str:
#     def pluralize(values: typing.List[str]) -> str:
#     async def slash_role(self, ctx: SlashContext, role: discord.Role):
#     async def role(self, ctx, role: discord.Role):
#     async def slash_rolemember(self, ctx: SlashContext, role: discord.Role):
#     async def rolemembers(self, ctx, role: discord.Role):
#     async def slash_guild(self, ctx: SlashContext):
#     async def guild(self, ctx):
# def setup(bot):


# Path: dozer/cogs/teams.py
import json
import discord
from aiotba.http import AioTBAError
from discord.ext.commands import BadArgument, guild_only, has_permissions
from discord_slash import cog_ext, SlashContext
from ._utils import *
from .info import blurple
from .. import db

    `{prefix}onteam type team_number` - Returns a list of users associated with a given team type and number
    """

    @onteam.command()
    @guild_only()
    async def top(self, ctx):
        """Show the top 10 teams by number of members in this guild."""
        users = [mem.id for mem in ctx.guild.members]
        counts = await TeamNumbers.top10(users)
        embed = discord.Embed(title=f'Top teams in {ctx.guild.name}', color=discord.Color.blue())
        embed.description = '\n'.join(
            f'{type_.upper()} team {num} ({count} member{"s" if count > 1 else ""})' for (type_, num, count) in counts)
        await ctx.send(embed=embed)

    top.example_usage = """
    `{prefix}onteam top` - List the 10 teams with the most members in this guild
    """

    @command()
    @guild_only()
    @has_permissions(manage_guild=True)
    async def toggleautoteam(self, ctx):
        """Toggles automatic adding of team association to member nicknames"""
        settings = await AutoAssociation.get_by(guild_id=ctx.guild.id)
        enabled = settings[0].team_on_join if settings else True
        new_settings = AutoAssociation(
            guild_id=ctx.guild.id,
            team_on_join=not enabled
        )
        await new_settings.update_or_add()

        e = discord.Embed(color=blurple)