Skip to content

Commit

Permalink
make punishDM execute as a go routine to keep it independent of failu…
Browse files Browse the repository at this point in the history
…res (#1821)

Co-authored-by: Ashish <[email protected]>
  • Loading branch information
ashishjh-bst and ashishjh-bst authored Jan 17, 2025
1 parent e886ffc commit 9e94359
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions moderation/punishments.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 := ""
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 9e94359

Please sign in to comment.