From e21cefd79d3c09215efea26cec5949b97bbbf268 Mon Sep 17 00:00:00 2001 From: Macintosh II <95250141+mctaylors@users.noreply.github.com> Date: Wed, 11 Oct 2023 22:16:52 +0300 Subject: [PATCH] Use link button for created event message (#158) Signed-off-by: Macintosh II --- src/InteractionResponders.cs | 42 ------------------- src/Octobot.cs | 4 -- .../Update/ScheduledEventUpdateService.cs | 6 +-- 3 files changed, 2 insertions(+), 50 deletions(-) delete mode 100644 src/InteractionResponders.cs diff --git a/src/InteractionResponders.cs b/src/InteractionResponders.cs deleted file mode 100644 index 8e42110..0000000 --- a/src/InteractionResponders.cs +++ /dev/null @@ -1,42 +0,0 @@ -using JetBrains.Annotations; -using Remora.Discord.API.Abstractions.Objects; -using Remora.Discord.Commands.Feedback.Messages; -using Remora.Discord.Commands.Feedback.Services; -using Remora.Discord.Interactivity; -using Remora.Results; - -namespace Octobot; - -/// -/// Handles responding to various interactions. -/// -[UsedImplicitly] -public class InteractionResponders : InteractionGroup -{ - private readonly FeedbackService _feedback; - - public InteractionResponders(FeedbackService feedback) - { - _feedback = feedback; - } - - /// - /// A button that will output an ephemeral embed containing the information about a scheduled event. - /// - /// The ID of the guild and scheduled event, encoded as "guildId:eventId". - /// An ephemeral feedback sending result which may or may not have succeeded. - [Button("scheduled-event-details")] - [UsedImplicitly] - public async Task OnStatefulButtonClicked(string? state = null) - { - if (state is null) - { - return new ArgumentNullError(nameof(state)); - } - - var idArray = state.Split(':'); - return (Result)await _feedback.SendContextualAsync( - $"https://discord.com/events/{idArray[0]}/{idArray[1]}", - options: new FeedbackMessageOptions(MessageFlags: MessageFlags.Ephemeral), ct: CancellationToken); - } -} diff --git a/src/Octobot.cs b/src/Octobot.cs index 662d1bf..234f3a8 100644 --- a/src/Octobot.cs +++ b/src/Octobot.cs @@ -17,7 +17,6 @@ using Remora.Discord.Commands.Services; using Remora.Discord.Gateway; using Remora.Discord.Gateway.Extensions; using Remora.Discord.Hosting.Extensions; -using Remora.Discord.Interactivity.Extensions; using Remora.Rest.Core; using Serilog.Extensions.Logging; @@ -80,9 +79,6 @@ public sealed class Octobot // Init .AddDiscordCaching() .AddDiscordCommands(true) - // Interactions - .AddInteractivity() - .AddInteractionGroup() // Slash command event handlers .AddPreparationErrorEvent() .AddPostExecutionEvent() diff --git a/src/Services/Update/ScheduledEventUpdateService.cs b/src/Services/Update/ScheduledEventUpdateService.cs index 97f9329..ee2c982 100644 --- a/src/Services/Update/ScheduledEventUpdateService.cs +++ b/src/Services/Update/ScheduledEventUpdateService.cs @@ -7,7 +7,6 @@ using Remora.Discord.API.Abstractions.Rest; using Remora.Discord.API.Objects; using Remora.Discord.Extensions.Embeds; using Remora.Discord.Extensions.Formatting; -using Remora.Discord.Interactivity; using Remora.Rest.Core; using Remora.Results; @@ -217,11 +216,10 @@ public sealed class ScheduledEventUpdateService : BackgroundService : string.Empty; var button = new ButtonComponent( - ButtonComponentStyle.Primary, + ButtonComponentStyle.Link, Messages.EventDetailsButton, new PartialEmoji(Name: "📋"), - CustomIDHelpers.CreateButtonIDWithState( - "scheduled-event-details", $"{scheduledEvent.GuildID}:{scheduledEvent.ID}") + URL: $"https://discord.com/events/{scheduledEvent.GuildID}/{scheduledEvent.ID}" ); return (Result)await _channelApi.CreateMessageAsync(