From 88c42b74c7da1ba12b4fb0004b81ee0316458bcf Mon Sep 17 00:00:00 2001 From: Kwoth Date: Mon, 12 Aug 2024 12:28:11 +0000 Subject: [PATCH] fix: Fixed xpcurrew breaking xp gain if user gains 0 xp from being in a voice channel while voice xp is enabled --- src/NadekoBot/Modules/Xp/XpService.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/NadekoBot/Modules/Xp/XpService.cs b/src/NadekoBot/Modules/Xp/XpService.cs index 3a2a2d192..4db556578 100644 --- a/src/NadekoBot/Modules/Xp/XpService.cs +++ b/src/NadekoBot/Modules/Xp/XpService.cs @@ -178,8 +178,9 @@ public class XpService : INService, IReadyExecutor, IExecNoCommand { foreach (var user in globalToAdd) { - var amount = user.Value.XpAmount * conf.CurrencyPerXp; - await _cs.AddAsync(user.Key, (long)(amount), null); + var amount = (long)(user.Value.XpAmount * conf.CurrencyPerXp); + if (amount > 0) + await _cs.AddAsync(user.Key, amount, null); } } @@ -422,8 +423,8 @@ public class XpService : INService, IReadyExecutor, IExecNoCommand await _sender.Response(chan) .Confirm(_strings.GetText(strs.level_up_global(user.Mention, - Format.Bold(newLevel.ToString())), - guild.Id)) + Format.Bold(newLevel.ToString())), + guild.Id)) .SendAsync(); } } @@ -769,9 +770,10 @@ public class XpService : INService, IReadyExecutor, IExecNoCommand private bool ShouldTrackXp(SocketGuildUser user, IMessageChannel channel) { var channelId = channel.Id; - - if (_excludedChannels.TryGetValue(user.Guild.Id, out var chans) && (chans.Contains(channelId) - || (channel is SocketThreadChannel tc && chans.Contains(tc.ParentChannel.Id)))) + + if (_excludedChannels.TryGetValue(user.Guild.Id, out var chans) + && (chans.Contains(channelId) + || (channel is SocketThreadChannel tc && chans.Contains(tc.ParentChannel.Id)))) return false; if (_excludedServers.Contains(user.Guild.Id))