2023-07-18 15:25:02 +03:00
|
|
|
using JetBrains.Annotations;
|
2023-07-09 16:32:14 +03:00
|
|
|
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 Boyfriend;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Handles responding to various interactions.
|
|
|
|
/// </summary>
|
2023-07-18 15:25:02 +03:00
|
|
|
[UsedImplicitly]
|
2023-07-09 16:32:14 +03:00
|
|
|
public class InteractionResponders : InteractionGroup {
|
|
|
|
private readonly FeedbackService _feedbackService;
|
|
|
|
|
|
|
|
public InteractionResponders(FeedbackService feedbackService) {
|
|
|
|
_feedbackService = feedbackService;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// A button that will output an ephemeral embed containing the information about a scheduled event.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="state">The ID of the guild and scheduled event, encoded as "guildId:eventId".</param>
|
|
|
|
/// <returns>An ephemeral feedback sending result which may or may not have succeeded.</returns>
|
|
|
|
[Button("scheduled-event-details")]
|
2023-07-18 15:25:02 +03:00
|
|
|
[UsedImplicitly]
|
2023-07-09 16:32:14 +03:00
|
|
|
public async Task<Result> OnStatefulButtonClicked(string? state = null) {
|
2023-07-28 19:58:55 +03:00
|
|
|
if (state is null) return new ArgumentNullError(nameof(state));
|
2023-07-09 16:32:14 +03:00
|
|
|
|
|
|
|
var idArray = state.Split(':');
|
|
|
|
return (Result)await _feedbackService.SendContextualAsync(
|
|
|
|
$"https://discord.com/events/{idArray[0]}/{idArray[1]}",
|
2023-07-20 23:41:02 +03:00
|
|
|
options: new FeedbackMessageOptions(MessageFlags: MessageFlags.Ephemeral), ct: CancellationToken);
|
2023-07-09 16:32:14 +03:00
|
|
|
}
|
|
|
|
}
|