Skip to content

Commit 816c8e9

Browse files
fix(discord): address review feedback on empty allowed_channels behavior
- docs: clarify "channels gate first" → "channels must be configured first" - discord.rs: add debug! log on early return when allowed_channels is empty - main.rs: downgrade startup log from error! to warn! (bot still starts intentionally) - main.rs: add missing `warn` to tracing imports (fixes compile error)
1 parent 077c745 commit 816c8e9

3 files changed

Lines changed: 4 additions & 3 deletions

File tree

docs/discord-bot-howto.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ allowed_channels = ["your-channel-id-from-step-6"]
7777
|---|---|---|
7878
| empty | empty | **No channels, no users — bot ignores all messages** |
7979
| set | empty | Only these channels, all users |
80-
| empty | set | **Bot ignores all messages** (channels gate first) |
80+
| empty | set | **Bot ignores all messages** (channels must be configured first) |
8181
| set | set | **AND** — must be in allowed channel AND allowed user |
8282

8383
- Empty `allowed_channels` = bot will not respond anywhere (secure by default)

src/discord.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ impl EventHandler for Handler {
213213

214214
let channel_id = msg.channel_id.get();
215215
if self.allowed_channels.is_empty() {
216+
debug!("allowed_channels is empty — ignoring message in channel {}", channel_id);
216217
return;
217218
}
218219
let in_allowed_channel = self.allowed_channels.contains(&channel_id);

src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use serenity::prelude::*;
1616
use std::collections::HashSet;
1717
use std::path::PathBuf;
1818
use std::sync::Arc;
19-
use tracing::{error, info};
19+
use tracing::{error, info, warn};
2020

2121
#[derive(Parser)]
2222
#[command(name = "openab")]
@@ -149,7 +149,7 @@ async fn main() -> anyhow::Result<()> {
149149
let allowed_channels =
150150
parse_id_set(&discord_cfg.allowed_channels, "discord.allowed_channels")?;
151151
if allowed_channels.is_empty() {
152-
error!("no allowed_channels configured — bot will not respond to any messages. Add at least one channel ID to [discord] allowed_channels.");
152+
warn!("no allowed_channels configured — bot will not respond to any messages. Add at least one channel ID to [discord] allowed_channels.");
153153
}
154154
let allowed_users = parse_id_set(&discord_cfg.allowed_users, "discord.allowed_users")?;
155155
let trusted_bot_ids = parse_id_set(&discord_cfg.trusted_bot_ids, "discord.trusted_bot_ids")?;

0 commit comments

Comments
 (0)