package main import ( "flag" "fmt" "math/rand" "os" "os/signal" "syscall" "github.com/bwmarrin/discordgo" ) var ( GuildID = flag.String("guild", "283189284679450624", "Test guild ID. If not passed - bot registers commands globally") appID = flag.String("appid", "1205531854896369703", "Application ID") RemoveCommands = flag.Bool("rmcmd", true, "Remove all commands after shutdowning or not") ) func main() { //Token := "For Testing" Token := os.Getenv("ZENBOTTOKEN") session, err := discordgo.New("Bot " + Token) if err != nil { fmt.Println("error creating Discord session,", err) return } _, error := session.ApplicationCommandBulkOverwrite(*appID, *GuildID, []*discordgo.ApplicationCommand{ { Name: "zenmusic", Description: "Sends you a carefully curated song", }, }) if error != nil { return } //session.AddHandler(messageCreate) session.AddHandler(commandHandler) session.Identify.Intents = discordgo.IntentsGuildMessages err = session.Open() if err != nil { fmt.Println("error opening connection,", err) return } fmt.Println("Bot is now running. Press CTRL-C to exit.") sc := make(chan os.Signal, 1) signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt) <-sc session.Close() } func getRandomYouTubeLink() string { youtubeLinks := []string{ "https://www.youtube.com/watch?v=dQw4w9WgXcQ", //Rick Astley - Never Gonna Give You Up (Official Music Video) "https://www.youtube.com/watch?v=yO7MWuJ7zLA", //Takeo Ischi - New Bibi Hendl (Chicken Yodeling) 2011 "https://www.youtube.com/watch?v=7XzLbGssArQ", //Alexander Marcus - Papaya (Official Video) "https://www.youtube.com/watch?v=9CaA_5A_PKw", //Zur Party - Official Video [HD] "https://www.youtube.com/watch?v=PcRyjkYdDxM", //Konis Hupen "https://www.youtube.com/watch?v=SPERjzzf_wc", //Alexander Marcus - Elektriker (Official Video) "https://www.youtube.com/watch?v=OaSEGZ3Xe_E", //Lil Kleine & Ronnie Flex - Stoff & Schnaps (prod. Jack $hirak) (Official German Video) "https://www.youtube.com/watch?v=KolfEhV-KiA", //Emotional Titanic Flute "https://www.youtube.com/watch?v=l12Csc_lW0Q", //Chacarron Macarron "https://www.youtube.com/watch?v=i63cgUeSsY0", //LITTLE BIG - BIG D*CK "https://www.youtube.com/watch?v=iq_d8VSM0nw", //IceJJFish - On The Floor (Official Music Video) ThatRaw.com Presents "https://www.youtube.com/watch?v=4pXfHLUlZf4", //Jizz In My Pants "https://www.youtube.com/watch?v=Kppx4bzfAaE", //Rappin' for Jesus "https://www.youtube.com/watch?v=VfCYZ3pks48", //Sex Offender Shuffle "https://www.youtube.com/watch?v=olmQXDpqmmg", //Immigration Song (funny) "https://www.youtube.com/watch?v=unRldLdllZ8", //D4NNY - Goodbye (Official Music Video) "https://www.youtube.com/watch?v=k78OjoJZcVc", //Melodysheep - The WTF news song player version "https://www.youtube.com/watch?v=9EcjWd-O4jI", //Technotronic - Pump Up The Jam (Official Music Video) "https://www.youtube.com/watch?v=5FOur8Js8gM", //Three Loco - "We Are Farmers" (Sample Removed) "https://www.youtube.com/watch?v=zi8ShAosqzI", //Kollektivet: Music Video - Compliments "https://www.youtube.com/watch?v=hQp5l4-sfFA", //"Cooking by the Book" A Lil' Bigger Mix by Mastgrr "https://www.youtube.com/watch?v=zPsZH0ub6Qs", //Buddy Ogün presents Mozart Margarethe "https://www.youtube.com/watch?v=Mue6Vc_T9Ds", //Grup Tekkan - Wo bist du, Mein Sonnenlicht (Studio Version) "https://www.youtube.com/watch?v=7n4gCK9joME", //KARL ESS VON DEM MOUNT EVEREST (OFFICIAL AUDIO) "https://www.youtube.com/watch?v=miomuSGoPzI", //Hühner Attacke // SONG REISE // Japan // "https://www.youtube.com/watch?v=XcicOBS9mBU", //Numb-Tongo (estreno a nivel mundial 2017) Parodia "https://www.youtube.com/watch?v=tD8w-AXuaXs", //Der Flötenmann Song - Inkognito [ReUpload] "https://www.youtube.com/watch?v=eoKtCivfuhw", //M1KO - Bohrmaschin feat. FH "https://www.youtube.com/watch?v=1ppisOulgG0", //God is doing a new thang - rap dropping it B-boy style "https://www.youtube.com/watch?v=tRBeGm0QMvU", //Was ist dein Lieblingsfach? (Club Remix) } randomIndex := rand.Intn(len(youtubeLinks)) return youtubeLinks[randomIndex] } func commandHandler(s *discordgo.Session, i *discordgo.InteractionCreate) { data := i.ApplicationCommandData() switch data.Name { case "zenmusic": err := s.InteractionRespond( i.Interaction, &discordgo.InteractionResponse{ Type: discordgo.InteractionResponseChannelMessageWithSource, Data: &discordgo.InteractionResponseData{ Content: getRandomYouTubeLink(), }, }, ) if err != nil { return } } }