diff --git a/commands.go b/commands.go index ac98f32..0603eb4 100644 --- a/commands.go +++ b/commands.go @@ -7,6 +7,8 @@ import ( "github.com/bwmarrin/discordgo" ) +var gitCommit string + func ping(session *discordgo.Session, interaction *discordgo.InteractionCreate) { session.InteractionRespond(interaction.Interaction, &discordgo.InteractionResponse{ Type: discordgo.InteractionResponseChannelMessageWithSource, @@ -45,3 +47,20 @@ func slowping(session *discordgo.Session, interaction *discordgo.InteractionCrea log.Println(err) } } + +func version(session *discordgo.Session, interaction *discordgo.InteractionCreate) { + var response string + if gitCommit == "" { + response = "Commit string not defined." + } else { + response = gitCommit + } + session.InteractionRespond(interaction.Interaction, &discordgo.InteractionResponse{ + Type: discordgo.InteractionResponseChannelMessageWithSource, + Data: &discordgo.InteractionResponseData{ + Flags: 1 << 6, // Only lets issuer see initial response + Content: response, + }, + }) +} + diff --git a/main.go b/main.go index 1c3b48a..e255468 100644 --- a/main.go +++ b/main.go @@ -38,11 +38,16 @@ func main() { Name: "slowping", Description: "Hopefully replies with pong 10 seconds later or else I'll be sad.", }, + { + Name: "version", + Description: "Gets the bot's current version.", + }, } commandHandlers = map[string]func(s *discordgo.Session, i *discordgo.InteractionCreate) { "ping": ping, "sping": sping, "slowping": slowping, + "version": version, } )