1 Commits
main ... 0.0.2

Author SHA1 Message Date
5c0caaf377 Added music and slash functions 2024-02-10 19:35:00 +01:00
2 changed files with 79 additions and 35 deletions

12
dockerfile Normal file
View File

@@ -0,0 +1,12 @@
FROM golang:1.22
WORKDIR /app
COPY go.mod .
COPY go.sum .
COPY *.go .
RUN go get
RUN go build -o bin .
ENTRYPOINT [ "/app/bin","-t","MTIwNTUzMTg1NDg5NjM2OTcwMw.G28dTb.-0RgGNRQOP8LVHZ_iw18gxypiBoT2LSwIbOmyY" ]

102
main.go
View File

@@ -3,6 +3,7 @@ package main
import ( import (
"flag" "flag"
"fmt" "fmt"
"math/rand"
"os" "os"
"os/signal" "os/signal"
"syscall" "syscall"
@@ -11,24 +12,31 @@ import (
) )
var ( var (
Token string 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 init() {
flag.StringVar(&Token, "t", "", "Bot Token")
flag.Parse()
}
func main() { func main() {
//Token := "For Testing"
Token := os.Getenv("ZENBOTTOKEN")
session, err := discordgo.New("Bot " + Token) session, err := discordgo.New("Bot " + Token)
if err != nil { if err != nil {
fmt.Println("error creating Discord session,", err) fmt.Println("error creating Discord session,", err)
return 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(messageCreate) session.AddHandler(commandHandler)
session.Identify.Intents = discordgo.IntentsGuildMessages session.Identify.Intents = discordgo.IntentsGuildMessages
err = session.Open() err = session.Open()
@@ -45,35 +53,59 @@ func main() {
session.Close() session.Close()
} }
func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) { func getRandomYouTubeLink() string {
youtubeLinks := []string{
if m.Author.ID == s.State.User.ID { "https://www.youtube.com/watch?v=dQw4w9WgXcQ", //Rick Astley - Never Gonna Give You Up (Official Music Video)
return "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)
fmt.Println(m.Content) "https://www.youtube.com/watch?v=9CaA_5A_PKw", //Zur Party - Official Video [HD]
if m.Content != "ping" { "https://www.youtube.com/watch?v=PcRyjkYdDxM", //Konis Hupen
return "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))
channel, err := s.UserChannelCreate(m.Author.ID) return youtubeLinks[randomIndex]
if err != nil { }
fmt.Println("error creating channel:", err) func commandHandler(s *discordgo.Session, i *discordgo.InteractionCreate) {
s.ChannelMessageSend( data := i.ApplicationCommandData()
m.ChannelID, switch data.Name {
"Something went wrong while sending the DM!", case "zenmusic":
) err := s.InteractionRespond(
return i.Interaction,
} &discordgo.InteractionResponse{
_, err = s.ChannelMessageSend(channel.ID, "Pong!") Type: discordgo.InteractionResponseChannelMessageWithSource,
Data: &discordgo.InteractionResponseData{
if err != nil { Content: getRandomYouTubeLink(),
},
fmt.Println("error sending DM message:", err) },
s.ChannelMessageSend(
m.ChannelID,
"Failed to send you a DM. "+
"Did you disable DM in your privacy settings?",
) )
if err != nil {
return
}
} }
} }