1
0
Fork 1
mirror of https://github.com/TeamOctolings/Octobot.git synced 2025-04-29 18:49:53 +03:00

Remora.Discord part 1 out of ∞

Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
Octol1ttle 2023-05-16 00:11:11 +05:00
parent 02949656bf
commit 201a1ce079
Signed by: Octol1ttle
GPG key ID: B77C34313AEE1FFF
24 changed files with 141 additions and 1588 deletions

31
EventResponders.cs Normal file
View file

@ -0,0 +1,31 @@
using Remora.Discord.API.Abstractions.Gateway.Events;
using Remora.Discord.API.Abstractions.Rest;
using Remora.Discord.Gateway.Responders;
using Remora.Results;
namespace Boyfriend;
public class ReadyResponder : IResponder<IGuildCreate> {
private readonly IDiscordRestChannelAPI _channelApi;
public ReadyResponder(IDiscordRestChannelAPI channelApi) {
_channelApi = channelApi;
}
public async Task<Result> RespondAsync(IGuildCreate gatewayEvent, CancellationToken ct = default) {
if (!gatewayEvent.Guild.IsT0) return Result.FromSuccess(); // is IAvailableGuild
var guild = gatewayEvent.Guild.AsT0;
if (guild.GetConfigBool("SendReadyMessages").IsDefined(out var enabled)
&& enabled
&& guild.GetChannel("PrivateFeedbackChannel").IsDefined(out var channel)) {
Messages.Culture = guild.GetCulture();
var i = Random.Shared.Next(1, 4);
return (Result)await _channelApi.CreateMessageAsync(
channel.ID, string.Format(Messages.Ready, Boyfriend.GetLocalized($"Beep{i}")), ct: ct);
}
return Result.FromSuccess();
}
}