[Feature Request] chat.z.ai: Add DM User Allowlist/Restriction for Hosted Discord Bot
Nobody has claimed this yet.
- Dominant language
- No language data
- Stars
- 22
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
π Feature Request
Add DM access control settings for the hosted Z.ai Discord bot integration, allowing bot owners to restrict which Discord users can send DMs to their bot instance.
Target Platform: chat.z.ai dashboard β Discord/IM Channel Configuration
π Current Behavior (Problem)
β Issue
The hosted Z.ai Discord bot currently accepts DMs from ANY user who shares a server with the bot. There is no dashboard setting to:
- Restrict DM access to specific user IDs
- Block unauthorized users from consuming bot owner's quota
- Prevent unwanted DM interactions
π― Use Case
Bot owners using the hosted Z.ai integration for personal use want to prevent other server members from:
- Consuming their paid quota via DM interactions
- Accessing their private bot instance
- Sending unsolicited messages
"Currently, the hosted Z.ai Discord bot accepts DMs from any user who shares a server with it. There is no dashboard setting to restrict DM access to specific Discord user IDs."
β kori [db], Discord
β Proposed Solution
New Dashboard Setting
Add a DM Access Policy section under Discord/IM channel configuration in chat.z.ai:
βββββββββββββββββββββββββββββββββββββββββββ
β Discord Bot DM Settings β
βββββββββββββββββββββββββββββββββββββββββββ€
β β
β DM Access Policy: β
β β Open (anyone can DM) [current]β
β β Allowlist (restricted) [NEW] β
β β Disabled (no DMs) [NEW] ββ ββ βββββββββββββββββββββββββββββββ βnβ β Allowed User IDs (one per line)β ββ β β ββ β 123456789012345678 β ββ β 987654321098765432 β ββ β β ββ βββββββββββββββββββββββββββββββ ββ ββ β Silently ignore DMs from others ββ β Reply with "access denied" message ββ ββββββββββββββββββββββββββββββββββββββββββββ```### Expected Behavior When Enabled
| Scenario | Behavior |
|----------|----------|
| Authorized user sends DM | β
Processed normally |
| Non-authorized user sends DM | π Silently ignored (or custom rejection) |
| User not in allowlist attempts DM | No quota consumed, no response |
---
## π Precedent: Self-Hosted OpenClaw
This feature **already exists** in self-hosted OpenClaw configurations:
```yaml
# openclaw.config.yaml
dmPolicy: "allowlist"
allowFrom:
- "123456789012345678"
- "987654321098765432"
Request: Port this same capability to the hosted Z.ai service via dashboard UI.
π‘ Implementation Suggestions
Priority: MEDIUM-HIGH
Phase 1: Basic Allowlist (MVP)
- Add "DM Policy" dropdown:
Open|Allowlist|Disabled - Text area for comma-separated or newline-separated Discord user IDs
- Server-side validation of user ID format (17-19 digit snowflake)
- Silent ignore behavior for non-authorized DMs
Phase 2: Enhanced Features
- Import from Discord role/server membership
- Custom rejection message option
- DM access log (who attempted, when)
- Rate limiting per-user even within allowlist
Phase 3: Advanced
- Time-based allowlist (temporary access windows)
- Webhook notification on blocked DM attempt
- Per-user quota limits within shared bot instance
π― User Impact
Who Benefits?
| User Type | Benefit |
|---|---|
| Personal bot hosters | Prevent quota theft by server members |
| Team/small org | Control internal bot access |
| Premium subscribers | Protect $168/month plan usage |
| Privacy-focused users | Ensure only authorized DMs processed |
Quota Protection
This is primarily a billing protection feature:
- Unauthorized DMs consume bot owner's quota
- No way to track/block this currently
- Could lead to unexpected charges from bad actors
π Technical Considerations
Discord API Level
- No Discord gateway changes needed
- Filter at message receive handler before processing
- Check
message.author.idagainst allowlist - If not allowed: return early, don't increment usage
Database Schema
ALTER TABLE bot_configurations
ADD COLUMN dm_policy ENUM('open', 'allowlist', 'disabled') DEFAULT 'open',
ADD COLUMN dm_allowlist JSON; -- Array of snowflake strings
Edge Cases
| Case | Recommended Handling |
|---|---|
| Empty allowlist + allowlist mode | Treat as "disabled" β block all |
| User leaves server but still in allowlist | Still allowed (ID-based, not membership) |
| Bot owner removes themselves from allowlist | Warning: "You'll lose DM access" |
| DM from bot itself/other bots | Always ignore (standard practice) |
π Security Implications
Positive
- β Prevents quota exhaustion attacks
- β Reduces unauthorized API usage surface
- β Aligns hosted feature parity with self-hosted security options
Risks
- None significant β purely additive feature, opt-in
π Alternatives Considered
| Alternative | Pros | Cons | Verdict |
|---|---|---|---|
| Status quo | No dev work | Quota vulnerable, user complaints | β Rejected |
| Server-level restriction | Broader control | Overkill, affects channels too | β οΈ Partial |
| Dashboard allowlist (PROPOSED) | Granular, UI-friendly, matches OpenClaw | Dev work required | β Recommended |
π Additional Context
User Statement
"Self-hosted OpenClaw already supports this via
dmPolicy: 'allowlist'+allowFromin config, but the hosted Z.ai service has no equivalent setting. Requested: A DM access restriction setting in the Z.ai dashboard (chat.z.ai) under the Discord/IM channel configuration, allowing bot owners to specify which Discord user IDs are authorized to DM the bot. DMs from non-authorized users should be silently ignored.""Use case: Bot owners using the hosted integration for personal use want to prevent other server members from consuming their quota or interacting with their bot instance via DM."
β kori [db], Discord
π Discord Thread Reference
Original Report: Feature request submitted by kori [db] via Discord
Submitted by: Roman Galaxys10 (Roman) β Z.ai Volunteer Ambassador
Discord: bignavi_x
GitHub: romangalaxys10-spec
Source: Discord Community β User: kori [db]
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up β it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the chat.z.ai dashboardβs Discord/IM channel configuration, the hosted botβs message receive handler, and the bot_configurations schema named in the issue. Compare the hosted flow with the referenced dmPolicy/allowFrom behavior. Done means owners can configure open, allowlist, or disabled DM access, unauthorized messages are blocked before quota usage, and the setting is validated and persisted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- sql
- Domain
- backend, databases, frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100