EngiBot/commands.go

67 lines
2.1 KiB
Go
Raw Normal View History

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