This repository has been archived on 2024-06-23. You can view files and clone it, but cannot push or open issues or pull requests.
OctobotStealth/src/InteractionResponders.cs
Octol1ttle 84e730838b
Add a new .editorconfig and reformat code (#76)
*I'll start working on features and bugfixes after this PR, I promise*
very short summary:
- no more braceless statements
- braces are on new lines now
- `sealed` on everything that can be `sealed`
- no more awkwardly looking alignment of fields/parameters
- no more `Service` suffix on service fields. yeah.
- no more `else`s. who needs them?
- code style is now enforced by CI

---------

Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
2023-08-02 20:51:16 +00:00

42 lines
1.4 KiB
C#

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 Boyfriend;
/// <summary>
/// Handles responding to various interactions.
/// </summary>
[UsedImplicitly]
public class InteractionResponders : InteractionGroup
{
private readonly FeedbackService _feedback;
public InteractionResponders(FeedbackService feedback)
{
_feedback = feedback;
}
/// <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")]
[UsedImplicitly]
public async Task<Result> 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);
}
}