Skip to content

Commit

Permalink
chore: formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Lulalaby committed Apr 19, 2024
1 parent fc22580 commit 069cb48
Show file tree
Hide file tree
Showing 11 changed files with 98 additions and 98 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -737,14 +737,12 @@ private async Task RegisterCommands(List<ApplicationCommandsModuleConfiguration>

if (cs.Count is not 0)
//translation.AddRange(cs.Select(c => JsonConvert.DeserializeObject<CommandTranslator>(JsonConvert.SerializeObject(c))!));
{
foreach (var c in cs)
{
var json = JsonConvert.SerializeObject(c);
var obj = JsonConvert.DeserializeObject<CommandTranslator>(json);
translation.Add(obj!);
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ private static void StatusAnalyzer(SyntaxNodeAnalysisContext context)
context.ReportDiagnostic(Diagnostic.Create(s_requiresFeatureRule, invocation.GetLocation(), kind, name, message));
}
}
catch(Exception ex)
catch (Exception ex)
{
Console.WriteLine($"StatusAnalyzer threw an exception: {ex.Message}");
if (!string.IsNullOrEmpty(ex.StackTrace))
Expand All @@ -211,8 +211,8 @@ private static void ExperimentalAnalyzer(SymbolAnalysisContext context)
try
{
var syntaxTrees = from x in context.Symbol.Locations
where x.IsInSource
select x.SourceTree;
where x.IsInSource
select x.SourceTree;
var declaration = context.Symbol;

// ReSharper disable HeuristicUnreachableCode
Expand Down Expand Up @@ -281,7 +281,7 @@ where x.IsInSource
context.ReportDiagnostic(Diagnostic.Create(s_requiresFeatureRule, context.Symbol.Locations.FirstOrDefault(x => x.IsInSource), kind, name, message));
}
}
catch(Exception ex)
catch (Exception ex)
{
Console.WriteLine($"StatusAnalyzer threw an exception: {ex.Message}");
if (!string.IsNullOrEmpty(ex.StackTrace))
Expand Down
4 changes: 2 additions & 2 deletions DisCatSharp/Clients/DiscordClient.Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,9 @@ public event AsyncEventHandler<DiscordClient, GuildBanRemoveEventArgs> GuildBanR

private AsyncEvent<DiscordClient, GuildBanRemoveEventArgs> _guildBanRemoved;

#endregion
#endregion

#region Guild Timeout
#region Guild Timeout

/// <summary>
/// Fired when a guild member timeout gets added.
Expand Down
20 changes: 10 additions & 10 deletions DisCatSharp/Entities/Channel/DiscordChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ internal DiscordChannel(List<string>? ignored = null)
this._permissionOverwritesLazy = new(() => new ReadOnlyCollection<DiscordOverwrite>(this.PermissionOverwritesInternal));
}

#region Methods
#region Methods

/// <summary>
/// Sends a message to this channel.
Expand Down Expand Up @@ -965,7 +965,7 @@ public Task<IReadOnlyList<DiscordInvite>> GetInvitesAsync() =>
public Task<DiscordInvite> CreateInviteAsync(int maxAge = 86400, int maxUses = 0, bool temporary = false, bool unique = false, TargetType? targetType = null, ulong? targetApplicationId = null, ulong? targetUser = null, string reason = null)
=> this.Discord.ApiClient.CreateChannelInviteAsync(this.Id, maxAge, maxUses, targetType, targetApplicationId, targetUser, temporary, unique, reason);

#region Voice Channel
#region Voice Channel

/// <summary>
/// Sets a voice channels status.
Expand All @@ -988,9 +988,9 @@ public Task SetVoiceChannelStatusAsync(string status)
public Task RemoveVoiceChannelStatusAsync(string reason = null)
=> this.Type != ChannelType.Voice ? throw new NotSupportedException("Cannot execute this request on a non-voice channel.") : this.Discord.ApiClient.ModifyVoiceChannelStatusAsync(this.Id, null);

#endregion
#endregion

#region Stage
#region Stage

/// <summary>
/// Opens a stage.
Expand Down Expand Up @@ -1041,9 +1041,9 @@ public async Task CloseStageAsync(string reason = null)
public async Task<DiscordStageInstance> GetStageAsync()
=> await this.Discord.ApiClient.GetStageInstanceAsync(this.Id).ConfigureAwait(false);

#endregion
#endregion

#region Scheduled Events
#region Scheduled Events

/// <summary>
/// Creates a scheduled event based on the channel type.
Expand All @@ -1067,9 +1067,9 @@ public async Task<DiscordScheduledEvent> CreateScheduledEventAsync(string name,
return await this.Guild.CreateScheduledEventAsync(name, scheduledStartTime, null, this, null, description, type, coverImage, reason).ConfigureAwait(false);
}

#endregion
#endregion

#region Threads
#region Threads

/// <summary>
/// Creates a thread.
Expand Down Expand Up @@ -1218,7 +1218,7 @@ public async Task<DiscordChannel> CreateForumPostTagAsync(string name, DiscordEm
public async Task<DiscordChannel> DeleteForumPostTag(ulong id, string reason = null)
=> this.Type != ChannelType.Forum ? throw new NotSupportedException("Channel needs to be type of Forum") : await this.Discord.ApiClient.ModifyForumChannelAsync(this.Id, null, null, Optional.None, Optional.None, null, Optional.None, this.InternalAvailableTags?.Where(x => x.Id != id)?.ToList(), Optional.None, Optional.None, Optional.None, Optional.None, Optional.None, Optional.None, null, Optional.None, reason).ConfigureAwait(false);

#endregion
#endregion

/// <summary>
/// Adds a channel permission overwrite for specified role.
Expand Down Expand Up @@ -1463,7 +1463,7 @@ public override string ToString() =>
? $"Channel {this.Name} ({this.Id})"
: $"Channel {this.Id}";

#endregion
#endregion

/// <summary>
/// Checks whether this <see cref="DiscordChannel"/> is equal to another object.
Expand Down
8 changes: 4 additions & 4 deletions DisCatSharp/Entities/Message/DiscordMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ public bool HasPoll
/// <returns>The fresh discord message.</returns>
/// <exception cref="InvalidOperationException">Thrown when the message has no poll, the author is not us, or the poll has been already ended.</exception>
public async Task<DiscordMessage> EndPollAsync()
=> this.Poll is null
=> this.Poll is null
? throw new InvalidOperationException("This message has no poll.")
: this.Author.Id != this.Discord.CurrentUser.Id
? throw new InvalidOperationException("Can only end own polls.")
Expand Down Expand Up @@ -527,7 +527,7 @@ private List<IMention> GetMentions()
var mentions = new List<IMention>();

try
{
{
if (this.ReferencedMessage is not null && this.MentionedUsersInternal.Count is not 0 && this.MentionedUsersInternal.Contains(this.ReferencedMessage.Author))
mentions.Add(new RepliedUserMention());

Expand All @@ -537,8 +537,8 @@ private List<IMention> GetMentions()
if (this.MentionedRoleIds.Count is not 0)
mentions.AddRange(this.MentionedRoleIds.Select(r => (IMention)new RoleMention(r)));
}
catch
{ }
catch
{ }

return mentions;
}
Expand Down
5 changes: 2 additions & 3 deletions DisCatSharp/Entities/Message/DiscordMessageBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,7 @@ internal void Validate(bool isModify = false)

this.Poll?.Validate();
}
else
if (this.Poll is not null)
throw new InvalidOperationException("Messages with polls can't be edited.");
else if (this.Poll is not null)
throw new InvalidOperationException("Messages with polls can't be edited.");
}
}
10 changes: 5 additions & 5 deletions DisCatSharp/Entities/Message/Polls/DiscordPoll.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ public async Task<ReadOnlyCollection<DiscordUser>> GetAnswerVotersAsync(int answ
/// <returns>The fresh discord message.</returns>
/// <exception cref="InvalidOperationException">Thrown when the author is not us, or the poll has been already ended.</exception>
public async Task<DiscordMessage> EndAsync()
=> this.AuthorId != this.Discord.CurrentUser.Id
? throw new InvalidOperationException("Can only end own polls.")
: this.Results?.IsFinalized ?? false
? throw new InvalidOperationException("The poll was already ended.")
: await this.Discord.ApiClient.EndPollAsync(this.ChannelId, this.MessageId);
=> this.AuthorId != this.Discord.CurrentUser.Id
? throw new InvalidOperationException("Can only end own polls.")
: this.Results?.IsFinalized ?? false
? throw new InvalidOperationException("The poll was already ended.")
: await this.Discord.ApiClient.EndPollAsync(this.ChannelId, this.MessageId);
}
4 changes: 2 additions & 2 deletions DisCatSharp/Entities/Message/Polls/DiscordPollBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ public DiscordPollBuilder AddAnswers(IEnumerable<DiscordPollAnswer> answers)
throw new ArgumentException("Cannot add more than 10 answers to a poll!");
}

int answerId = 1;
foreach(var answer in answers)
var answerId = 1;
foreach (var answer in answers)
{
if (answer.PollMedia.Text.Length > 55)
throw new ArgumentException($"Answers text cannot exceed 55 characters. Thrown in answer {answerId}");
Expand Down
2 changes: 1 addition & 1 deletion DisCatSharp/Enums/Discord/DiscordIntents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public enum DiscordIntents
/// </summary>
AllUnprivileged = Guilds | GuildModeration | GuildEmojisAndStickers | GuildIntegrations | GuildWebhooks | GuildInvites | GuildVoiceStates | GuildMessages |
GuildMessageReactions | GuildMessageTyping | DirectMessages | DirectMessageReactions | DirectMessageTyping | GuildScheduledEvents | AutoModerationConfiguration | AutoModerationExecution |
GuildMessagePolls | DirectMessagePolls,
GuildMessagePolls | DirectMessagePolls,

/// <summary>
/// Includes all intents.
Expand Down
6 changes: 3 additions & 3 deletions DisCatSharp/Enums/Message/PollLayoutType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ public enum PollLayoutType
/// <summary>
/// The default layout type.
/// </summary>
Default = 1/*,
Default = 1 /*,
/// <summary>
/// Poll answers are images only.
/// </summary>
ImageOnlyAnswers = 2
*/
ImageOnlyAnswers = 2
*/
}
Loading

0 comments on commit 069cb48

Please sign in to comment.