EngiBot/commands.go

66 lines
2.1 KiB
Go

package main
import (
"log"
"time"
"github.com/bwmarrin/discordgo"
)
var gitCommit string
func ping(session *discordgo.Session, interaction *discordgo.InteractionCreate) {
session.InteractionRespond(interaction.Interaction, &discordgo.InteractionResponse{
Type: discordgo.InteractionResponseChannelMessageWithSource,
Data: &discordgo.InteractionResponseData{
//Flags: 1 << 6, // Only lets issuer see initial response
Content: "Pong!",
},
})
}
func sping(session *discordgo.Session, interaction *discordgo.InteractionCreate) {
session.InteractionRespond(interaction.Interaction, &discordgo.InteractionResponse{
Type: discordgo.InteractionResponseChannelMessageWithSource,
Data: &discordgo.InteractionResponseData{
Flags: 1 << 6, // Only lets issuer see initial response
Content: "Pong!",
},
})
}
func slowping(session *discordgo.Session, interaction *discordgo.InteractionCreate) {
session.InteractionRespond(interaction.Interaction, &discordgo.InteractionResponse{
Type: discordgo.InteractionResponseChannelMessageWithSource,
Data: &discordgo.InteractionResponseData{
//Flags: 1 << 6, // Only lets issuer see initial response
Content: "...",
},
})
time.Sleep(10 * time.Second)
_, err := session.FollowupMessageCreate(interaction.Interaction, true, &discordgo.WebhookParams{
Content: "Pong!",
})
if err != nil {
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,
},
})
}