Optimize event handlers until we update to .NET 7

This commit is contained in:
Octol1ttle 2022-11-16 23:28:05 +05:00
parent 29c2332ad9
commit 917e7e5775
Signed by: Octol1ttle
GPG key ID: B77C34313AEE1FFF

View file

@ -1,4 +1,5 @@
using Discord; using System.Diagnostics.CodeAnalysis;
using Discord;
using Discord.Rest; using Discord.Rest;
using Discord.WebSocket; using Discord.WebSocket;
@ -8,16 +9,17 @@ public static class EventHandler {
private static readonly DiscordSocketClient Client = Boyfriend.Client; private static readonly DiscordSocketClient Client = Boyfriend.Client;
private static bool _sendReadyMessages = true; private static bool _sendReadyMessages = true;
[SuppressMessage("ReSharper", "ConvertClosureToMethodGroup")]
public static void InitEvents() { public static void InitEvents() {
Client.Ready += ReadyEvent; Client.Ready += () => ReadyEvent();
Client.MessageDeleted += MessageDeletedEvent; Client.MessageDeleted += (x, y) => MessageDeletedEvent(x, y);
Client.MessageReceived += MessageReceivedEvent; Client.MessageReceived += x => MessageReceivedEvent(x);
Client.MessageUpdated += MessageUpdatedEvent; Client.MessageUpdated += (x, y, z) => MessageUpdatedEvent(x, y, z);
Client.UserJoined += UserJoinedEvent; Client.UserJoined += x => UserJoinedEvent(x);
Client.GuildScheduledEventCreated += ScheduledEventCreatedEvent; Client.GuildScheduledEventCreated += x => ScheduledEventCreatedEvent(x);
Client.GuildScheduledEventCancelled += ScheduledEventCancelledEvent; Client.GuildScheduledEventCancelled += x => ScheduledEventCancelledEvent(x);
Client.GuildScheduledEventStarted += ScheduledEventStartedEvent; Client.GuildScheduledEventStarted += x => ScheduledEventStartedEvent(x);
Client.GuildScheduledEventCompleted += ScheduledEventCompletedEvent; Client.GuildScheduledEventCompleted += x => ScheduledEventCompletedEvent(x);
} }
private static Task ReadyEvent() { private static Task ReadyEvent() {