[Refactor] Refactor some stuff (#2688)

* fix some `internal` classes being exposed

* update xmldoc comments to use `<see langword>`

* bump library version in samples

* fix possible oversight
This commit is contained in:
Misha133
2023-06-27 17:11:16 +03:00
committed by GitHub
parent fe4130df45
commit 9ddd922d2f
119 changed files with 326 additions and 324 deletions

View File

@@ -102,7 +102,7 @@ namespace Discord.WebSocket
/// <remarks>
/// This method gets the user present in the WebSocket cache with the given condition.
/// <note type="warning">
/// Sometimes a user may return <c>null</c> due to Discord not sending offline users in large guilds
/// Sometimes a user may return <see langword="null" /> due to Discord not sending offline users in large guilds
/// (i.e. guild with 100+ members) actively. To download users on startup and to see more information
/// about this subject, see <see cref="Discord.WebSocket.DiscordSocketConfig.AlwaysDownloadUsers" />.
/// </note>
@@ -114,7 +114,7 @@ namespace Discord.WebSocket
/// </note>
/// </remarks>
/// <returns>
/// A generic WebSocket-based user; <c>null</c> when the user cannot be found.
/// A generic WebSocket-based user; <see langword="null" /> when the user cannot be found.
/// </returns>
public abstract SocketUser GetUser(ulong id);
@@ -124,7 +124,7 @@ namespace Discord.WebSocket
/// <remarks>
/// This method gets the user present in the WebSocket cache with the given condition.
/// <note type="warning">
/// Sometimes a user may return <c>null</c> due to Discord not sending offline users in large guilds
/// Sometimes a user may return <see langword="null" /> due to Discord not sending offline users in large guilds
/// (i.e. guild with 100+ members) actively. To download users on startup and to see more information
/// about this subject, see <see cref="Discord.WebSocket.DiscordSocketConfig.AlwaysDownloadUsers" />.
/// </note>
@@ -138,7 +138,7 @@ namespace Discord.WebSocket
/// <param name="username">The name of the user.</param>
/// <param name="discriminator">The discriminator value of the user.</param>
/// <returns>
/// A generic WebSocket-based user; <c>null</c> when the user cannot be found.
/// A generic WebSocket-based user; <see langword="null" /> when the user cannot be found.
/// </returns>
public abstract SocketUser GetUser(string username, string discriminator);
/// <summary>
@@ -147,7 +147,7 @@ namespace Discord.WebSocket
/// <param name="id">The snowflake identifier of the channel (e.g. `381889909113225237`).</param>
/// <returns>
/// A generic WebSocket-based channel object (voice, text, category, etc.) associated with the identifier;
/// <c>null</c> when the channel cannot be found.
/// <see langword="null" /> when the channel cannot be found.
/// </returns>
public abstract SocketChannel GetChannel(ulong id);
/// <summary>
@@ -155,7 +155,7 @@ namespace Discord.WebSocket
/// </summary>
/// <param name="id">The guild snowflake identifier.</param>
/// <returns>
/// A WebSocket-based guild associated with the snowflake identifier; <c>null</c> when the guild cannot be
/// A WebSocket-based guild associated with the snowflake identifier; <see langword="null" /> when the guild cannot be
/// found.
/// </returns>
public abstract SocketGuild GetGuild(ulong id);
@@ -173,7 +173,7 @@ namespace Discord.WebSocket
/// <param name="id">The identifier of the voice region (e.g. <c>eu-central</c> ).</param>
/// <param name="options">The options to be used when sending the request.</param>
/// <returns>
/// A task that contains a REST-based voice region associated with the identifier; <c>null</c> if the
/// A task that contains a REST-based voice region associated with the identifier; <see langword="null" /> if the
/// voice region is not found.
/// </returns>
public abstract ValueTask<RestVoiceRegion> GetVoiceRegionAsync(string id, RequestOptions options = null);

View File

@@ -390,7 +390,7 @@ namespace Discord.WebSocket
/// <param name="options">The options to be used when sending the request.</param>
/// <returns>
/// A task that represents the asynchronous get operation. The task result contains the channel associated
/// with the snowflake identifier; <c>null</c> when the channel cannot be found.
/// with the snowflake identifier; <see langword="null" /> when the channel cannot be found.
/// </returns>
public async ValueTask<IChannel> GetChannelAsync(ulong id, RequestOptions options = null)
=> GetChannel(id) ?? (IChannel)await ClientHelper.GetChannelAsync(this, id, options).ConfigureAwait(false);
@@ -408,7 +408,7 @@ namespace Discord.WebSocket
/// <param name="options">The options to be used when sending the request.</param>
/// <returns>
/// A task that represents the asynchronous get operation. The task result contains the user associated with
/// the snowflake identifier; <c>null</c> if the user is not found.
/// the snowflake identifier; <see langword="null" /> if the user is not found.
/// </returns>
public async ValueTask<IUser> GetUserAsync(ulong id, RequestOptions options = null)
=> await ((IDiscordClient)this).GetUserAsync(id, CacheMode.AllowDownload, options).ConfigureAwait(false);

View File

@@ -31,7 +31,7 @@ namespace Discord.WebSocket
public const string GatewayEncoding = "json";
/// <summary>
/// Gets or sets the WebSocket host to connect to. If <c>null</c>, the client will use the
/// Gets or sets the WebSocket host to connect to. If <see langword="null" />, the client will use the
/// /gateway endpoint.
/// </summary>
public string GatewayHost { get; set; } = null;
@@ -136,7 +136,7 @@ namespace Discord.WebSocket
/// <summary>
/// Gets or sets the timeout for event handlers, in milliseconds, after which a warning will be logged.
/// Setting this property to <c>null</c>disables this check.
/// Setting this property to <see langword="null" />disables this check.
/// </summary>
public int? HandlerTimeout { get; set; } = 3000;

View File

@@ -90,7 +90,7 @@ public class SocketChannelCreateAuditLogData : ISocketAuditLogData
/// <returns>
/// An <see cref="int"/> representing the time in seconds required before the user can send another
/// message; <c>0</c> if disabled.
/// <c>null</c> if this is not mentioned in this entry.
/// <see langword="null" /> if this is not mentioned in this entry.
/// </returns>
public int? SlowModeInterval { get; }
@@ -98,8 +98,8 @@ public class SocketChannelCreateAuditLogData : ISocketAuditLogData
/// Gets the value that indicates whether the created channel is NSFW.
/// </summary>
/// <returns>
/// <c>true</c> if the created channel has the NSFW flag enabled; otherwise <c>false</c>.
/// <c>null</c> if this is not mentioned in this entry.
/// <see langword="true" /> if the created channel has the NSFW flag enabled; otherwise <see langword="false" />.
/// <see langword="null" /> if this is not mentioned in this entry.
/// </returns>
public bool? IsNsfw { get; }
@@ -109,7 +109,7 @@ public class SocketChannelCreateAuditLogData : ISocketAuditLogData
/// <returns>
/// An <see cref="int"/> representing the bit-rate (bps) that the created voice channel defines and requests the
/// client(s) to use.
/// <c>null</c> if this is not mentioned in this entry.
/// <see langword="null" /> if this is not mentioned in this entry.
/// </returns>
public int? Bitrate { get; }

View File

@@ -96,7 +96,7 @@ public class SocketChannelDeleteAuditLogData : ISocketAuditLogData
/// <returns>
/// An <see cref="int"/> representing the time in seconds required before the user can send another
/// message; <c>0</c> if disabled.
/// <c>null</c> if this is not mentioned in this entry.
/// <see langword="null" /> if this is not mentioned in this entry.
/// </returns>
public int? SlowModeInterval { get; }
@@ -104,8 +104,8 @@ public class SocketChannelDeleteAuditLogData : ISocketAuditLogData
/// Gets the value that indicates whether the deleted channel was NSFW.
/// </summary>
/// <returns>
/// <c>true</c> if this channel had the NSFW flag enabled; otherwise <c>false</c>.
/// <c>null</c> if this is not mentioned in this entry.
/// <see langword="true" /> if this channel had the NSFW flag enabled; otherwise <see langword="false" />.
/// <see langword="null" /> if this is not mentioned in this entry.
/// </returns>
public bool? IsNsfw { get; }
@@ -114,7 +114,7 @@ public class SocketChannelDeleteAuditLogData : ISocketAuditLogData
/// </summary>
/// <returns>
/// An <see cref="int"/> representing the bit-rate set of the voice channel.
/// <c>null</c> if this is not mentioned in this entry.
/// <see langword="null" /> if this is not mentioned in this entry.
/// </returns>
public int? Bitrate { get; }

View File

@@ -81,7 +81,7 @@ public struct SocketChannelInfo
/// Gets the type of this channel.
/// </summary>
/// <returns>
/// The channel type of this channel; <c>null</c> if not applicable.
/// The channel type of this channel; <see langword="null" /> if not applicable.
/// </returns>
public ChannelType? ChannelType { get; }

View File

@@ -67,8 +67,8 @@ public class SocketInviteCreateAuditLogData : ISocketAuditLogData
/// Gets a value that determines whether the invite is a temporary one.
/// </summary>
/// <returns>
/// <c>true</c> if users accepting this invite will be removed from the guild when they log off; otherwise
/// <c>false</c>.
/// <see langword="true" /> if users accepting this invite will be removed from the guild when they log off; otherwise
/// <see langword="false" />.
/// </returns>
public bool Temporary { get; }
@@ -104,7 +104,7 @@ public class SocketInviteCreateAuditLogData : ISocketAuditLogData
/// </summary>
/// <returns>
/// An <see cref="int"/> representing the number of uses this invite may be accepted until it is removed
/// from the guild; <c>null</c> if none is set.
/// from the guild; <see langword="null" /> if none is set.
/// </returns>
public int MaxUses { get; }
}

View File

@@ -66,8 +66,8 @@ public class SocketInviteDeleteAuditLogData : ISocketAuditLogData
/// Gets a value that indicates whether the invite is a temporary one.
/// </summary>
/// <returns>
/// <c>true</c> if users accepting this invite will be removed from the guild when they log off; otherwise
/// <c>false</c>.
/// <see langword="true" /> if users accepting this invite will be removed from the guild when they log off; otherwise
/// <see langword="false" />.
/// </returns>
public bool Temporary { get; }
@@ -103,7 +103,7 @@ public class SocketInviteDeleteAuditLogData : ISocketAuditLogData
/// </summary>
/// <returns>
/// An <see cref="int"/> representing the number of uses this invite may be accepted until it is removed
/// from the guild; <c>null</c> if none is set.
/// from the guild; <see langword="null" /> if none is set.
/// </returns>
public int MaxUses { get; }
}

View File

@@ -21,7 +21,7 @@ public struct SocketInviteInfo
/// Gets the time (in seconds) until the invite expires.
/// </summary>
/// <returns>
/// An <see cref="int"/> representing the time in seconds until this invite expires; <c>null</c> if this
/// An <see cref="int"/> representing the time in seconds until this invite expires; <see langword="null" /> if this
/// invite never expires or not specified.
/// </returns>
public int? MaxAge { get; }
@@ -38,8 +38,8 @@ public struct SocketInviteInfo
/// Gets a value that indicates whether the invite is a temporary one.
/// </summary>
/// <returns>
/// <c>true</c> if users accepting this invite will be removed from the guild when they log off,
/// <c>false</c> if not; <c>null</c> if not specified.
/// <see langword="true" /> if users accepting this invite will be removed from the guild when they log off,
/// <see langword="false" /> if not; <see langword="null" /> if not specified.
/// </returns>
public bool? Temporary { get; }
@@ -48,7 +48,7 @@ public struct SocketInviteInfo
/// </summary>
/// <returns>
/// A <see cref="ulong"/> representing the channel snowflake identifier that the invite points to;
/// <c>null</c> if not specified.
/// <see langword="null" /> if not specified.
/// </returns>
public ulong? ChannelId { get; }
@@ -57,7 +57,7 @@ public struct SocketInviteInfo
/// </summary>
/// <returns>
/// An <see cref="int"/> representing the number of uses this invite may be accepted until it is removed
/// from the guild; <c>null</c> if none is specified.
/// from the guild; <see langword="null" /> if none is specified.
/// </returns>
public int? MaxUses { get; }

View File

@@ -30,7 +30,7 @@ public struct SocketMemberRoleEditInfo
/// Gets a value that indicates whether the role was added to the user.
/// </summary>
/// <returns>
/// <c>true</c> if the role was added to the user; otherwise <c>false</c>.
/// <see langword="true" /> if the role was added to the user; otherwise <see langword="false" />.
/// </returns>
public bool Added { get; }
}

View File

@@ -30,7 +30,7 @@ public struct SocketRoleEditInfo
/// Gets the color of this role.
/// </summary>
/// <returns>
/// A color object representing the color assigned to this role; <c>null</c> if this role does not have a
/// A color object representing the color assigned to this role; <see langword="null" /> if this role does not have a
/// color.
/// </returns>
public Color? Color { get; }
@@ -39,8 +39,8 @@ public struct SocketRoleEditInfo
/// Gets a value that indicates whether this role is mentionable.
/// </summary>
/// <returns>
/// <c>true</c> if other members can mention this role in a text channel; otherwise <c>false</c>;
/// <c>null</c> if this is not mentioned in this entry.
/// <see langword="true" /> if other members can mention this role in a text channel; otherwise <see langword="false" />;
/// <see langword="null" /> if this is not mentioned in this entry.
/// </returns>
public bool? Mentionable { get; }
@@ -49,8 +49,8 @@ public struct SocketRoleEditInfo
/// section on the user list).
/// </summary>
/// <returns>
/// <c>true</c> if this role's members will appear in a separate section in the user list; otherwise
/// <c>false</c>; <c>null</c> if this is not mentioned in this entry.
/// <see langword="true" /> if this role's members will appear in a separate section in the user list; otherwise
/// <see langword="false" />; <see langword="null" /> if this is not mentioned in this entry.
/// </returns>
public bool? Hoist { get; }
@@ -66,7 +66,7 @@ public struct SocketRoleEditInfo
/// Gets the permissions assigned to this role.
/// </summary>
/// <returns>
/// A guild permissions object representing the permissions that have been assigned to this role; <c>null</c>
/// A guild permissions object representing the permissions that have been assigned to this role; <see langword="null" />
/// if no permissions have been assigned.
/// </returns>
public GuildPermissions? Permissions { get; }

View File

@@ -61,7 +61,7 @@ public class SocketThreadCreateAuditLogData : ISocketAuditLogData
/// Gets the value that indicates whether the thread is archived.
/// </summary>
/// <returns>
/// <c>true</c> if this thread has the Archived flag enabled; otherwise <c>false</c>.
/// <see langword="true" /> if this thread has the Archived flag enabled; otherwise <see langword="false" />.
/// </returns>
public bool IsArchived { get; }
@@ -77,7 +77,7 @@ public class SocketThreadCreateAuditLogData : ISocketAuditLogData
/// Gets the value that indicates whether the thread is locked.
/// </summary>
/// <returns>
/// <c>true</c> if this thread has the Locked flag enabled; otherwise <c>false</c>.
/// <see langword="true" /> if this thread has the Locked flag enabled; otherwise <see langword="false" />.
/// </returns>
public bool IsLocked { get; }
@@ -87,7 +87,7 @@ public class SocketThreadCreateAuditLogData : ISocketAuditLogData
/// <returns>
/// An <see cref="int"/> representing the time in seconds required before the user can send another
/// message; <c>0</c> if disabled.
/// <c>null</c> if this is not mentioned in this entry.
/// <see langword="null" /> if this is not mentioned in this entry.
/// </returns>
public int? SlowModeInterval { get; }

View File

@@ -63,7 +63,7 @@ public class SocketThreadDeleteAuditLogData : ISocketAuditLogData
/// Gets the value that indicates whether the deleted thread was archived.
/// </summary>
/// <returns>
/// <c>true</c> if this thread had the Archived flag enabled; otherwise <c>false</c>.
/// <see langword="true" /> if this thread had the Archived flag enabled; otherwise <see langword="false" />.
/// </returns>
public bool IsArchived { get; }
@@ -79,7 +79,7 @@ public class SocketThreadDeleteAuditLogData : ISocketAuditLogData
/// Gets the value that indicates whether the deleted thread was locked.
/// </summary>
/// <returns>
/// <c>true</c> if this thread had the Locked flag enabled; otherwise <c>false</c>.
/// <see langword="true" /> if this thread had the Locked flag enabled; otherwise <see langword="false" />.
/// </returns>
public bool IsLocked { get; }
@@ -89,7 +89,7 @@ public class SocketThreadDeleteAuditLogData : ISocketAuditLogData
/// <returns>
/// An <see cref="int"/> representing the time in seconds required before the user can send another
/// message; <c>0</c> if disabled.
/// <c>null</c> if this is not mentioned in this entry.
/// <see langword="null" /> if this is not mentioned in this entry.
/// </returns>
public int? SlowModeInterval { get; }

View File

@@ -54,7 +54,7 @@ namespace Discord.WebSocket
/// <remarks>
/// <note type="warning">
/// This method requires the use of cache, which is not enabled by default; if caching is not enabled,
/// this method will always return <c>null</c>. Please refer to
/// this method will always return <see langword="null" />. Please refer to
/// <see cref="Discord.WebSocket.DiscordSocketConfig.MessageCacheSize" /> for more details.
/// </note>
/// <para>
@@ -64,7 +64,7 @@ namespace Discord.WebSocket
/// </remarks>
/// <param name="id">The snowflake identifier of the message.</param>
/// <returns>
/// A WebSocket-based message object; <c>null</c> if it does not exist in the cache or if caching is not
/// A WebSocket-based message object; <see langword="null" /> if it does not exist in the cache or if caching is not
/// enabled.
/// </returns>
SocketMessage GetCachedMessage(ulong id);

View File

@@ -71,7 +71,7 @@ namespace Discord.WebSocket
/// <param name="id">TThe ID of the message.</param>
/// <param name="options">The options to be used when sending the request.</param>
/// <returns>
/// The message gotten from either the cache or the download, or <c>null</c> if none is found.
/// The message gotten from either the cache or the download, or <see langword="null" /> if none is found.
/// </returns>
public async Task<IMessage> GetMessageAsync(ulong id, RequestOptions options = null)
{
@@ -215,7 +215,7 @@ namespace Discord.WebSocket
/// </summary>
/// <param name="id">The snowflake identifier of the user.</param>
/// <returns>
/// A <see cref="SocketUser"/> object that is a recipient of this channel; otherwise <c>null</c>.
/// A <see cref="SocketUser"/> object that is a recipient of this channel; otherwise <see langword="null" />.
/// </returns>
public new SocketUser GetUser(ulong id)
{

View File

@@ -52,7 +52,7 @@ namespace Discord.WebSocket
/// Gets the parent (category) of this channel in the guild's channel list.
/// </summary>
/// <returns>
/// An <see cref="ICategoryChannel"/> representing the parent of this channel; <c>null</c> if none is set.
/// An <see cref="ICategoryChannel"/> representing the parent of this channel; <see langword="null" /> if none is set.
/// </returns>
public ICategoryChannel Category
=> CategoryId.HasValue ? Guild.GetChannel(CategoryId.Value) as ICategoryChannel : null;

View File

@@ -107,7 +107,7 @@ namespace Discord.WebSocket
/// <param name="options">The options to be used when sending the request.</param>
/// <returns>
/// A task that represents an asynchronous get operation for retrieving the message. The task result contains
/// the retrieved message; <c>null</c> if no message is found with the specified identifier.
/// the retrieved message; <see langword="null" /> if no message is found with the specified identifier.
/// </returns>
public async Task<IMessage> GetMessageAsync(ulong id, RequestOptions options = null)
{

View File

@@ -93,7 +93,7 @@ namespace Discord.WebSocket
/// </summary>
/// <param name="user">The user to get the overwrite from.</param>
/// <returns>
/// An overwrite object for the targeted user; <c>null</c> if none is set.
/// An overwrite object for the targeted user; <see langword="null" /> if none is set.
/// </returns>
public virtual OverwritePermissions? GetPermissionOverwrite(IUser user)
{
@@ -109,7 +109,7 @@ namespace Discord.WebSocket
/// </summary>
/// <param name="role">The role to get the overwrite from.</param>
/// <returns>
/// An overwrite object for the targeted role; <c>null</c> if none is set.
/// An overwrite object for the targeted role; <see langword="null" /> if none is set.
/// </returns>
public virtual OverwritePermissions? GetPermissionOverwrite(IRole role)
{

View File

@@ -31,7 +31,7 @@ namespace Discord.WebSocket
/// Gets the parent (category) of this channel in the guild's channel list.
/// </summary>
/// <returns>
/// An <see cref="ICategoryChannel"/> representing the parent of this channel; <c>null</c> if none is set.
/// An <see cref="ICategoryChannel"/> representing the parent of this channel; <see langword="null" /> if none is set.
/// </returns>
public ICategoryChannel Category
=> CategoryId.HasValue ? Guild.GetChannel(CategoryId.Value) as ICategoryChannel : null;
@@ -151,7 +151,7 @@ namespace Discord.WebSocket
/// <param name="options">The options to be used when sending the request.</param>
/// <returns>
/// A task that represents an asynchronous get operation for retrieving the message. The task result contains
/// the retrieved message; <c>null</c> if no message is found with the specified identifier.
/// the retrieved message; <see langword="null" /> if no message is found with the specified identifier.
/// </returns>
public virtual async Task<IMessage> GetMessageAsync(ulong id, RequestOptions options = null)
{
@@ -332,7 +332,7 @@ namespace Discord.WebSocket
/// <param name="options">The options to be used when sending the request.</param>
/// <returns>
/// A task that represents the asynchronous get operation. The task result contains a webhook associated
/// with the identifier; <c>null</c> if the webhook is not found.
/// with the identifier; <see langword="null" /> if the webhook is not found.
/// </returns>
public virtual Task<RestWebhook> GetWebhookAsync(ulong id, RequestOptions options = null)
=> ChannelHelper.GetWebhookAsync(this, Discord, id, options);

View File

@@ -50,7 +50,7 @@ namespace Discord.WebSocket
/// Returns a value that determines if the role is an @everyone role.
/// </summary>
/// <returns>
/// <c>true</c> if the role is @everyone; otherwise <c>false</c>.
/// <see langword="true" /> if the role is @everyone; otherwise <see langword="false" />.
/// </returns>
public bool IsEveryone => Id == Guild.Id;
/// <inheritdoc />

View File

@@ -82,7 +82,7 @@ namespace Discord.WebSocket
public IReadOnlyCollection<SocketRole> Roles
=> _roleIds.Select(id => Guild.GetRole(id)).Where(x => x != null).ToReadOnlyCollection(() => _roleIds.Length);
/// <summary>
/// Returns the voice channel the user is in, or <c>null</c> if none.
/// Returns the voice channel the user is in, or <see langword="null" /> if none.
/// </summary>
public SocketVoiceChannel VoiceChannel => VoiceState?.VoiceChannel;
/// <inheritdoc />
@@ -91,7 +91,7 @@ namespace Discord.WebSocket
/// Gets the voice connection status of the user if any.
/// </summary>
/// <returns>
/// A <see cref="SocketVoiceState" /> representing the user's voice status; <c>null</c> if the user is not
/// A <see cref="SocketVoiceState" /> representing the user's voice status; <see langword="null" /> if the user is not
/// connected to a voice channel.
/// </returns>
public SocketVoiceState? VoiceState => Guild.GetVoiceState(Id);

View File

@@ -11,7 +11,7 @@ namespace Discord.WebSocket
public struct SocketVoiceState : IVoiceState
{
/// <summary>
/// Initializes a default <see cref="SocketVoiceState"/> with everything set to <c>null</c> or <c>false</c>.
/// Initializes a default <see cref="SocketVoiceState"/> with everything set to <see langword="null" /> or <see langword="false" />.
/// </summary>
public static readonly SocketVoiceState Default = new SocketVoiceState(null, null, null, false, false, false, false, false, false, false);
@@ -31,7 +31,7 @@ namespace Discord.WebSocket
private readonly Flags _voiceStates;
/// <summary>
/// Gets the voice channel that the user is currently in; or <c>null</c> if none.
/// Gets the voice channel that the user is currently in; or <see langword="null" /> if none.
/// </summary>
public SocketVoiceChannel VoiceChannel { get; }
/// <inheritdoc />