From eceb0ecdeff47a51253ba726a125b5d7f5907791 Mon Sep 17 00:00:00 2001 From: Joren Date: Tue, 18 Jun 2024 16:26:10 +0200 Subject: [PATCH] Simple project base --- go.mod | 11 +++++++++++ main.go | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 go.mod create mode 100644 main.go diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..e12cebf --- /dev/null +++ b/go.mod @@ -0,0 +1,11 @@ +module git.directme.in/Joren/SolMonitor + +go 1.22.4 + +require github.com/bwmarrin/discordgo v0.28.1 + +require ( + github.com/gorilla/websocket v1.4.2 // indirect + golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b // indirect + golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 // indirect +) diff --git a/main.go b/main.go new file mode 100644 index 0000000..49e4195 --- /dev/null +++ b/main.go @@ -0,0 +1,47 @@ +package main + +import ( + "fmt" + "os" + + + "github.com/bwmarrin/discordgo" +) + +var ( + Token string +) + +func init() { + Token = os.Getenv("DISCORD_BOT_TOKEN") + if Token == "" { + fmt.Println("No token provided. Please set DISCORD_BOT_TOKEN environment variable.") + os.Exit(1) + } +} + +func main() { + dg, err := discordgo.New("Bot " + Token) + if err != nil { + fmt.Println("Error creating Discord session:", err) + return + } + + dg.AddHandler(ready) + + dg.Identify.Intents = discordgo.IntentsGuilds | discordgo.IntentsGuildMessages + + err = dg.Open() + if err != nil { + fmt.Println("Error opening connection:", err) + return + } + + fmt.Println("Bot is now running. Press CTRL+C to exit.") + select {} +} + +func ready(s *discordgo.Session, event *discordgo.Ready) { + s.UpdateGameStatus(0, "Monitoring addresses") +} +