Add /manifesto Discord command

This commit is contained in:
Ben Visness 2023-01-22 09:38:14 -06:00
parent 348feff4cf
commit 9e27835e51
1 changed files with 18 additions and 0 deletions

View File

@ -18,6 +18,7 @@ const SlashCommandProfile = "profile"
const ProfileOptionUser = "user" const ProfileOptionUser = "user"
const SlashCommandWishlist = "wishlist" const SlashCommandWishlist = "wishlist"
const SlashCommandManifesto = "manifesto"
// User command names // User command names
const UserCommandProfile = "HMN Profile" const UserCommandProfile = "HMN Profile"
@ -54,6 +55,12 @@ func (bot *botInstance) createApplicationCommands(ctx context.Context) {
Name: SlashCommandWishlist, Name: SlashCommandWishlist,
Description: "Check out the Handmade Network wishlist", Description: "Check out the Handmade Network wishlist",
})) }))
doOrWarn(CreateGuildApplicationCommand(ctx, CreateGuildApplicationCommandRequest{
Type: ApplicationCommandTypeChatInput,
Name: SlashCommandManifesto,
Description: "Read the Handmade manifesto",
}))
} }
func (bot *botInstance) doInteraction(ctx context.Context, i *Interaction) { func (bot *botInstance) doInteraction(ctx context.Context, i *Interaction) {
@ -87,6 +94,17 @@ func (bot *botInstance) doInteraction(ctx context.Context, i *Interaction) {
if err != nil { if err != nil {
logging.ExtractLogger(ctx).Error().Err(err).Msg("failed to send wishlist response") logging.ExtractLogger(ctx).Error().Err(err).Msg("failed to send wishlist response")
} }
case SlashCommandManifesto:
err := CreateInteractionResponse(ctx, i.ID, i.Token, InteractionResponse{
Type: InteractionCallbackTypeChannelMessageWithSource,
Data: &InteractionCallbackData{
Content: "Read the Handmade manifesto at https://handmade.network/manifesto",
Flags: FlagEphemeral,
},
})
if err != nil {
logging.ExtractLogger(ctx).Error().Err(err).Msg("failed to send manifesto response")
}
default: default:
logging.ExtractLogger(ctx).Warn().Str("name", i.Data.Name).Msg("didn't recognize Discord interaction name") logging.ExtractLogger(ctx).Warn().Str("name", i.Data.Name).Msg("didn't recognize Discord interaction name")
} }