From d11ee1216c990ba618e9e178d8ee9767ed75751c Mon Sep 17 00:00:00 2001 From: Ryuga Date: Thu, 2 Apr 2026 19:18:40 +0530 Subject: [PATCH] Teams function update dashboard --- bot/cogs/teams.py | 61 +++++++++++++++++++++++++++++++++++++++++++---- bot/constants.py | 4 ++++ 2 files changed, 61 insertions(+), 4 deletions(-) diff --git a/bot/cogs/teams.py b/bot/cogs/teams.py index 16edac4..a468bc6 100644 --- a/bot/cogs/teams.py +++ b/bot/cogs/teams.py @@ -3,11 +3,15 @@ from discord.ext import commands from discord import app_commands -from bot.constants import accepting_team_invites_role_id, system_log_channel_id, success_emoji +from bot.constants import ( + accepting_team_invites_role_id, system_log_channel_id, success_emoji, + teams_dashboard_message_id, join_a_team_channel_id +) from bot.utils.embed_handler import success, failure, warning, info, authored_sm from bot.utils.checks import tortoise_bot_developer_only + class CreateTeamModal(discord.ui.Modal, title="Create Team"): name = discord.ui.TextInput(label="Team Name", max_length=50) @@ -51,7 +55,7 @@ async def on_submit(self, interaction: discord.Interaction): try: role = await guild.create_role(name=name) - category = await guild.create_category(f"TEAM - {name}") + category = await guild.create_category(f"Team - {name}") overwrites = { guild.default_role: discord.PermissionOverwrite( @@ -67,13 +71,13 @@ async def on_submit(self, interaction: discord.Interaction): } text = await guild.create_text_channel( - name=name, + name="team-chat", category=category, overwrites=overwrites ) voice = await guild.create_voice_channel( - name=name, + name="team-voice", category=category, overwrites=overwrites ) @@ -632,6 +636,55 @@ async def leave_team(self, interaction: discord.Interaction): embed=success("You left the team.") ) + async def _build_team_embed(self, guild: discord.Guild): + + teams = await self.team.get_all_teams(guild.id) + + if not teams: + return info("No teams created yet.", self.bot.user, "Teams Dashboard") + + desc = "" + + for team in teams: + leader = guild.get_member(team["leader_id"]) + members = await self.team.get_team_members(team["team_id"]) + + desc += ( + f"**{team['name']}**\n" + f"Lead: {leader.mention if leader else 'Unknown'}\n" + f"Timezone: `{team['timezone']}`\n" + f"Members: {len(members)}\n\n" + ) + + return info(desc, self.bot.user, "Teams Dashboard", "powered by Tortoise Programming Community") + + @app_commands.command(name="update_team_dashboard") + @app_commands.check(tortoise_bot_developer_only) + async def update_team_dashboard(self, interaction: discord.Interaction): + + channel = self.bot.get_channel(join_a_team_channel_id) + if not channel: + return await interaction.response.send_message( + embed=failure("Channel not found."), + ephemeral=True + ) + + try: + msg = await channel.fetch_message(teams_dashboard_message_id) + except: + return await interaction.response.send_message( + embed=failure("Dashboard message not found."), + ephemeral=True + ) + + embed = await self._build_team_embed(interaction.guild) + + await msg.edit(embed=embed) + + await interaction.response.send_message( + embed=success("Dashboard updated."), + ephemeral=True + ) async def setup(bot): await bot.add_cog(TeamCog(bot)) \ No newline at end of file diff --git a/bot/constants.py b/bot/constants.py index da0a18a..cb00f20 100644 --- a/bot/constants.py +++ b/bot/constants.py @@ -54,6 +54,10 @@ challenges_channel_id = 780841435712716800 bait_channel_id = 1461666781612740750 introduction_channel_id = 1487413734056923236 +join_a_team_channel_id = 1489254495522390186 + +# Message id +teams_dashboard_message_id = 1489259245282267208 # Roles muted_role_id = 707007421066772530