diff --git a/DisCatSharp/Clients/Sharding/DiscordShardedClient.cs b/DisCatSharp/Clients/Sharding/DiscordShardedClient.cs
deleted file mode 100644
index b6492fad4..000000000
--- a/DisCatSharp/Clients/Sharding/DiscordShardedClient.cs
+++ /dev/null
@@ -1,778 +0,0 @@
-// This file is part of the DisCatSharp project, based off DSharpPlus.
-//
-// Copyright (c) 2021-2022 AITSYS
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-#pragma warning disable CS0618
-using System;
-using System.Collections.Concurrent;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Diagnostics;
-using System.Globalization;
-using System.Linq;
-using System.Net.Http;
-using System.Reflection;
-using System.Threading.Tasks;
-
-using DisCatSharp.Common.Utilities;
-using DisCatSharp.Entities;
-using DisCatSharp.EventArgs;
-using DisCatSharp.Net;
-
-using Microsoft.Extensions.Logging;
-
-using Newtonsoft.Json.Linq;
-
-namespace DisCatSharp;
-
-///
-/// A Discord client that shards automatically.
-///
-public sealed partial class DiscordShardedClient
-{
- #region Public Properties
-
- ///
- /// Gets the logger for this client.
- ///
- public ILogger Logger { get; }
-
- ///
- /// Gets all client shards.
- ///
- public IReadOnlyDictionary ShardClients { get; }
-
- ///
- /// Gets the gateway info for the client's session.
- ///
- public GatewayInfo GatewayInfo { get; private set; }
-
- ///
- /// Gets the current user.
- ///
- public DiscordUser CurrentUser { get; private set; }
-
- ///
- /// Gets the current application.
- ///
- public DiscordApplication CurrentApplication { get; private set; }
-
- [Obsolete("Use GetLibraryDevelopmentTeamAsync")]
- public DisCatSharpTeam LibraryDeveloperTeam
- => this.GetLibraryDevelopmentTeamAsync().Result;
-
- ///
- /// Gets the list of available voice regions. Note that this property will not contain VIP voice regions.
- ///
- public IReadOnlyDictionary VoiceRegions
- => this._voiceRegionsLazy?.Value;
-
- #endregion
-
- #region Private Properties/Fields
-
- ///
- /// Gets the configuration.
- ///
- private readonly DiscordConfiguration _configuration;
-
- ///
- /// Gets the list of available voice regions. This property is meant as a way to modify .
- ///
- private ConcurrentDictionary _internalVoiceRegions;
-
- ///
- /// Gets a list of shards.
- ///
- private readonly ConcurrentDictionary _shards = new();
-
- ///
- /// Gets a lazy list of voice regions.
- ///
- private Lazy> _voiceRegionsLazy;
-
- ///
- /// Whether the shard client is started.
- ///
- private bool _isStarted;
-
- ///
- /// Whether manual sharding is enabled.
- ///
- private readonly bool _manuallySharding;
-
- #endregion
-
- #region Constructor
-
- ///
- /// Initializes a new auto-sharding Discord client.
- ///
- /// The configuration to use.
- public DiscordShardedClient(DiscordConfiguration config)
- {
- this.InternalSetup();
-
- if (config.ShardCount > 1)
- this._manuallySharding = true;
-
- this._configuration = config;
- this.ShardClients = new ReadOnlyConcurrentDictionary(this._shards);
-
- if (this._configuration.LoggerFactory == null)
- {
- this._configuration.LoggerFactory = new DefaultLoggerFactory();
- this._configuration.LoggerFactory.AddProvider(new DefaultLoggerProvider(this._configuration.MinimumLogLevel, this._configuration.LogTimestampFormat));
- }
- this.Logger = this._configuration.LoggerFactory.CreateLogger();
- }
-
- #endregion
-
- #region Public Methods
-
- ///
- /// Initializes and connects all shards.
- ///
- ///
- ///
- public async Task StartAsync()
- {
- if (this._isStarted)
- throw new InvalidOperationException("This client has already been started.");
-
- this._isStarted = true;
-
- try
- {
- if (this._configuration.TokenType != TokenType.Bot)
- this.Logger.LogWarning(LoggerEvents.Misc, "You are logging in with a token that is not a bot token. This is not officially supported by Discord, and can result in your account being terminated if you aren't careful.");
- this.Logger.LogInformation(LoggerEvents.Startup, "Lib {0}, version {1}", this._botLibrary, this._versionString.Value);
-
- var shardc = await this.InitializeShardsAsync().ConfigureAwait(false);
- var connectTasks = new List();
- this.Logger.LogInformation(LoggerEvents.ShardStartup, "Booting {0} shards.", shardc);
-
- for (var i = 0; i < shardc; i++)
- {
- //This should never happen, but in case it does...
- if (this.GatewayInfo.SessionBucket.MaxConcurrency < 1)
- this.GatewayInfo.SessionBucket.MaxConcurrency = 1;
-
- if (this.GatewayInfo.SessionBucket.MaxConcurrency == 1)
- await this.ConnectShardAsync(i).ConfigureAwait(false);
- else
- {
- //Concurrent login.
- connectTasks.Add(this.ConnectShardAsync(i));
-
- if (connectTasks.Count == this.GatewayInfo.SessionBucket.MaxConcurrency)
- {
- await Task.WhenAll(connectTasks).ConfigureAwait(false);
- connectTasks.Clear();
- }
- }
- }
- }
- catch (Exception ex)
- {
- await this.InternalStopAsync(false).ConfigureAwait(false);
-
- var message = $"Shard initialization failed, check inner exceptions for details: ";
-
- this.Logger.LogCritical(LoggerEvents.ShardClientError, $"{message}\n{ex}");
- throw new AggregateException(message, ex);
- }
- }
-
- ///
- /// Disconnects and disposes all shards.
- ///
- ///
- public Task StopAsync()
- => this.InternalStopAsync();
-
- ///
- /// Gets a shard from a guild id.
- ///
- /// If automatically sharding, this will use the method.
- /// Otherwise if manually sharding, it will instead iterate through each shard's guild caches.
- ///
- ///
- /// The guild ID for the shard.
- /// The found shard. Otherwise null if the shard was not found for the guild id.
- public DiscordClient GetShard(ulong guildId)
- {
- var index = this._manuallySharding ? this.GetShardIdFromGuilds(guildId) : Utilities.GetShardId(guildId, this.ShardClients.Count);
-
- return index != -1 ? this._shards[index] : null;
- }
-
- ///
- /// Gets a shard from a guild.
- ///
- /// If automatically sharding, this will use the method.
- /// Otherwise if manually sharding, it will instead iterate through each shard's guild caches.
- ///
- ///
- /// The guild for the shard.
- /// The found shard. Otherwise null if the shard was not found for the guild.
- public DiscordClient GetShard(DiscordGuild guild)
- => this.GetShard(guild.Id);
-
- ///
- /// Updates the status on all shards.
- ///
- /// The activity to set. Defaults to null.
- /// The optional status to set. Defaults to null.
- /// Since when is the client performing the specified activity. Defaults to null.
- /// Asynchronous operation.
- public async Task UpdateStatusAsync(DiscordActivity activity = null, UserStatus? userStatus = null, DateTimeOffset? idleSince = null)
- {
- var tasks = new List();
- foreach (var client in this._shards.Values)
- tasks.Add(client.UpdateStatusAsync(activity, userStatus, idleSince));
-
- await Task.WhenAll(tasks).ConfigureAwait(false);
- }
-
- ///
- ///
- ///
- public async Task GetLibraryDevelopmentTeamAsync()
- => await this.GetShard(0).GetLibraryDevelopmentTeamAsync().ConfigureAwait(false);
-
- #endregion
-
- #region Internal Methods
-
- ///
- /// Initializes the shards.
- ///
- /// The count of initialized shards.
- internal async Task InitializeShardsAsync()
- {
- if (!this._shards.IsEmpty)
- return this._shards.Count;
-
- this.GatewayInfo = await this.GetGatewayInfoAsync().ConfigureAwait(false);
- var shardCount = this._configuration.ShardCount == 1 ? this.GatewayInfo.ShardCount : this._configuration.ShardCount;
- var lf = new ShardedLoggerFactory(this.Logger);
- for (var i = 0; i < shardCount; i++)
- {
- var cfg = new DiscordConfiguration(this._configuration)
- {
- ShardId = i,
- ShardCount = shardCount,
- LoggerFactory = lf
- };
-
- var client = new DiscordClient(cfg);
- if (!this._shards.TryAdd(i, client))
- throw new InvalidOperationException("Could not initialize shards.");
- }
-
- return shardCount;
- }
-
- #endregion
-
- #region Private Methods & Version Property
-
- ///
- /// Gets the gateway info.
- ///
- private async Task GetGatewayInfoAsync()
- {
- var url = $"{Utilities.GetApiBaseUri(this._configuration)}{Endpoints.GATEWAY}{Endpoints.BOT}";
- var http = new HttpClient();
-
- http.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", Utilities.GetUserAgent());
- http.DefaultRequestHeaders.TryAddWithoutValidation("Authorization", Utilities.GetFormattedToken(this._configuration));
- if (this._configuration != null && this._configuration.Override != null)
- {
- http.DefaultRequestHeaders.TryAddWithoutValidation("x-super-properties", this._configuration.Override);
- }
-
- this.Logger.LogDebug(LoggerEvents.ShardRest, $"Obtaining gateway information from GET {Endpoints.GATEWAY}{Endpoints.BOT}...");
- var resp = await http.GetAsync(url).ConfigureAwait(false);
-
- http.Dispose();
-
- if (!resp.IsSuccessStatusCode)
- {
- var ratelimited = await HandleHttpError(url, resp).ConfigureAwait(false);
-
- if (ratelimited)
- return await this.GetGatewayInfoAsync().ConfigureAwait(false);
- }
-
- var timer = new Stopwatch();
- timer.Start();
-
- var jo = JObject.Parse(await resp.Content.ReadAsStringAsync().ConfigureAwait(false));
- var info = jo.ToObject();
-
- //There is a delay from parsing here.
- timer.Stop();
-
- info.SessionBucket.ResetAfterInternal -= (int)timer.ElapsedMilliseconds;
- info.SessionBucket.ResetAfter = DateTimeOffset.UtcNow + TimeSpan.FromMilliseconds(info.SessionBucket.ResetAfterInternal);
-
- return info;
-
- async Task HandleHttpError(string reqUrl, HttpResponseMessage msg)
- {
- var code = (int)msg.StatusCode;
-
- if (code == 401 || code == 403)
- {
- throw new Exception($"Authentication failed, check your token and try again: {code} {msg.ReasonPhrase}");
- }
- else if (code == 429)
- {
- this.Logger.LogError(LoggerEvents.ShardClientError, $"Ratelimit hit, requeuing request to {reqUrl}");
-
- var hs = msg.Headers.ToDictionary(xh => xh.Key, xh => string.Join("\n", xh.Value), StringComparer.OrdinalIgnoreCase);
- var waitInterval = 0;
-
- if (hs.TryGetValue("Retry-After", out var retryAfterRaw))
- waitInterval = int.Parse(retryAfterRaw, CultureInfo.InvariantCulture);
-
- await Task.Delay(waitInterval).ConfigureAwait(false);
- return true;
- }
- else if (code >= 500)
- {
- throw new Exception($"Internal Server Error: {code} {msg.ReasonPhrase}");
- }
- else
- {
- throw new Exception($"An unsuccessful HTTP status code was encountered: {code} {msg.ReasonPhrase}");
- }
- }
- }
-
- ///
- /// Gets the version string.
- ///
- private readonly Lazy _versionString = new(() =>
- {
- var a = typeof(DiscordShardedClient).GetTypeInfo().Assembly;
-
- var iv = a.GetCustomAttribute();
- if (iv != null)
- return iv.InformationalVersion;
-
- var v = a.GetName().Version;
- var vs = v.ToString(3);
-
- if (v.Revision > 0)
- vs = $"{vs}, CI build {v.Revision}";
-
- return vs;
- });
-
- ///
- /// Gets the name of the used bot library.
- ///
- private readonly string _botLibrary = "DisCatSharp";
-
- #endregion
-
- #region Private Connection Methods
-
- ///
- /// Connects a shard.
- ///
- /// The shard id.
- private async Task ConnectShardAsync(int i)
- {
- if (!this._shards.TryGetValue(i, out var client))
- throw new Exception($"Could not initialize shard {i}.");
-
- if (this.GatewayInfo != null)
- {
- client.GatewayInfo = this.GatewayInfo;
- client.GatewayUri = new Uri(client.GatewayInfo.Url);
- }
-
- if (this.CurrentUser != null)
- client.CurrentUser = this.CurrentUser;
-
- if (this.CurrentApplication != null)
- client.CurrentApplication = this.CurrentApplication;
-
- if (this._internalVoiceRegions != null)
- {
- client.InternalVoiceRegions = this._internalVoiceRegions;
- client.VoiceRegionsLazy = new Lazy>(() => new ReadOnlyDictionary(client.InternalVoiceRegions));
- }
-
- this.HookEventHandlers(client);
-
- client.IsShard = true;
- await client.ConnectAsync().ConfigureAwait(false);
- this.Logger.LogInformation(LoggerEvents.ShardStartup, "Booted shard {0}.", i);
-
- if (this.CurrentUser == null)
- this.CurrentUser = client.CurrentUser;
-
- if (this.CurrentApplication == null)
- this.CurrentApplication = client.CurrentApplication;
-
- if (this._internalVoiceRegions == null)
- {
- this._internalVoiceRegions = client.InternalVoiceRegions;
- this._voiceRegionsLazy = new Lazy>(() => new ReadOnlyDictionary(this._internalVoiceRegions));
- }
- }
-
- ///
- /// Stops all shards.
- ///
- /// Whether to enable the logger.
- private Task InternalStopAsync(bool enableLogger = true)
- {
- if (!this._isStarted)
- throw new InvalidOperationException("This client has not been started.");
-
- if (enableLogger)
- this.Logger.LogInformation(LoggerEvents.ShardShutdown, "Disposing {0} shards.", this._shards.Count);
-
- this._isStarted = false;
- this._voiceRegionsLazy = null;
-
- this.GatewayInfo = null;
- this.CurrentUser = null;
- this.CurrentApplication = null;
-
- for (var i = 0; i < this._shards.Count; i++)
- {
- if (this._shards.TryGetValue(i, out var client))
- {
- this.UnhookEventHandlers(client);
-
- client.Dispose();
-
- if (enableLogger)
- this.Logger.LogInformation(LoggerEvents.ShardShutdown, "Disconnected shard {0}.", i);
- }
- }
-
- this._shards.Clear();
-
- return Task.CompletedTask;
- }
-
- #endregion
-
- #region Event Handler Initialization/Registering
-
- ///
- /// Sets the shard client up internally..
- ///
- private void InternalSetup()
- {
- this._clientErrored = new AsyncEvent("CLIENT_ERRORED", DiscordClient.EventExecutionLimit, this.Goof);
- this._socketErrored = new AsyncEvent("SOCKET_ERRORED", DiscordClient.EventExecutionLimit, this.Goof);
- this._socketOpened = new AsyncEvent("SOCKET_OPENED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._socketClosed = new AsyncEvent("SOCKET_CLOSED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._ready = new AsyncEvent("READY", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._resumed = new AsyncEvent("RESUMED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._channelCreated = new AsyncEvent("CHANNEL_CREATED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._channelUpdated = new AsyncEvent("CHANNEL_UPDATED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._channelDeleted = new AsyncEvent("CHANNEL_DELETED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._dmChannelDeleted = new AsyncEvent("DM_CHANNEL_DELETED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._channelPinsUpdated = new AsyncEvent("CHANNEL_PINS_UPDATED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._guildCreated = new AsyncEvent("GUILD_CREATED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._guildAvailable = new AsyncEvent("GUILD_AVAILABLE", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._guildUpdated = new AsyncEvent("GUILD_UPDATED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._guildDeleted = new AsyncEvent("GUILD_DELETED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._guildUnavailable = new AsyncEvent("GUILD_UNAVAILABLE", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._guildDownloadCompleted = new AsyncEvent("GUILD_DOWNLOAD_COMPLETED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._inviteCreated = new AsyncEvent("INVITE_CREATED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._inviteDeleted = new AsyncEvent("INVITE_DELETED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._messageCreated = new AsyncEvent("MESSAGE_CREATED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._presenceUpdated = new AsyncEvent("PRESENCE_UPDATED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._guildBanAdded = new AsyncEvent("GUILD_BAN_ADDED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._guildBanRemoved = new AsyncEvent("GUILD_BAN_REMOVED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._guildEmojisUpdated = new AsyncEvent("GUILD_EMOJI_UPDATED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._guildStickersUpdated = new AsyncEvent("GUILD_STICKER_UPDATED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._guildIntegrationsUpdated = new AsyncEvent("GUILD_INTEGRATIONS_UPDATED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._guildMemberAdded = new AsyncEvent("GUILD_MEMBER_ADDED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._guildMemberRemoved = new AsyncEvent("GUILD_MEMBER_REMOVED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._guildMemberUpdated = new AsyncEvent("GUILD_MEMBER_UPDATED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._guildRoleCreated = new AsyncEvent("GUILD_ROLE_CREATED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._guildRoleUpdated = new AsyncEvent("GUILD_ROLE_UPDATED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._guildRoleDeleted = new AsyncEvent("GUILD_ROLE_DELETED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._messageUpdated = new AsyncEvent("MESSAGE_UPDATED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._messageDeleted = new AsyncEvent("MESSAGE_DELETED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._messageBulkDeleted = new AsyncEvent("MESSAGE_BULK_DELETED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._interactionCreated = new AsyncEvent("INTERACTION_CREATED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._componentInteractionCreated = new AsyncEvent("COMPONENT_INTERACTED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._contextMenuInteractionCreated = new AsyncEvent("CONTEXT_MENU_INTERACTED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._typingStarted = new AsyncEvent("TYPING_STARTED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._userSettingsUpdated = new AsyncEvent("USER_SETTINGS_UPDATED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._userUpdated = new AsyncEvent("USER_UPDATED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._voiceStateUpdated = new AsyncEvent("VOICE_STATE_UPDATED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._voiceServerUpdated = new AsyncEvent("VOICE_SERVER_UPDATED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._guildMembersChunk = new AsyncEvent("GUILD_MEMBERS_CHUNKED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._unknownEvent = new AsyncEvent("UNKNOWN_EVENT", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._messageReactionAdded = new AsyncEvent("MESSAGE_REACTION_ADDED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._messageReactionRemoved = new AsyncEvent("MESSAGE_REACTION_REMOVED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._messageReactionsCleared = new AsyncEvent("MESSAGE_REACTIONS_CLEARED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._messageReactionRemovedEmoji = new AsyncEvent("MESSAGE_REACTION_REMOVED_EMOJI", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._webhooksUpdated = new AsyncEvent("WEBHOOKS_UPDATED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._heartbeated = new AsyncEvent("HEARTBEATED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._applicationCommandCreated = new AsyncEvent("APPLICATION_COMMAND_CREATED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._applicationCommandUpdated = new AsyncEvent("APPLICATION_COMMAND_UPDATED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._applicationCommandDeleted = new AsyncEvent("APPLICATION_COMMAND_DELETED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._guildApplicationCommandCountUpdated = new AsyncEvent("GUILD_APPLICATION_COMMAND_COUNTS_UPDATED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._applicationCommandPermissionsUpdated = new AsyncEvent("APPLICATION_COMMAND_PERMISSIONS_UPDATED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._guildIntegrationCreated = new AsyncEvent("INTEGRATION_CREATED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._guildIntegrationUpdated = new AsyncEvent("INTEGRATION_UPDATED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._guildIntegrationDeleted = new AsyncEvent("INTEGRATION_DELETED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._stageInstanceCreated = new AsyncEvent("STAGE_INSTANCE_CREATED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._stageInstanceUpdated = new AsyncEvent("STAGE_INSTANCE_UPDATED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._stageInstanceDeleted = new AsyncEvent("STAGE_INSTANCE_DELETED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._threadCreated = new AsyncEvent("THREAD_CREATED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._threadUpdated = new AsyncEvent("THREAD_UPDATED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._threadDeleted = new AsyncEvent("THREAD_DELETED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._threadListSynced = new AsyncEvent("THREAD_LIST_SYNCED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._threadMemberUpdated = new AsyncEvent("THREAD_MEMBER_UPDATED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._threadMembersUpdated = new AsyncEvent("THREAD_MEMBERS_UPDATED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._zombied = new AsyncEvent("ZOMBIED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._payloadReceived = new AsyncEvent("PAYLOAD_RECEIVED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._guildScheduledEventCreated = new AsyncEvent("GUILD_SCHEDULED_EVENT_CREATED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._guildScheduledEventUpdated = new AsyncEvent("GUILD_SCHEDULED_EVENT_UPDATED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._guildScheduledEventDeleted = new AsyncEvent("GUILD_SCHEDULED_EVENT_DELETED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._guildScheduledEventUserAdded = new AsyncEvent("GUILD_SCHEDULED_EVENT_USER_ADDED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._guildScheduledEventUserRemoved = new AsyncEvent("GUILD_SCHEDULED_EVENT_USER_REMOVED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._embeddedActivityUpdated = new AsyncEvent("EMBEDDED_ACTIVITY_UPDATED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._guildMemberTimeoutAdded = new AsyncEvent("GUILD_MEMBER_TIMEOUT_ADDED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._guildMemberTimeoutChanged = new AsyncEvent("GUILD_MEMBER_TIMEOUT_UPDATED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- this._guildMemberTimeoutRemoved = new AsyncEvent("GUILD_MEMBER_TIMEOUT_REMOVED", DiscordClient.EventExecutionLimit, this.EventErrorHandler);
- }
-
- ///
- /// Hooks the event handlers.
- ///
- /// The client.
- private void HookEventHandlers(DiscordClient client)
- {
- client.ClientErrored += this.Client_ClientError;
- client.SocketErrored += this.Client_SocketError;
- client.SocketOpened += this.Client_SocketOpened;
- client.SocketClosed += this.Client_SocketClosed;
- client.Ready += this.Client_Ready;
- client.Resumed += this.Client_Resumed;
- client.ChannelCreated += this.Client_ChannelCreated;
- client.ChannelUpdated += this.Client_ChannelUpdated;
- client.ChannelDeleted += this.Client_ChannelDeleted;
- client.DmChannelDeleted += this.Client_DMChannelDeleted;
- client.ChannelPinsUpdated += this.Client_ChannelPinsUpdated;
- client.GuildCreated += this.Client_GuildCreated;
- client.GuildAvailable += this.Client_GuildAvailable;
- client.GuildUpdated += this.Client_GuildUpdated;
- client.GuildDeleted += this.Client_GuildDeleted;
- client.GuildUnavailable += this.Client_GuildUnavailable;
- client.GuildDownloadCompleted += this.Client_GuildDownloadCompleted;
- client.InviteCreated += this.Client_InviteCreated;
- client.InviteDeleted += this.Client_InviteDeleted;
- client.MessageCreated += this.Client_MessageCreated;
- client.PresenceUpdated += this.Client_PresenceUpdate;
- client.GuildBanAdded += this.Client_GuildBanAdd;
- client.GuildBanRemoved += this.Client_GuildBanRemove;
- client.GuildEmojisUpdated += this.Client_GuildEmojisUpdate;
- client.GuildStickersUpdated += this.Client_GuildStickersUpdate;
- client.GuildIntegrationsUpdated += this.Client_GuildIntegrationsUpdate;
- client.GuildMemberAdded += this.Client_GuildMemberAdd;
- client.GuildMemberRemoved += this.Client_GuildMemberRemove;
- client.GuildMemberUpdated += this.Client_GuildMemberUpdate;
- client.GuildRoleCreated += this.Client_GuildRoleCreate;
- client.GuildRoleUpdated += this.Client_GuildRoleUpdate;
- client.GuildRoleDeleted += this.Client_GuildRoleDelete;
- client.MessageUpdated += this.Client_MessageUpdate;
- client.MessageDeleted += this.Client_MessageDelete;
- client.MessagesBulkDeleted += this.Client_MessageBulkDelete;
- client.InteractionCreated += this.Client_InteractionCreate;
- client.ComponentInteractionCreated += this.Client_ComponentInteractionCreate;
- client.ContextMenuInteractionCreated += this.Client_ContextMenuInteractionCreate;
- client.TypingStarted += this.Client_TypingStart;
- client.UserSettingsUpdated += this.Client_UserSettingsUpdate;
- client.UserUpdated += this.Client_UserUpdate;
- client.VoiceStateUpdated += this.Client_VoiceStateUpdate;
- client.VoiceServerUpdated += this.Client_VoiceServerUpdate;
- client.GuildMembersChunked += this.Client_GuildMembersChunk;
- client.UnknownEvent += this.Client_UnknownEvent;
- client.MessageReactionAdded += this.Client_MessageReactionAdd;
- client.MessageReactionRemoved += this.Client_MessageReactionRemove;
- client.MessageReactionsCleared += this.Client_MessageReactionRemoveAll;
- client.MessageReactionRemovedEmoji += this.Client_MessageReactionRemovedEmoji;
- client.WebhooksUpdated += this.Client_WebhooksUpdate;
- client.Heartbeated += this.Client_HeartBeated;
- client.ApplicationCommandCreated += this.Client_ApplicationCommandCreated;
- client.ApplicationCommandUpdated += this.Client_ApplicationCommandUpdated;
- client.ApplicationCommandDeleted += this.Client_ApplicationCommandDeleted;
- client.GuildApplicationCommandCountUpdated += this.Client_GuildApplicationCommandCountUpdated;
- client.ApplicationCommandPermissionsUpdated += this.Client_ApplicationCommandPermissionsUpdated;
- client.GuildIntegrationCreated += this.Client_GuildIntegrationCreated;
- client.GuildIntegrationUpdated += this.Client_GuildIntegrationUpdated;
- client.GuildIntegrationDeleted += this.Client_GuildIntegrationDeleted;
- client.StageInstanceCreated += this.Client_StageInstanceCreated;
- client.StageInstanceUpdated += this.Client_StageInstanceUpdated;
- client.StageInstanceDeleted += this.Client_StageInstanceDeleted;
- client.ThreadCreated += this.Client_ThreadCreated;
- client.ThreadUpdated += this.Client_ThreadUpdated;
- client.ThreadDeleted += this.Client_ThreadDeleted;
- client.ThreadListSynced += this.Client_ThreadListSynced;
- client.ThreadMemberUpdated += this.Client_ThreadMemberUpdated;
- client.ThreadMembersUpdated += this.Client_ThreadMembersUpdated;
- client.Zombied += this.Client_Zombied;
- client.PayloadReceived += this.Client_PayloadReceived;
- client.GuildScheduledEventCreated += this.Client_GuildScheduledEventCreated;
- client.GuildScheduledEventUpdated += this.Client_GuildScheduledEventUpdated;
- client.GuildScheduledEventDeleted += this.Client_GuildScheduledEventDeleted;
- client.GuildScheduledEventUserAdded += this.Client_GuildScheduledEventUserAdded; ;
- client.GuildScheduledEventUserRemoved += this.Client_GuildScheduledEventUserRemoved;
- client.EmbeddedActivityUpdated += this.Client_EmbeddedActivityUpdated;
- client.GuildMemberTimeoutAdded += this.Client_GuildMemberTimeoutAdded;
- client.GuildMemberTimeoutChanged += this.Client_GuildMemberTimeoutChanged;
- client.GuildMemberTimeoutRemoved += this.Client_GuildMemberTimeoutRemoved;
- }
-
- ///
- /// Unhooks the event handlers.
- ///
- /// The client.
- private void UnhookEventHandlers(DiscordClient client)
- {
- client.ClientErrored -= this.Client_ClientError;
- client.SocketErrored -= this.Client_SocketError;
- client.SocketOpened -= this.Client_SocketOpened;
- client.SocketClosed -= this.Client_SocketClosed;
- client.Ready -= this.Client_Ready;
- client.Resumed -= this.Client_Resumed;
- client.ChannelCreated -= this.Client_ChannelCreated;
- client.ChannelUpdated -= this.Client_ChannelUpdated;
- client.ChannelDeleted -= this.Client_ChannelDeleted;
- client.DmChannelDeleted -= this.Client_DMChannelDeleted;
- client.ChannelPinsUpdated -= this.Client_ChannelPinsUpdated;
- client.GuildCreated -= this.Client_GuildCreated;
- client.GuildAvailable -= this.Client_GuildAvailable;
- client.GuildUpdated -= this.Client_GuildUpdated;
- client.GuildDeleted -= this.Client_GuildDeleted;
- client.GuildUnavailable -= this.Client_GuildUnavailable;
- client.GuildDownloadCompleted -= this.Client_GuildDownloadCompleted;
- client.InviteCreated -= this.Client_InviteCreated;
- client.InviteDeleted -= this.Client_InviteDeleted;
- client.MessageCreated -= this.Client_MessageCreated;
- client.PresenceUpdated -= this.Client_PresenceUpdate;
- client.GuildBanAdded -= this.Client_GuildBanAdd;
- client.GuildBanRemoved -= this.Client_GuildBanRemove;
- client.GuildEmojisUpdated -= this.Client_GuildEmojisUpdate;
- client.GuildStickersUpdated -= this.Client_GuildStickersUpdate;
- client.GuildIntegrationsUpdated -= this.Client_GuildIntegrationsUpdate;
- client.GuildMemberAdded -= this.Client_GuildMemberAdd;
- client.GuildMemberRemoved -= this.Client_GuildMemberRemove;
- client.GuildMemberUpdated -= this.Client_GuildMemberUpdate;
- client.GuildRoleCreated -= this.Client_GuildRoleCreate;
- client.GuildRoleUpdated -= this.Client_GuildRoleUpdate;
- client.GuildRoleDeleted -= this.Client_GuildRoleDelete;
- client.MessageUpdated -= this.Client_MessageUpdate;
- client.MessageDeleted -= this.Client_MessageDelete;
- client.MessagesBulkDeleted -= this.Client_MessageBulkDelete;
- client.InteractionCreated -= this.Client_InteractionCreate;
- client.ComponentInteractionCreated -= this.Client_ComponentInteractionCreate;
- client.ContextMenuInteractionCreated -= this.Client_ContextMenuInteractionCreate;
- client.TypingStarted -= this.Client_TypingStart;
- client.UserSettingsUpdated -= this.Client_UserSettingsUpdate;
- client.UserUpdated -= this.Client_UserUpdate;
- client.VoiceStateUpdated -= this.Client_VoiceStateUpdate;
- client.VoiceServerUpdated -= this.Client_VoiceServerUpdate;
- client.GuildMembersChunked -= this.Client_GuildMembersChunk;
- client.UnknownEvent -= this.Client_UnknownEvent;
- client.MessageReactionAdded -= this.Client_MessageReactionAdd;
- client.MessageReactionRemoved -= this.Client_MessageReactionRemove;
- client.MessageReactionsCleared -= this.Client_MessageReactionRemoveAll;
- client.MessageReactionRemovedEmoji -= this.Client_MessageReactionRemovedEmoji;
- client.WebhooksUpdated -= this.Client_WebhooksUpdate;
- client.Heartbeated -= this.Client_HeartBeated;
- client.ApplicationCommandCreated -= this.Client_ApplicationCommandCreated;
- client.ApplicationCommandUpdated -= this.Client_ApplicationCommandUpdated;
- client.ApplicationCommandDeleted -= this.Client_ApplicationCommandDeleted;
- client.GuildApplicationCommandCountUpdated -= this.Client_GuildApplicationCommandCountUpdated;
- client.ApplicationCommandPermissionsUpdated -= this.Client_ApplicationCommandPermissionsUpdated;
- client.GuildIntegrationCreated -= this.Client_GuildIntegrationCreated;
- client.GuildIntegrationUpdated -= this.Client_GuildIntegrationUpdated;
- client.GuildIntegrationDeleted -= this.Client_GuildIntegrationDeleted;
- client.StageInstanceCreated -= this.Client_StageInstanceCreated;
- client.StageInstanceUpdated -= this.Client_StageInstanceUpdated;
- client.StageInstanceDeleted -= this.Client_StageInstanceDeleted;
- client.ThreadCreated -= this.Client_ThreadCreated;
- client.ThreadUpdated -= this.Client_ThreadUpdated;
- client.ThreadDeleted -= this.Client_ThreadDeleted;
- client.ThreadListSynced -= this.Client_ThreadListSynced;
- client.ThreadMemberUpdated -= this.Client_ThreadMemberUpdated;
- client.ThreadMembersUpdated -= this.Client_ThreadMembersUpdated;
- client.Zombied -= this.Client_Zombied;
- client.PayloadReceived -= this.Client_PayloadReceived;
- client.GuildScheduledEventCreated -= this.Client_GuildScheduledEventCreated;
- client.GuildScheduledEventUpdated -= this.Client_GuildScheduledEventUpdated;
- client.GuildScheduledEventDeleted -= this.Client_GuildScheduledEventDeleted;
- client.GuildScheduledEventUserAdded -= this.Client_GuildScheduledEventUserAdded; ;
- client.GuildScheduledEventUserRemoved -= this.Client_GuildScheduledEventUserRemoved;
- client.EmbeddedActivityUpdated -= this.Client_EmbeddedActivityUpdated;
- client.GuildMemberTimeoutAdded -= this.Client_GuildMemberTimeoutAdded;
- client.GuildMemberTimeoutChanged -= this.Client_GuildMemberTimeoutChanged;
- client.GuildMemberTimeoutRemoved -= this.Client_GuildMemberTimeoutRemoved;
- }
-
- ///
- /// Gets the shard id from guilds.
- ///
- /// The id.
- /// An int.
- private int GetShardIdFromGuilds(ulong id)
- {
- foreach (var s in this._shards.Values)
- {
- if (s.GuildsInternal.TryGetValue(id, out _))
- {
- return s.ShardId;
- }
- }
-
- return -1;
- }
-
- #endregion
-
- #region Destructor
-
- ~DiscordShardedClient()
- {
- this.InternalStopAsync(false).GetAwaiter().GetResult();
- }
-
- #endregion
-}
diff --git a/DisCatSharp/Clients/Sharding/Events/DiscordShardedClient.Events.cs b/DisCatSharp/Clients/Sharding/Events/DiscordShardedClient.Events.cs
deleted file mode 100644
index 12a111485..000000000
--- a/DisCatSharp/Clients/Sharding/Events/DiscordShardedClient.Events.cs
+++ /dev/null
@@ -1,1641 +0,0 @@
-// This file is part of the DisCatSharp project, based off DSharpPlus.
-//
-// Copyright (c) 2021-2022 AITSYS
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-
-using System;
-using System.Threading.Tasks;
-
-using DisCatSharp.Common.Utilities;
-using DisCatSharp.EventArgs;
-
-using Microsoft.Extensions.Logging;
-
-namespace DisCatSharp;
-
-///
-/// Represents a discord sharded client.
-///
-public sealed partial class DiscordShardedClient
-{
- #region WebSocket
-
- ///
- /// Fired whenever a WebSocket error occurs within the client.
- ///
- public event AsyncEventHandler SocketErrored
- {
- add => this._socketErrored.Register(value);
- remove => this._socketErrored.Unregister(value);
- }
- private AsyncEvent _socketErrored;
-
- ///
- /// Fired whenever WebSocket connection is established.
- ///
- public event AsyncEventHandler SocketOpened
- {
- add => this._socketOpened.Register(value);
- remove => this._socketOpened.Unregister(value);
- }
- private AsyncEvent _socketOpened;
-
- ///
- /// Fired whenever WebSocket connection is terminated.
- ///
- public event AsyncEventHandler SocketClosed
- {
- add => this._socketClosed.Register(value);
- remove => this._socketClosed.Unregister(value);
- }
- private AsyncEvent _socketClosed;
-
- ///
- /// Fired when the client enters ready state.
- ///
- public event AsyncEventHandler Ready
- {
- add => this._ready.Register(value);
- remove => this._ready.Unregister(value);
- }
- private AsyncEvent _ready;
-
- ///
- /// Fired whenever a session is resumed.
- ///
- public event AsyncEventHandler Resumed
- {
- add => this._resumed.Register(value);
- remove => this._resumed.Unregister(value);
- }
- private AsyncEvent _resumed;
-
- ///
- /// Fired on received heartbeat ACK.
- ///
- public event AsyncEventHandler Heartbeated
- {
- add => this._heartbeated.Register(value);
- remove => this._heartbeated.Unregister(value);
- }
- private AsyncEvent _heartbeated;
-
- #endregion
-
- #region Channel
-
- ///
- /// Fired when a new channel is created.
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler ChannelCreated
- {
- add => this._channelCreated.Register(value);
- remove => this._channelCreated.Unregister(value);
- }
- private AsyncEvent _channelCreated;
-
- ///
- /// Fired when a channel is updated.
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler ChannelUpdated
- {
- add => this._channelUpdated.Register(value);
- remove => this._channelUpdated.Unregister(value);
- }
- private AsyncEvent _channelUpdated;
-
- ///
- /// Fired when a channel is deleted
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler ChannelDeleted
- {
- add => this._channelDeleted.Register(value);
- remove => this._channelDeleted.Unregister(value);
- }
- private AsyncEvent _channelDeleted;
-
- ///
- /// Fired when a dm channel is deleted
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler DmChannelDeleted
- {
- add => this._dmChannelDeleted.Register(value);
- remove => this._dmChannelDeleted.Unregister(value);
- }
- private AsyncEvent _dmChannelDeleted;
-
- ///
- /// Fired whenever a channel's pinned message list is updated.
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler ChannelPinsUpdated
- {
- add => this._channelPinsUpdated.Register(value);
- remove => this._channelPinsUpdated.Unregister(value);
- }
- private AsyncEvent _channelPinsUpdated;
-
- #endregion
-
- #region Guild
-
- ///
- /// Fired when the user joins a new guild.
- /// For this Event you need the intent specified in
- ///
- /// [alias="GuildJoined"][alias="JoinedGuild"]
- public event AsyncEventHandler GuildCreated
- {
- add => this._guildCreated.Register(value);
- remove => this._guildCreated.Unregister(value);
- }
- private AsyncEvent _guildCreated;
-
- ///
- /// Fired when a guild is becoming available.
- ///
- public event AsyncEventHandler GuildAvailable
- {
- add => this._guildAvailable.Register(value);
- remove => this._guildAvailable.Unregister(value);
- }
- private AsyncEvent _guildAvailable;
-
- ///
- /// Fired when a guild is updated.
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler GuildUpdated
- {
- add => this._guildUpdated.Register(value);
- remove => this._guildUpdated.Unregister(value);
- }
- private AsyncEvent _guildUpdated;
-
- ///
- /// Fired when the user leaves or is removed from a guild.
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler GuildDeleted
- {
- add => this._guildDeleted.Register(value);
- remove => this._guildDeleted.Unregister(value);
- }
- private AsyncEvent _guildDeleted;
-
- ///
- /// Fired when a guild becomes unavailable.
- ///
- public event AsyncEventHandler GuildUnavailable
- {
- add => this._guildUnavailable.Register(value);
- remove => this._guildUnavailable.Unregister(value);
- }
- private AsyncEvent _guildUnavailable;
-
- ///
- /// Fired when all guilds finish streaming from Discord.
- ///
- public event AsyncEventHandler GuildDownloadCompleted
- {
- add => this._guildDownloadCompleted.Register(value);
- remove => this._guildDownloadCompleted.Unregister(value);
- }
- private AsyncEvent _guildDownloadCompleted;
-
- ///
- /// Fired when a guilds emojis get updated
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler GuildEmojisUpdated
- {
- add => this._guildEmojisUpdated.Register(value);
- remove => this._guildEmojisUpdated.Unregister(value);
- }
- private AsyncEvent _guildEmojisUpdated;
-
- ///
- /// Fired when a guilds stickers get updated
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler GuildStickersUpdated
- {
- add => this._guildStickersUpdated.Register(value);
- remove => this._guildStickersUpdated.Unregister(value);
- }
- private AsyncEvent _guildStickersUpdated;
-
- ///
- /// Fired when a guild integration is updated.
- ///
- public event AsyncEventHandler GuildIntegrationsUpdated
- {
- add => this._guildIntegrationsUpdated.Register(value);
- remove => this._guildIntegrationsUpdated.Unregister(value);
- }
- private AsyncEvent _guildIntegrationsUpdated;
-
- #endregion
-
- #region Guild Ban
-
- ///
- /// Fired when a guild ban gets added
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler GuildBanAdded
- {
- add => this._guildBanAdded.Register(value);
- remove => this._guildBanAdded.Unregister(value);
- }
- private AsyncEvent _guildBanAdded;
-
- ///
- /// Fired when a guild ban gets removed
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler GuildBanRemoved
- {
- add => this._guildBanRemoved.Register(value);
- remove => this._guildBanRemoved.Unregister(value);
- }
- private AsyncEvent _guildBanRemoved;
-
- #endregion
-
- #region Guild Timeout
-
- ///
- /// Fired when a guild member timeout gets added.
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler GuildMemberTimeoutAdded
- {
- add => this._guildMemberTimeoutAdded.Register(value);
- remove => this._guildMemberTimeoutAdded.Unregister(value);
- }
- private AsyncEvent _guildMemberTimeoutAdded;
-
- ///
- /// Fired when a guild member timeout gets changed.
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler GuildMemberTimeoutChanged
- {
- add => this._guildMemberTimeoutChanged.Register(value);
- remove => this._guildMemberTimeoutChanged.Unregister(value);
- }
- private AsyncEvent _guildMemberTimeoutChanged;
-
-
- ///
- /// Fired when a guild member timeout gets removed.
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler GuildMemberTimeoutRemoved
- {
- add => this._guildMemberTimeoutRemoved.Register(value);
- remove => this._guildMemberTimeoutRemoved.Unregister(value);
- }
- private AsyncEvent _guildMemberTimeoutRemoved;
-
- #endregion
-
- #region Guild Event
-
- ///
- /// Fired when a scheduled event is created.
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler GuildScheduledEventCreated
- {
- add => this._guildScheduledEventCreated.Register(value);
- remove => this._guildScheduledEventCreated.Unregister(value);
- }
- private AsyncEvent _guildScheduledEventCreated;
-
- ///
- /// Fired when a scheduled event is updated.
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler GuildScheduledEventUpdated
- {
- add => this._guildScheduledEventUpdated.Register(value);
- remove => this._guildScheduledEventUpdated.Unregister(value);
- }
- private AsyncEvent _guildScheduledEventUpdated;
-
- ///
- /// Fired when a scheduled event is deleted.
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler GuildScheduledEventDeleted
- {
- add => this._guildScheduledEventDeleted.Register(value);
- remove => this._guildScheduledEventDeleted.Unregister(value);
- }
- private AsyncEvent _guildScheduledEventDeleted;
-
- ///
- /// Fired when a user subscribes to a scheduled event.
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler GuildScheduledEventUserAdded
- {
- add => this._guildScheduledEventUserAdded.Register(value);
- remove => this._guildScheduledEventUserAdded.Unregister(value);
- }
- private AsyncEvent _guildScheduledEventUserAdded;
-
- ///
- /// Fired when a user unsubscribes from a scheduled event.
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler GuildScheduledEventUserRemoved
- {
- add => this._guildScheduledEventUserRemoved.Register(value);
- remove => this._guildScheduledEventUserRemoved.Unregister(value);
- }
- private AsyncEvent _guildScheduledEventUserRemoved;
-
- #endregion
-
- #region Guild Integration
-
- ///
- /// Fired when a guild integration is created.
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler GuildIntegrationCreated
- {
- add => this._guildIntegrationCreated.Register(value);
- remove => this._guildIntegrationCreated.Unregister(value);
- }
- private AsyncEvent _guildIntegrationCreated;
-
- ///
- /// Fired when a guild integration is updated.
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler GuildIntegrationUpdated
- {
- add => this._guildIntegrationUpdated.Register(value);
- remove => this._guildIntegrationUpdated.Unregister(value);
- }
- private AsyncEvent _guildIntegrationUpdated;
-
- ///
- /// Fired when a guild integration is deleted.
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler GuildIntegrationDeleted
- {
- add => this._guildIntegrationDeleted.Register(value);
- remove => this._guildIntegrationDeleted.Unregister(value);
- }
- private AsyncEvent _guildIntegrationDeleted;
-
- #endregion
-
- #region Guild Member
-
- ///
- /// Fired when a new user joins a guild.
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler GuildMemberAdded
- {
- add => this._guildMemberAdded.Register(value);
- remove => this._guildMemberAdded.Unregister(value);
- }
- private AsyncEvent _guildMemberAdded;
-
- ///
- /// Fired when a user is removed from a guild (leave/kick/ban).
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler GuildMemberRemoved
- {
- add => this._guildMemberRemoved.Register(value);
- remove => this._guildMemberRemoved.Unregister(value);
- }
- private AsyncEvent _guildMemberRemoved;
-
- ///
- /// Fired when a guild member is updated.
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler GuildMemberUpdated
- {
- add => this._guildMemberUpdated.Register(value);
- remove => this._guildMemberUpdated.Unregister(value);
- }
- private AsyncEvent _guildMemberUpdated;
-
- ///
- /// Fired in response to Gateway Request Guild Members.
- ///
- public event AsyncEventHandler GuildMembersChunked
- {
- add => this._guildMembersChunk.Register(value);
- remove => this._guildMembersChunk.Unregister(value);
- }
- private AsyncEvent _guildMembersChunk;
-
- #endregion
-
- #region Guild Role
-
- ///
- /// Fired when a guild role is created.
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler GuildRoleCreated
- {
- add => this._guildRoleCreated.Register(value);
- remove => this._guildRoleCreated.Unregister(value);
- }
- private AsyncEvent _guildRoleCreated;
-
- ///
- /// Fired when a guild role is updated.
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler GuildRoleUpdated
- {
- add => this._guildRoleUpdated.Register(value);
- remove => this._guildRoleUpdated.Unregister(value);
- }
- private AsyncEvent _guildRoleUpdated;
-
- ///
- /// Fired when a guild role is updated.
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler GuildRoleDeleted
- {
- add => this._guildRoleDeleted.Register(value);
- remove => this._guildRoleDeleted.Unregister(value);
- }
- private AsyncEvent _guildRoleDeleted;
-
- #endregion
-
- #region Invite
-
- ///
- /// Fired when an invite is created.
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler InviteCreated
- {
- add => this._inviteCreated.Register(value);
- remove => this._inviteCreated.Unregister(value);
- }
- private AsyncEvent _inviteCreated;
-
- ///
- /// Fired when an invite is deleted.
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler InviteDeleted
- {
- add => this._inviteDeleted.Register(value);
- remove => this._inviteDeleted.Unregister(value);
- }
- private AsyncEvent _inviteDeleted;
-
- #endregion
-
- #region Message
-
- ///
- /// Fired when a message is created.
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler MessageCreated
- {
- add => this._messageCreated.Register(value);
- remove => this._messageCreated.Unregister(value);
- }
- private AsyncEvent _messageCreated;
-
- ///
- /// Fired when a message is updated.
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler MessageUpdated
- {
- add => this._messageUpdated.Register(value);
- remove => this._messageUpdated.Unregister(value);
- }
- private AsyncEvent _messageUpdated;
-
- ///
- /// Fired when a message is deleted.
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler MessageDeleted
- {
- add => this._messageDeleted.Register(value);
- remove => this._messageDeleted.Unregister(value);
- }
- private AsyncEvent _messageDeleted;
-
- ///
- /// Fired when multiple messages are deleted at once.
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler MessagesBulkDeleted
- {
- add => this._messageBulkDeleted.Register(value);
- remove => this._messageBulkDeleted.Unregister(value);
- }
- private AsyncEvent _messageBulkDeleted;
-
- #endregion
-
- #region Message Reaction
-
- ///
- /// Fired when a reaction gets added to a message.
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler MessageReactionAdded
- {
- add => this._messageReactionAdded.Register(value);
- remove => this._messageReactionAdded.Unregister(value);
- }
- private AsyncEvent _messageReactionAdded;
-
- ///
- /// Fired when a reaction gets removed from a message.
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler MessageReactionRemoved
- {
- add => this._messageReactionRemoved.Register(value);
- remove => this._messageReactionRemoved.Unregister(value);
- }
- private AsyncEvent _messageReactionRemoved;
-
- ///
- /// Fired when all reactions get removed from a message.
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler MessageReactionsCleared
- {
- add => this._messageReactionsCleared.Register(value);
- remove => this._messageReactionsCleared.Unregister(value);
- }
- private AsyncEvent _messageReactionsCleared;
-
- ///
- /// Fired when all reactions of a specific reaction are removed from a message.
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler MessageReactionRemovedEmoji
- {
- add => this._messageReactionRemovedEmoji.Register(value);
- remove => this._messageReactionRemovedEmoji.Unregister(value);
- }
- private AsyncEvent _messageReactionRemovedEmoji;
-
- #endregion
-
- #region Stage Instance
-
- ///
- /// Fired when a Stage Instance is created.
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler StageInstanceCreated
- {
- add => this._stageInstanceCreated.Register(value);
- remove => this._stageInstanceCreated.Unregister(value);
- }
- private AsyncEvent _stageInstanceCreated;
-
- ///
- /// Fired when a Stage Instance is updated.
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler StageInstanceUpdated
- {
- add => this._stageInstanceUpdated.Register(value);
- remove => this._stageInstanceUpdated.Unregister(value);
- }
- private AsyncEvent _stageInstanceUpdated;
-
- ///
- /// Fired when a Stage Instance is deleted.
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler StageInstanceDeleted
- {
- add => this._stageInstanceDeleted.Register(value);
- remove => this._stageInstanceDeleted.Unregister(value);
- }
- private AsyncEvent _stageInstanceDeleted;
-
- #endregion
-
- #region Thread
-
- ///
- /// Fired when a thread is created.
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler ThreadCreated
- {
- add => this._threadCreated.Register(value);
- remove => this._threadCreated.Unregister(value);
- }
- private AsyncEvent _threadCreated;
-
- ///
- /// Fired when a thread is updated.
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler ThreadUpdated
- {
- add => this._threadUpdated.Register(value);
- remove => this._threadUpdated.Unregister(value);
- }
- private AsyncEvent _threadUpdated;
-
- ///
- /// Fired when a thread is deleted.
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler ThreadDeleted
- {
- add => this._threadDeleted.Register(value);
- remove => this._threadDeleted.Unregister(value);
- }
- private AsyncEvent _threadDeleted;
-
- ///
- /// Fired when a thread member is updated.
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler ThreadListSynced
- {
- add => this._threadListSynced.Register(value);
- remove => this._threadListSynced.Unregister(value);
- }
- private AsyncEvent _threadListSynced;
-
- ///
- /// Fired when a thread member is updated.
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler ThreadMemberUpdated
- {
- add => this._threadMemberUpdated.Register(value);
- remove => this._threadMemberUpdated.Unregister(value);
- }
- private AsyncEvent _threadMemberUpdated;
-
- ///
- /// Fired when the thread members are updated.
- /// For this Event you need the or intent specified in
- ///
- public event AsyncEventHandler ThreadMembersUpdated
- {
- add => this._threadMembersUpdated.Register(value);
- remove => this._threadMembersUpdated.Unregister(value);
- }
- private AsyncEvent _threadMembersUpdated;
-
- #endregion
-
- #region Activities
-
- ///
- /// Fired when a embedded activity has been updated.
- ///
- public event AsyncEventHandler EmbeddedActivityUpdated
- {
- add => this._embeddedActivityUpdated.Register(value);
- remove => this._embeddedActivityUpdated.Unregister(value);
- }
- private AsyncEvent _embeddedActivityUpdated;
-
- #endregion
-
- #region User/Presence Update
-
- ///
- /// Fired when a presence has been updated.
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler PresenceUpdated
- {
- add => this._presenceUpdated.Register(value);
- remove => this._presenceUpdated.Unregister(value);
- }
- private AsyncEvent _presenceUpdated;
-
-
- ///
- /// Fired when the current user updates their settings.
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler UserSettingsUpdated
- {
- add => this._userSettingsUpdated.Register(value);
- remove => this._userSettingsUpdated.Unregister(value);
- }
- private AsyncEvent _userSettingsUpdated;
-
- ///
- /// Fired when properties about the current user change.
- /// For this Event you need the intent specified in
- ///
- ///
- /// NB: This event only applies for changes to the current user, the client that is connected to Discord.
- ///
- public event AsyncEventHandler UserUpdated
- {
- add => this._userUpdated.Register(value);
- remove => this._userUpdated.Unregister(value);
- }
- private AsyncEvent _userUpdated;
-
- #endregion
-
- #region Voice
-
- ///
- /// Fired when someone joins/leaves/moves voice channels.
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler VoiceStateUpdated
- {
- add => this._voiceStateUpdated.Register(value);
- remove => this._voiceStateUpdated.Unregister(value);
- }
- private AsyncEvent _voiceStateUpdated;
-
- ///
- /// Fired when a guild's voice server is updated.
- /// For this Event you need the intent specified in
- ///
- public event AsyncEventHandler VoiceServerUpdated
- {
- add => this._voiceServerUpdated.Register(value);
- remove => this._voiceServerUpdated.Unregister(value);
- }
- private AsyncEvent _voiceServerUpdated;
-
- #endregion
-
- #region Application
-
- ///
- /// Fired when a new application command is registered.
- ///
- public event AsyncEventHandler ApplicationCommandCreated
- {
- add => this._applicationCommandCreated.Register(value);
- remove => this._applicationCommandCreated.Unregister(value);
- }
- private AsyncEvent _applicationCommandCreated;
-
- ///
- /// Fired when an application command is updated.
- ///
- public event AsyncEventHandler ApplicationCommandUpdated
- {
- add => this._applicationCommandUpdated.Register(value);
- remove => this._applicationCommandUpdated.Unregister(value);
- }
- private AsyncEvent _applicationCommandUpdated;
-
- ///
- /// Fired when an application command is deleted.
- ///
- public event AsyncEventHandler ApplicationCommandDeleted
- {
- add => this._applicationCommandDeleted.Register(value);
- remove => this._applicationCommandDeleted.Unregister(value);
- }
- private AsyncEvent _applicationCommandDeleted;
-
- ///
- /// Fired when a new application command is registered.
- ///
- public event AsyncEventHandler GuildApplicationCommandCountUpdated
- {
- add => this._guildApplicationCommandCountUpdated.Register(value);
- remove => this._guildApplicationCommandCountUpdated.Unregister(value);
- }
- private AsyncEvent _guildApplicationCommandCountUpdated;
-
- ///
- /// Fired when a user uses a context menu.
- ///
- public event AsyncEventHandler ContextMenuInteractionCreated
- {
- add => this._contextMenuInteractionCreated.Register(value);
- remove => this._contextMenuInteractionCreated.Unregister(value);
- }
-
- private AsyncEvent _contextMenuInteractionCreated;
-
- ///
- /// Fired when application command permissions gets updated.
- ///
- public event AsyncEventHandler ApplicationCommandPermissionsUpdated
- {
- add => this._applicationCommandPermissionsUpdated.Register(value);
- remove => this._applicationCommandPermissionsUpdated.Unregister(value);
- }
-
- private AsyncEvent _applicationCommandPermissionsUpdated;
-
-
- #endregion
-
- #region Misc
-
- ///
- /// Fired when an interaction is invoked.
- ///
- public event AsyncEventHandler InteractionCreated
- {
- add => this._interactionCreated.Register(value);
- remove => this._interactionCreated.Unregister(value);
- }
- private AsyncEvent _interactionCreated;
-
- ///
- /// Fired when a component is invoked.
- ///
- public event AsyncEventHandler ComponentInteractionCreated
- {
- add => this._componentInteractionCreated.Register(value);
- remove => this._componentInteractionCreated.Unregister(value);
- }
- private AsyncEvent _componentInteractionCreated;
-
- ///
- /// Fired when a user starts typing in a channel.
- ///
- public event AsyncEventHandler TypingStarted
- {
- add => this._typingStarted.Register(value);
- remove => this._typingStarted.Unregister(value);
- }
- private AsyncEvent _typingStarted;
-
- ///
- /// Fired when an unknown event gets received.
- ///
- public event AsyncEventHandler UnknownEvent
- {
- add => this._unknownEvent.Register(value);
- remove => this._unknownEvent.Unregister(value);
- }
- private AsyncEvent _unknownEvent;
-
- ///
- /// Fired whenever webhooks update.
- ///
- public event AsyncEventHandler WebhooksUpdated
- {
- add => this._webhooksUpdated.Register(value);
- remove => this._webhooksUpdated.Unregister(value);
- }
- private AsyncEvent _webhooksUpdated;
-
- ///
- /// Fired whenever an error occurs within an event handler.
- ///
- public event AsyncEventHandler ClientErrored
- {
- add => this._clientErrored.Register(value);
- remove => this._clientErrored.Unregister(value);
- }
- private AsyncEvent _clientErrored;
-
- #endregion
-
- #region Error Handling
-
- ///