Skip to content

Commit 85b1102

Browse files
authored
fix: improve gateway intents and auth error messages (#328)
Catch DisallowedGatewayIntents and InvalidAuthentication errors from Discord gateway with actionable error messages instead of cryptic serenity errors. Add prerequisites section to README documenting required Discord Developer Portal settings. Closes #116 Co-authored-by: Masami <masami-agent@users.noreply.github.com>
1 parent 196b2de commit 85b1102

2 files changed

Lines changed: 33 additions & 1 deletion

File tree

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,19 @@ A lightweight, secure, cloud-native ACP harness that bridges **Discord, Slack**,
4444

4545
## Quick Start
4646

47+
### Prerequisites
48+
49+
Before running openab, enable these in the [Discord Developer Portal](https://discord.com/developers/applications):
50+
51+
1. **Bot → Privileged Gateway Intents**:
52+
- ✅ Message Content Intent
53+
- ✅ Server Members Intent
54+
2. **OAuth2 → URL Generator → Bot Permissions**:
55+
- Send Messages, Embed Links, Attach Files
56+
- Read Message History, Add Reactions
57+
58+
See [docs/discord.md](docs/discord.md) for a detailed step-by-step guide.
59+
4760
### 1. Create a Bot
4861

4962
<details>

src/main.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ mod gateway;
1616

1717
use adapter::AdapterRouter;
1818
use clap::Parser;
19+
use serenity::gateway::GatewayError;
1920
use serenity::prelude::*;
2021
use std::collections::HashSet;
2122
use std::path::PathBuf;
@@ -336,7 +337,25 @@ async fn main() -> anyhow::Result<()> {
336337
});
337338

338339
info!("discord bot running");
339-
client.start().await?;
340+
match client.start().await {
341+
Err(serenity::Error::Gateway(GatewayError::DisallowedGatewayIntents)) => {
342+
error!(
343+
"Discord rejected privileged intents. \
344+
Enable MESSAGE CONTENT INTENT at: \
345+
https://discord.com/developers/applications → Bot → Privileged Gateway Intents"
346+
);
347+
std::process::exit(1);
348+
}
349+
Err(serenity::Error::Gateway(GatewayError::InvalidAuthentication)) => {
350+
error!(
351+
"Discord rejected bot token. \
352+
Verify your bot_token in config.toml is correct and has not been reset."
353+
);
354+
std::process::exit(1);
355+
}
356+
Err(e) => return Err(e.into()),
357+
Ok(_) => {}
358+
}
340359
} else {
341360
// No Discord — wait for SIGINT or SIGTERM
342361
info!("running without discord, press ctrl+c to stop");

0 commit comments

Comments
 (0)