fix(discord): register slash command modules
PR Checks / test-and-build (pull_request) Successful in 8m27s
PR Checks / test-and-build (pull_request) Successful in 8m27s
Register NetCord application command modules after the host is built so module-based commands are published alongside the minimal /ping command. Update README Discord env guidance to avoid the unused DISCORD_BOT_CLIENT_ID variable. Bump version to 3.0.2.
This commit is contained in:
@@ -6,7 +6,7 @@ on:
|
|||||||
- main
|
- main
|
||||||
|
|
||||||
env:
|
env:
|
||||||
VERSION: 3.0.1
|
VERSION: 3.0.2
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# ЧАСТЬ 1: Собираем образы и кладем в Gitea (чтобы делиться с ребятами)
|
# ЧАСТЬ 1: Собираем образы и кладем в Gitea (чтобы делиться с ребятами)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<Project>
|
<Project>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Version>3.0.1</Version>
|
<Version>3.0.2</Version>
|
||||||
<TargetFramework>net10.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
<LangVersion>preview</LangVersion>
|
<LangVersion>preview</LangVersion>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -85,8 +85,10 @@ TELEGRAM_BOT_TOKEN=ваш_токен_здесь
|
|||||||
# Токен Discord application bot
|
# Токен Discord application bot
|
||||||
DISCORD_BOT_TOKEN=ваш_discord_токен_здесь
|
DISCORD_BOT_TOKEN=ваш_discord_токен_здесь
|
||||||
|
|
||||||
# Client ID Discord application (используется для slash-команд)
|
# Discord OAuth (для Web Dashboard)
|
||||||
DISCORD_BOT_CLIENT_ID=ваш_discord_client_id_здесь
|
DISCORD_CLIENT_ID=ваш_discord_client_id_здесь
|
||||||
|
DISCORD_CLIENT_SECRET=ваш_discord_client_secret_здесь
|
||||||
|
DISCORD_REDIRECT_URI=https://your-domain.example/auth/discord/callback
|
||||||
|
|
||||||
# Имя бота без @ (для Telegram Login Widget)
|
# Имя бота без @ (для Telegram Login Widget)
|
||||||
TELEGRAM_BOT_USERNAME=ваше_имя_бота_здесь
|
TELEGRAM_BOT_USERNAME=ваше_имя_бота_здесь
|
||||||
@@ -119,7 +121,7 @@ docker compose up -d
|
|||||||
1. Напишите боту `/start`.
|
1. Напишите боту `/start`.
|
||||||
2. Создайте группу через `/newgroup`.
|
2. Создайте группу через `/newgroup`.
|
||||||
3. Откройте Mini App или Web Dashboard для расширенного управления.
|
3. Откройте Mini App или Web Dashboard для расширенного управления.
|
||||||
4. Для Discord пригласите application bot на сервер с правами `bot` и `applications.commands`. Скопируйте `DISCORD_BOT_TOKEN` и `DISCORD_BOT_CLIENT_ID` в `.env`.
|
4. Для Discord пригласите application bot на сервер с правами `bot` и `applications.commands`. Скопируйте `DISCORD_BOT_TOKEN` в `.env`; `DISCORD_CLIENT_ID`, `DISCORD_CLIENT_SECRET` и `DISCORD_REDIRECT_URI` нужны только для входа в Web Dashboard через Discord.
|
||||||
5. Перезапустите Docker Compose (`docker compose up -d`), а затем в Discord создайте сессию через `/newsession` или опубликуйте расписание через `/listsessions`; игроки записываются и выходят кнопками в опубликованном сообщении.
|
5. Перезапустите Docker Compose (`docker compose up -d`), а затем в Discord создайте сессию через `/newsession` или опубликуйте расписание через `/listsessions`; игроки записываются и выходят кнопками в опубликованном сообщении.
|
||||||
|
|
||||||
## 💾 Backup и восстановление
|
## 💾 Backup и восстановление
|
||||||
|
|||||||
+3
-3
@@ -49,7 +49,7 @@ services:
|
|||||||
crond -f
|
crond -f
|
||||||
|
|
||||||
bot:
|
bot:
|
||||||
image: git.codeanddice.ru/toutsu/gmrelay-bot:3.0.1
|
image: git.codeanddice.ru/toutsu/gmrelay-bot:3.0.2
|
||||||
restart: always
|
restart: always
|
||||||
depends_on:
|
depends_on:
|
||||||
db:
|
db:
|
||||||
@@ -67,7 +67,7 @@ services:
|
|||||||
retries: 3
|
retries: 3
|
||||||
|
|
||||||
discord:
|
discord:
|
||||||
image: git.codeanddice.ru/toutsu/gmrelay-discord-bot:3.0.1
|
image: git.codeanddice.ru/toutsu/gmrelay-discord-bot:3.0.2
|
||||||
restart: always
|
restart: always
|
||||||
depends_on:
|
depends_on:
|
||||||
db:
|
db:
|
||||||
@@ -84,7 +84,7 @@ services:
|
|||||||
retries: 3
|
retries: 3
|
||||||
|
|
||||||
web:
|
web:
|
||||||
image: git.codeanddice.ru/toutsu/gmrelay-web:3.0.1
|
image: git.codeanddice.ru/toutsu/gmrelay-web:3.0.2
|
||||||
restart: always
|
restart: always
|
||||||
depends_on:
|
depends_on:
|
||||||
db:
|
db:
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ using Microsoft.Extensions.DependencyInjection;
|
|||||||
using NetCord;
|
using NetCord;
|
||||||
using NetCord.Gateway;
|
using NetCord.Gateway;
|
||||||
using NetCord.Hosting.Gateway;
|
using NetCord.Hosting.Gateway;
|
||||||
|
using NetCord.Hosting.Services;
|
||||||
using NetCord.Hosting.Services.ApplicationCommands;
|
using NetCord.Hosting.Services.ApplicationCommands;
|
||||||
using NetCord.Hosting.Services.ComponentInteractions;
|
using NetCord.Hosting.Services.ComponentInteractions;
|
||||||
using NetCord.Services.ComponentInteractions;
|
using NetCord.Services.ComponentInteractions;
|
||||||
@@ -89,5 +90,6 @@ builder.Services
|
|||||||
var host = builder.Build();
|
var host = builder.Build();
|
||||||
|
|
||||||
host.AddSlashCommand("ping", "Checks whether GM-Relay Discord is online.", () => "Pong!");
|
host.AddSlashCommand("ping", "Checks whether GM-Relay Discord is online.", () => "Pong!");
|
||||||
|
host.AddModules(typeof(Program).Assembly);
|
||||||
|
|
||||||
await host.RunAsync();
|
await host.RunAsync();
|
||||||
|
|||||||
@@ -73,7 +73,7 @@
|
|||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<div class="nav-version">v3.0.1</div>
|
<div class="nav-version">v3.0.2</div>
|
||||||
</div>
|
</div>
|
||||||
</Authorized>
|
</Authorized>
|
||||||
<NotAuthorized>
|
<NotAuthorized>
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ public sealed class DiscordProjectStructureTests
|
|||||||
var prChecks = File.ReadAllText(Path.Combine(repoRoot, ".gitea", "workflows", "pr-checks.yml"));
|
var prChecks = File.ReadAllText(Path.Combine(repoRoot, ".gitea", "workflows", "pr-checks.yml"));
|
||||||
var deploy = File.ReadAllText(Path.Combine(repoRoot, ".gitea", "workflows", "deploy.yml"));
|
var deploy = File.ReadAllText(Path.Combine(repoRoot, ".gitea", "workflows", "deploy.yml"));
|
||||||
|
|
||||||
Assert.Contains("gmrelay-discord-bot:3.0.1", compose);
|
Assert.Contains("gmrelay-discord-bot:3.0.2", compose);
|
||||||
Assert.Contains("Discord__Token=${DISCORD_BOT_TOKEN:?Set DISCORD_BOT_TOKEN in .env}", compose);
|
Assert.Contains("Discord__Token=${DISCORD_BOT_TOKEN:?Set DISCORD_BOT_TOKEN in .env}", compose);
|
||||||
Assert.Contains("src/GmRelay.DiscordBot/Dockerfile", deploy);
|
Assert.Contains("src/GmRelay.DiscordBot/Dockerfile", deploy);
|
||||||
Assert.Contains("DISCORD_BOT_TOKEN", deploy);
|
Assert.Contains("DISCORD_BOT_TOKEN", deploy);
|
||||||
@@ -75,13 +75,13 @@ public sealed class DiscordProjectStructureTests
|
|||||||
{
|
{
|
||||||
var repoRoot = GetRepoRoot();
|
var repoRoot = GetRepoRoot();
|
||||||
|
|
||||||
Assert.Contains("<Version>3.0.1</Version>", File.ReadAllText(Path.Combine(repoRoot, "Directory.Build.props")));
|
Assert.Contains("<Version>3.0.2</Version>", File.ReadAllText(Path.Combine(repoRoot, "Directory.Build.props")));
|
||||||
Assert.Contains("VERSION: 3.0.1", File.ReadAllText(Path.Combine(repoRoot, ".gitea", "workflows", "deploy.yml")));
|
Assert.Contains("VERSION: 3.0.2", File.ReadAllText(Path.Combine(repoRoot, ".gitea", "workflows", "deploy.yml")));
|
||||||
Assert.Contains("gmrelay-bot:3.0.1", File.ReadAllText(Path.Combine(repoRoot, "compose.yaml")));
|
Assert.Contains("gmrelay-bot:3.0.2", File.ReadAllText(Path.Combine(repoRoot, "compose.yaml")));
|
||||||
Assert.Contains("gmrelay-web:3.0.1", File.ReadAllText(Path.Combine(repoRoot, "compose.yaml")));
|
Assert.Contains("gmrelay-web:3.0.2", File.ReadAllText(Path.Combine(repoRoot, "compose.yaml")));
|
||||||
Assert.Contains("gmrelay-discord-bot:3.0.1", File.ReadAllText(Path.Combine(repoRoot, "compose.yaml")));
|
Assert.Contains("gmrelay-discord-bot:3.0.2", File.ReadAllText(Path.Combine(repoRoot, "compose.yaml")));
|
||||||
Assert.Contains(
|
Assert.Contains(
|
||||||
"v3.0.1",
|
"v3.0.2",
|
||||||
File.ReadAllText(Path.Combine(repoRoot, "src", "GmRelay.Web", "Components", "Layout", "NavMenu.razor")));
|
File.ReadAllText(Path.Combine(repoRoot, "src", "GmRelay.Web", "Components", "Layout", "NavMenu.razor")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,6 +94,16 @@ public sealed class DiscordProjectStructureTests
|
|||||||
Assert.Contains("DISCORD_BOT_TOKEN", envExample);
|
Assert.Contains("DISCORD_BOT_TOKEN", envExample);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Readme_ShouldNotAskForUnusedDiscordBotClientId()
|
||||||
|
{
|
||||||
|
var repoRoot = GetRepoRoot();
|
||||||
|
var readme = File.ReadAllText(Path.Combine(repoRoot, "README.md"));
|
||||||
|
|
||||||
|
Assert.DoesNotContain("DISCORD_BOT_CLIENT_ID", readme);
|
||||||
|
Assert.Contains("DISCORD_CLIENT_ID", readme);
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Compose_ShouldIncludeDiscordHealthcheck()
|
public void Compose_ShouldIncludeDiscordHealthcheck()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ public sealed class DiscordStartupTests
|
|||||||
Assert.Contains(".AddComponentInteractions", program);
|
Assert.Contains(".AddComponentInteractions", program);
|
||||||
Assert.Contains(".AddGatewayHandlers", program);
|
Assert.Contains(".AddGatewayHandlers", program);
|
||||||
Assert.Contains("AddSlashCommand", program);
|
Assert.Contains("AddSlashCommand", program);
|
||||||
|
Assert.Contains("AddModules(typeof(Program).Assembly)", program);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|||||||
Reference in New Issue
Block a user