diff --git a/automod/effects.go b/automod/effects.go index 23a58d98e1..a36b4c8f07 100644 --- a/automod/effects.go +++ b/automod/effects.go @@ -269,7 +269,7 @@ func (kick *KickUserEffect) Apply(ctxData *TriggeredRuleData, settings interface reason += ctxData.ConstructReason(true) } - err := moderation.KickUser(nil, ctxData.GS.ID, ctxData.CS, ctxData.Message, common.BotUser, reason, &ctxData.MS.User, -1, false) + err := moderation.KickUser(nil, ctxData.GS.ID, ctxData.CS, ctxData.Message, common.BotUser, reason, &ctxData.MS.User, -1) return err } @@ -340,7 +340,7 @@ func (ban *BanUserEffect) Apply(ctxData *TriggeredRuleData, settings interface{} } duration := time.Duration(settingsCast.Duration) * time.Minute - err := moderation.BanUserWithDuration(nil, ctxData.GS.ID, ctxData.CS, ctxData.Message, common.BotUser, reason, &ctxData.MS.User, duration, settingsCast.MessageDeleteDays, false) + err := moderation.BanUserWithDuration(nil, ctxData.GS.ID, ctxData.CS, ctxData.Message, common.BotUser, reason, &ctxData.MS.User, duration, settingsCast.MessageDeleteDays) return err } @@ -402,7 +402,7 @@ func (mute *MuteUserEffect) Apply(ctxData *TriggeredRuleData, settings interface reason += ctxData.ConstructReason(true) } - err := moderation.MuteUnmuteUser(nil, true, ctxData.GS.ID, ctxData.CS, ctxData.Message, common.BotUser, reason, ctxData.MS, settingsCast.Duration, false) + err := moderation.MuteUnmuteUser(nil, true, ctxData.GS.ID, ctxData.CS, ctxData.Message, common.BotUser, reason, ctxData.MS, settingsCast.Duration) return err } @@ -472,7 +472,7 @@ func (timeout *TimeoutUserEffect) Apply(ctxData *TriggeredRuleData, settings int } duration := time.Duration(settingsCast.Duration) * time.Minute - err := moderation.TimeoutUser(nil, ctxData.GS.ID, ctxData.CS, ctxData.Message, common.BotUser, reason, &ctxData.MS.User, duration, false) + err := moderation.TimeoutUser(nil, ctxData.GS.ID, ctxData.CS, ctxData.Message, common.BotUser, reason, &ctxData.MS.User, duration) return err } @@ -526,7 +526,7 @@ func (warn *WarnUserEffect) Apply(ctxData *TriggeredRuleData, settings interface reason += ctxData.ConstructReason(true) } - err := moderation.WarnUser(nil, ctxData.GS.ID, ctxData.CS, ctxData.Message, common.BotUser, &ctxData.MS.User, reason, false) + err := moderation.WarnUser(nil, ctxData.GS.ID, ctxData.CS, ctxData.Message, common.BotUser, &ctxData.MS.User, reason) return err } diff --git a/automod_legacy/bot.go b/automod_legacy/bot.go index f83cae842f..f76562fcd1 100644 --- a/automod_legacy/bot.go +++ b/automod_legacy/bot.go @@ -152,13 +152,13 @@ func CheckMessage(evt *eventsystem.EventData, m *discordgo.Message) bool { go func() { switch highestPunish { case PunishNone: - err = moderation.WarnUser(nil, cs.GuildID, cs, m, common.BotUser, &member.User, "Automoderator: "+punishMsg, false) + err = moderation.WarnUser(nil, cs.GuildID, cs, m, common.BotUser, &member.User, "Automoderator: "+punishMsg) case PunishMute: - err = moderation.MuteUnmuteUser(nil, true, cs.GuildID, cs, m, common.BotUser, "Automoderator: "+punishMsg, member, muteDuration, false) + err = moderation.MuteUnmuteUser(nil, true, cs.GuildID, cs, m, common.BotUser, "Automoderator: "+punishMsg, member, muteDuration) case PunishKick: - err = moderation.KickUser(nil, cs.GuildID, cs, m, common.BotUser, "Automoderator: "+punishMsg, &member.User, -1, false) + err = moderation.KickUser(nil, cs.GuildID, cs, m, common.BotUser, "Automoderator: "+punishMsg, &member.User, -1) case PunishBan: - err = moderation.BanUser(nil, cs.GuildID, cs, m, common.BotUser, "Automoderator: "+punishMsg, &member.User, false) + err = moderation.BanUser(nil, cs.GuildID, cs, m, common.BotUser, "Automoderator: "+punishMsg, &member.User) } // Execute the punishment before removing the message to make sure it's included in logs diff --git a/commands/commands.go b/commands/commands.go index ccc6e54dc4..6d15c91dbd 100644 --- a/commands/commands.go +++ b/commands/commands.go @@ -25,8 +25,6 @@ const ( CtxKeyCmdSettings CtxKey = iota CtxKeyChannelOverride CtxKeyExecutedByCC - CtxKeyExecutedByCommandTemplate - CtxKeyExecutedByNestedCommandTemplate ) type MessageFilterFunc func(evt *eventsystem.EventData, msg *discordgo.Message) bool diff --git a/commands/tmplexec.go b/commands/tmplexec.go index 4d2c785de6..69b73c64ae 100644 --- a/commands/tmplexec.go +++ b/commands/tmplexec.go @@ -205,13 +205,6 @@ func execCmd(tmplCtx *templates.Context, dryRun bool, m *discordgo.MessageCreate data = data.WithContext(context.WithValue(data.Context(), paginatedmessages.CtxKeyNoPagination, true)) data = data.WithContext(context.WithValue(data.Context(), CtxKeyExecutedByCC, true)) - switch tmplCtx.ExecutedFrom { - case templates.ExecutedFromCommandTemplate: - data = data.WithContext(context.WithValue(data.Context(), CtxKeyExecutedByCommandTemplate, true)) - case templates.ExecutedFromNestedCommandTemplate: - data = data.WithContext(context.WithValue(data.Context(), CtxKeyExecutedByNestedCommandTemplate, true)) - } - cast := foundCmd.Command.(*YAGCommand) err = dcmd.ParseCmdArgs(data) diff --git a/common/templates/context.go b/common/templates/context.go index 3d813db5c2..2c46082fa2 100644 --- a/common/templates/context.go +++ b/common/templates/context.go @@ -160,12 +160,10 @@ var GuildPremiumFunc func(guildID int64) (bool, error) type ExecutedFromType int const ( - ExecutedFromStandard ExecutedFromType = 0 - ExecutedFromJoin ExecutedFromType = 1 - ExecutedFromLeave ExecutedFromType = 2 - ExecutedFromEvalCC ExecutedFromType = 3 - ExecutedFromCommandTemplate ExecutedFromType = 4 - ExecutedFromNestedCommandTemplate ExecutedFromType = 5 + ExecutedFromStandard ExecutedFromType = 0 + ExecutedFromJoin ExecutedFromType = 1 + ExecutedFromLeave ExecutedFromType = 2 + ExecutedFromEvalCC ExecutedFromType = 3 ) type Context struct { diff --git a/customcommands/tmplextensions.go b/customcommands/tmplextensions.go index 581d1aaec7..545889e41b 100644 --- a/customcommands/tmplextensions.go +++ b/customcommands/tmplextensions.go @@ -176,10 +176,6 @@ func (pa *ParsedArgs) IsSet(index int) interface{} { // or schedules a custom command to be run in the future sometime with the provided data placed in .ExecData func tmplRunCC(ctx *templates.Context) interface{} { return func(ccID int, channel interface{}, delaySeconds interface{}, data interface{}) (string, error) { - if ctx.ExecutedFrom == templates.ExecutedFromCommandTemplate || ctx.ExecutedFrom == templates.ExecutedFromNestedCommandTemplate { - return "", nil - } - if ctx.IncreaseCheckCallCounterPremium("runcc", 1, 10) { return "", templates.ErrTooManyCalls } diff --git a/moderation/commands.go b/moderation/commands.go index 7c87415a85..b5457d19f9 100644 --- a/moderation/commands.go +++ b/moderation/commands.go @@ -169,10 +169,6 @@ var ModerationCommands = []*commands.YAGCommand{ DefaultEnabled: false, IsResponseEphemeral: true, RunFunc: func(parsed *dcmd.Data) (interface{}, error) { - if parsed.Context().Value(commands.CtxKeyExecutedByNestedCommandTemplate) == true { - return nil, errors.New("cannot nest exec/execAdmin calls") - } - config, target, err := MBaseCmd(parsed, parsed.Args[0].Int64()) if err != nil { return nil, err @@ -203,7 +199,7 @@ var ModerationCommands = []*commands.YAGCommand{ if parsed.TraditionalTriggerData != nil { msg = parsed.TraditionalTriggerData.Message } - err = BanUserWithDuration(config, parsed.GuildData.GS.ID, parsed.GuildData.CS, msg, parsed.Author, reason, target, banDuration, ddays, parsed.Context().Value(commands.CtxKeyExecutedByCommandTemplate) == true) + err = BanUserWithDuration(config, parsed.GuildData.GS.ID, parsed.GuildData.CS, msg, parsed.Author, reason, target, banDuration, ddays) if err != nil { return nil, err } @@ -279,10 +275,6 @@ var ModerationCommands = []*commands.YAGCommand{ SlashCommandEnabled: true, IsResponseEphemeral: true, RunFunc: func(parsed *dcmd.Data) (interface{}, error) { - if parsed.Context().Value(commands.CtxKeyExecutedByNestedCommandTemplate) == true { - return nil, errors.New("cannot nest exec/execAdmin calls") - } - config, target, err := MBaseCmd(parsed, parsed.Args[0].Int64()) if err != nil { return nil, err @@ -318,7 +310,7 @@ var ModerationCommands = []*commands.YAGCommand{ msg = parsed.TraditionalTriggerData.Message } - err = KickUser(config, parsed.GuildData.GS.ID, parsed.GuildData.CS, msg, parsed.Author, reason, target, toDel, parsed.Context().Value(commands.CtxKeyExecutedByCommandTemplate) == true) + err = KickUser(config, parsed.GuildData.GS.ID, parsed.GuildData.CS, msg, parsed.Author, reason, target, toDel) if err != nil { return nil, err } @@ -343,10 +335,6 @@ var ModerationCommands = []*commands.YAGCommand{ DefaultEnabled: false, IsResponseEphemeral: true, RunFunc: func(parsed *dcmd.Data) (interface{}, error) { - if parsed.Context().Value(commands.CtxKeyExecutedByNestedCommandTemplate) == true { - return nil, errors.New("cannot nest exec/execAdmin calls") - } - config, target, err := MBaseCmd(parsed, parsed.Args[0].Int64()) if err != nil { return nil, err @@ -381,7 +369,7 @@ var ModerationCommands = []*commands.YAGCommand{ if parsed.TraditionalTriggerData != nil { msg = parsed.TraditionalTriggerData.Message } - err = MuteUnmuteUser(config, true, parsed.GuildData.GS.ID, parsed.GuildData.CS, msg, parsed.Author, reason, member, int(d.Minutes()), parsed.Context().Value(commands.CtxKeyExecutedByCommandTemplate) == true) + err = MuteUnmuteUser(config, true, parsed.GuildData.GS.ID, parsed.GuildData.CS, msg, parsed.Author, reason, member, int(d.Minutes())) if err != nil { return nil, err } @@ -406,10 +394,6 @@ var ModerationCommands = []*commands.YAGCommand{ DefaultEnabled: false, IsResponseEphemeral: true, RunFunc: func(parsed *dcmd.Data) (interface{}, error) { - if parsed.Context().Value(commands.CtxKeyExecutedByNestedCommandTemplate) == true { - return nil, errors.New("cannot nest exec/execAdmin calls") - } - config, target, err := MBaseCmd(parsed, parsed.Args[0].Int64()) if err != nil { return nil, err @@ -434,7 +418,7 @@ var ModerationCommands = []*commands.YAGCommand{ if parsed.TraditionalTriggerData != nil { msg = parsed.TraditionalTriggerData.Message } - err = MuteUnmuteUser(config, false, parsed.GuildData.GS.ID, parsed.GuildData.CS, msg, parsed.Author, reason, member, 0, parsed.Context().Value(commands.CtxKeyExecutedByCommandTemplate) == true) + err = MuteUnmuteUser(config, false, parsed.GuildData.GS.ID, parsed.GuildData.CS, msg, parsed.Author, reason, member, 0) if err != nil { return nil, err } @@ -460,9 +444,6 @@ var ModerationCommands = []*commands.YAGCommand{ DefaultEnabled: false, IsResponseEphemeral: true, RunFunc: func(parsed *dcmd.Data) (interface{}, error) { - if parsed.Context().Value(commands.CtxKeyExecutedByNestedCommandTemplate) == true { - return nil, errors.New("cannot nest exec/execAdmin calls") - } config, target, err := MBaseCmd(parsed, parsed.Args[0].Int64()) if err != nil { return nil, err @@ -493,7 +474,7 @@ var ModerationCommands = []*commands.YAGCommand{ if parsed.TraditionalTriggerData != nil { msg = parsed.TraditionalTriggerData.Message } - err = TimeoutUser(config, parsed.GuildData.GS.ID, parsed.GuildData.CS, msg, parsed.Author, reason, &member.User, d, parsed.Context().Value(commands.CtxKeyExecutedByCommandTemplate) == true) + err = TimeoutUser(config, parsed.GuildData.GS.ID, parsed.GuildData.CS, msg, parsed.Author, reason, &member.User, d) if err != nil { return nil, err } @@ -840,10 +821,6 @@ var ModerationCommands = []*commands.YAGCommand{ DefaultEnabled: false, IsResponseEphemeral: true, RunFunc: func(parsed *dcmd.Data) (interface{}, error) { - if parsed.Context().Value(commands.CtxKeyExecutedByNestedCommandTemplate) == true { - return nil, errors.New("cannot nest exec/execAdmin calls") - } - config, target, err := MBaseCmd(parsed, parsed.Args[0].Int64()) if err != nil { return nil, err @@ -862,7 +839,7 @@ var ModerationCommands = []*commands.YAGCommand{ if parsed.TraditionalTriggerData != nil { msg = parsed.TraditionalTriggerData.Message } - err = WarnUser(config, parsed.GuildData.GS.ID, parsed.GuildData.CS, msg, parsed.Author, target, parsed.Args[1].Str(), parsed.Context().Value(commands.CtxKeyExecutedByCommandTemplate) == true) + err = WarnUser(config, parsed.GuildData.GS.ID, parsed.GuildData.CS, msg, parsed.Author, target, parsed.Args[1].Str()) if err != nil { return nil, err } diff --git a/moderation/plugin_bot.go b/moderation/plugin_bot.go index ead1e70de9..090efcb29b 100644 --- a/moderation/plugin_bot.go +++ b/moderation/plugin_bot.go @@ -721,7 +721,7 @@ func handleScheduledUnmute(evt *seventsmodels.ScheduledEvent, data interface{}) return scheduledevents2.CheckDiscordErrRetry(err), err } - err = MuteUnmuteUser(nil, false, evt.GuildID, nil, nil, common.BotUser, "Mute Duration Expired", member, 0, false) + err = MuteUnmuteUser(nil, false, evt.GuildID, nil, nil, common.BotUser, "Mute Duration Expired", member, 0) if errors.Cause(err) != ErrNoMuteRole { return scheduledevents2.CheckDiscordErrRetry(err), err } diff --git a/moderation/punishments.go b/moderation/punishments.go index 281285fa9d..544278661c 100644 --- a/moderation/punishments.go +++ b/moderation/punishments.go @@ -53,7 +53,7 @@ func getMemberWithFallback(gs *dstate.GuildSet, user *discordgo.User) (ms *dstat } // Kick or bans someone, uploading a hasebin log, and sending the report message in the action channel -func punish(config *Config, p Punishment, guildID int64, channel *dstate.ChannelState, message *discordgo.Message, author *discordgo.User, reason string, user *discordgo.User, duration time.Duration, executedFromCommandTemplate bool, variadicBanDeleteDays ...int) error { +func punish(config *Config, p Punishment, guildID int64, channel *dstate.ChannelState, message *discordgo.Message, author *discordgo.User, reason string, user *discordgo.User, duration time.Duration, variadicBanDeleteDays ...int) error { config, err := GetConfigIfNotSet(guildID, config) if err != nil { @@ -90,7 +90,7 @@ func punish(config *Config, p Punishment, guildID int64, channel *dstate.Channel gs := bot.State.GetGuild(guildID) member, memberNotFound := getMemberWithFallback(gs, user) if !memberNotFound { - sendPunishDM(config, msg, action, gs, channel, message, author, member, duration, reason, -1, executedFromCommandTemplate) + sendPunishDM(config, msg, action, gs, channel, message, author, member, duration, reason, -1) } logLink := "" @@ -166,18 +166,13 @@ var ActionMap = map[string]string{ MATimeoutAdded.Prefix: "Timeout DM", } -func sendPunishDM(config *Config, dmMsg string, action ModlogAction, gs *dstate.GuildSet, channel *dstate.ChannelState, message *discordgo.Message, author *discordgo.User, member *dstate.MemberState, duration time.Duration, reason string, warningID int, executedFromCommandTemplate bool) { +func sendPunishDM(config *Config, dmMsg string, action ModlogAction, gs *dstate.GuildSet, channel *dstate.ChannelState, message *discordgo.Message, author *discordgo.User, member *dstate.MemberState, duration time.Duration, reason string, warningID int) { if dmMsg == "" { dmMsg = DefaultDMMessage } // Execute and send the DM message template ctx := templates.NewContext(gs, channel, member) - if executedFromCommandTemplate { - ctx.ExecutedFrom = templates.ExecutedFromNestedCommandTemplate - } else { - ctx.ExecutedFrom = templates.ExecutedFromCommandTemplate - } ctx.Data["Reason"] = reason if duration > 0 { ctx.Data["Duration"] = duration @@ -216,13 +211,13 @@ func sendPunishDM(config *Config, dmMsg string, action ModlogAction, gs *dstate. } } -func KickUser(config *Config, guildID int64, channel *dstate.ChannelState, message *discordgo.Message, author *discordgo.User, reason string, user *discordgo.User, del int, executedFromCommandTemplate bool) error { +func KickUser(config *Config, guildID int64, channel *dstate.ChannelState, message *discordgo.Message, author *discordgo.User, reason string, user *discordgo.User, del int) error { config, err := GetConfigIfNotSet(guildID, config) if err != nil { return common.ErrWithCaller(err) } - err = punish(config, PunishmentKick, guildID, channel, message, author, reason, user, 0, executedFromCommandTemplate) + err = punish(config, PunishmentKick, guildID, channel, message, author, reason, user, 0) if err != nil { return err } @@ -276,7 +271,7 @@ func DeleteMessages(guildID, channelID int64, filterUser int64, deleteNum, fetch return len(toDelete), err } -func BanUserWithDuration(config *Config, guildID int64, channel *dstate.ChannelState, message *discordgo.Message, author *discordgo.User, reason string, user *discordgo.User, duration time.Duration, deleteMessageDays int, executedByCommandTemplate bool) error { +func BanUserWithDuration(config *Config, guildID int64, channel *dstate.ChannelState, message *discordgo.Message, author *discordgo.User, reason string, user *discordgo.User, duration time.Duration, deleteMessageDays int) error { // Set a key in redis that marks that this user has appeared in the modlog already common.RedisPool.Do(radix.Cmd(nil, "SETEX", RedisKeyBannedUser(guildID, user.ID), "60", "1")) if deleteMessageDays > 7 { @@ -286,7 +281,7 @@ func BanUserWithDuration(config *Config, guildID int64, channel *dstate.ChannelS deleteMessageDays = 0 } - err := punish(config, PunishmentBan, guildID, channel, message, author, reason, user, duration, executedByCommandTemplate, deleteMessageDays) + err := punish(config, PunishmentBan, guildID, channel, message, author, reason, user, duration, deleteMessageDays) if err != nil { return err } @@ -306,8 +301,8 @@ func BanUserWithDuration(config *Config, guildID int64, channel *dstate.ChannelS return nil } -func BanUser(config *Config, guildID int64, channel *dstate.ChannelState, message *discordgo.Message, author *discordgo.User, reason string, user *discordgo.User, executedByCommandTemplate bool) error { - return BanUserWithDuration(config, guildID, channel, message, author, reason, user, 0, 1, executedByCommandTemplate) +func BanUser(config *Config, guildID int64, channel *dstate.ChannelState, message *discordgo.Message, author *discordgo.User, reason string, user *discordgo.User) error { + return BanUserWithDuration(config, guildID, channel, message, author, reason, user, 0, 1) } func UnbanUser(config *Config, guildID int64, author *discordgo.User, reason string, user *discordgo.User) (bool, error) { @@ -356,8 +351,8 @@ func UnbanUser(config *Config, guildID int64, author *discordgo.User, reason str return false, err } -func TimeoutUser(config *Config, guildID int64, channel *dstate.ChannelState, message *discordgo.Message, author *discordgo.User, reason string, user *discordgo.User, duration time.Duration, executedByCommandTemplate bool) error { - err := punish(config, PunishmentTimeout, guildID, channel, message, author, reason, user, duration, executedByCommandTemplate, 0) +func TimeoutUser(config *Config, guildID int64, channel *dstate.ChannelState, message *discordgo.Message, author *discordgo.User, reason string, user *discordgo.User, duration time.Duration) error { + err := punish(config, PunishmentTimeout, guildID, channel, message, author, reason, user, duration, 0) if err != nil { return err } @@ -406,7 +401,7 @@ const ( // Unmut or mute a user, ignore duration if unmuting // TODO: i don't think we need to track mutes in its own database anymore now with the new scheduled event system -func MuteUnmuteUser(config *Config, mute bool, guildID int64, channel *dstate.ChannelState, message *discordgo.Message, author *discordgo.User, reason string, member *dstate.MemberState, duration int, executedByCommandTemplate bool) error { +func MuteUnmuteUser(config *Config, mute bool, guildID int64, channel *dstate.ChannelState, message *discordgo.Message, author *discordgo.User, reason string, member *dstate.MemberState, duration int) error { config, err := GetConfigIfNotSet(guildID, config) if err != nil { return common.ErrWithCaller(err) @@ -530,7 +525,7 @@ func MuteUnmuteUser(config *Config, mute bool, guildID int64, channel *dstate.Ch gs := bot.State.GetGuild(guildID) if gs != nil { - go sendPunishDM(config, dmMsg, action, gs, channel, message, author, member, time.Duration(duration)*time.Minute, reason, -1, executedByCommandTemplate) + go sendPunishDM(config, dmMsg, action, gs, channel, message, author, member, time.Duration(duration)*time.Minute, reason, -1) } // Create the modlog entry @@ -611,7 +606,7 @@ func decideUnmuteRoles(config *Config, currentRoles []int64, mute *models.MutedU return newMemberRoles } -func WarnUser(config *Config, guildID int64, channel *dstate.ChannelState, msg *discordgo.Message, author *discordgo.User, target *discordgo.User, message string, executedByCommandTemplate bool) error { +func WarnUser(config *Config, guildID int64, channel *dstate.ChannelState, msg *discordgo.Message, author *discordgo.User, target *discordgo.User, message string) error { warning := &models.ModerationWarning{ GuildID: guildID, UserID: discordgo.StrID(target.ID), @@ -644,7 +639,7 @@ 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) + sendPunishDM(config, config.WarnMessage, MAWarned, gs, channel, msg, author, ms, -1, message, int(warning.ID)) } // go bot.SendDM(target.ID, fmt.Sprintf("**%s**: You have been warned for: %s", bot.GuildName(guildID), message)) diff --git a/tickets/tickets_bot.go b/tickets/tickets_bot.go index 15667286f9..ddb8583e4f 100644 --- a/tickets/tickets_bot.go +++ b/tickets/tickets_bot.go @@ -50,7 +50,7 @@ const ( ErrMaxOpenTickets TicketUserError = "You're currently in over 10 open tickets on this server, please close some of the ones you're in." ) -func CreateTicket(ctx context.Context, gs *dstate.GuildSet, ms *dstate.MemberState, conf *models.TicketConfig, topic string, checkMaxTickets, executedByCommandTemplate bool) (*dstate.GuildSet, *models.Ticket, error) { +func CreateTicket(ctx context.Context, gs *dstate.GuildSet, ms *dstate.MemberState, conf *models.TicketConfig, topic string, checkMaxTickets bool) (*dstate.GuildSet, *models.Ticket, error) { if gs.GetChannel(conf.TicketsChannelCategory) == nil { return gs, nil, ErrNoTicketCateogry } @@ -119,11 +119,6 @@ func CreateTicket(ctx context.Context, gs *dstate.GuildSet, ms *dstate.MemberSta gs.Channels = append(gs.Channels, cs) tmplCTX := templates.NewContext(gs, &cs, ms) - if executedByCommandTemplate { - tmplCTX.ExecutedFrom = templates.ExecutedFromNestedCommandTemplate - } else { - tmplCTX.ExecutedFrom = templates.ExecutedFromCommandTemplate - } tmplCTX.Name = "ticket open message" tmplCTX.Data["Reason"] = topic ticketOpenMsg := conf.TicketOpenMSG diff --git a/tickets/tickets_commands.go b/tickets/tickets_commands.go index ea61e1bd7c..38f941cc80 100644 --- a/tickets/tickets_commands.go +++ b/tickets/tickets_commands.go @@ -6,7 +6,6 @@ import ( "context" "database/sql" "encoding/json" - "errors" "fmt" "io" "net/http" @@ -52,16 +51,12 @@ func (p *Plugin) AddCommands() { {Name: "subject", Type: dcmd.String}, }, RunFunc: func(parsed *dcmd.Data) (interface{}, error) { - if parsed.Context().Value(commands.CtxKeyExecutedByNestedCommandTemplate) == true { - return nil, errors.New("cannot nest exec/execAdmin calls") - } - conf := parsed.Context().Value(CtxKeyConfig).(*models.TicketConfig) if !conf.Enabled { return createTicketsDisabledError(parsed.GuildData), nil } - _, ticket, err := CreateTicket(parsed.Context(), parsed.GuildData.GS, parsed.GuildData.MS, conf, parsed.Args[0].Str(), true, parsed.Context().Value(commands.CtxKeyExecutedByCommandTemplate) == true) + _, ticket, err := CreateTicket(parsed.Context(), parsed.GuildData.GS, parsed.GuildData.MS, conf, parsed.Args[0].Str(), true) if err != nil { switch t := err.(type) { case TicketUserError: diff --git a/tickets/tmplextensions.go b/tickets/tmplextensions.go index 4c33a98139..c2334d7e91 100644 --- a/tickets/tmplextensions.go +++ b/tickets/tmplextensions.go @@ -25,10 +25,6 @@ func init() { // or schedules a custom command to be run in the future sometime with the provided data placed in .ExecData func tmplCreateTicket(ctx *templates.Context) interface{} { return func(author interface{}, topic string) (*TemplateTicket, error) { - if ctx.ExecutedFrom == templates.ExecutedFromNestedCommandTemplate { - return nil, errors.New("cannot nest exec/execAdmin/ticket creation") - } - if ctx.IncreaseCheckCallCounterPremium("ticket", 1, 1) { return nil, templates.ErrTooManyCalls } @@ -84,7 +80,7 @@ func tmplCreateTicket(ctx *templates.Context) interface{} { return nil, errors.New("tickets are disabled on this server") } - gs, ticket, err := CreateTicket(context.Background(), ctx.GS, ms, conf, topic, true, ctx.ExecutedFrom == templates.ExecutedFromCommandTemplate) + gs, ticket, err := CreateTicket(context.Background(), ctx.GS, ms, conf, topic, true) ctx.GS = gs if err != nil { diff --git a/verification/verification_bot.go b/verification/verification_bot.go index 5813c89157..2904f27312 100644 --- a/verification/verification_bot.go +++ b/verification/verification_bot.go @@ -334,7 +334,7 @@ func (p *Plugin) handleUserVerifiedScheduledEvent(ms *dstate.MemberState, guildI banReason = string(r) + "..." } - err := moderation.BanUser(nil, guildID, nil, nil, common.BotUser, banReason, &ms.User, false) + err := moderation.BanUser(nil, guildID, nil, nil, common.BotUser, banReason, &ms.User) if err != nil { return scheduledevents2.CheckDiscordErrRetry(err), err } @@ -674,7 +674,7 @@ func (p *Plugin) banAlts(ban *discordgo.GuildBanAdd, alts []*discordgo.User) { logger.WithField("guild", ban.GuildID).WithField("user", v.ID).WithField("dupe-of", ban.User.ID).Info("banning alt account") reason := fmt.Sprintf("Alt of banned user (%s (%d))", ban.User.String(), ban.User.ID) markRecentlyBannedByVerification(ban.GuildID, v.ID) - moderation.BanUser(nil, ban.GuildID, nil, nil, common.BotUser, reason, v, false) + moderation.BanUser(nil, ban.GuildID, nil, nil, common.BotUser, reason, v) continue } }