Format the project with 'dotnet format' (#2551)

* Sync and Re-Format

* Fix Title string.

* Fix indentation.
This commit is contained in:
NaN
2023-02-13 14:45:59 -03:00
committed by GitHub
parent 71e9ecb21e
commit 257f246d1d
401 changed files with 3178 additions and 2671 deletions

View File

@@ -19,20 +19,20 @@ namespace Discord.WebSocket
IReadOnlyCollection<SocketMessage> CachedMessages { get; }
/// <inheritdoc cref="IMessageChannel.SendMessageAsync(string, bool, Embed, RequestOptions, AllowedMentions, MessageReference, MessageComponent, ISticker[], Embed[], MessageFlags)"/>
new Task<RestUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null,
new Task<RestUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null,
RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null,
MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None);
/// <inheritdoc cref="IMessageChannel.SendFileAsync(string, string, bool, Embed, RequestOptions, bool, AllowedMentions, MessageReference, MessageComponent, ISticker[], Embed[], MessageFlags)"/>
new Task<RestUserMessage> SendFileAsync(string filePath, string text = null, bool isTTS = false, Embed embed = null,
RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null,
MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null,
new Task<RestUserMessage> SendFileAsync(string filePath, string text = null, bool isTTS = false, Embed embed = null,
RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null,
MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null,
Embed[] embeds = null, MessageFlags flags = MessageFlags.None);
/// <inheritdoc cref="IMessageChannel.SendFileAsync(Stream, string, string, bool, Embed, RequestOptions, bool, AllowedMentions, MessageReference, MessageComponent, ISticker[], Embed[], MessageFlags)"/>
new Task<RestUserMessage> SendFileAsync(Stream stream, string filename, string text = null, bool isTTS = false,
Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null,
MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null,
new Task<RestUserMessage> SendFileAsync(Stream stream, string filename, string text = null, bool isTTS = false,
Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null,
MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null,
Embed[] embeds = null, MessageFlags flags = MessageFlags.None);
/// <inheritdoc cref="IMessageChannel.SendFileAsync(FileAttachment, string, bool, Embed, RequestOptions, AllowedMentions, MessageReference, MessageComponent, ISticker[], Embed[], MessageFlags)"/>

View File

@@ -1,10 +1,10 @@
using Discord.Rest;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Discord.Rest;
using Model = Discord.API.Channel;
namespace Discord.WebSocket

View File

@@ -68,11 +68,20 @@ namespace Discord.WebSocket
{
switch (channel)
{
case SocketDMChannel dmChannel: dmChannel.AddMessage(msg); break;
case SocketGroupChannel groupChannel: groupChannel.AddMessage(msg); break;
case SocketThreadChannel threadChannel: threadChannel.AddMessage(msg); break;
case SocketTextChannel textChannel: textChannel.AddMessage(msg); break;
default: throw new NotSupportedException($"Unexpected {nameof(ISocketMessageChannel)} type.");
case SocketDMChannel dmChannel:
dmChannel.AddMessage(msg);
break;
case SocketGroupChannel groupChannel:
groupChannel.AddMessage(msg);
break;
case SocketThreadChannel threadChannel:
threadChannel.AddMessage(msg);
break;
case SocketTextChannel textChannel:
textChannel.AddMessage(msg);
break;
default:
throw new NotSupportedException($"Unexpected {nameof(ISocketMessageChannel)} type.");
}
}
/// <exception cref="NotSupportedException">Unexpected <see cref="ISocketMessageChannel"/> type.</exception>

View File

@@ -140,16 +140,16 @@ namespace Discord.WebSocket
/// <inheritdoc />
/// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception>
/// <exception cref="ArgumentException">The only valid <see cref="MessageFlags"/> are <see cref="MessageFlags.SuppressEmbeds"/> and <see cref="MessageFlags.None"/>.</exception>
public Task<RestUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null,
RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null,
public Task<RestUserMessage> SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null,
RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null,
MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None)
=> ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference,
=> ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference,
components, stickers, options, embeds, flags);
/// <inheritdoc />
/// <exception cref="ArgumentException">The only valid <see cref="MessageFlags"/> are <see cref="MessageFlags.SuppressEmbeds"/> and <see cref="MessageFlags.None"/>.</exception>
public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null,
RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null,
public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null,
RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null,
MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null,
Embed[] embeds = null, MessageFlags flags = MessageFlags.None)
=> ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, allowedMentions, messageReference,
@@ -158,28 +158,28 @@ namespace Discord.WebSocket
/// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception>
/// <exception cref="ArgumentException">The only valid <see cref="MessageFlags"/> are <see cref="MessageFlags.SuppressEmbeds"/> and <see cref="MessageFlags.None"/>.</exception>
public Task<RestUserMessage> SendFileAsync(Stream stream, string filename, string text, bool isTTS = false,
Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null,
MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null,
Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null,
MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null,
Embed[] embeds = null, MessageFlags flags = MessageFlags.None)
=> ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, allowedMentions,
=> ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, allowedMentions,
messageReference, components, stickers, options, isSpoiler, embeds, flags);
/// <inheritdoc />
/// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception>
/// <exception cref="ArgumentException">The only valid <see cref="MessageFlags"/> are <see cref="MessageFlags.SuppressEmbeds"/> and <see cref="MessageFlags.None"/>.</exception>
public Task<RestUserMessage> SendFileAsync(FileAttachment attachment, string text, bool isTTS = false,
Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null,
MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null,
public Task<RestUserMessage> SendFileAsync(FileAttachment attachment, string text, bool isTTS = false,
Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null,
MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null,
Embed[] embeds = null, MessageFlags flags = MessageFlags.None)
=> ChannelHelper.SendFileAsync(this, Discord, attachment, text, isTTS, embed, allowedMentions,
=> ChannelHelper.SendFileAsync(this, Discord, attachment, text, isTTS, embed, allowedMentions,
messageReference, components, stickers, options, embeds, flags);
/// <inheritdoc />
/// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception>
/// <exception cref="ArgumentException">The only valid <see cref="MessageFlags"/> are <see cref="MessageFlags.SuppressEmbeds"/> and <see cref="MessageFlags.None"/>.</exception>
public Task<RestUserMessage> SendFilesAsync(IEnumerable<FileAttachment> attachments, string text, bool isTTS = false,
Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null,
MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null,
public Task<RestUserMessage> SendFilesAsync(IEnumerable<FileAttachment> attachments, string text, bool isTTS = false,
Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null,
MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null,
Embed[] embeds = null, MessageFlags flags = MessageFlags.None)
=> ChannelHelper.SendFilesAsync(this, Discord, attachments, text, isTTS, embed, allowedMentions,
=> ChannelHelper.SendFilesAsync(this, Discord, attachments, text, isTTS, embed, allowedMentions,
messageReference, components, stickers, options, embeds, flags);
/// <inheritdoc />

View File

@@ -90,7 +90,7 @@ namespace Discord.WebSocket
{
throw new NotSupportedException("Voice is not yet supported for group channels.");
}
#endregion
#endregion
#region Messages
/// <inheritdoc />

View File

@@ -184,7 +184,7 @@ namespace Discord.WebSocket
public override string ToString() => Name;
private string DebuggerDisplay => $"{Name} ({Id}, Guild)";
internal new SocketGuildChannel Clone() => MemberwiseClone() as SocketGuildChannel;
#endregion
#endregion
#region SocketChannel
/// <inheritdoc />

View File

@@ -19,7 +19,7 @@ namespace Discord.WebSocket
public class SocketNewsChannel : SocketTextChannel, INewsChannel
{
internal SocketNewsChannel(DiscordSocketClient discord, ulong id, SocketGuild guild)
:base(discord, id, guild)
: base(discord, id, guild)
{
}
internal new static SocketNewsChannel Create(SocketGuild guild, ClientState state, Model model)

View File

@@ -120,7 +120,7 @@ namespace Discord.WebSocket
var thread = (SocketThreadChannel)Guild.AddOrUpdateChannel(Discord.State, model);
if(Discord.AlwaysDownloadUsers && Discord.HasGatewayIntent(GatewayIntents.GuildMembers))
if (Discord.AlwaysDownloadUsers && Discord.HasGatewayIntent(GatewayIntents.GuildMembers))
await thread.DownloadUsersAsync();
return thread;
@@ -461,7 +461,7 @@ namespace Discord.WebSocket
AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent components,
ISticker[] stickers, Embed[] embeds, MessageFlags flags)
=> await SendMessageAsync(text, isTTS, embed, options, allowedMentions, messageReference, components, stickers, embeds, flags).ConfigureAwait(false);
#endregion
#region INestedChannel

View File

@@ -1,5 +1,6 @@
using Discord.Rest;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
@@ -8,7 +9,6 @@ using System.Linq;
using System.Threading.Tasks;
using Model = Discord.API.Channel;
using ThreadMember = Discord.API.ThreadMember;
using System.Collections.Concurrent;
namespace Discord.WebSocket
{

View File

@@ -128,7 +128,7 @@ namespace Discord.WebSocket
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.DeleteMessageAsync(messageId, options);
return base.DeleteMessageAsync(messageId, options);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
@@ -136,7 +136,7 @@ namespace Discord.WebSocket
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.DeleteMessagesAsync(messages, options);
return base.DeleteMessagesAsync(messages, options);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
@@ -144,7 +144,7 @@ namespace Discord.WebSocket
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.DeleteMessagesAsync(messageIds, options);
return base.DeleteMessagesAsync(messageIds, options);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
@@ -160,7 +160,7 @@ namespace Discord.WebSocket
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.GetCachedMessage(id);
return base.GetCachedMessage(id);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
@@ -192,7 +192,7 @@ namespace Discord.WebSocket
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.GetMessagesAsync(fromMessage, dir, limit, options);
return base.GetMessagesAsync(fromMessage, dir, limit, options);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
@@ -232,7 +232,7 @@ namespace Discord.WebSocket
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.GetWebhooksAsync(options);
return base.GetWebhooksAsync(options);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>
@@ -256,7 +256,7 @@ namespace Discord.WebSocket
{
if (!IsTextInVoice)
throw new NotSupportedException("This function is only supported in Text-In-Voice channels");
return base.SendFileAsync(attachment, text, isTTS, embed, options, allowedMentions, messageReference, components, stickers, embeds, flags);
return base.SendFileAsync(attachment, text, isTTS, embed, options, allowedMentions, messageReference, components, stickers, embeds, flags);
}
/// <inheritdoc/> <exception cref="NotSupportedException">This function is only supported in Text-In-Voice channels.</exception>

View File

@@ -7,22 +7,22 @@ using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using ChannelModel = Discord.API.Channel;
using EmojiUpdateModel = Discord.API.Gateway.GuildEmojiUpdateEvent;
using EventModel = Discord.API.GuildScheduledEvent;
using ExtendedModel = Discord.API.Gateway.ExtendedGuild;
using GuildSyncModel = Discord.API.Gateway.GuildSyncEvent;
using MemberModel = Discord.API.GuildMember;
using Model = Discord.API.Guild;
using PresenceModel = Discord.API.Presence;
using RoleModel = Discord.API.Role;
using StickerModel = Discord.API.Sticker;
using UserModel = Discord.API.User;
using VoiceStateModel = Discord.API.VoiceState;
using StickerModel = Discord.API.Sticker;
using EventModel = Discord.API.GuildScheduledEvent;
using System.IO;
namespace Discord.WebSocket
{
@@ -403,7 +403,7 @@ namespace Discord.WebSocket
IsAvailable = !(model.Unavailable ?? false);
if (!IsAvailable)
{
if(_events == null)
if (_events == null)
_events = new ConcurrentDictionary<ulong, SocketGuildEvent>();
if (_channels == null)
_channels = new ConcurrentDictionary<ulong, SocketGuildChannel>();
@@ -431,7 +431,7 @@ namespace Discord.WebSocket
channels.TryAdd(channel.Id, channel);
}
for(int i = 0; i < model.Threads.Length; i++)
for (int i = 0; i < model.Threads.Length; i++)
{
var threadChannel = SocketThreadChannel.Create(this, state, model.Threads[i]);
state.AddChannel(threadChannel);
@@ -987,7 +987,7 @@ namespace Discord.WebSocket
Discord.State.PurgeCommands(x => !x.IsGlobalCommand && x.Guild.Id == Id);
foreach(var entity in entities)
foreach (var entity in entities)
{
Discord.State.AddCommand(entity);
}
@@ -1195,7 +1195,7 @@ namespace Discord.WebSocket
var membersToKeep = Users.Where(x => !predicate.Invoke(x) || x?.Id == Discord.CurrentUser.Id);
foreach (var member in membersToPurge)
if(_members.TryRemove(member.Id, out _))
if (_members.TryRemove(member.Id, out _))
member.GlobalUser.RemoveRef(Discord);
foreach (var member in membersToKeep)
@@ -1347,7 +1347,7 @@ namespace Discord.WebSocket
{
case GuildScheduledEventType.Stage:
CurrentUser.GuildPermissions.Ensure(GuildPermission.ManageEvents | GuildPermission.ManageChannels | GuildPermission.MuteMembers | GuildPermission.MoveMembers);
break;
break;
case GuildScheduledEventType.Voice:
CurrentUser.GuildPermissions.Ensure(GuildPermission.ManageEvents | GuildPermission.ViewChannel | GuildPermission.Connect);
break;
@@ -2008,7 +2008,7 @@ namespace Discord.WebSocket
async Task<IReadOnlyCollection<IWebhook>> IGuild.GetWebhooksAsync(RequestOptions options)
=> await GetWebhooksAsync(options).ConfigureAwait(false);
/// <inheritdoc />
async Task<IReadOnlyCollection<IApplicationCommand>> IGuild.GetApplicationCommandsAsync (bool withLocalizations, string locale, RequestOptions options)
async Task<IReadOnlyCollection<IApplicationCommand>> IGuild.GetApplicationCommandsAsync(bool withLocalizations, string locale, RequestOptions options)
=> await GetApplicationCommandsAsync(withLocalizations, locale, options).ConfigureAwait(false);
/// <inheritdoc />
async Task<ICustomSticker> IGuild.CreateStickerAsync(string name, string description, IEnumerable<string> tags, Image image, RequestOptions options)

View File

@@ -86,9 +86,9 @@ namespace Discord.WebSocket
{
var guildUser = Guild.GetUser(model.CreatorId.Value);
if(guildUser != null)
if (guildUser != null)
{
if(model.Creator.IsSpecified)
if (model.Creator.IsSpecified)
guildUser.Update(Discord.State, model.Creator.Value);
Creator = guildUser;

View File

@@ -1,12 +1,12 @@
using Discord.Net.Rest;
using Discord.Rest;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Model = Discord.API.Interaction;
using DataModel = Discord.API.MessageComponentInteractionData;
using Discord.Rest;
using System.Collections.Generic;
using Discord.Net.Rest;
using System.IO;
using Model = Discord.API.Interaction;
namespace Discord.WebSocket
{

View File

@@ -1,9 +1,9 @@
using Discord.Rest;
using Discord.Utils;
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using Model = Discord.API.MessageComponentInteractionData;
namespace Discord.WebSocket

View File

@@ -27,7 +27,7 @@ namespace Discord.WebSocket
var dataModel = model.Data.IsSpecified
? (DataModel)model.Data.Value
: null;
Data = new SocketModalData(dataModel, client, client.State, client.State.GetGuild(model.GuildId.GetValueOrDefault()), model.User.GetValueOrDefault());
}
@@ -380,7 +380,7 @@ namespace Discord.WebSocket
/// <inheritdoc/>
public override Task RespondWithModalAsync(Modal modal, RequestOptions options = null)
=> throw new NotSupportedException("You cannot respond to a modal with a modal!");
IModalInteractionData IModalInteraction.Data => Data;
}
}

View File

@@ -1,9 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System;
using Model = Discord.API.ModalInteractionData;
using InterationModel = Discord.API.Interaction;
using DataModel = Discord.API.MessageComponentInteractionData;
using InterationModel = Discord.API.Interaction;
using Model = Discord.API.ModalInteractionData;
namespace Discord.WebSocket
{

View File

@@ -3,8 +3,8 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Model = Discord.API.Interaction;
using DataModel = Discord.API.AutocompleteInteractionData;
using Model = Discord.API.Interaction;
namespace Discord.WebSocket
{

View File

@@ -269,7 +269,7 @@ namespace Discord.WebSocket
return await InteractionHelper.SendFollowupAsync(Discord.Rest, args, Token, Channel, options);
}
/// <inheritdoc/>
public override async Task<RestFollowupMessage> FollowupWithFilesAsync(
IEnumerable<FileAttachment> attachments,

View File

@@ -1,11 +1,11 @@
using Discord.Net;
using Discord.Rest;
using System;
using System.Threading.Tasks;
using Model = Discord.API.Interaction;
using DataModel = Discord.API.ApplicationCommandInteractionData;
using System.IO;
using System.Collections.Generic;
using Discord.Net;
using System.IO;
using System.Threading.Tasks;
using DataModel = Discord.API.ApplicationCommandInteractionData;
using Model = Discord.API.Interaction;
namespace Discord.WebSocket
{
@@ -130,7 +130,7 @@ namespace Discord.WebSocket
Data = model.Data.IsSpecified
? model.Data.Value
: null;
Token = model.Token;
Version = model.Version;
Type = model.Type;
@@ -398,7 +398,7 @@ namespace Discord.WebSocket
/// <param name="options">The request options for this <see langword="async"/> request.</param>
/// <returns>A task that represents the asynchronous operation of responding to the interaction.</returns>
public abstract Task RespondWithModalAsync(Modal modal, RequestOptions options = null);
#endregion
#endregion
/// <summary>
/// Attepts to get the channel this interaction was executed in.
@@ -407,7 +407,7 @@ namespace Discord.WebSocket
/// <returns>
/// A task that represents the asynchronous operation of fetching the channel.
/// </returns>
public async ValueTask<IMessageChannel> GetChannelAsync(RequestOptions options = null)
public async ValueTask<IMessageChannel> GetChannelAsync(RequestOptions options = null)
{
if (Channel != null)
return Channel;
@@ -419,10 +419,10 @@ namespace Discord.WebSocket
{
return (IMessageChannel)await Discord.GetChannelAsync(ChannelId.Value, options).ConfigureAwait(false);
}
catch(HttpException ex) when (ex.DiscordCode == DiscordErrorCode.MissingPermissions) { return null; } // bot can't view that channel, return null instead of throwing.
catch (HttpException ex) when (ex.DiscordCode == DiscordErrorCode.MissingPermissions) { return null; } // bot can't view that channel, return null instead of throwing.
}
#region IDiscordInteraction
#region IDiscordInteraction
/// <inheritdoc/>
IUser IDiscordInteraction.User => User;
@@ -452,6 +452,6 @@ namespace Discord.WebSocket
async Task<IUserMessage> IDiscordInteraction.FollowupWithFileAsync(FileAttachment attachment, string text, Embed[] embeds, bool isTTS, bool ephemeral, AllowedMentions allowedMentions, MessageComponent components, Embed embed, RequestOptions options)
=> await FollowupWithFileAsync(attachment, text, embeds, isTTS, ephemeral, allowedMentions, components, embed, options).ConfigureAwait(false);
#endif
#endregion
#endregion
}
}

View File

@@ -48,8 +48,10 @@ namespace Discord.WebSocket
/// <exception cref="ArgumentOutOfRangeException"><paramref name="limit"/> is less than 0.</exception>
public IReadOnlyCollection<SocketMessage> GetMany(ulong? fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch)
{
if (limit < 0) throw new ArgumentOutOfRangeException(nameof(limit));
if (limit == 0) return ImmutableArray<SocketMessage>.Empty;
if (limit < 0)
throw new ArgumentOutOfRangeException(nameof(limit));
if (limit == 0)
return ImmutableArray<SocketMessage>.Empty;
IEnumerable<ulong> cachedMessageIds;
if (fromMessageId == null)

View File

@@ -309,7 +309,7 @@ namespace Discord.WebSocket
/// </returns>
public override string ToString() => Content;
internal SocketMessage Clone() => MemberwiseClone() as SocketMessage;
#endregion
#endregion
#region IMessage
/// <inheritdoc />

View File

@@ -86,11 +86,14 @@ namespace Discord.WebSocket
/// <inheritdoc />
public override bool Equals(object other)
{
if (other == null) return false;
if (other == this) return true;
if (other == null)
return false;
if (other == this)
return true;
var otherReaction = other as SocketReaction;
if (otherReaction == null) return false;
if (otherReaction == null)
return false;
return UserId == otherReaction.UserId && MessageId == otherReaction.MessageId && Emote.Equals(otherReaction.Emote);
}

View File

@@ -23,7 +23,7 @@ namespace Discord.WebSocket
{
base.Update(state, model);
}
private string DebuggerDisplay => $"{Author}: {Content} ({Id}, {Type})";
internal new SocketSystemMessage Clone() => MemberwiseClone() as SocketSystemMessage;
}

View File

@@ -6,9 +6,9 @@ using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using UserModel = Discord.API.User;
using MemberModel = Discord.API.GuildMember;
using PresenceModel = Discord.API.Presence;
using UserModel = Discord.API.User;
namespace Discord.WebSocket
{

View File

@@ -1,9 +1,9 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Threading.Tasks;
using Model = Discord.API.ThreadMember;
using System.Collections.Immutable;
namespace Discord.WebSocket
{
@@ -142,7 +142,7 @@ namespace Discord.WebSocket
{
Thread = thread;
Guild = guild;
if(member is not null)
if (member is not null)
GuildUser = member;
}
@@ -156,7 +156,7 @@ namespace Discord.WebSocket
internal static SocketThreadUser Create(SocketGuild guild, SocketThreadChannel thread, SocketGuildUser owner)
{
// this is used for creating the owner of the thread.
var entity = new SocketThreadUser(guild, thread, owner.Id, owner);
var entity = new SocketThreadUser(guild, thread, owner.Id, owner);
entity.Update(new Model
{
JoinTimestamp = thread.CreatedAt,
@@ -167,7 +167,7 @@ namespace Discord.WebSocket
internal void Update(Model model)
{
ThreadJoinedAt = model.JoinTimestamp;
if(model.GuildMember.IsSpecified)
if (model.GuildMember.IsSpecified)
GuildUser = Guild.AddOrUpdateUser(model.GuildMember.Value);
}

View File

@@ -1,3 +1,4 @@
using Discord.Rest;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
@@ -5,7 +6,6 @@ using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;
using Discord.Rest;
using Model = Discord.API.User;
using PresenceModel = Discord.API.Presence;

View File

@@ -53,7 +53,7 @@ namespace Discord.WebSocket
public bool IsStreaming => (_voiceStates & Flags.SelfStream) != 0;
/// <inheritdoc />
public bool IsVideoing => (_voiceStates & Flags.SelfVideo) != 0;
internal SocketVoiceState(SocketVoiceChannel voiceChannel, DateTimeOffset? requestToSpeak, string sessionId, bool isSelfMuted, bool isSelfDeafened, bool isMuted, bool isDeafened, bool isSuppressed, bool isStream, bool isVideo)
{

View File

@@ -51,7 +51,7 @@ namespace Discord.WebSocket
private string DebuggerDisplay => $"{Username}#{Discriminator} ({Id}{(IsBot ? ", Bot" : "")}, Webhook)";
internal new SocketWebhookUser Clone() => MemberwiseClone() as SocketWebhookUser;
#endregion
#endregion
#region IGuildUser
/// <inheritdoc />