Fixed xpcurrew breaking xp gain if user gains 0 xp from being in a voice channel while voice xp is enabled

This commit is contained in:
Toastie (DCS Team) 2024-08-13 13:56:59 +12:00
parent 6128703bcc
commit 97f9a4e609
Signed by: toastie_t0ast
GPG key ID: 27F3B6855AFD40A4

View file

@ -178,8 +178,9 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand
{ {
foreach (var user in globalToAdd) foreach (var user in globalToAdd)
{ {
var amount = user.Value.XpAmount * conf.CurrencyPerXp; var amount = (long)(user.Value.XpAmount * conf.CurrencyPerXp);
await _cs.AddAsync(user.Key, (long)(amount), null); if (amount > 0)
await _cs.AddAsync(user.Key, amount, null);
} }
} }
@ -422,8 +423,8 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand
await _sender.Response(chan) await _sender.Response(chan)
.Confirm(_strings.GetText(strs.level_up_global(user.Mention, .Confirm(_strings.GetText(strs.level_up_global(user.Mention,
Format.Bold(newLevel.ToString())), Format.Bold(newLevel.ToString())),
guild.Id)) guild.Id))
.SendAsync(); .SendAsync();
} }
} }
@ -770,8 +771,9 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand
{ {
var channelId = channel.Id; var channelId = channel.Id;
if (_excludedChannels.TryGetValue(user.Guild.Id, out var chans) && (chans.Contains(channelId) if (_excludedChannels.TryGetValue(user.Guild.Id, out var chans)
|| (channel is SocketThreadChannel tc && chans.Contains(tc.ParentChannel.Id)))) && (chans.Contains(channelId)
|| (channel is SocketThreadChannel tc && chans.Contains(tc.ParentChannel.Id))))
return false; return false;
if (_excludedServers.Contains(user.Guild.Id)) if (_excludedServers.Contains(user.Guild.Id))