From 676dff2224a5a83d4ddcc2263cf3299476edb46f Mon Sep 17 00:00:00 2001 From: Satont Date: Tue, 21 May 2024 18:28:58 +0300 Subject: [PATCH] fix(bots): timeout user only on positive decision --- .../messagehandler/handle_games_voteban.go | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/apps/bots/internal/messagehandler/handle_games_voteban.go b/apps/bots/internal/messagehandler/handle_games_voteban.go index a243b247f..a1edd176e 100644 --- a/apps/bots/internal/messagehandler/handle_games_voteban.go +++ b/apps/bots/internal/messagehandler/handle_games_voteban.go @@ -106,19 +106,21 @@ func (c *MessageHandler) handleGamesVoteban(ctx context.Context, msg handleMessa message = strings.ReplaceAll(message, "{targetUser}", voteEntity.TargetUserName) - if err := c.twitchActions.Ban( - ctx, - twitchactions.BanOpts{ - Duration: gameEntity.TimeoutSeconds, - Reason: message, - BroadcasterID: msg.BroadcasterUserId, - UserID: voteEntity.TargetUserId, - ModeratorID: msg.DbChannel.BotID, - IsModerator: voteEntity.TargetIsMod, - AddModAfterBan: true, - }, - ); err != nil { - return err + if isPositive { + if err := c.twitchActions.Ban( + ctx, + twitchactions.BanOpts{ + Duration: gameEntity.TimeoutSeconds, + Reason: message, + BroadcasterID: msg.BroadcasterUserId, + UserID: voteEntity.TargetUserId, + ModeratorID: msg.DbChannel.BotID, + IsModerator: voteEntity.TargetIsMod, + AddModAfterBan: true, + }, + ); err != nil { + return err + } } if err := c.twitchActions.SendMessage(