-
Notifications
You must be signed in to change notification settings - Fork 0
News‐Bot
b1tk1ll3r edited this page Aug 15, 2025
·
2 revisions
The News Bot allows curated messages to be delivered via direct messages (DMs) to subscribed users.
Users must actively opt in to receive messages. Server admins can also add recipients directly.
-
Bot User with the following OAuth2 scopes:
botapplications.commands
-
Required server permissions:
View Channels-
Send Messages(only for welcome posts / informational messages)
-
Privileged Gateway Intents: not required
→ No message content or full member list collection.
There are two ways to add users to the distribution list:
- User runs
/subscribe. - Bot stores the user ID and optionally the display name in a SQLite database.
- Optional: immediate welcome DM.
- Admin right-clicks a user in the member list → Apps → “Add to recipients”.
- Bot checks whether the executing user has admin/mod rights (
AdministratororManage Guild). - If allowed: target user ID is stored in the database.
- Slash command
/unsubscribe - Removes the user from the recipient list.
- Confirmation sent as an ephemeral message.
Table: subscribers
-
user_id(PRIMARY KEY) username-
added_at(timestamp of subscription)
- Through the web interface, send a message to a single user ID.
- Send a message to all stored subscribers.
- A delay (~1.2 s) is added between sends to avoid hitting rate limits.
- Displays a summary of successful and failed deliveries.
- Only admins can add other users (via user context command).
- Every user must actively opt in or be added by an admin.
- Users can opt out anytime with
/unsubscribe. - No message content is stored — only user IDs, usernames, and subscription date.
- Bot does not require any privileged gateway intents.
- discordgo – Discord API client
- modernc.org/sqlite – SQLite driver without CGO
- net/http – Web interface
-
/subscribe&/unsubscribe:ChatApplicationCommand -
Add to recipients:UserApplicationCommand(visible to admins only)
sequenceDiagram
participant Admin
participant Discord
participant Bot
Admin->>Discord: Right-click user → Apps → "Add to recipients"
Discord->>Bot: InteractionCreate Event
Bot->>Bot: Check admin permissions
Bot->>SQLite: Save user ID + username
Bot-->>Admin: Ephemeral confirmation