Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config.toml.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[discord]
bot_token = "${DISCORD_BOT_TOKEN}"
# Required: at least one channel ID. Empty list = bot will not respond to any messages.
allowed_channels = ["1234567890"]

[agent]
Expand Down
6 changes: 4 additions & 2 deletions src/discord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ impl EventHandler for Handler {
let bot_id = ctx.cache.current_user().id;

let channel_id = msg.channel_id.get();
let in_allowed_channel =
self.allowed_channels.is_empty() || self.allowed_channels.contains(&channel_id);
let in_allowed_channel = self.allowed_channels.contains(&channel_id);

let is_mentioned = msg.mentions_user_id(bot_id)
|| msg.content.contains(&format!("<@{}>", bot_id))
Expand Down Expand Up @@ -172,6 +171,9 @@ impl EventHandler for Handler {

async fn ready(&self, _ctx: Context, ready: Ready) {
info!(user = %ready.user.name, "discord bot connected");
if self.allowed_channels.is_empty() {
tracing::warn!("allowed_channels is empty — bot will NOT respond to any messages. Configure allowed_channels in config.toml.");
}
}
}

Expand Down