This my code
var GuildID = flag.String("guild", "", "Test guild ID. If not passed - bot registers commands globally")
func init() { flag.Parse() }
func DiscordHandler() {
dg, err := discordgo.New("Bot " + DISCORD)
if err != nil {
fmt.Println("Error creating Discord session,", err)
return
}
dg.AddHandler(func(s *discordgo.Session, i *discordgo.InteractionCreate) {
if i.Type == discordgo.InteractionApplicationCommand {
switch i.ApplicationCommandData().Name {
case "hello":
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
Type: discordgo.InteractionResponseChannelMessageWithSource,
Data: &discordgo.InteractionResponseData{
Content: "HELLO",
},
})
}
}
})
dg.AddHandler(func(s *discordgo.Session, m *discordgo.MessageCreate) {
SendMessages(s, m)
})
dg.Identify.Intents = discordgo.IntentsAllWithoutPrivileged
err = dg.Open()
if err != nil {
fmt.Println("Error opening connection,", err)
return
}
defer dg.Close()
fmt.Println("AetherAI is online")
sc := make(chan os.Signal, 1)
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt)
<-sc
}