Added version command
This commit is contained in:
parent
369bca9547
commit
6d4cd79940
2 changed files with 24 additions and 0 deletions
19
commands.go
19
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,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
|
|
5
main.go
5
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,
|
||||
}
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue