Skip to content

Commit 9b9835c

Browse files
committed
Run Code Cleanup
1 parent 17dfd3a commit 9b9835c

38 files changed

+170
-188
lines changed

CommandChecks/HomeServerPerms.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public static async Task<ServerPermLevel> GetPermLevelAsync(DiscordMember target
3535
return ServerPermLevel.Admin;
3636

3737
bool HasRole(ulong roleId) => target.Roles.Any(r => r.Id == roleId);
38-
38+
3939
return HasRole(Program.cfgjson.AdminRole) ? ServerPermLevel.Admin
4040
: HasRole(Program.cfgjson.ModRole) ? ServerPermLevel.Moderator
4141
: HasRole(Program.cfgjson.MutedRole) ? ServerPermLevel.Muted

Commands/AnnouncementCmds.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ public class AnnouncementCmds
55
// used to pass context to modal handling for /editannounce
66
// keyed by user ID
77
public static Dictionary<ulong, (ulong msgId, string role1, string role2)> EditAnnounceCache = new();
8-
8+
99
[Command("announcebuild")]
1010
[Description("Announce a Windows Insider build in the current channel.")]
1111
[AllowedProcessors(typeof(SlashCommandProcessor))]
@@ -51,13 +51,13 @@ public async Task AnnounceBuildSlashCommand(SlashCommandContext ctx,
5151
await ctx.RespondAsync(text: $"{Program.cfgjson.Emoji.Error} Windows 10 only has a Release Preview Channel.", ephemeral: true);
5252
return;
5353
}
54-
54+
5555
if (threadChannel != default && threadChannel == threadChannel2)
5656
{
5757
await ctx.RespondAsync($"{Program.cfgjson.Emoji.Error} Both threads cannot be the same! Simply set one instead.", ephemeral: true);
5858
return;
5959
}
60-
60+
6161
if (threadChannel == default && threadChannel2 != default)
6262
{
6363
threadChannel = threadChannel2;
@@ -188,7 +188,7 @@ public async Task AnnounceBuildSlashCommand(SlashCommandContext ctx,
188188
threadChannel = await ctx.Client.GetChannelAsync(Program.cfgjson.InsiderThreads["rp"]);
189189
break;
190190
}
191-
191+
192192
switch (insiderChannel2)
193193
{
194194
case "Canary":
@@ -207,7 +207,7 @@ public async Task AnnounceBuildSlashCommand(SlashCommandContext ctx,
207207
threadChannel2 = await ctx.Client.GetChannelAsync(Program.cfgjson.InsiderThreads["rp"]);
208208
break;
209209
}
210-
210+
211211
pingMsgString += $"\n\nDiscuss it here: {threadChannel.Mention}";
212212
if (threadChannel2 != default)
213213
pingMsgString += $" & {threadChannel2.Mention}";
@@ -258,7 +258,7 @@ public async Task AnnounceBuildSlashCommand(SlashCommandContext ctx,
258258
threadChannel = await ctx.Client.GetChannelAsync(Program.cfgjson.InsiderThreads["rp"]);
259259
break;
260260
}
261-
261+
262262
switch (insiderChannel2)
263263
{
264264
case "Canary":
@@ -277,7 +277,7 @@ public async Task AnnounceBuildSlashCommand(SlashCommandContext ctx,
277277
threadChannel2 = await ctx.Client.GetChannelAsync(Program.cfgjson.InsiderThreads["rp"]);
278278
break;
279279
}
280-
280+
281281
noPingMsgString += $"\n\nDiscuss it here: {threadChannel.Mention}";
282282
if (threadChannel2 != default)
283283
noPingMsgString += $" & {threadChannel2.Mention}";
@@ -384,13 +384,13 @@ public async Task EditAnnounce(
384384
await ctx.RespondAsync($"{Program.cfgjson.Emoji.Error} That message ID wasn't recognised!", ephemeral: true);
385385
return;
386386
}
387-
387+
388388
if (msg.Author.Id != ctx.Client.CurrentUser.Id)
389389
{
390390
await ctx.RespondAsync($"{Program.cfgjson.Emoji.Error} That message wasn't sent by me, so I can't edit it!", ephemeral: true);
391391
return;
392392
}
393-
393+
394394
// Validate roles
395395
if (!Program.cfgjson.AnnouncementRoles.ContainsKey(role1Name) || (role2Name is not null && !Program.cfgjson.AnnouncementRoles.ContainsKey(role2Name)))
396396
{
@@ -402,12 +402,12 @@ public async Task EditAnnounce(
402402
await ctx.RespondAsync($"{Program.cfgjson.Emoji.Warning} You provided the same role name twice! Did you mean to use two different roles?", ephemeral: true);
403403
return;
404404
}
405-
405+
406406
EditAnnounceCache[ctx.User.Id] = (Convert.ToUInt64(messageId), role1Name, role2Name);
407407

408408
await ctx.RespondWithModalAsync(new DiscordInteractionResponseBuilder().WithTitle("Edit Announcement").WithCustomId("editannounce-modal-callback").AddTextInputComponent(new DiscordTextInputComponent("New announcement text. Do not include roles!", "editannounce-modal-new-text", value: msg.Content, style: DiscordTextInputStyle.Paragraph)));
409409
}
410-
410+
411411
[Command("announce")]
412412
[Description("Announces something in the current channel, pinging an Insider role in the process.")]
413413
[HomeServer, RequireHomeserverPerm(ServerPermLevel.Moderator)]
@@ -431,7 +431,7 @@ public async Task AnounceSlashCmd(SlashCommandContext ctx,
431431
await ctx.RespondAsync(text: $"{Program.cfgjson.Emoji.Error} Windows 10 only has a Release Preview Channel.", ephemeral: true);
432432
return;
433433
}
434-
434+
435435
string roleKey1;
436436
if (windowsVersion == 10 && insiderChannel1 == "RP")
437437
{
@@ -465,7 +465,7 @@ public async Task AnounceSlashCmd(SlashCommandContext ctx,
465465

466466
insiderRole2 = await ctx.Guild.GetRoleAsync(Program.cfgjson.AnnouncementRoles[roleKey2]);
467467
}
468-
468+
469469
await insiderRole1.ModifyAsync(mentionable: true);
470470
if (insiderRole2 != default)
471471
await insiderRole2.ModifyAsync(mentionable: true);
@@ -486,7 +486,7 @@ public async Task AnounceSlashCmd(SlashCommandContext ctx,
486486
await insiderRole1.ModifyAsync(mentionable: false);
487487
if (insiderRole2 != default)
488488
await insiderRole2.ModifyAsync(mentionable: false);
489-
489+
490490
await ctx.RespondAsync($"{Program.cfgjson.Emoji.Success} Announcement sent successfully!");
491491
}
492492

@@ -632,7 +632,7 @@ public async ValueTask<IEnumerable<DiscordApplicationCommandOptionChoice>> Provi
632632
};
633633
}
634634
}
635-
635+
636636
internal class AnnouncementRoleChoiceProvider : IChoiceProvider
637637
{
638638
public async ValueTask<IEnumerable<DiscordApplicationCommandOptionChoice>> ProvideAsync(CommandParameter _)

Commands/BanCmds.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ public async Task BankeepCmd(TextCommandContext ctx,
441441
}
442442
}
443443
}
444-
444+
445445
[Command("editbantextcmd")]
446446
[TextAlias("editban")]
447447
[Description("Edit the details of a ban. Updates the DM to the user, among other things.")]
@@ -457,39 +457,39 @@ public async Task EditBanCmd(TextCommandContext ctx,
457457
await ctx.RespondAsync($"{Program.cfgjson.Emoji.Error} There's no record of a ban for that user! Please make sure they're banned or you got the right user.");
458458
return;
459459
}
460-
460+
461461
(TimeSpan banDuration, string reason, bool appealable) = PunishmentHelpers.UnpackTimeAndReason(timeAndReason, ctx.Message.Timestamp.DateTime);
462462

463463
var ban = JsonConvert.DeserializeObject<MemberPunishment>(await Program.redis.HashGetAsync("bans", targetUser.Id));
464-
464+
465465
ban.ModId = ctx.User.Id;
466466
if (banDuration == default)
467467
ban.ExpireTime = null;
468468
else
469469
ban.ExpireTime = ban.ActionTime + banDuration;
470470
ban.Reason = reason;
471-
471+
472472
var guild = await Program.discord.GetGuildAsync(ban.ServerId);
473-
473+
474474
var contextMessage = await DiscordHelpers.GetMessageFromReferenceAsync(ban.ContextMessageReference);
475475
var dmMessage = await DiscordHelpers.GetMessageFromReferenceAsync(ban.DmMessageReference);
476-
476+
477477
reason = reason.Replace("`", "\\`").Replace("*", "\\*");
478-
478+
479479
if (contextMessage is not null)
480480
{
481481
string newCtxMsg;
482482
if (banDuration == default)
483483
newCtxMsg = $"{Program.cfgjson.Emoji.Banned} {targetUser.Mention} has been banned: **{reason}**";
484484
else
485485
newCtxMsg = $"{Program.cfgjson.Emoji.Banned} {targetUser.Mention} has been banned for **{TimeHelpers.TimeToPrettyFormat(banDuration, false)}**: **{reason}**";
486-
486+
487487
if (contextMessage.Content.Contains("-# This user's messages have been kept."))
488488
newCtxMsg += "\n-# This user's messages have been kept.";
489-
489+
490490
await contextMessage.ModifyAsync(newCtxMsg);
491491
}
492-
492+
493493
if (dmMessage is not null)
494494
{
495495
if (ban.ExpireTime == null)
@@ -511,12 +511,12 @@ public async Task EditBanCmd(TextCommandContext ctx,
511511
await dmMessage.ModifyAsync($"{Program.cfgjson.Emoji.Banned} You have been banned from **{guild.Name}** for {TimeHelpers.TimeToPrettyFormat(banDuration, false)}!\nReason: **{reason}**\nBan expires: <t:{TimeHelpers.ToUnixTimestamp(ban.ExpireTime)}:R>");
512512
}
513513
}
514-
514+
515515
await Program.redis.HashSetAsync("bans", targetUser.Id.ToString(), JsonConvert.SerializeObject(ban));
516-
516+
517517
// Construct log message
518518
string logOut = $"{Program.cfgjson.Emoji.MessageEdit} The ban for {targetUser.Mention} was edited by {ctx.User.Mention}!\nReason: **{reason}**";
519-
519+
520520
if (ban.ExpireTime == null)
521521
{
522522
logOut += "\nBan expires: **Never**"
@@ -526,10 +526,10 @@ public async Task EditBanCmd(TextCommandContext ctx,
526526
{
527527
logOut += $"\nBan expires: <t:{TimeHelpers.ToUnixTimestamp(ban.ExpireTime)}:R>";
528528
}
529-
529+
530530
// Log to mod log
531531
await LogChannelHelper.LogMessageAsync("mod", logOut);
532-
532+
533533
await ctx.RespondAsync($"{Program.cfgjson.Emoji.Success} Successfully edited the ban for {targetUser.Mention}!");
534534
}
535535
}

Commands/ClearCmds.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public async Task ClearSlashCommand(SlashCommandContext ctx,
2424
)
2525
{
2626
await ctx.DeferResponseAsync(ephemeral: !dryRun);
27-
27+
2828
if (channel is null)
2929
channel = ctx.Channel;
3030

Commands/DebugCmds.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using Cliptok.Helpers;
21
using Microsoft.EntityFrameworkCore;
32

43
namespace Cliptok.Commands
@@ -159,7 +158,8 @@ public async Task Restart(TextCommandContext ctx)
159158
{
160159
await ctx.RespondAsync("Invalid argument. Make sure you know what you are doing.");
161160

162-
};
161+
}
162+
;
163163
}
164164

165165
[Command("refresh")]

Commands/FunCmds.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using Cliptok.Constants;
2-
31
namespace Cliptok.Commands
42
{
53
public class FunCmds

Commands/GlobalCmds.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ await ctx.RespondAsync(
116116
var defaultGroupCommand = cmd.Subcommands.FirstOrDefault(sc => sc.Attributes.Any(a => a is DefaultGroupCommandAttribute));
117117
arguments = defaultGroupCommand?.Method?.GetParameters();
118118
}
119-
119+
120120
if (arguments is not null && arguments.Length > 0)
121121
{
122122
var argumentsStr = $"`{cmd.Name.Replace("textcmd", "")}";
@@ -257,7 +257,7 @@ public async Task RemindMe(
257257
)
258258
{
259259
DateTime t = TimeHelpers.ParseAnyDateFormat(timetoParse);
260-
260+
261261
if (t <= DateTime.Now)
262262
{
263263
await ctx.RespondAsync($"{Program.cfgjson.Emoji.Error} Time can't be in the past!");

Commands/ListCmds.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public async Task ListAdd(
110110
if (
111111
Program.cfgjson.GitHubWorkflowPrivate is not null
112112
&& githubTokenPrivate is not null
113-
&& Directory.GetFiles($"Lists/{Program.cfgjson.GitListDirectory}").Any(x => x.EndsWith(fileName)) )
113+
&& Directory.GetFiles($"Lists/{Program.cfgjson.GitListDirectory}").Any(x => x.EndsWith(fileName)))
114114
{
115115
workflowId = Program.cfgjson.GitHubWorkflowPrivate.WorkflowId;
116116
refName = Program.cfgjson.GitHubWorkflowPrivate.Ref;
@@ -185,33 +185,33 @@ public async Task ScamCheck(CommandContext ctx, [Parameter("input"), Description
185185
await ctx.RespondAsync($"{Program.cfgjson.Emoji.Error} Anti-phishing API is not configured, nothing for me to do.");
186186
}
187187
}
188-
188+
189189
[Command("invitecheck")]
190190
[Description("Check if a server invite is known to the malicious invites API.")]
191191
[AllowedProcessors(typeof(SlashCommandProcessor), typeof(TextCommandProcessor))]
192192
[RequireHomeserverPerm(ServerPermLevel.TrialModerator), RequirePermissions(DiscordPermission.ModerateMembers)]
193193
public async Task InviteCheck(CommandContext ctx, [Parameter("input"), Description("Server invite to scan.")] string content)
194194
{
195195
var inviteMatches = Constants.RegexConstants.invite_rx.Matches(content);
196-
196+
197197
if (inviteMatches.Count == 0)
198198
{
199199
await ctx.RespondAsync($"{Program.cfgjson.Emoji.Error} That doesn't look like a valid invite! Please try again.");
200200
return;
201201
}
202-
202+
203203
var invite = inviteMatches.First();
204204
ulong guildId;
205205
try
206206
{
207-
guildId = (await Program.discord.GetInviteByCodeAsync(invite.Groups[1].Value)).Guild.Id;
207+
guildId = (await Program.discord.GetInviteByCodeAsync(invite.Groups[1].Value)).Guild.Id;
208208
}
209209
catch (DSharpPlus.Exceptions.NotFoundException)
210210
{
211211
await ctx.RespondAsync($"{Program.cfgjson.Emoji.Error} That invite isn't valid!");
212212
return;
213213
}
214-
214+
215215
var (match, httpStatus, responseString, _) = await APIs.ServerAPI.ServerAPICheckAsync(guildId);
216216

217217
string responseToSend;

0 commit comments

Comments
 (0)