PolyhydraGames.Discord 1.0.8

dotnet add package PolyhydraGames.Discord --version 1.0.8
                    
NuGet\Install-Package PolyhydraGames.Discord -Version 1.0.8
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PolyhydraGames.Discord" Version="1.0.8" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PolyhydraGames.Discord" Version="1.0.8" />
                    
Directory.Packages.props
<PackageReference Include="PolyhydraGames.Discord" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add PolyhydraGames.Discord --version 1.0.8
                    
#r "nuget: PolyhydraGames.Discord, 1.0.8"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package PolyhydraGames.Discord@1.0.8
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=PolyhydraGames.Discord&version=1.0.8
                    
Install as a Cake Addin
#tool nuget:?package=PolyhydraGames.Discord&version=1.0.8
                    
Install as a Cake Tool

PolyhydraGames.Discord

NuGet Build and Publish

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, /link commands
  • 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                               │
└─────────────────────────────────────────────────────────────┘
  • ChannelCheevos - Main streaming achievement platform
  • PolyhydraGames.OAuth.Core - OAuth and command queue infrastructure
  • PolyhydraGames.Streaming.Interfaces - Platform abstraction interfaces

Repository

Publishing

Use ./pub.sh to restore, test, pack, and publish.

  • GitHub Packages is the default publish target.
  • Set PUBLISH_NUGET_ORG=true only when the package should also go to nuget.org.
  • Set DRY_RUN=true to skip pushes.
  • Use PACKAGE_API_KEY, GHCR_TOKEN, GITHUB_PACKAGES_TOKEN, GITHUB_TOKEN, or GH_TOKEN for 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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