~witcher/discord_covid19

55346083822c94a90932c1875d96ba4393d9b3ab — Witcher01 3 years ago 65cfbea
cleanup + reaction intent and basic Makefile
2 files changed, 26 insertions(+), 5 deletions(-)

A Makefile
M main.go
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 {