Simple project base

This commit is contained in:
Joren 2024-06-18 16:26:10 +02:00
parent f115b03742
commit eceb0ecdef
Signed by: Joren
GPG Key ID: 280E33DFBC0F1B55
2 changed files with 58 additions and 0 deletions

11
go.mod Normal file
View File

@ -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
)

47
main.go Normal file
View File

@ -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")
}