Skip to content

Commit

Permalink
remove role name from source
Browse files Browse the repository at this point in the history
  • Loading branch information
haryu703 committed Apr 6, 2024
1 parent d3c8b3d commit 9666603
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ jobs:
ACTIVE_CATEGORY = '${{ secrets.ACTIVE_CATEGORY }}'
ARCHIVE_CATEGORY = '${{ secrets.ARCHIVE_CATEGORY }}'
THRESHOLD_DAYS = '${{ secrets.THRESHOLD_DAYS }}'
CERTIFIED_MEMBER_ROLES = '${{ secrets.CERTIFIED_MEMBER_ROLES }}'
4 changes: 3 additions & 1 deletion src/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ pub async fn archive(ctx: super::Context<'_>) -> anyhow::Result<()> {

#[poise::command(prefix_command, slash_command)]
pub async fn role(ctx: super::Context<'_>) -> anyhow::Result<()> {
let config = &ctx.data().config;
let certified_member_roles = config.certified_member_roles.clone();
let guild_id = ctx.guild_id().ok_or_else(|| anyhow!("no guild"))?;

let channel_name = match ctx.channel_id().to_channel(&ctx).await? {
Expand All @@ -104,7 +106,7 @@ pub async fn role(ctx: super::Context<'_>) -> anyhow::Result<()> {
let human_role_ids: Vec<_> = roles
.iter()
.filter_map(|r| {
if r.name == "ひと" || r.name == "いちばんつよいひと" {
if certified_member_roles.contains(&r.name) {
Some(r.id)
} else {
None
Expand Down
8 changes: 8 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub struct Config {
pub threshold_days: i64,
pub active_category: String,
pub archive_category: String,
pub certified_member_roles: Vec<String>,
}

impl Config {
Expand All @@ -20,11 +21,18 @@ impl Config {
let archive_category = secret_store
.get("ARCHIVE_CATEGORY")
.context("ARCHIVE_CATEGORY")?;
let certified_member_roles = secret_store
.get("CERTIFIED_MEMBER_ROLES")
.context("CERTIFIED_MEMBER_ROLES")?
.split(",")
.map(|s| s.trim().to_owned())
.collect();

Ok(Self {
threshold_days,
active_category,
archive_category,
certified_member_roles,
})
}
}

0 comments on commit 9666603

Please sign in to comment.