A Makefile => Makefile +21 -0
@@ 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 $@
M main.go => main.go +5 -5
@@ 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)
- // Cleanly close down the Discord session on program end
- defer discord.Close()
if err != nil {
log.Fatalf("error creating bot: %v", err)
}
+ // Cleanly close down the Discord session on program end
+ defer discord.Close()
InitDiscordBot(discord)
- discord.Identify.Intents = discordgo.IntentsGuildMessages
+ discord.Identify.Intents = discordgo.IntentsGuildMessages | discordgo.IntentsGuildMessageReactions
err = discord.Open()
if err != nil {