From 662760b03702c709abfe9e0173089b5375c4114b Mon Sep 17 00:00:00 2001 From: Vegard Berg Date: Mon, 30 Sep 2024 21:00:52 +0200 Subject: [PATCH 1/2] chore(gatekeep): Use command contexts --- commands/gatekeep.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/commands/gatekeep.go b/commands/gatekeep.go index f418ba4..193e2fb 100644 --- a/commands/gatekeep.go +++ b/commands/gatekeep.go @@ -18,14 +18,18 @@ import ( var ApproveUserCommand = discord.UserCommandCreate{ Name: "Approve", DefaultMemberPermissions: json.NewNullablePtr(discord.PermissionKickMembers), - DMPermission: utils.Ref(false), + Contexts: []discord.InteractionContextType{ + discord.InteractionContextTypeGuild, + }, } var ApproveSlashCommand = discord.SlashCommandCreate{ Name: "approve", Description: "Approve a user to join the server", DefaultMemberPermissions: json.NewNullablePtr(discord.PermissionKickMembers), - DMPermission: utils.Ref(false), + Contexts: []discord.InteractionContextType{ + discord.InteractionContextTypeGuild, + }, Options: []discord.ApplicationCommandOption{ discord.ApplicationCommandOptionUser{ From 2d3e7bfdd6ced1e2acb3af24c6a32c465cd521e7 Mon Sep 17 00:00:00 2001 From: Vegard Berg Date: Mon, 30 Sep 2024 21:04:16 +0200 Subject: [PATCH 2/2] feat: sanity check - log if guild ID is nil. --- commands/gatekeep.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/commands/gatekeep.go b/commands/gatekeep.go index 193e2fb..877b2c7 100644 --- a/commands/gatekeep.go +++ b/commands/gatekeep.go @@ -45,7 +45,8 @@ func ApproveUserCommandHandler(e *handler.CommandEvent) error { guild, inGuild := e.Guild() if !inGuild { - slog.Warn("Approve command supplied in DMs or guild ID is otherwise nil") + slog.Warn("Approve command supplied in DMs or guild ID is otherwise nil", + "guild_id_is_nil", e.GuildID() == nil) return nil } member := e.UserCommandInteractionData().TargetMember() @@ -58,7 +59,8 @@ func ApproveSlashCommandHandler(e *handler.CommandEvent) error { guild, inGuild := e.Guild() if !inGuild { - slog.Warn("Approve command supplied in DMs or guild ID is otherwise nil") + slog.Warn("Approve command supplied in DMs or guild ID is otherwise nil", + "guild_id_is_nil", e.GuildID() == nil) return nil } member := e.SlashCommandInteractionData().Member("user")