Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/use command contexts #28

Merged
merged 2 commits into from
Sep 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions commands/gatekeep.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -41,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()
Expand All @@ -54,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")
Expand Down