commit 55346083822c94a90932c1875d96ba4393d9b3ab from: Witcher01 date: Tue Jun 8 19:58:51 2021 UTC cleanup + reaction intent and basic Makefile commit - 65cfbeaa871be4faad6419479871592e85ac0bfe commit + 55346083822c94a90932c1875d96ba4393d9b3ab blob - /dev/null blob + 1f05761c106e263bb228ca786192fd61538ca445 (mode 644) --- /dev/null +++ Makefile @@ -0,0 +1,21 @@ +GO=go +SOURCES=$(wildcard *.go) +BIN=discord_covid19 + +default: build + +all: clean build + +clean: + rm -rf $(BIN) + +build: $(BIN) + +fmt: + $(GO) fmt $(SOURCESE) + +tidy: + $(GO) mod tidy + +$(BIN): $(SOURCES) + $(GO) build -o $@ blob - f7f68c0739ee745d3dcb9321b7bd0b9fd7ed64fb blob + a8198d818e12232dd73cccb00cd506b4bde8d345 --- main.go +++ main.go @@ -5,15 +5,14 @@ import ( "os/signal" "syscall" - log "github.com/sirupsen/logrus" "github.com/bwmarrin/discordgo" + log "github.com/sirupsen/logrus" ) const districtEnd = "districts/" var coronaChannelID string -// make this global so gocron can call a function without no arguments to print information var discord *discordgo.Session func main() { @@ -27,18 +26,19 @@ func main() { } } log.Infof("Added districts: %+v", ParsedArgs.Districts) + // initialize moderators AddModerators(ParsedArgs.ModeratorIds) discord, err := discordgo.New("Bot " + ParsedArgs.Token) + if err != nil { + log.Fatalf("error creating bot: %v", err) + } // Cleanly close down the Discord session on program end defer discord.Close() - if err != nil { - log.Fatalf("error creating bot: %v", err) - } InitDiscordBot(discord) - discord.Identify.Intents = discordgo.IntentsGuildMessages + discord.Identify.Intents = discordgo.IntentsGuildMessages | discordgo.IntentsGuildMessageReactions err = discord.Open() if err != nil {