~witcher/discord_covid19

6351f7a5d9a79337764fea1b83a2762fac8b0e76 — Witcher01 3 years ago 624d824
more error logging
1 files changed, 37 insertions(+), 9 deletions(-)

M discord.go
M discord.go => discord.go +37 -9
@@ 36,7 36,9 @@ func InitDiscordBot(s *discordgo.Session) {
		},
		BotsAllowed: false,
		PingHandler: func(ctx *dgc.Ctx) {
			ctx.RespondText("Pong!")
			if err := ctx.RespondText("Pong!"); err != nil {
				log.Error(err)
			}
		},
	})



@@ 101,12 103,19 @@ func addDistrict(ctx *dgc.Ctx) {
	name, err := AddTrackedDistrict(arg.Raw())
	if err != nil {
		log.Error(err.Error())
		ctx.RespondText(err.Error())

		if err := ctx.RespondText(err.Error()); err != nil {
			log.Error(err)
		}

		return
	}

	log.Infof("Added district %s to trackedDistricts", name)
	ctx.RespondText(fmt.Sprintf("Added district %s.\n", name))

	if err := ctx.RespondText(fmt.Sprintf("Added district %s.\n", name)); err != nil {
		log.Error(err)
	}
}

func removeDistrict(ctx *dgc.Ctx) {


@@ 120,19 129,30 @@ func removeDistrict(ctx *dgc.Ctx) {
	name, err := RemoveTrackedDistrict(arg.Raw())
	if err != nil {
		log.Error(err.Error())
		ctx.RespondText(err.Error())

		if err := ctx.RespondText(err.Error()); err != nil {
			log.Error(err)
		}

		return
	}

	log.Infof("Removed district %s from trackedDistricts", name)
	ctx.RespondText(fmt.Sprintf("Removed district %s.\n", name))

	if err := ctx.RespondText(fmt.Sprintf("Removed district %s.\n", name)); err != nil {
		log.Error(err)
	}
}

func getTrackedDistricts(ctx *dgc.Ctx) {
	districts, err := GetTrackedDistricts()
	if err != nil {
		log.Error(err.Error())
		ctx.RespondText(err.Error())

		if err := ctx.RespondText(err.Error()); err != nil {
			log.Error(err)
		}

		return
	}



@@ 146,14 166,20 @@ func getTrackedDistricts(ctx *dgc.Ctx) {
		}
	}

	ctx.RespondText(sb.String())
	if err := ctx.RespondText(sb.String()); err != nil {
		log.Error(err)
	}
}

func getTrackedIncidences(ctx *dgc.Ctx) {
	districts, err := GetTrackedDistricts()
	if err != nil {
		log.Error(err.Error())
		ctx.RespondText(err.Error())

		if err := ctx.RespondText(err.Error()); err != nil {
			log.Error(err)
		}

		return
	}



@@ 191,5 217,7 @@ func getDistrictInformation(ctx *dgc.Ctx) {
		return
	}

	ctx.RespondText(district.String())
	if err := ctx.RespondText(district.String()); err != nil {
		log.Error(err)
	}
}