PolyhydraGames.Discord
1.0.8
dotnet add package PolyhydraGames.Discord --version 1.0.8
NuGet\Install-Package PolyhydraGames.Discord -Version 1.0.8
<PackageReference Include="PolyhydraGames.Discord" Version="1.0.8" />
<PackageVersion Include="PolyhydraGames.Discord" Version="1.0.8" />
<PackageReference Include="PolyhydraGames.Discord" />
paket add PolyhydraGames.Discord --version 1.0.8
#r "nuget: PolyhydraGames.Discord, 1.0.8"
#:package PolyhydraGames.Discord@1.0.8
#addin nuget:?package=PolyhydraGames.Discord&version=1.0.8
#tool nuget:?package=PolyhydraGames.Discord&version=1.0.8
PolyhydraGames.Discord
Discord bot integration library for PolyhydraGames and ChannelCheevos. Provides a Discord.Net-based client for real-time chat monitoring, slash commands, and role synchronization.
Documentation
Tags
- dotnet
- api
- api-discord
- auth
- discord
- chat
Features
- Discord Bot Client - Connect as a bot, monitor channels, send messages
- Slash Commands - Register and handle
/cheevos,/score,/linkcommands - Role Synchronization - Auto-assign Discord roles when users unlock achievements
- Webhook Messenger - Simple outbound messaging via Discord webhooks
- Account Linking - Link Discord accounts to ChannelCheevos accounts
Installation
dotnet add package PolyhydraGames.Discord
Configuration
Add to your appsettings.json:
{
"Discord": {
"Enabled": true,
"BotKey": "your-discord-bot-token",
"ChannelMonitor": "bot-commands",
"OwnerUserId": "1234567890",
"GuildId": "987654321098765432",
"CheevoRoles": "first-blood:111222333444555666,gold-winner:777888999000111222",
"DefaultCheevoRole": "123456789012345678",
"OutboundWebhookEnabled": true,
"OutboundWebhookUrl": "https://discord.com/api/webhooks/...",
"Admins": "admin1,admin2"
}
}
Configuration Options
| Key | Type | Description |
|---|---|---|
Enabled |
bool |
Enable/disable the Discord bot |
BotKey |
string |
Discord bot token |
ChannelMonitor |
string |
Channel name to monitor for messages |
OwnerUserId |
string |
Platform owner user ID for message routing |
GuildId |
ulong? |
Discord guild ID for slash commands (optional; global if unset) |
CheevoRoles |
string |
Comma-separated cheevo-key:role-id mappings |
DefaultCheevoRole |
ulong? |
Default role to assign when any cheevo unlocked |
OutboundWebhookEnabled |
bool |
Enable webhook-based messaging |
OutboundWebhookUrl |
string |
Discord webhook URL for outbound messages |
Admins |
string |
Comma-separated list of admin usernames |
Usage
Basic Bot Setup
using PolyhydraGames.Discord.Extensions;
using PolyhydraGames.Discord.Services;
// In Program.cs or Startup.cs
services.AddDiscordBot(Configuration);
// Resolve and start the bot
var bot = serviceProvider.GetRequiredService<DiscordBot>();
await bot.Start();
Slash Commands & Role Sync
using PolyhydraGames.Discord.Extensions;
using PolyhydraGames.Discord.Interfaces;
// Add with external service integration
services.AddDiscordCheevoService(
Configuration,
sp => userId => cheevoService.GetCheevosDisplayAsync(userId),
sp => userId => cheevoService.GetScoreDisplayAsync(userId),
sp => (userId, cheevoKey, guildId) => roleService.SyncRoleAsync(userId, cheevoKey, guildId),
sp => (userId, username, token) => accountService.LinkAccountAsync(userId, username, token)
);
// The DiscordCheevoService will automatically:
// 1. Register slash commands on bot ready
// 2. Handle /cheevos, /score, /link commands
// 3. Sync roles when cheevos are unlocked
Webhook Messaging
For simple outbound notifications without a full bot:
using PolyhydraGames.Discord.Extensions;
using PolyhydraGames.Discord.Interfaces;
services.AddDiscordWebhookMessenger(Configuration);
// Inject and use
public class MyService
{
private readonly IDiscordWebhookMessenger _messenger;
public MyService(IDiscordWebhookMessenger messenger)
{
_messenger = messenger;
}
public async Task NotifyAsync(string message)
{
await _messenger.SendAsync(message);
}
}
Main Types
| Type | Description |
|---|---|
DiscordBot |
Main bot service - connects, monitors channels, sends messages |
DiscordCheevoService |
Slash command handler and role synchronization |
DiscordWebhookMessenger |
Simple webhook-based message sender |
DiscordBotConfig |
Configuration POCO from IConfiguration |
IDiscordService |
Base interface for API services |
Slash Commands
When using DiscordCheevoService, the following commands are registered:
| Command | Description |
|---|---|
/cheevos [user] |
Display achievements for yourself or another user |
/score [user] |
Display total cheevo points |
/link <token> |
Link your Discord account to ChannelCheevos |
Architecture
┌─────────────────────────────────────────────────────────────┐
│ Your Application │
├─────────────────────────────────────────────────────────────┤
│ IDiscordCheevoService │ IDiscordWebhookMessenger │
│ (slash commands, roles) │ (outbound messages) │
├───────────────────────────┴─────────────────────────────────┤
│ DiscordBot │
│ (DiscordSocketClient wrapper) │
├─────────────────────────────────────────────────────────────┤
│ Discord.Net │
└─────────────────────────────────────────────────────────────┘
Related Projects
- ChannelCheevos - Main streaming achievement platform
- PolyhydraGames.OAuth.Core - OAuth and command queue infrastructure
- PolyhydraGames.Streaming.Interfaces - Platform abstraction interfaces
Repository
- GitHub: https://github.com/lancer1977/Api.Discord
- Issues: https://github.com/lancer1977/Api.Discord/issues
Publishing
Use ./pub.sh to restore, test, pack, and publish.
- GitHub Packages is the default publish target.
- Set
PUBLISH_NUGET_ORG=trueonly when the package should also go to nuget.org. - Set
DRY_RUN=trueto skip pushes. - Use
PACKAGE_API_KEY,GHCR_TOKEN,GITHUB_PACKAGES_TOKEN,GITHUB_TOKEN, orGH_TOKENfor GitHub Packages auth.
For private/internal consumption from GitHub Packages, add the GitHub NuGet source for this organization and authenticate with a GitHub token or PAT:
dotnet nuget add source https://nuget.pkg.github.com/lancer1977/index.json \
--name lancer1977 \
--username YOUR_GITHUB_USERNAME \
--password YOUR_GITHUB_TOKEN \
--store-password-in-clear-text
License
MIT License - see LICENSE for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Discord.Net (>= 3.20.1)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.9)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.9)
- Microsoft.Extensions.Http (>= 10.0.9)
- PolyhydraGames.Auth.Abstractions (>= 1.1.7)
- PolyhydraGames.Core.Global (>= 1.0.3.11)
- PolyhydraGames.Extensions (>= 2.1.2.4)
- PolyhydraGames.Platforms.Abstractions (>= 1.1.7)
- PolyhydraGames.PostOffice.Abstractions (>= 1.1.7)
- PolyhydraGames.PostOffice.Core (>= 1.1.7)
- ReactiveUI (>= 23.2.28)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.8 | 38 | 10/6/2026 |