用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/csharpfritz/Discord-Minecraft --skill discord-net-worker-service命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | discord-net-worker-service |
| description | Pattern for hosting Discord.NET bot inside a .NET generic host BackgroundService |
| domain | integration |
| confidence | low |
| source | earned |
When building a Discord bot as part of a larger .NET service architecture (Aspire, microservices), the bot needs to integrate with the generic host lifecycle rather than running standalone.
DiscordSocketConfig and DiscordSocketClient as singletons in DIBackgroundService that receives the client via constructor injectionExecuteAsync: wire events → LoginAsync → StartAsync → Task.Delay(Infinite, token) → StopAsyncLogSeverity to Microsoft.Extensions.Logging.LogLevel via the client.Log eventclient.Ready event (gateway is fully connected at that point)client.SlashCommandExecutedIConfiguration["Discord:BotToken"] — works with user secrets and env varsclient.ChannelCreated, client.ChannelDestroyed, client.ChannelUpdated — detect category vs text channel with is ICategoryChannelIConnectionMultiplexer (from Aspire's AddRedisClient) to get ISubscriber for Redis pub/subRedisChannel.Literal(channelName) for publish — avoid pattern-matching overheadChannelUpdated events to only publish when meaningful properties change (name, position) — Discord fires this event for many property changes// Program.cs
builder.Services.AddSingleton(new DiscordSocketConfig
{
GatewayIntents = GatewayIntents.Guilds,
LogLevel = LogSeverity.Info
});
builder.Services.AddSingleton<DiscordSocketClient>();
builder.Services.AddHostedService<DiscordBotWorker>();
// Graceful shutdown in ExecuteAsync
try { await Task.Delay(Timeout.Infinite, stoppingToken); }
catch (OperationCanceledException) { }
await client.StopAsync();
DiscordSocketClient per-request or as transient — it manages a persistent WebSocketReady event — the client isn't connected yetwhile (!token.IsCancellationRequested) { await Task.Delay(...) } — Task.Delay(Infinite) is cleaner and avoids unnecessary wake-ups