aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar ks129 <[email protected]>2020-06-11 09:44:20 +0300
committerGravatar ks129 <[email protected]>2020-06-11 09:44:20 +0300
commite8ef1b0f7ae9426da8be66fdeb6cecc81870c070 (patch)
tree95fdc92861b76f502e9bc9fb95dc68b9b7aec0f8
parentJams: Move overwrites generation to outside of command (diff)
Jams: Move channels creation to new function instead inside command
-rw-r--r--bot/cogs/jams.py45
1 files changed, 26 insertions, 19 deletions
diff --git a/bot/cogs/jams.py b/bot/cogs/jams.py
index 2b4575d5f..9089dcec2 100644
--- a/bot/cogs/jams.py
+++ b/bot/cogs/jams.py
@@ -41,24 +41,7 @@ class CodeJams(commands.Cog):
)
return
- code_jam_category = await self.get_category(ctx)
- team_channel_overwrites = self.get_overwrites(members, ctx)
-
- # Create a text channel for the team
- team_channel = await ctx.guild.create_text_channel(
- team_name,
- overwrites=team_channel_overwrites,
- category=code_jam_category
- )
-
- # Create a voice channel for the team
- team_voice_name = " ".join(team_name.split("-")).title()
-
- await ctx.guild.create_voice_channel(
- team_voice_name,
- overwrites=team_channel_overwrites,
- category=code_jam_category
- )
+ team_channel = await self.create_channels(ctx, team_name, members)
# Assign team leader role
await members[0].add_roles(ctx.guild.get_role(Roles.team_leaders))
@@ -69,7 +52,7 @@ class CodeJams(commands.Cog):
await member.add_roles(jammer_role)
await ctx.send(
- f":ok_hand: Team created: {team_channel.mention}\n"
+ f":ok_hand: Team created: {team_channel}\n"
f"**Team Leader:** {members[0].mention}\n"
f"**Team Members:** {' '.join(member.mention for member in members[1:])}"
)
@@ -120,6 +103,30 @@ class CodeJams(commands.Cog):
return team_channel_overwrites
+ async def create_channels(self, ctx: commands.Context, team_name: str, members: t.List[Member]) -> str:
+ """Create team text and voice channel. Return name of text channel."""
+ # Get permission overwrites and category
+ team_channel_overwrites = self.get_overwrites(members, ctx)
+ code_jam_category = await self.get_category(ctx)
+
+ # Create a text channel for the team
+ team_channel = await ctx.guild.create_text_channel(
+ team_name,
+ overwrites=team_channel_overwrites,
+ category=code_jam_category
+ )
+
+ # Create a voice channel for the team
+ team_voice_name = " ".join(team_name.split("-")).title()
+
+ await ctx.guild.create_voice_channel(
+ team_voice_name,
+ overwrites=team_channel_overwrites,
+ category=code_jam_category
+ )
+
+ return str(team_channel)
+
def setup(bot: Bot) -> None:
"""Load the CodeJams cog."""