mirror of
				https://gitlab.com/ddorn/tfjm-discord-bot.git
				synced 2025-11-04 09:02:14 +01:00 
			
		
		
		
	✨ capitains can now create private channels
This commit is contained in:
		@@ -108,7 +108,7 @@ class TeamsCog(Cog, name="Teams"):
 | 
			
		||||
    @commands.has_role(Role.CAPTAIN)
 | 
			
		||||
    async def team_add(self, ctx, member: discord.Member):
 | 
			
		||||
        """
 | 
			
		||||
        Ajoute un membre a ton équipe.
 | 
			
		||||
        (cap) Ajoute un membre a ton équipe.
 | 
			
		||||
 | 
			
		||||
        Commande réservée aux capitaines pour ajouter un
 | 
			
		||||
        membre dans leur équipe. Cela permet juste de donner
 | 
			
		||||
@@ -148,6 +148,32 @@ class TeamsCog(Cog, name="Teams"):
 | 
			
		||||
                f"{member.mention} à été ajouté dans l'équipe {the_team[1].mention}"
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
    @team.command(name="channel", ignore_extra=False)
 | 
			
		||||
    @commands.has_role(Role.CAPTAIN)
 | 
			
		||||
    async def team_channel(self, ctx, channel_name):
 | 
			
		||||
        """
 | 
			
		||||
        (cap) Crée une channel privée pour l'équipe
 | 
			
		||||
 | 
			
		||||
        Crée un endroit de discussion privé seulement pour l'équipe
 | 
			
		||||
        personne d'autre n'y aura accès.
 | 
			
		||||
 | 
			
		||||
        Exemple:
 | 
			
		||||
            `!team channel un-nom-sympa`
 | 
			
		||||
        """
 | 
			
		||||
 | 
			
		||||
        guild: discord.Guild = ctx.guild
 | 
			
		||||
        team_role = self.teams_for(ctx.author)[0][1]
 | 
			
		||||
        team_channel_category = get(guild.categories, name=TEAMS_CHANNEL_CATEGORY)
 | 
			
		||||
        await guild.create_text_channel(
 | 
			
		||||
            channel_name,
 | 
			
		||||
            overwrites={
 | 
			
		||||
                guild.default_role: discord.PermissionOverwrite(read_messages=False),
 | 
			
		||||
                team_role: discord.PermissionOverwrite(read_messages=True),
 | 
			
		||||
            },
 | 
			
		||||
            category=team_channel_category,
 | 
			
		||||
            reason=f"{ctx.author.name} à demandé une channel pour son équipe.",
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def setup(bot: Bot):
 | 
			
		||||
    bot.add_cog(TeamsCog())
 | 
			
		||||
 
 | 
			
		||||
@@ -9,6 +9,7 @@ __all__ = [
 | 
			
		||||
    "ROUND_NAMES",
 | 
			
		||||
    "TIRAGES_FILE",
 | 
			
		||||
    "TEAMS_FILE",
 | 
			
		||||
    "TEAMS_CHANNEL_CATEGORY",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
TOKEN = os.environ.get("TFJM_DISCORD_TOKEN")
 | 
			
		||||
@@ -34,6 +35,8 @@ class Role:
 | 
			
		||||
    PARTICIPANT = "Participant"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
TEAMS_CHANNEL_CATEGORY = "Channels d'équipes"
 | 
			
		||||
 | 
			
		||||
ROUND_NAMES = ["premier tour", "deuxième tour"]
 | 
			
		||||
 | 
			
		||||
TOP_LEVEL_DIR = Path(__file__).parent.parent
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user