Skip to content

Commit

Permalink
Retarget to .NET 9 and upgrade DSharpPlus to 5.0.0-nightly-02428
Browse files Browse the repository at this point in the history
  • Loading branch information
FloatingMilkshake committed Dec 13, 2024
1 parent 914889a commit fd2f473
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 36 deletions.
4 changes: 2 additions & 2 deletions Commands/BanCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public class BanCommands
{
[Command("ban")]
[Description("Ban a user. They will not be able to rejoin unless unbanned.")]
[RequirePermissions(DiscordPermissions.BanMembers)]
[RequirePermissions(DiscordPermission.BanMembers)]
public static async Task BanCommand(SlashCommandContext ctx,
[Parameter("user"), Description("The user to ban.")] DiscordUser userToBan,
[Parameter("reason"), Description("The reason for the ban.")] [MinMaxLength(maxLength: 1500)]
Expand Down Expand Up @@ -40,7 +40,7 @@ await ctx.FollowupAsync(new DiscordFollowupMessageBuilder()

[Command("unban")]
[Description("Unban a user.")]
[RequirePermissions(DiscordPermissions.BanMembers)]
[RequirePermissions(DiscordPermission.BanMembers)]
public static async Task UnbanCommand(SlashCommandContext ctx,
[Parameter("user"), Description("The user to unban.")] DiscordUser userToUnban)
{
Expand Down
2 changes: 1 addition & 1 deletion Commands/Clear.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public partial class Clear

[Command("clear")]
[Description("Delete many messages from the current channel.")]
[RequirePermissions(DiscordPermissions.ManageMessages)]
[RequirePermissions(DiscordPermission.ManageMessages)]
public static async Task ClearCommand(SlashCommandContext ctx,
[Parameter("count"), Description("The number of messages to consider for deletion. Required if you don't use the 'up_to' argument.")]
long count = 0,
Expand Down
2 changes: 1 addition & 1 deletion Commands/Kick.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public class Kick
{
[Command("kick")]
[Description("Kick a user. They can rejoin the server with an invite.")]
[RequirePermissions(DiscordPermissions.KickMembers)]
[RequirePermissions(DiscordPermission.KickMembers)]
public static async Task KickCommand(SlashCommandContext ctx,
[Parameter("user"), Description("The user to kick.")] DiscordUser userToKick,
[Parameter("reason"), Description("The reason for the kick.")] [MinMaxLength(maxLength: 1500)]
Expand Down
22 changes: 11 additions & 11 deletions Commands/LockdownCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[Command("lockdown")]
[Description("Lock or unlock a channel.")]
[RequireGuild]
[RequirePermissions(DiscordPermissions.ManageChannels, DiscordPermissions.ModerateMembers)]
[RequirePermissions(DiscordPermission.ManageChannels, DiscordPermission.ModerateMembers)]
public class Lockdown
{
[Command("lock")]
Expand All @@ -21,29 +21,29 @@ public static async Task Lock(SlashCommandContext ctx)
// Add initial overwrites for failsafes (bot & user who called /lockdown), deny everyone else Send Messages
if (invokerExistingAllowedOverwrites is null)
{
await ctx.Channel.AddOverwriteAsync(ctx.Member, DiscordPermissions.SendMessages, DiscordPermissions.None,
await ctx.Channel.AddOverwriteAsync(ctx.Member, DiscordPermission.SendMessages, DiscordPermissions.None,
"Failsafe for lockdown");
}
else
{
await ctx.Channel.AddOverwriteAsync(ctx.Member,
invokerExistingAllowedOverwrites.Allowed | DiscordPermissions.SendMessages,
invokerExistingAllowedOverwrites.Allowed | DiscordPermission.SendMessages,
invokerExistingAllowedOverwrites.Denied, "Failsafe for lockdown");
}

if (botAllowedOverwrites is null)
{
await ctx.Channel.AddOverwriteAsync(await ctx.Guild.GetMemberAsync(ctx.Client.CurrentUser.Id),
DiscordPermissions.SendMessages, DiscordPermissions.None, "Failsafe for lockdown");
DiscordPermission.SendMessages, DiscordPermissions.None, "Failsafe for lockdown");
}
else
{
await ctx.Channel.AddOverwriteAsync(await ctx.Guild.GetMemberAsync(ctx.Client.CurrentUser.Id),
botAllowedOverwrites.Allowed | DiscordPermissions.SendMessages, botAllowedOverwrites.Denied,
botAllowedOverwrites.Allowed | DiscordPermission.SendMessages, botAllowedOverwrites.Denied,
"Failsafe for lockdown");
}

await ctx.Channel.AddOverwriteAsync(ctx.Guild.EveryoneRole, DiscordPermissions.None, DiscordPermissions.SendMessages,
await ctx.Channel.AddOverwriteAsync(ctx.Guild.EveryoneRole, DiscordPermissions.None, DiscordPermission.SendMessages,
"Lockdown");

// Restore overwrites that may have been present before the lockdown
Expand All @@ -53,7 +53,7 @@ await ctx.Channel.AddOverwriteAsync(ctx.Guild.EveryoneRole, DiscordPermissions.N
{
if (await overwrite.GetRoleAsync() == ctx.Guild.EveryoneRole)
await ctx.Channel.AddOverwriteAsync(await overwrite.GetRoleAsync(), overwrite.Allowed,
DiscordPermissions.SendMessages | overwrite.Denied,
DiscordPermission.SendMessages | overwrite.Denied,
"Restoring previous overrides for lockdown");
else
await ctx.Channel.AddOverwriteAsync(await overwrite.GetRoleAsync(), overwrite.Allowed,
Expand Down Expand Up @@ -89,7 +89,7 @@ public static async Task Unlock(SlashCommandContext ctx)
// Checking <2 because there will always be 1 overwrite for @everyone permissions
if (ctx.Channel.PermissionOverwrites.ToArray().Length < 2
|| ctx.Channel.PermissionOverwrites.Any(o => o.Id == ctx.Guild.EveryoneRole.Id &&
!o.Denied.HasPermission(DiscordPermissions.SendMessages)))
!o.Denied.HasPermission(DiscordPermission.SendMessages)))
{
await ctx.FollowupAsync(new DiscordFollowupMessageBuilder()
.WithContent("This channel is not locked!").AsEphemeral());
Expand All @@ -106,7 +106,7 @@ await ctx.FollowupAsync(new DiscordFollowupMessageBuilder()
DiscordOverwriteBuilder newOverwrite = new(ctx.Guild.EveryoneRole)
{
Allowed = permission.Allowed,
Denied = (DiscordPermissions)(permission.Denied - DiscordPermissions.SendMessages)
Denied = (DiscordPermissions)(permission.Denied - DiscordPermission.SendMessages)
};

await ctx.Channel.AddOverwriteAsync(ctx.Guild.EveryoneRole, newOverwrite.Allowed,
Expand All @@ -115,12 +115,12 @@ await ctx.Channel.AddOverwriteAsync(ctx.Guild.EveryoneRole, newOverwrite.Allowed
else
{
// Filter to user overrides that have Send Messages allowed (failsafes) so we can remove
if (!permission.Allowed.HasPermission(DiscordPermissions.SendMessages)) continue;
if (!permission.Allowed.HasPermission(DiscordPermission.SendMessages)) continue;

// Remove failsafe Send Message overrides
DiscordOverwriteBuilder newOverwrite = new(await permission.GetMemberAsync())
{
Allowed = (DiscordPermissions)(permission.Allowed - DiscordPermissions.SendMessages),
Allowed = (DiscordPermissions)(permission.Allowed - DiscordPermission.SendMessages),
Denied = permission.Denied
};

Expand Down
2 changes: 1 addition & 1 deletion Commands/Nickname.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public class Nickname
{
[Command("nickname")]
[Description("Changes my nickname.")]
[RequirePermissions(DiscordPermissions.ChangeNickname, DiscordPermissions.ManageNicknames)]
[RequirePermissions(DiscordPermission.ChangeNickname, DiscordPermission.ManageNicknames)]
public static async Task NicknameCommand(SlashCommandContext ctx,
[Parameter("nickname"), Description("What to change my nickname to. Leave this blank to clear it.")] [MinMaxLength(maxLength: 32)]
string nickname = null)
Expand Down
2 changes: 1 addition & 1 deletion Commands/TimeoutCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[Command("timeout")]
[Description("Set or clear a timeout for a user.")]
[RequirePermissions(DiscordPermissions.ModerateMembers)]
[RequirePermissions(DiscordPermission.ModerateMembers)]
[RequireGuild]
public class TimeoutCmds
{
Expand Down
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
FROM --platform=${BUILDPLATFORM} \
mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build-env
FROM --platform=${BUILDPLATFORM} mcr.microsoft.com/dotnet/sdk:9.0-alpine AS build-env
WORKDIR /app
COPY *.csproj ./
RUN dotnet restore
COPY . ./
RUN dotnet build -c Release -o out
FROM mcr.microsoft.com/dotnet/runtime:8.0-alpine
FROM mcr.microsoft.com/dotnet/runtime:9.0-alpine
LABEL com.centurylinklabs.watchtower.enable="true"
WORKDIR /app
COPY --from=build-env /app/out .
Expand Down
2 changes: 1 addition & 1 deletion Events/ErrorEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ await e.Context.RespondAsync(
// Check if bot has perms to send error response and send if so
if (e.Context.Channel
.PermissionsFor(await e.Context.Guild.GetMemberAsync(e.Context.Client.CurrentUser.Id))
.HasPermission(DiscordPermissions.SendMessages))
.HasPermission(DiscordPermission.SendMessages))
await e.Context.RespondAsync(embed.Build()).ConfigureAwait(false);
}

Expand Down
2 changes: 1 addition & 1 deletion Helpers/KeywordTrackingHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public static async Task KeywordCheck(DiscordMessage message, bool isEdit = fals
return;
}

if (!message.Channel.PermissionsFor(member).HasPermission(DiscordPermissions.AccessChannels) || !message.Channel.PermissionsFor(member).HasPermission(DiscordPermissions.ReadMessageHistory))
if (!message.Channel.PermissionsFor(member).HasPermission(DiscordPermission.ViewChannel) || !message.Channel.PermissionsFor(member).HasPermission(DiscordPermission.ReadMessageHistory))
break;

if (fieldValue.MatchWholeWord)
Expand Down
20 changes: 10 additions & 10 deletions Helpers/UserInfoHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,31 @@ public static Task<DiscordEmbed> GenerateUserInfoEmbed(DiscordMember member)
{
notablePerms.Add("Server Owner");
}
else if (member.Permissions.HasPermission(DiscordPermissions.Administrator))
else if (member.Permissions.HasPermission(DiscordPermission.Administrator))
{
notablePerms.Add("Administrator");
}
else
{
if (member.Permissions.HasPermission(DiscordPermissions.ManageChannels))
if (member.Permissions.HasPermission(DiscordPermission.ManageChannels))
notablePerms.Add("Manage Channels");
if (member.Permissions.HasPermission(DiscordPermissions.ManageEmojis))
if (member.Permissions.HasPermission(DiscordPermission.ManageGuildExpressions))
notablePerms.Add("Manage Emojis and Stickers");
if (member.Permissions.HasPermission(DiscordPermissions.ManageEvents))
if (member.Permissions.HasPermission(DiscordPermission.ManageEvents))
notablePerms.Add("Manage Events");
if (member.Permissions.HasPermission(DiscordPermissions.ManageGuild))
if (member.Permissions.HasPermission(DiscordPermission.ManageGuild))
notablePerms.Add("Manage Server");
if (member.Permissions.HasPermission(DiscordPermissions.ManageMessages))
if (member.Permissions.HasPermission(DiscordPermission.ManageMessages))
notablePerms.Add("Manage Messages");
if (member.Permissions.HasPermission(DiscordPermissions.ManageNicknames))
if (member.Permissions.HasPermission(DiscordPermission.ManageNicknames))
notablePerms.Add("Manage Nicknames");
if (member.Permissions.HasPermission(DiscordPermissions.ManageRoles))
if (member.Permissions.HasPermission(DiscordPermission.ManageRoles))
notablePerms.Add("Manage Roles");
if (member.Permissions.HasPermission(DiscordPermissions.ManageThreads))
if (member.Permissions.HasPermission(DiscordPermission.ManageThreads))
notablePerms.Add(member.Guild.Features.Contains("COMMUNITY")
? "Manage Threads and Posts"
: "Manage Threads");
if (member.Permissions.HasPermission(DiscordPermissions.ManageWebhooks))
if (member.Permissions.HasPermission(DiscordPermission.ManageWebhooks))
notablePerms.Add("Manage Webhooks");
}

Expand Down
8 changes: 4 additions & 4 deletions MechanicalMilkshake.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<InvariantGlobalization>false</InvariantGlobalization>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Abyssal.HumanDateParser" Version="2.0.0-20191113.1"/>
<PackageReference Include="DSharpPlus" Version="5.0.0-nightly-02383" />
<PackageReference Include="DSharpPlus.Commands" Version="5.0.0-nightly-02383" />
<PackageReference Include="DSharpPlus.Interactivity" Version="5.0.0-nightly-02383" />
<PackageReference Include="DSharpPlus" Version="5.0.0-nightly-02428" />
<PackageReference Include="DSharpPlus.Commands" Version="5.0.0-nightly-02428" />
<PackageReference Include="DSharpPlus.Interactivity" Version="5.0.0-nightly-02428" />
<PackageReference Include="Humanizer.Core" Version="3.0.0-beta.54" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.12.0-2.final" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.12.0-2.final" />
Expand Down

0 comments on commit fd2f473

Please sign in to comment.