package main import ( "fmt" "os" "os/signal" "github.com/bwmarrin/discordgo" ) func main() { //discordServerId := os.Getenv("DISCORD_SERVER_ID") //discordChannelId := os.Getenv("DISCORD_CHANNEL_ID") //discordWaintingRoleId := os.Getenv("DISCORD_WAITING_ROLE_ID") discordToken := os.Getenv("DISCORD_TOKEN") discord, err := discordgo.New("Bot " + discordToken) if err != nil { panic(err) } discord.AddHandler(func(s *discordgo.Session, r *discordgo.Ready) { fmt.Println("Bot is now running. Press CTRL+C to exit.") }) discord.AddHandler(func(s *discordgo.Session, i *discordgo.InteractionCreate) { if i.Type == discordgo.InteractionApplicationCommand { switch i.ApplicationCommandData().Name { case "addwait": // Handle addwait command s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{ Type: discordgo.InteractionResponseChannelMessageWithSource, Data: &discordgo.InteractionResponseData{ Content: "User added to waiting list.", }, }) } } }) openErr := discord.Open() if openErr != nil { panic(openErr) } // define command to wait discord.ApplicationCommandCreate(discord.State.User.ID, "", &discordgo.ApplicationCommand{ Name: "addwait", Description: "Add a user to the waiting list", Options: []*discordgo.ApplicationCommandOption{ { Type: discordgo.ApplicationCommandOptionUser, Name: "user", Description: "The user to add to the waiting list", Required: true, }, }, }) stop := make(chan os.Signal, 1) signal.Notify(stop, os.Interrupt) fmt.Println("Press Ctrl+C to exit") <-stop // add role to user /* err2 := discord.GuildMemberRoleAdd(discordServerId, "316091695941025793", discordWaintingRoleId) if err2 != nil { panic(err2) } */ }