Format the project with 'dotnet format' (#2551)
* Sync and Re-Format * Fix Title string. * Fix indentation.
This commit is contained in:
@@ -333,7 +333,8 @@ namespace Discord.WebSocket
|
||||
await heartbeatTask.ConfigureAwait(false);
|
||||
_heartbeatTask = null;
|
||||
|
||||
while (_heartbeatTimes.TryDequeue(out _)) { }
|
||||
while (_heartbeatTimes.TryDequeue(out _))
|
||||
{ }
|
||||
_lastMessageTime = 0;
|
||||
|
||||
await _gatewayLogger.DebugAsync("Waiting for guild downloader").ConfigureAwait(false);
|
||||
@@ -344,7 +345,8 @@ namespace Discord.WebSocket
|
||||
|
||||
//Clear large guild queue
|
||||
await _gatewayLogger.DebugAsync("Clearing large guild queue").ConfigureAwait(false);
|
||||
while (_largeGuilds.TryDequeue(out _)) { }
|
||||
while (_largeGuilds.TryDequeue(out _))
|
||||
{ }
|
||||
|
||||
//Raise virtual GUILD_UNAVAILABLEs
|
||||
await _gatewayLogger.DebugAsync("Raising virtual GuildUnavailables").ConfigureAwait(false);
|
||||
@@ -461,7 +463,7 @@ namespace Discord.WebSocket
|
||||
{
|
||||
var commands = (await ApiClient.GetGlobalApplicationCommandsAsync(withLocalizations, locale, options)).Select(x => SocketApplicationCommand.Create(this, x));
|
||||
|
||||
foreach(var command in commands)
|
||||
foreach (var command in commands)
|
||||
{
|
||||
State.AddCommand(command);
|
||||
}
|
||||
@@ -490,7 +492,7 @@ namespace Discord.WebSocket
|
||||
//Purge our previous commands
|
||||
State.PurgeCommands(x => x.IsGlobalCommand);
|
||||
|
||||
foreach(var entity in entities)
|
||||
foreach (var entity in entities)
|
||||
{
|
||||
State.AddCommand(entity);
|
||||
}
|
||||
@@ -531,7 +533,7 @@ namespace Discord.WebSocket
|
||||
if (sticker != null)
|
||||
return sticker;
|
||||
|
||||
foreach(var guild in Guilds)
|
||||
foreach (var guild in Guilds)
|
||||
{
|
||||
sticker = await guild.GetStickerAsync(id, CacheMode.CacheOnly).ConfigureAwait(false);
|
||||
|
||||
@@ -544,7 +546,7 @@ namespace Discord.WebSocket
|
||||
|
||||
var model = await ApiClient.GetStickerAsync(id, options).ConfigureAwait(false);
|
||||
|
||||
if(model == null)
|
||||
if (model == null)
|
||||
return null;
|
||||
|
||||
|
||||
@@ -750,7 +752,7 @@ namespace Discord.WebSocket
|
||||
await _gatewayLogger.WarningAsync("You're using the GuildPresences intent without listening to the PresenceUpdate event, consider removing the intent from your config.").ConfigureAwait(false);
|
||||
}
|
||||
|
||||
if(!_gatewayIntents.HasFlag(GatewayIntents.GuildPresences) &&
|
||||
if (!_gatewayIntents.HasFlag(GatewayIntents.GuildPresences) &&
|
||||
((_shardedClient is null && _presenceUpdated.HasSubscribers) ||
|
||||
(_shardedClient is not null && _shardedClient._presenceUpdated.HasSubscribers)))
|
||||
{
|
||||
@@ -767,7 +769,7 @@ namespace Discord.WebSocket
|
||||
_guildScheduledEventUserAdd.HasSubscribers;
|
||||
|
||||
bool shardedClientHasGuildScheduledEventsSubscribers =
|
||||
_shardedClient is not null &&
|
||||
_shardedClient is not null &&
|
||||
(_shardedClient._guildScheduledEventCancelled.HasSubscribers ||
|
||||
_shardedClient._guildScheduledEventUserRemove.HasSubscribers ||
|
||||
_shardedClient._guildScheduledEventCompleted.HasSubscribers ||
|
||||
@@ -783,7 +785,7 @@ namespace Discord.WebSocket
|
||||
await _gatewayLogger.WarningAsync("You're using the GuildScheduledEvents gateway intent without listening to any events related to that intent, consider removing the intent from your config.").ConfigureAwait(false);
|
||||
}
|
||||
|
||||
if(!_gatewayIntents.HasFlag(GatewayIntents.GuildScheduledEvents) &&
|
||||
if (!_gatewayIntents.HasFlag(GatewayIntents.GuildScheduledEvents) &&
|
||||
((_shardedClient is null && hasGuildScheduledEventsSubscribers) ||
|
||||
(_shardedClient is not null && shardedClientHasGuildScheduledEventsSubscribers)))
|
||||
{
|
||||
@@ -2238,12 +2240,12 @@ namespace Discord.WebSocket
|
||||
await TimedInvokeAsync(_requestToSpeak, nameof(RequestToSpeak), stage, guildUser);
|
||||
return;
|
||||
}
|
||||
if(before.IsSuppressed && !after.IsSuppressed)
|
||||
if (before.IsSuppressed && !after.IsSuppressed)
|
||||
{
|
||||
await TimedInvokeAsync(_speakerAdded, nameof(SpeakerAdded), stage, guildUser);
|
||||
return;
|
||||
}
|
||||
if(!before.IsSuppressed && after.IsSuppressed)
|
||||
if (!before.IsSuppressed && after.IsSuppressed)
|
||||
{
|
||||
await TimedInvokeAsync(_speakerRemoved, nameof(SpeakerRemoved), stage, guildUser);
|
||||
}
|
||||
@@ -2349,7 +2351,7 @@ namespace Discord.WebSocket
|
||||
case "INTERACTION_CREATE":
|
||||
{
|
||||
await _gatewayLogger.DebugAsync("Received Dispatch (INTERACTION_CREATE)").ConfigureAwait(false);
|
||||
|
||||
|
||||
var data = (payload as JToken).ToObject<API.Interaction>(_serializer);
|
||||
|
||||
var guild = data.GuildId.IsSpecified ? GetGuild(data.GuildId.Value) : null;
|
||||
@@ -2366,7 +2368,7 @@ namespace Discord.WebSocket
|
||||
: State.GetOrAddUser(data.Member.Value.User.Id, (_) => SocketGlobalUser.Create(this, State, data.Member.Value.User));
|
||||
|
||||
SocketChannel channel = null;
|
||||
if(data.ChannelId.IsSpecified)
|
||||
if (data.ChannelId.IsSpecified)
|
||||
{
|
||||
channel = State.GetChannel(data.ChannelId.Value);
|
||||
|
||||
@@ -2507,7 +2509,7 @@ namespace Discord.WebSocket
|
||||
{
|
||||
threadChannel.Update(State, data);
|
||||
|
||||
if(data.ThreadMember.IsSpecified)
|
||||
if (data.ThreadMember.IsSpecified)
|
||||
threadChannel.AddOrUpdateThreadMember(data.ThreadMember.Value, guild.CurrentUser);
|
||||
}
|
||||
else
|
||||
@@ -2570,7 +2572,7 @@ namespace Discord.WebSocket
|
||||
|
||||
var guild = State.GetGuild(data.GuildId.Value);
|
||||
|
||||
if(guild == null)
|
||||
if (guild == null)
|
||||
{
|
||||
await UnknownGuildAsync(type, data.GuildId.Value).ConfigureAwait(false);
|
||||
return;
|
||||
@@ -2591,17 +2593,17 @@ namespace Discord.WebSocket
|
||||
|
||||
var guild = State.GetGuild(data.GuildId);
|
||||
|
||||
if(guild == null)
|
||||
if (guild == null)
|
||||
{
|
||||
await UnknownGuildAsync(type, data.GuildId).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
foreach(var thread in data.Threads)
|
||||
foreach (var thread in data.Threads)
|
||||
{
|
||||
var entity = guild.ThreadChannels.FirstOrDefault(x => x.Id == thread.Id);
|
||||
|
||||
if(entity == null)
|
||||
if (entity == null)
|
||||
{
|
||||
entity = (SocketThreadChannel)guild.AddChannel(State, thread);
|
||||
}
|
||||
@@ -2610,7 +2612,7 @@ namespace Discord.WebSocket
|
||||
entity.Update(State, thread);
|
||||
}
|
||||
|
||||
foreach(var member in data.Members.Where(x => x.Id.Value == entity.Id))
|
||||
foreach (var member in data.Members.Where(x => x.Id.Value == entity.Id))
|
||||
{
|
||||
var guildMember = guild.GetUser(member.Id.Value);
|
||||
|
||||
@@ -2653,7 +2655,7 @@ namespace Discord.WebSocket
|
||||
|
||||
var thread = (SocketThreadChannel)guild.GetChannel(data.Id);
|
||||
|
||||
if(thread == null)
|
||||
if (thread == null)
|
||||
{
|
||||
await UnknownChannelAsync(type, data.Id);
|
||||
return;
|
||||
@@ -2671,13 +2673,13 @@ namespace Discord.WebSocket
|
||||
if (data.AddedMembers.IsSpecified)
|
||||
{
|
||||
List<SocketThreadUser> newThreadMembers = new List<SocketThreadUser>();
|
||||
foreach(var threadMember in data.AddedMembers.Value)
|
||||
foreach (var threadMember in data.AddedMembers.Value)
|
||||
{
|
||||
SocketGuildUser guildMember;
|
||||
|
||||
guildMember = guild.GetUser(threadMember.UserId.Value);
|
||||
|
||||
if(guildMember == null)
|
||||
if (guildMember == null)
|
||||
{
|
||||
await UnknownGuildUserAsync("THREAD_MEMBERS_UPDATE", threadMember.UserId.Value, guild.Id);
|
||||
}
|
||||
@@ -2691,15 +2693,15 @@ namespace Discord.WebSocket
|
||||
|
||||
if (leftUsers != null)
|
||||
{
|
||||
foreach(var threadUser in leftUsers)
|
||||
foreach (var threadUser in leftUsers)
|
||||
{
|
||||
await TimedInvokeAsync(_threadMemberLeft, nameof(ThreadMemberLeft), threadUser).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
if(joinUsers != null)
|
||||
if (joinUsers != null)
|
||||
{
|
||||
foreach(var threadUser in joinUsers)
|
||||
foreach (var threadUser in joinUsers)
|
||||
{
|
||||
await TimedInvokeAsync(_threadMemberJoined, nameof(ThreadMemberJoined), threadUser).ConfigureAwait(false);
|
||||
}
|
||||
@@ -2718,7 +2720,7 @@ namespace Discord.WebSocket
|
||||
|
||||
var guild = State.GetGuild(data.GuildId);
|
||||
|
||||
if(guild == null)
|
||||
if (guild == null)
|
||||
{
|
||||
await UnknownGuildAsync(type, data.GuildId).ConfigureAwait(false);
|
||||
return;
|
||||
@@ -2726,7 +2728,7 @@ namespace Discord.WebSocket
|
||||
|
||||
var stageChannel = guild.GetStageChannel(data.ChannelId);
|
||||
|
||||
if(stageChannel == null)
|
||||
if (stageChannel == null)
|
||||
{
|
||||
await UnknownChannelAsync(type, data.ChannelId).ConfigureAwait(false);
|
||||
return;
|
||||
@@ -2792,15 +2794,16 @@ namespace Discord.WebSocket
|
||||
|
||||
var after = guild.AddOrUpdateEvent(data);
|
||||
|
||||
if((before != null ? before.Status != GuildScheduledEventStatus.Completed : true) && data.Status == GuildScheduledEventStatus.Completed)
|
||||
if ((before != null ? before.Status != GuildScheduledEventStatus.Completed : true) && data.Status == GuildScheduledEventStatus.Completed)
|
||||
{
|
||||
await TimedInvokeAsync(_guildScheduledEventCompleted, nameof(GuildScheduledEventCompleted), after).ConfigureAwait(false);
|
||||
}
|
||||
else if((before != null ? before.Status != GuildScheduledEventStatus.Active : false) && data.Status == GuildScheduledEventStatus.Active)
|
||||
else if ((before != null ? before.Status != GuildScheduledEventStatus.Active : false) && data.Status == GuildScheduledEventStatus.Active)
|
||||
{
|
||||
await TimedInvokeAsync(_guildScheduledEventStarted, nameof(GuildScheduledEventStarted), after).ConfigureAwait(false);
|
||||
}
|
||||
else await TimedInvokeAsync(_guildScheduledEventUpdated, nameof(GuildScheduledEventUpdated), beforeCacheable, after).ConfigureAwait(false);
|
||||
else
|
||||
await TimedInvokeAsync(_guildScheduledEventUpdated, nameof(GuildScheduledEventUpdated), beforeCacheable, after).ConfigureAwait(false);
|
||||
}
|
||||
break;
|
||||
case "GUILD_SCHEDULED_EVENT_DELETE":
|
||||
@@ -2830,7 +2833,7 @@ namespace Discord.WebSocket
|
||||
|
||||
var guild = State.GetGuild(data.GuildId);
|
||||
|
||||
if(guild == null)
|
||||
if (guild == null)
|
||||
{
|
||||
await UnknownGuildAsync(type, data.GuildId).ConfigureAwait(false);
|
||||
return;
|
||||
@@ -2902,7 +2905,8 @@ namespace Discord.WebSocket
|
||||
|
||||
#region Others
|
||||
default:
|
||||
if(!SuppressUnknownDispatchWarnings) await _gatewayLogger.WarningAsync($"Unknown Dispatch ({type})").ConfigureAwait(false);
|
||||
if (!SuppressUnknownDispatchWarnings)
|
||||
await _gatewayLogger.WarningAsync($"Unknown Dispatch ({type})").ConfigureAwait(false);
|
||||
break;
|
||||
#endregion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user