From 9e943595055da047eed656ae5bbe01c2a8d50ba0 Mon Sep 17 00:00:00 2001 From: Ashish <51633862+ashishjh-bst@users.noreply.github.com> Date: Fri, 17 Jan 2025 11:04:04 +0530 Subject: [PATCH] make punishDM execute as a go routine to keep it independent of failures (#1821) Co-authored-by: Ashish --- moderation/punishments.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/moderation/punishments.go b/moderation/punishments.go index 9ba4cdbac..890c64f1c 100644 --- a/moderation/punishments.go +++ b/moderation/punishments.go @@ -121,7 +121,7 @@ func punish(config *Config, p Punishment, guildID int64, channel *dstate.Channel return errors.New("cannot " + actionPresentTense + " a member who is ranked higher than the bot") } - sendPunishDM(config, msg, action, gs, channel, message, author, member, duration, reason, -1, executedFromCommandTemplate) + go sendPunishDM(config, msg, action, gs, channel, message, author, member, duration, reason, -1, executedFromCommandTemplate) } logLink := "" @@ -691,11 +691,9 @@ func WarnUser(config *Config, guildID int64, channel *dstate.ChannelState, msg * gs := bot.State.GetGuild(guildID) ms, _ := bot.GetMember(guildID, target.ID) if gs != nil && ms != nil { - sendPunishDM(config, config.WarnMessage, MAWarned, gs, channel, msg, author, ms, -1, message, int(warning.ID), executedByCommandTemplate) + go sendPunishDM(config, config.WarnMessage, MAWarned, gs, channel, msg, author, ms, -1, message, int(warning.ID), executedByCommandTemplate) } - // go bot.SendDM(target.ID, fmt.Sprintf("**%s**: You have been warned for: %s", bot.GuildName(guildID), message)) - if config.WarnSendToModlog && config.ActionChannel != 0 { err = CreateModlogEmbed(config, author, MAWarned, target, message, warning.LogsLink.String) if err != nil {