feat(discord): improve UX and add source-level tests for /newsession
PR Checks / test-and-build (pull_request) Successful in 5m59s
PR Checks / test-and-build (pull_request) Successful in 5m59s
- DiscordNewSessionCommand: on success, renders session details via DiscordSessionBatchRenderer.Render() with embeds and action rows. - DiscordNewSessionCommand: uses Discord emoji shortcodes for error and success messages (✅, ⛔, 💥). - DiscordNewSessionHandlerTests: added 7 source-level structural tests verifying Dapper usage, NpgsqlDataSource, permission checks, platform neutrality, transaction safety, CancellationToken usage, and embed rendering in the command. Refs issue #28 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using GmRelay.DiscordBot.Rendering;
|
||||
using NetCord.Rest;
|
||||
using NetCord.Services.ApplicationCommands;
|
||||
|
||||
@@ -49,19 +50,23 @@ public class DiscordNewSessionCommand : ApplicationCommandModule<SlashCommandCon
|
||||
joinLink: link,
|
||||
CancellationToken.None);
|
||||
|
||||
var (embeds, actionRows) = DiscordSessionBatchRenderer.Render(view);
|
||||
await Context.Interaction.SendResponseAsync(
|
||||
InteractionCallback.Message("+ Session created!"));
|
||||
InteractionCallback.Message(new InteractionMessageProperties()
|
||||
.WithContent(":white_check_mark: **Session created successfully!**")
|
||||
.WithEmbeds(embeds)
|
||||
.WithComponents(actionRows)));
|
||||
}
|
||||
catch (UnauthorizedAccessException ex)
|
||||
{
|
||||
await Context.Interaction.SendResponseAsync(
|
||||
InteractionCallback.Message($"! {ex.Message}"));
|
||||
InteractionCallback.Message($":no_entry: {ex.Message}"));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Failed to create session for user {UserId} in guild {GuildId}", Context.User.Id, guild.Id);
|
||||
await Context.Interaction.SendResponseAsync(
|
||||
InteractionCallback.Message("* An error occurred while creating the session."));
|
||||
InteractionCallback.Message(":boom: An error occurred while creating the session."));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user