Skip to content

Commit

Permalink
Upgrade DSharpPlus to 5.0.0-nightly-02416 + permissions changes (#242)
Browse files Browse the repository at this point in the history
* Upgrade DSharpPlus to 5.0.0-nightly-02416

Includes changes to DiscordPermissions

* Remove resolved todo
  • Loading branch information
FloatingMilkshake authored Nov 16, 2024
1 parent 8d872dd commit 57f6a37
Show file tree
Hide file tree
Showing 24 changed files with 71 additions and 71 deletions.
6 changes: 3 additions & 3 deletions Cliptok.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

<ItemGroup>
<PackageReference Include="Abyssal.HumanDateParser" Version="2.0.0-20191113.1" />
<PackageReference Include="DSharpPlus" Version="5.0.0-nightly-02374" />
<PackageReference Include="DSharpPlus.CommandsNext" Version="5.0.0-nightly-02374" />
<PackageReference Include="DSharpPlus.SlashCommands" Version="5.0.0-nightly-02374" />
<PackageReference Include="DSharpPlus" Version="5.0.0-nightly-02416" />
<PackageReference Include="DSharpPlus.CommandsNext" Version="5.0.0-nightly-02416" />
<PackageReference Include="DSharpPlus.SlashCommands" Version="5.0.0-nightly-02416" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="9.0.0" />
Expand Down
6 changes: 3 additions & 3 deletions Commands/Bans.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public async Task MassBanCmd(CommandContext ctx, [RemainingText] string input)
[Command("ban")]
[Aliases("tempban", "bonk", "isekaitruck")]
[Description("Bans a user that you have permission to ban, deleting all their messages in the process. See also: bankeep.")]
[HomeServer, RequireHomeserverPerm(ServerPermLevel.Moderator), RequirePermissions(DiscordPermissions.BanMembers)]
[HomeServer, RequireHomeserverPerm(ServerPermLevel.Moderator), RequirePermissions(permissions: DiscordPermission.BanMembers)]
public async Task BanCmd(CommandContext ctx,
[Description("The user you wish to ban. Accepts many formats")] DiscordUser targetMember,
[RemainingText, Description("The time and reason for the ban. e.g. '14d trolling' NOTE: Add 'appeal' to the start of the reason to include an appeal link")] string timeAndReason = "No reason specified.")
Expand Down Expand Up @@ -134,7 +134,7 @@ public async Task BanCmd(CommandContext ctx,
/// Sue me, I beg you.
[Command("bankeep")]
[Aliases("bansave")]
[Description("Bans a user but keeps their messages around."), HomeServer, RequireHomeserverPerm(ServerPermLevel.Moderator), RequirePermissions(DiscordPermissions.BanMembers)]
[Description("Bans a user but keeps their messages around."), HomeServer, RequireHomeserverPerm(ServerPermLevel.Moderator), RequirePermissions(permissions: DiscordPermission.BanMembers)]
public async Task BankeepCmd(CommandContext ctx,
[Description("The user you wish to ban. Accepts many formats")] DiscordUser targetMember,
[RemainingText, Description("The time and reason for the ban. e.g. '14d trolling' NOTE: Add 'appeal' to the start of the reason to include an appeal link")] string timeAndReason = "No reason specified.")
Expand Down Expand Up @@ -216,7 +216,7 @@ public async Task BankeepCmd(CommandContext ctx,

[Command("unban")]
[Description("Unbans a user who has been previously banned.")]
[HomeServer, RequireHomeserverPerm(ServerPermLevel.Moderator), RequirePermissions(DiscordPermissions.BanMembers)]
[HomeServer, RequireHomeserverPerm(ServerPermLevel.Moderator), RequirePermissions(permissions: DiscordPermission.BanMembers)]
public async Task UnbanCmd(CommandContext ctx, [Description("The user to unban, usually a mention or ID")] DiscordUser targetUser, [Description("Used in audit log only currently")] string reason = "No reason specified.")
{
if ((await Program.db.HashExistsAsync("bans", targetUser.Id)))
Expand Down
4 changes: 2 additions & 2 deletions Commands/Debug.cs
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,8 @@ public async Task Add(CommandContext ctx,
[Description("Denied permissions. Use a permission integer. See https://discordlookup.com/permissions-calculator.")] int deniedPermissions)
{
// Confirm permission overrides before we do anything.
var parsedAllowedPerms = (DiscordPermissions)allowedPermissions;
var parsedDeniedPerms = (DiscordPermissions)deniedPermissions;
var parsedAllowedPerms = (DiscordPermission)allowedPermissions;
var parsedDeniedPerms = (DiscordPermission)deniedPermissions;

var confirmButton = new DiscordButtonComponent(DiscordButtonStyle.Success, "debug-overrides-add-confirm-callback", "Yes");
var cancelButton = new DiscordButtonComponent(DiscordButtonStyle.Danger, "debug-overrides-add-cancel-callback", "No");
Expand Down
2 changes: 1 addition & 1 deletion Commands/InteractionCommands/AnnouncementInteractions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ internal class AnnouncementInteractions : ApplicationCommandModule
{
[SlashCommand("announcebuild", "Announce a Windows Insider build in the current channel.", defaultPermission: false)]
[SlashRequireHomeserverPerm(ServerPermLevel.TrialModerator)]
[SlashCommandPermissions(DiscordPermissions.ModerateMembers)]
[SlashCommandPermissions(permissions: DiscordPermission.ModerateMembers)]
public async Task AnnounceBuildSlashCommand(InteractionContext ctx,
[Choice("Windows 10", 10)]
[Choice("Windows 11", 11)]
Expand Down
6 changes: 3 additions & 3 deletions Commands/InteractionCommands/BanInteractions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Cliptok.Commands.InteractionCommands
internal class BanInteractions : ApplicationCommandModule
{
[SlashCommand("ban", "Bans a user from the server, either permanently or temporarily.", defaultPermission: false)]
[SlashRequireHomeserverPerm(ServerPermLevel.Moderator), SlashCommandPermissions(DiscordPermissions.BanMembers)]
[SlashRequireHomeserverPerm(ServerPermLevel.Moderator), SlashCommandPermissions(permissions: DiscordPermission.BanMembers)]
public async Task BanSlashCommand(InteractionContext ctx,
[Option("user", "The user to ban")] DiscordUser user,
[Option("reason", "The reason the user is being banned")] string reason,
Expand Down Expand Up @@ -114,7 +114,7 @@ public async Task BanSlashCommand(InteractionContext ctx,
}

[SlashCommand("unban", "Unbans a user who has been previously banned.", defaultPermission: false)]
[SlashRequireHomeserverPerm(ServerPermLevel.Moderator), SlashCommandPermissions(DiscordPermissions.BanMembers)]
[SlashRequireHomeserverPerm(ServerPermLevel.Moderator), SlashCommandPermissions(permissions: DiscordPermission.BanMembers)]
public async Task SlashUnbanCommand(InteractionContext ctx, [Option("user", "The ID or mention of the user to unban. Ignore the suggestions, IDs work.")] SnowflakeObject userId, [Option("reason", "Used in audit log only currently")] string reason = "No reason specified.")
{
DiscordUser targetUser = default;
Expand Down Expand Up @@ -145,7 +145,7 @@ public async Task SlashUnbanCommand(InteractionContext ctx, [Option("user", "The
}

[SlashCommand("kick", "Kicks a user, removing them from the server until they rejoin.", defaultPermission: false)]
[SlashRequireHomeserverPerm(ServerPermLevel.Moderator), SlashCommandPermissions(DiscordPermissions.KickMembers)]
[SlashRequireHomeserverPerm(ServerPermLevel.Moderator), SlashCommandPermissions(permissions: DiscordPermission.KickMembers)]
public async Task KickCmd(InteractionContext ctx, [Option("user", "The user you want to kick from the server.")] DiscordUser target, [Option("reason", "The reason for kicking this user.")] string reason = "No reason specified.")
{
if (target.IsBot)
Expand Down
2 changes: 1 addition & 1 deletion Commands/InteractionCommands/ClearInteractions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public class ClearInteractions : ApplicationCommandModule
public static Dictionary<ulong, List<DiscordMessage>> MessagesToClear = new();

[SlashCommand("clear", "Delete many messages from the current channel.", defaultPermission: false)]
[HomeServer, SlashRequireHomeserverPerm(ServerPermLevel.TrialModerator), RequireBotPermissions(DiscordPermissions.ManageMessages), SlashCommandPermissions(DiscordPermissions.ModerateMembers)]
[HomeServer, SlashRequireHomeserverPerm(ServerPermLevel.TrialModerator), RequireBotPermissions(permissions: [DiscordPermission.ManageMessages, DiscordPermission.ModerateMembers])]
public async Task ClearSlashCommand(InteractionContext ctx,
[Option("count", "The number of messages to consider for deletion. Required if you don't use the 'up_to' argument.")] long count = 0,
[Option("up_to", "Optionally delete messages up to (not including) this one. Accepts IDs and links.")] string upTo = "",
Expand Down
2 changes: 1 addition & 1 deletion Commands/InteractionCommands/ContextCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public async Task ContextAvatar(ContextMenuContext ctx)
}

[ContextMenu(DiscordApplicationCommandType.UserContextMenu, "Show Notes", defaultPermission: false)]
[SlashRequireHomeserverPerm(ServerPermLevel.TrialModerator), SlashCommandPermissions(DiscordPermissions.ModerateMembers)]
[SlashRequireHomeserverPerm(ServerPermLevel.TrialModerator), SlashCommandPermissions(permissions: DiscordPermission.ModerateMembers)]
public async Task ShowNotes(ContextMenuContext ctx)
{
await ctx.RespondAsync(embed: await UserNoteHelpers.GenerateUserNotesEmbedAsync(ctx.TargetUser), ephemeral: true);
Expand Down
8 changes: 4 additions & 4 deletions Commands/InteractionCommands/DebugInteractions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ internal class DebugInteractions : ApplicationCommandModule
{
[SlashCommand("scamcheck", "Check if a link or message is known to the anti-phishing API.", defaultPermission: false)]
[Description("Check if a link or message is known to the anti-phishing API.")]
[SlashRequireHomeserverPerm(ServerPermLevel.TrialModerator), SlashCommandPermissions(DiscordPermissions.ModerateMembers)]
[SlashRequireHomeserverPerm(ServerPermLevel.TrialModerator), SlashCommandPermissions(permissions: DiscordPermission.ModerateMembers)]
public async Task ScamCheck(InteractionContext ctx, [Option("input", "Domain or message content to scan.")] string content)
{
var urlMatches = Constants.RegexConstants.url_rx.Matches(content);
Expand Down Expand Up @@ -35,7 +35,7 @@ public async Task ScamCheck(InteractionContext ctx, [Option("input", "Domain or
}

[SlashCommand("tellraw", "You know what you're here for.", defaultPermission: false)]
[SlashRequireHomeserverPerm(ServerPermLevel.Moderator), SlashCommandPermissions(DiscordPermissions.ModerateMembers)]
[SlashRequireHomeserverPerm(ServerPermLevel.Moderator), SlashCommandPermissions(permissions: DiscordPermission.ModerateMembers)]
public async Task TellRaw(InteractionContext ctx, [Option("input", "???")] string input, [Option("reply_msg_id", "ID of message to use in a reply context.")] string replyID = "0", [Option("pingreply", "Ping pong.")] bool pingreply = true, [Option("channel", "Either mention or ID. Not a name.")] string discordChannel = default)
{
DiscordChannel channelObj = default;
Expand Down Expand Up @@ -97,7 +97,7 @@ public async Task UserInfoSlashCommand(InteractionContext ctx, [Option("user", "

[SlashCommand("muteinfo", "Show information about the mute for a user.")]
[SlashRequireHomeserverPerm(ServerPermLevel.TrialModerator)]
[SlashCommandPermissions(DiscordPermissions.ModerateMembers)]
[SlashCommandPermissions(permissions: DiscordPermission.ModerateMembers)]
public async Task MuteInfoSlashCommand(
InteractionContext ctx,
[Option("user", "The user whose mute information to show.")] DiscordUser targetUser,
Expand All @@ -108,7 +108,7 @@ public async Task MuteInfoSlashCommand(

[SlashCommand("baninfo", "Show information about the ban for a user.")]
[SlashRequireHomeserverPerm(ServerPermLevel.TrialModerator)]
[SlashCommandPermissions(DiscordPermissions.ModerateMembers)]
[SlashCommandPermissions(permissions: DiscordPermission.ModerateMembers)]
public async Task BanInfoSlashCommand(
InteractionContext ctx,
[Option("user", "The user whose ban information to show.")] DiscordUser targetUser,
Expand Down
4 changes: 2 additions & 2 deletions Commands/InteractionCommands/DehoistInteractions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
internal class DehoistInteractions : ApplicationCommandModule
{
[SlashCommand("dehoist", "Dehoist a member, dropping them to the bottom of the list. Lasts until they change nickname.", defaultPermission: false)]
[SlashRequireHomeserverPerm(ServerPermLevel.Moderator), SlashCommandPermissions(DiscordPermissions.ManageNicknames)]
[SlashRequireHomeserverPerm(ServerPermLevel.Moderator), SlashCommandPermissions(permissions: DiscordPermission.ManageNicknames)]
public async Task DehoistSlashCmd(InteractionContext ctx, [Option("member", "The member to dehoist.")] DiscordUser user)
{
DiscordMember member;
Expand Down Expand Up @@ -39,7 +39,7 @@ await member.ModifyAsync(a =>
}

[SlashCommandGroup("permadehoist", "Permanently/persistently dehoist members.", defaultPermission: false)]
[SlashRequireHomeserverPerm(ServerPermLevel.TrialModerator), SlashCommandPermissions(DiscordPermissions.ManageNicknames)]
[SlashRequireHomeserverPerm(ServerPermLevel.TrialModerator), SlashCommandPermissions(permissions: DiscordPermission.ManageNicknames)]
public class PermadehoistSlashCommands
{
[SlashCommand("enable", "Permanently dehoist a member. They will be automatically dehoisted until disabled.")]
Expand Down
4 changes: 2 additions & 2 deletions Commands/InteractionCommands/LockdownInteractions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class LockdownInteractions : ApplicationCommandModule
public static bool ongoingLockdown = false;

[SlashCommandGroup("lockdown", "Lock the current channel or all channels in the server, preventing new messages. See also: unlock")]
[HomeServer, SlashRequireHomeserverPerm(ServerPermLevel.Moderator), RequireBotPermissions(DiscordPermissions.ManageChannels)]
[HomeServer, SlashRequireHomeserverPerm(ServerPermLevel.Moderator), RequireBotPermissions(permissions: DiscordPermission.ManageChannels)]
public class LockdownCmds
{
[SlashCommand("channel", "Lock the current channel. See also: unlock channel")]
Expand Down Expand Up @@ -103,7 +103,7 @@ public async Task LockdownAllCommand(
}

[SlashCommandGroup("unlock", "Unlock the current channel or all channels in the server, allowing new messages. See also: lockdown")]
[HomeServer, SlashRequireHomeserverPerm(ServerPermLevel.Moderator), RequireBotPermissions(DiscordPermissions.ManageChannels)]
[HomeServer, SlashRequireHomeserverPerm(ServerPermLevel.Moderator), RequireBotPermissions(permissions: DiscordPermission.ManageChannels)]
public class UnlockCmds
{
[SlashCommand("channel", "Unlock the current channel. See also: lockdown")]
Expand Down
4 changes: 2 additions & 2 deletions Commands/InteractionCommands/MuteInteractions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ internal class MuteInteractions : ApplicationCommandModule
{
[SlashCommand("mute", "Mute a user, temporarily or permanently.")]
[SlashRequireHomeserverPerm(ServerPermLevel.TrialModerator)]
[SlashCommandPermissions(DiscordPermissions.ModerateMembers)]
[SlashCommandPermissions(permissions: DiscordPermission.ModerateMembers)]
public async Task MuteSlashCommand(
InteractionContext ctx,
[Option("user", "The user you wish to mute.")] DiscordUser targetUser,
Expand Down Expand Up @@ -50,7 +50,7 @@ public async Task MuteSlashCommand(

[SlashCommand("unmute", "Unmute a user.")]
[SlashRequireHomeserverPerm(ServerPermLevel.TrialModerator)]
[SlashCommandPermissions(DiscordPermissions.ModerateMembers)]
[SlashCommandPermissions(permissions: DiscordPermission.ModerateMembers)]
public async Task UnmuteSlashCommand(
InteractionContext ctx,
[Option("user", "The user you wish to mute.")] DiscordUser targetUser,
Expand Down
2 changes: 1 addition & 1 deletion Commands/InteractionCommands/NicknameLockInteraction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Cliptok.Commands.InteractionCommands
public class NicknameLockInteraction : ApplicationCommandModule
{
[SlashCommandGroup("nicknamelock", "Prevent a member from changing their nickname.", defaultPermission: false)]
[SlashRequireHomeserverPerm(ServerPermLevel.TrialModerator), SlashCommandPermissions(DiscordPermissions.ManageNicknames)]
[SlashRequireHomeserverPerm(ServerPermLevel.TrialModerator), SlashCommandPermissions(permissions: DiscordPermission.ManageNicknames)]
public class NicknameLockSlashCommands
{
[SlashCommand("enable", "Prevent a member from changing their nickname.")]
Expand Down
2 changes: 1 addition & 1 deletion Commands/InteractionCommands/RaidmodeInteractions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ internal class RaidmodeInteractions : ApplicationCommandModule
{
[SlashCommandGroup("raidmode", "Commands relating to Raidmode", defaultPermission: false)]
[SlashRequireHomeserverPerm(ServerPermLevel.Moderator)]
[SlashCommandPermissions(DiscordPermissions.ModerateMembers)]
[SlashCommandPermissions(permissions: DiscordPermission.ModerateMembers)]
public class RaidmodeSlashCommands : ApplicationCommandModule
{
[SlashCommand("status", "Check the current state of raidmode.")]
Expand Down
2 changes: 1 addition & 1 deletion Commands/InteractionCommands/RoleInteractions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
internal class RoleInteractions : ApplicationCommandModule
{
[SlashCommand("grant", "Grant a user Tier 1, bypassing any verification requirements.", defaultPermission: false)]
[SlashRequireHomeserverPerm(ServerPermLevel.TrialModerator), SlashCommandPermissions(DiscordPermissions.ModerateMembers)]
[SlashRequireHomeserverPerm(ServerPermLevel.TrialModerator), SlashCommandPermissions(permissions: DiscordPermission.ModerateMembers)]
public async Task SlashGrant(InteractionContext ctx, [Option("user", "The user to grant Tier 1 to.")] DiscordUser _)
{
await ctx.RespondAsync($"{Program.cfgjson.Emoji.Error} This command is deprecated and no longer works. Please right click (or tap and hold on mobile) the user and click \"Verify Member\" if available.");
Expand Down
4 changes: 2 additions & 2 deletions Commands/InteractionCommands/SecurityActionInteractions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace Cliptok.Commands.InteractionCommands
public class SecurityActionInteractions : ApplicationCommandModule
{
[SlashCommand("pausedms", "Temporarily pause DMs between server members.", defaultPermission: false)]
[HomeServer, SlashRequireHomeserverPerm(ServerPermLevel.Moderator), SlashCommandPermissions(DiscordPermissions.ModerateMembers)]
[HomeServer, SlashRequireHomeserverPerm(ServerPermLevel.Moderator), SlashCommandPermissions(permissions: DiscordPermission.ModerateMembers)]
public async Task SlashPauseDMs(InteractionContext ctx, [Option("time", "The amount of time to pause DMs for. Cannot be greater than 24 hours.")] string time)
{
// need to make our own api calls because D#+ can't do this natively?
Expand Down Expand Up @@ -51,7 +51,7 @@ public async Task SlashPauseDMs(InteractionContext ctx, [Option("time", "The amo
}

[SlashCommand("unpausedms", "Unpause DMs between server members.", defaultPermission: false)]
[HomeServer, SlashRequireHomeserverPerm(ServerPermLevel.Moderator), SlashCommandPermissions(DiscordPermissions.ModerateMembers)]
[HomeServer, SlashRequireHomeserverPerm(ServerPermLevel.Moderator), SlashCommandPermissions(permissions: DiscordPermission.ModerateMembers)]
public async Task SlashUnpauseDMs(InteractionContext ctx)
{
// need to make our own api calls because D#+ can't do this natively?
Expand Down
2 changes: 1 addition & 1 deletion Commands/InteractionCommands/SlowmodeInteractions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ internal class SlowmodeInteractions : ApplicationCommandModule
{
[SlashCommand("slowmode", "Slow down the channel...", defaultPermission: false)]
[SlashRequireHomeserverPerm(ServerPermLevel.TrialModerator)]
[SlashCommandPermissions(DiscordPermissions.ModerateMembers)]
[SlashCommandPermissions(permissions: DiscordPermission.ModerateMembers)]
public async Task SlowmodeSlashCommand(
InteractionContext ctx,
[Option("slow_time", "Allowed time between each users messages. 0 for off. A number of seconds or a parseable time.")] string timeToParse,
Expand Down
2 changes: 1 addition & 1 deletion Commands/InteractionCommands/StatusInteractions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ internal class StatusInteractions : ApplicationCommandModule
{
[SlashCommandGroup("status", "Status commands")]
[SlashRequireHomeserverPerm(ServerPermLevel.TrialModerator)]
[SlashCommandPermissions(DiscordPermissions.ModerateMembers)]
[SlashCommandPermissions(permissions: DiscordPermission.ModerateMembers)]

public class StatusSlashCommands
{
Expand Down
Loading

0 comments on commit 57f6a37

Please sign in to comment.