Xp system fixes

This commit is contained in:
Master Kwoth 2017-09-11 23:39:28 +02:00
parent 4c591a69b1
commit ea0ca1471f
3 changed files with 8 additions and 5 deletions

View File

@ -343,9 +343,6 @@ namespace NadekoBot.Modules.Xp.Services
var _ = Task.Run(() =>
{
if (!SetUserRewarded(user.Id))
return;
if (_excludedChannels.TryGetValue(user.Guild.Id, out var chans) &&
chans.Contains(arg.Channel.Id))
return;
@ -359,6 +356,10 @@ namespace NadekoBot.Modules.Xp.Services
if (!arg.Content.Contains(' ') && arg.Content.Length < 5)
return;
if (!SetUserRewarded(user.Id))
return;
_addMessageXp.Enqueue(new UserCacheItem { Guild = user.Guild, Channel = arg.Channel, User = user });
});
return Task.CompletedTask;

View File

@ -58,7 +58,9 @@ namespace NadekoBot.Services.Database.Repositories.Impl
.Where(x => x.GuildId == guildId)
.Count(x => x.Xp > (_set
.Where(y => y.UserId == userId && y.GuildId == guildId)
.Sum(y => y.Xp))) + 1;
.Select(y => y.Xp)
.DefaultIfEmpty()
.Sum())) + 1;
}
public (ulong UserId, int TotalXp)[] GetUsersFor(int page)

View File

@ -135,7 +135,7 @@ namespace NadekoBot.Extensions
public static MemoryStream ToStream(this ImageSharp.Image<Rgba32> img)
{
var imageStream = new MemoryStream();
img.SaveAsPng(imageStream);
img.SaveAsPng(imageStream, new ImageSharp.Formats.PngEncoder() { CompressionLevel = 9});
imageStream.Position = 0;
return imageStream;
}