Compare commits

..

2 commits

Author SHA1 Message Date
df56c76a89
Updated Help module 2024-06-27 21:08:15 +12:00
b7b8366fe2
Updated Xp module 2024-06-27 21:07:29 +12:00
4 changed files with 13 additions and 9 deletions

View file

@ -524,7 +524,7 @@ public sealed partial class Help : EllieModule<HelpService>
=> smc.RespondConfirmAsync(_sender,
"""
- In case you don't want or cannot Donate to EllieBot project, but you
- EllieBot is a free and [open source](https://toastielab.dev/Emotions-stuff/Ellie) project which means you can run your own "selfhosted" instance on your computer.
- EllieBot is a free and [open source](https://toastielab.dev/Emotions-stuff/elliebot) project which means you can run your own "selfhosted" instance on your computer.
*Keep in mind that running the bot on your computer means that the bot will be offline when you turn off your computer*

View file

@ -2,6 +2,7 @@
using EllieBot.Modules.Xp.Services;
using EllieBot.Db.Models;
using EllieBot.Modules.Patronage;
using EllieBot.Modules.Utility;
namespace EllieBot.Modules.Xp;

View file

@ -668,7 +668,7 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand
/// <param name="channel"></param>
private async Task ScanUserForVoiceXp(SocketGuildUser user, SocketVoiceChannel channel)
{
if (UserParticipatingInVoiceChannel(user) && ShouldTrackXp(user, channel.Id))
if (UserParticipatingInVoiceChannel(user) && ShouldTrackXp(user, channel))
await UserJoinedVoiceChannel(user);
else
await UserLeftVoiceChannel(user, channel);
@ -767,9 +767,12 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand
}
*/
private bool ShouldTrackXp(SocketGuildUser user, ulong channelId)
private bool ShouldTrackXp(SocketGuildUser user, IMessageChannel channel)
{
if (_excludedChannels.TryGetValue(user.Guild.Id, out var chans) && chans.Contains(channelId))
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))))
return false;
if (_excludedServers.Contains(user.Guild.Id))
@ -788,7 +791,7 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand
_ = Task.Run(async () =>
{
if (!ShouldTrackXp(user, arg.Channel.Id))
if (!ShouldTrackXp(user, arg.Channel))
return;
var xpConf = _xpConfig.Data;
@ -1286,9 +1289,9 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand
Image? frame = null;
if (item is null)
{
if (patron.Tier == PatronTier.V)
if (patron?.Tier == PatronTier.V)
frame = Image.Load<Rgba32>(File.OpenRead("data/images/frame_silver.png"));
else if (patron.Tier >= PatronTier.X || _creds.IsOwner(userId))
else if (patron?.Tier >= PatronTier.X || _creds.IsOwner(userId))
frame = Image.Load<Rgba32>(File.OpenRead("data/images/frame_gold.png"));
}
else
@ -1465,7 +1468,7 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand
{
var patron = await _ps.GetPatronAsync(userId);
if ((int)patron.Tier < (int)req)
if (patron is null || (int)patron.Value.Tier < (int)req)
return BuyResult.InsufficientPatronTier;
}

View file

@ -1,4 +1,4 @@
#nullable disable warnings
#nullable disable warnings
namespace EllieBot.Db.Models;
public class XpShopOwnedItem : DbEntity