Skip to content

Commit

Permalink
Add toggle to configure team channel topic
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryoga Saito committed Dec 6, 2023
1 parent 1a56e4b commit 21f7674
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/bot/channels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,15 @@ impl Bot {
.get_permission_overwrites_for_team_channel(team)
.await?;

let topic = Self::generate_team_channel_topic(team);
let topic = match self.configure_channel_topics {
true => Some(Self::generate_team_channel_topic(team)),
false => Some(String::new()),
};
channels.push(
GuildChannelDefinitionBuilder::default()
.name(format!("{}-{}", team.id, TEXT_CHANNEL_NAME_SUFFIX))
.kind(ChannelType::Text)
.topic(Some(topic))
.topic(topic)
.category(Some(team_category_id))
.permissions(permissions_for_team_channel.clone())
.build()?,
Expand Down
4 changes: 4 additions & 0 deletions src/bot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ pub struct Bot {
redeploy_service: Box<dyn RedeployService + Send + Sync>,
redeploy_notifiers: Vec<Box<dyn RedeployNotifier + Send + Sync>>,

configure_channel_topics: bool,

role_cache: RwLock<Option<Vec<Role>>>,
}

Expand All @@ -42,6 +44,7 @@ impl Bot {
problems: Vec<Problem>,
redeploy_service: Box<dyn RedeployService + Send + Sync>,
redeploy_notifiers: Vec<Box<dyn RedeployNotifier + Send + Sync>>,
configure_channel_topics: bool,
) -> Self {
let application_id = ApplicationId(application_id);
let guild_id = GuildId(guild_id);
Expand All @@ -56,6 +59,7 @@ impl Bot {
problems,
redeploy_service,
redeploy_notifiers,
configure_channel_topics,
role_cache: RwLock::new(None),
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ pub struct DiscordConfiguration {
pub token: String,
pub application_id: u64,
pub guild_id: u64,
pub disabled_commands: Option<Vec<String>>,

#[serde(default)]
pub configure_channel_topics: bool,
}

#[derive(Debug, Deserialize)]
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ async fn main() {
config.problems,
redeploy_service,
redeploy_notifiers,
config.discord.configure_channel_topics,
);

let result = match args.command {
Expand Down

0 comments on commit 21f7674

Please sign in to comment.