Packages
DIR | SlashCommands
File | ping.go
File | main.gopackage SlashCommands
import (
"github.com/bwmarrin/discordgo"
)
func Ping(s *discordgo.Session, i *discordgo.InteractionCreate) {
// send ping
}
Last updated
DIR | SlashCommands
File | ping.go
File | main.gopackage SlashCommands
import (
"github.com/bwmarrin/discordgo"
)
func Ping(s *discordgo.Session, i *discordgo.InteractionCreate) {
// send ping
}
Last updated
package main
import "github.com/bwmarrin/discordgo"
import "MyBot/SlashCommands"
func main() {
dg, err := discordgo.New("Bot <your-discord-bot-token>")
if err != nil {
fmt.Println("error creating Discord session,", err)
return
}
// we add interaction create handler and use Ping function from ping.go
s.AddHandler(func(s *discordgo.Session, i *discordgo.InteractionCreate) {
SlashCommands.Ping(s,i);
})
err = dg.Open()
if err != nil {
fmt.Println("error opening connection,", err)
return
}
fmt.Println("Bot is now running. Press CTRL-C to exit.")
stop := make(chan os.Signal, 1)
signal.Notify(stop, syscall.SIGINT, syscall.SIGTERM, os.Interrupt)
<-sc
}