Added .xplevelset
removed awardedxp from database. .sclr show will now show hex .awardxp will now add directly to user's real xp
This commit is contained in:
parent
dfd5b7a823
commit
4a723b7c1c
12 changed files with 141 additions and 106 deletions
|
@ -31,17 +31,17 @@ public static class UserXpExtensions
|
||||||
public static async Task<List<UserXpStats>> GetTopUserXps(this DbSet<UserXpStats> xps, ulong guildId, int count)
|
public static async Task<List<UserXpStats>> GetTopUserXps(this DbSet<UserXpStats> xps, ulong guildId, int count)
|
||||||
=> await xps.ToLinqToDBTable()
|
=> await xps.ToLinqToDBTable()
|
||||||
.Where(x => x.GuildId == guildId)
|
.Where(x => x.GuildId == guildId)
|
||||||
.OrderByDescending(x => x.Xp + x.AwardedXp)
|
.OrderByDescending(x => x.Xp)
|
||||||
.Take(count)
|
.Take(count)
|
||||||
.ToListAsyncLinqToDB();
|
.ToListAsyncLinqToDB();
|
||||||
|
|
||||||
public static async Task<int> GetUserGuildRanking(this DbSet<UserXpStats> xps, ulong userId, ulong guildId)
|
public static async Task<int> GetUserGuildRanking(this DbSet<UserXpStats> xps, ulong userId, ulong guildId)
|
||||||
=> await xps.ToLinqToDBTable()
|
=> await xps.ToLinqToDBTable()
|
||||||
.Where(x => x.GuildId == guildId
|
.Where(x => x.GuildId == guildId
|
||||||
&& x.Xp + x.AwardedXp
|
&& x.Xp
|
||||||
> xps.AsQueryable()
|
> xps.AsQueryable()
|
||||||
.Where(y => y.UserId == userId && y.GuildId == guildId)
|
.Where(y => y.UserId == userId && y.GuildId == guildId)
|
||||||
.Select(y => y.Xp + y.AwardedXp)
|
.Select(y => y.Xp)
|
||||||
.FirstOrDefault())
|
.FirstOrDefault())
|
||||||
.CountAsyncLinqToDB()
|
.CountAsyncLinqToDB()
|
||||||
+ 1;
|
+ 1;
|
||||||
|
@ -53,6 +53,6 @@ public static class UserXpExtensions
|
||||||
=> await userXp
|
=> await userXp
|
||||||
.Where(x => x.GuildId == guildId && x.UserId == userId)
|
.Where(x => x.GuildId == guildId && x.UserId == userId)
|
||||||
.FirstOrDefaultAsyncLinqToDB() is UserXpStats uxs
|
.FirstOrDefaultAsyncLinqToDB() is UserXpStats uxs
|
||||||
? new(uxs.Xp + uxs.AwardedXp)
|
? new(uxs.Xp)
|
||||||
: new(0);
|
: new(0);
|
||||||
}
|
}
|
|
@ -3,38 +3,28 @@ namespace EllieBot.Db;
|
||||||
|
|
||||||
public readonly struct LevelStats
|
public readonly struct LevelStats
|
||||||
{
|
{
|
||||||
public const int XP_REQUIRED_LVL_1 = 36;
|
|
||||||
|
|
||||||
public long Level { get; }
|
public long Level { get; }
|
||||||
public long LevelXp { get; }
|
public long LevelXp { get; }
|
||||||
public long RequiredXp { get; }
|
public long RequiredXp { get; }
|
||||||
public long TotalXp { get; }
|
public long TotalXp { get; }
|
||||||
|
|
||||||
public LevelStats(long xp)
|
public LevelStats(long totalXp)
|
||||||
{
|
{
|
||||||
if (xp < 0)
|
if (totalXp < 0)
|
||||||
xp = 0;
|
totalXp = 0;
|
||||||
|
|
||||||
TotalXp = xp;
|
TotalXp = totalXp;
|
||||||
|
Level = GetLevelByTotalXp(totalXp);
|
||||||
const int baseXp = XP_REQUIRED_LVL_1;
|
LevelXp = totalXp - GetTotalXpReqForLevel(Level);
|
||||||
|
RequiredXp = (9 * (Level + 1)) + 27;
|
||||||
var required = baseXp;
|
|
||||||
var totalXp = 0;
|
|
||||||
var lvl = 1;
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
required = (int)(baseXp + (baseXp / 4.0 * (lvl - 1)));
|
|
||||||
|
|
||||||
if (required + totalXp > xp)
|
|
||||||
break;
|
|
||||||
|
|
||||||
totalXp += required;
|
|
||||||
lvl++;
|
|
||||||
}
|
|
||||||
|
|
||||||
Level = lvl - 1;
|
|
||||||
LevelXp = xp - totalXp;
|
|
||||||
RequiredXp = required;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static LevelStats CreateForLevel(long level)
|
||||||
|
=> new(GetTotalXpReqForLevel(level));
|
||||||
|
|
||||||
|
public static long GetTotalXpReqForLevel(long level)
|
||||||
|
=> ((9 * level * level) + (63 * level)) / 2;
|
||||||
|
|
||||||
|
public static long GetLevelByTotalXp(long totalXp)
|
||||||
|
=> (long)((-7.0 / 2) + (1 / 6.0 * Math.Sqrt((8 * totalXp) + 441)));
|
||||||
}
|
}
|
|
@ -66,9 +66,9 @@ public partial class Administration
|
||||||
|
|
||||||
await message.ModifyAsync(x =>
|
await message.ModifyAsync(x =>
|
||||||
x.Embed = CreateEmbed()
|
x.Embed = CreateEmbed()
|
||||||
.WithDescription(GetText(strs.cache_users_done(added, updated)))
|
.WithDescription(GetText(strs.cache_users_done(added, updated)))
|
||||||
.WithOkColor()
|
.WithOkColor()
|
||||||
.Build()
|
.Build()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,13 +119,13 @@ public partial class Administration
|
||||||
|
|
||||||
await Response()
|
await Response()
|
||||||
.Embed(CreateEmbed()
|
.Embed(CreateEmbed()
|
||||||
.WithOkColor()
|
.WithOkColor()
|
||||||
.WithTitle(GetText(strs.scadd))
|
.WithTitle(GetText(strs.scadd))
|
||||||
.AddField(GetText(strs.server),
|
.AddField(GetText(strs.server),
|
||||||
cmd.GuildId is null ? "-" : $"{cmd.GuildName}/{cmd.GuildId}",
|
cmd.GuildId is null ? "-" : $"{cmd.GuildName}/{cmd.GuildId}",
|
||||||
true)
|
true)
|
||||||
.AddField(GetText(strs.channel), $"{cmd.ChannelName}/{cmd.ChannelId}", true)
|
.AddField(GetText(strs.channel), $"{cmd.ChannelName}/{cmd.ChannelId}", true)
|
||||||
.AddField(GetText(strs.command_text), cmdText))
|
.AddField(GetText(strs.command_text), cmdText))
|
||||||
.SendAsync();
|
.SendAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,16 +323,16 @@ public partial class Administration
|
||||||
.ToArray());
|
.ToArray());
|
||||||
|
|
||||||
var allShardStrings = statuses.Select(st =>
|
var allShardStrings = statuses.Select(st =>
|
||||||
{
|
{
|
||||||
var timeDiff = DateTime.UtcNow - st.LastUpdate;
|
var timeDiff = DateTime.UtcNow - st.LastUpdate;
|
||||||
var stateStr = ConnectionStateToEmoji(st);
|
var stateStr = ConnectionStateToEmoji(st);
|
||||||
var maxGuildCountLength =
|
var maxGuildCountLength =
|
||||||
statuses.Max(x => x.GuildCount).ToString().Length;
|
statuses.Max(x => x.GuildCount).ToString().Length;
|
||||||
return $"`{stateStr} "
|
return $"`{stateStr} "
|
||||||
+ $"| #{st.ShardId.ToString().PadBoth(3)} "
|
+ $"| #{st.ShardId.ToString().PadBoth(3)} "
|
||||||
+ $"| {timeDiff:mm\\:ss} "
|
+ $"| {timeDiff:mm\\:ss} "
|
||||||
+ $"| {st.GuildCount.ToString().PadBoth(maxGuildCountLength)} `";
|
+ $"| {st.GuildCount.ToString().PadBoth(maxGuildCountLength)} `";
|
||||||
})
|
})
|
||||||
.ToArray();
|
.ToArray();
|
||||||
await Response()
|
await Response()
|
||||||
.Paginated()
|
.Paginated()
|
||||||
|
@ -440,7 +440,8 @@ public partial class Administration
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try { await Response().Confirm(strs.restarting).SendAsync(); }
|
try
|
||||||
|
{ await Response().Confirm(strs.restarting).SendAsync(); }
|
||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,17 +12,21 @@ public partial class Utility
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async Task ServerColorsShow()
|
public async Task ServerColorsShow()
|
||||||
{
|
{
|
||||||
|
var colors = _service.GetColors(ctx.Guild.Id);
|
||||||
|
var okHex = colors?.Ok?.RawValue.ToString("X8");
|
||||||
|
var warnHex = colors?.Warn?.RawValue.ToString("X8");
|
||||||
|
var errHex = colors?.Error?.RawValue.ToString("X8");
|
||||||
EmbedBuilder[] ebs =
|
EmbedBuilder[] ebs =
|
||||||
[
|
[
|
||||||
CreateEmbed()
|
CreateEmbed()
|
||||||
.WithOkColor()
|
.WithOkColor()
|
||||||
.WithDescription("\\✅"),
|
.WithDescription($"\\✅ {okHex}"),
|
||||||
CreateEmbed()
|
CreateEmbed()
|
||||||
.WithPendingColor()
|
.WithPendingColor()
|
||||||
.WithDescription("\\⏳\\⚠️"),
|
.WithDescription($"\\⏳\\⚠️ {warnHex}"),
|
||||||
CreateEmbed()
|
CreateEmbed()
|
||||||
.WithErrorColor()
|
.WithErrorColor()
|
||||||
.WithDescription("\\❌")
|
.WithDescription($"\\❌ {errHex}")
|
||||||
];
|
];
|
||||||
|
|
||||||
await Response()
|
await Response()
|
||||||
|
|
|
@ -59,9 +59,9 @@ public partial class Xp : EllieModule<XpService>
|
||||||
var serverSetting = _service.GetNotificationType(ctx.User.Id, ctx.Guild.Id);
|
var serverSetting = _service.GetNotificationType(ctx.User.Id, ctx.Guild.Id);
|
||||||
|
|
||||||
var embed = CreateEmbed()
|
var embed = CreateEmbed()
|
||||||
.WithOkColor()
|
.WithOkColor()
|
||||||
.AddField(GetText(strs.xpn_setting_global), GetNotifLocationString(globalSetting))
|
.AddField(GetText(strs.xpn_setting_global), GetNotifLocationString(globalSetting))
|
||||||
.AddField(GetText(strs.xpn_setting_server), GetNotifLocationString(serverSetting));
|
.AddField(GetText(strs.xpn_setting_server), GetNotifLocationString(serverSetting));
|
||||||
|
|
||||||
await Response().Embed(embed).SendAsync();
|
await Response().Embed(embed).SendAsync();
|
||||||
}
|
}
|
||||||
|
@ -154,9 +154,9 @@ public partial class Xp : EllieModule<XpService>
|
||||||
.Page((items, _) =>
|
.Page((items, _) =>
|
||||||
{
|
{
|
||||||
var embed = CreateEmbed()
|
var embed = CreateEmbed()
|
||||||
.WithTitle(GetText(strs.exclusion_list))
|
.WithTitle(GetText(strs.exclusion_list))
|
||||||
.WithDescription(string.Join('\n', items))
|
.WithDescription(string.Join('\n', items))
|
||||||
.WithOkColor();
|
.WithOkColor();
|
||||||
|
|
||||||
return embed;
|
return embed;
|
||||||
})
|
})
|
||||||
|
@ -214,16 +214,12 @@ public partial class Xp : EllieModule<XpService>
|
||||||
|
|
||||||
for (var i = 0; i < users.Count; i++)
|
for (var i = 0; i < users.Count; i++)
|
||||||
{
|
{
|
||||||
var levelStats = new LevelStats(users[i].Xp + users[i].AwardedXp);
|
var levelStats = new LevelStats(users[i].Xp);
|
||||||
var user = ((SocketGuild)ctx.Guild).GetUser(users[i].UserId);
|
var user = ((SocketGuild)ctx.Guild).GetUser(users[i].UserId);
|
||||||
|
|
||||||
var userXpData = users[i];
|
var userXpData = users[i];
|
||||||
|
|
||||||
var awardStr = string.Empty;
|
var awardStr = string.Empty;
|
||||||
if (userXpData.AwardedXp > 0)
|
|
||||||
awardStr = $"(+{userXpData.AwardedXp})";
|
|
||||||
else if (userXpData.AwardedXp < 0)
|
|
||||||
awardStr = $"({userXpData.AwardedXp})";
|
|
||||||
|
|
||||||
embed.AddField($"#{i + 1 + (curPage * 10)} {user?.ToString() ?? users[i].UserId.ToString()}",
|
embed.AddField($"#{i + 1 + (curPage * 10)} {user?.ToString() ?? users[i].UserId.ToString()}",
|
||||||
$"{GetText(strs.level_x(levelStats.Level))} - {levelStats.TotalXp}xp {awardStr}");
|
$"{GetText(strs.level_x(levelStats.Level))} - {levelStats.TotalXp}xp {awardStr}");
|
||||||
|
@ -266,8 +262,8 @@ public partial class Xp : EllieModule<XpService>
|
||||||
.Page((users, curPage) =>
|
.Page((users, curPage) =>
|
||||||
{
|
{
|
||||||
var embed = CreateEmbed()
|
var embed = CreateEmbed()
|
||||||
.WithOkColor()
|
.WithOkColor()
|
||||||
.WithTitle(GetText(strs.global_leaderboard));
|
.WithTitle(GetText(strs.global_leaderboard));
|
||||||
|
|
||||||
if (!users.Any())
|
if (!users.Any())
|
||||||
{
|
{
|
||||||
|
@ -287,6 +283,28 @@ public partial class Xp : EllieModule<XpService>
|
||||||
.SendAsync();
|
.SendAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Cmd]
|
||||||
|
[RequireContext(ContextType.Guild)]
|
||||||
|
[UserPerm(GuildPerm.Administrator)]
|
||||||
|
[Priority(1)]
|
||||||
|
public Task XpLevelSet(int level, IGuildUser user)
|
||||||
|
=> XpLevelSet(level, user.Id);
|
||||||
|
|
||||||
|
[Cmd]
|
||||||
|
[RequireContext(ContextType.Guild)]
|
||||||
|
[UserPerm(GuildPerm.Administrator)]
|
||||||
|
[Priority(0)]
|
||||||
|
public async Task XpLevelSet(int level, ulong userId)
|
||||||
|
{
|
||||||
|
if (level < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
await _service.SetLevelAsync(ctx.Guild.Id, userId, level);
|
||||||
|
await Response()
|
||||||
|
.Confirm(strs.level_set($"<@{userId}>", Format.Bold(level.ToString())))
|
||||||
|
.SendAsync();
|
||||||
|
}
|
||||||
|
|
||||||
[Cmd]
|
[Cmd]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
[UserPerm(GuildPerm.Administrator)]
|
[UserPerm(GuildPerm.Administrator)]
|
||||||
|
@ -351,8 +369,8 @@ public partial class Xp : EllieModule<XpService>
|
||||||
public async Task XpReset(ulong userId)
|
public async Task XpReset(ulong userId)
|
||||||
{
|
{
|
||||||
var embed = CreateEmbed()
|
var embed = CreateEmbed()
|
||||||
.WithTitle(GetText(strs.reset))
|
.WithTitle(GetText(strs.reset))
|
||||||
.WithDescription(GetText(strs.reset_user_confirm));
|
.WithDescription(GetText(strs.reset_user_confirm));
|
||||||
|
|
||||||
if (!await PromptUserConfirmAsync(embed))
|
if (!await PromptUserConfirmAsync(embed))
|
||||||
return;
|
return;
|
||||||
|
@ -368,8 +386,8 @@ public partial class Xp : EllieModule<XpService>
|
||||||
public async Task XpReset()
|
public async Task XpReset()
|
||||||
{
|
{
|
||||||
var embed = CreateEmbed()
|
var embed = CreateEmbed()
|
||||||
.WithTitle(GetText(strs.reset))
|
.WithTitle(GetText(strs.reset))
|
||||||
.WithDescription(GetText(strs.reset_server_confirm));
|
.WithDescription(GetText(strs.reset_server_confirm));
|
||||||
|
|
||||||
if (!await PromptUserConfirmAsync(embed))
|
if (!await PromptUserConfirmAsync(embed))
|
||||||
return;
|
return;
|
||||||
|
@ -446,20 +464,20 @@ public partial class Xp : EllieModule<XpService>
|
||||||
{
|
{
|
||||||
if (!items.Any())
|
if (!items.Any())
|
||||||
return CreateEmbed()
|
return CreateEmbed()
|
||||||
.WithDescription(GetText(strs.not_found))
|
.WithDescription(GetText(strs.not_found))
|
||||||
.WithErrorColor();
|
.WithErrorColor();
|
||||||
|
|
||||||
var (key, item) = items.FirstOrDefault();
|
var (key, item) = items.FirstOrDefault();
|
||||||
|
|
||||||
var eb = CreateEmbed()
|
var eb = CreateEmbed()
|
||||||
.WithOkColor()
|
.WithOkColor()
|
||||||
.WithTitle(item.Name)
|
.WithTitle(item.Name)
|
||||||
.AddField(GetText(strs.price),
|
.AddField(GetText(strs.price),
|
||||||
CurrencyHelper.N(item.Price, Culture, _gss.GetCurrencySign()),
|
CurrencyHelper.N(item.Price, Culture, _gss.GetCurrencySign()),
|
||||||
true)
|
true)
|
||||||
.WithImageUrl(string.IsNullOrWhiteSpace(item.Preview)
|
.WithImageUrl(string.IsNullOrWhiteSpace(item.Preview)
|
||||||
? item.Url
|
? item.Url
|
||||||
: item.Preview);
|
: item.Preview);
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(item.Desc))
|
if (!string.IsNullOrWhiteSpace(item.Desc))
|
||||||
eb.AddField(GetText(strs.desc), item.Desc);
|
eb.AddField(GetText(strs.desc), item.Desc);
|
||||||
|
|
|
@ -261,7 +261,6 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand
|
||||||
GuildId = guildId,
|
GuildId = guildId,
|
||||||
Xp = group.Key,
|
Xp = group.Key,
|
||||||
DateAdded = DateTime.UtcNow,
|
DateAdded = DateTime.UtcNow,
|
||||||
AwardedXp = 0,
|
|
||||||
NotifyOnLevelUp = XpNotificationLocation.None
|
NotifyOnLevelUp = XpNotificationLocation.None
|
||||||
},
|
},
|
||||||
_ => new()
|
_ => new()
|
||||||
|
@ -310,8 +309,8 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand
|
||||||
if (guildToAdd.TryGetValue(du.GuildId, out var users)
|
if (guildToAdd.TryGetValue(du.GuildId, out var users)
|
||||||
&& users.TryGetValue(du.UserId, out var xpGainData))
|
&& users.TryGetValue(du.UserId, out var xpGainData))
|
||||||
{
|
{
|
||||||
var oldLevel = new LevelStats(du.Xp - xpGainData.XpAmount + du.AwardedXp);
|
var oldLevel = new LevelStats(du.Xp - xpGainData.XpAmount);
|
||||||
var newLevel = new LevelStats(du.Xp + du.AwardedXp);
|
var newLevel = new LevelStats(du.Xp);
|
||||||
|
|
||||||
if (oldLevel.Level < newLevel.Level)
|
if (oldLevel.Level < newLevel.Level)
|
||||||
{
|
{
|
||||||
|
@ -595,7 +594,7 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand
|
||||||
return await uow
|
return await uow
|
||||||
.UserXpStats
|
.UserXpStats
|
||||||
.Where(x => x.GuildId == guildId)
|
.Where(x => x.GuildId == guildId)
|
||||||
.OrderByDescending(x => x.Xp + x.AwardedXp)
|
.OrderByDescending(x => x.Xp)
|
||||||
.Skip(page * 10)
|
.Skip(page * 10)
|
||||||
.Take(10)
|
.Take(10)
|
||||||
.ToArrayAsyncLinqToDB();
|
.ToArrayAsyncLinqToDB();
|
||||||
|
@ -606,7 +605,7 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand
|
||||||
await using var uow = _db.GetDbContext();
|
await using var uow = _db.GetDbContext();
|
||||||
return await uow.Set<UserXpStats>()
|
return await uow.Set<UserXpStats>()
|
||||||
.Where(x => x.GuildId == guildId && x.UserId.In(users))
|
.Where(x => x.GuildId == guildId && x.UserId.In(users))
|
||||||
.OrderByDescending(x => x.Xp + x.AwardedXp)
|
.OrderByDescending(x => x.Xp)
|
||||||
.Skip(page * 10)
|
.Skip(page * 10)
|
||||||
.Take(10)
|
.Take(10)
|
||||||
.ToArrayAsyncLinqToDB();
|
.ToArrayAsyncLinqToDB();
|
||||||
|
@ -903,7 +902,7 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand
|
||||||
using var uow = _db.GetDbContext();
|
using var uow = _db.GetDbContext();
|
||||||
var usr = uow.GetOrCreateUserXpStats(guildId, userId);
|
var usr = uow.GetOrCreateUserXpStats(guildId, userId);
|
||||||
|
|
||||||
usr.AwardedXp += amount;
|
usr.Xp += amount;
|
||||||
|
|
||||||
uow.SaveChanges();
|
uow.SaveChanges();
|
||||||
}
|
}
|
||||||
|
@ -949,7 +948,7 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand
|
||||||
return new(du,
|
return new(du,
|
||||||
stats,
|
stats,
|
||||||
new(totalXp),
|
new(totalXp),
|
||||||
new(stats.Xp + stats.AwardedXp),
|
new(stats.Xp),
|
||||||
globalRank,
|
globalRank,
|
||||||
guildRank);
|
guildRank);
|
||||||
}
|
}
|
||||||
|
@ -1192,19 +1191,6 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand
|
||||||
outlinePen));
|
outlinePen));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stats.FullGuildStats.AwardedXp != 0 && template.User.Xp.Awarded.Show)
|
|
||||||
{
|
|
||||||
var sign = stats.FullGuildStats.AwardedXp > 0 ? "+ " : "";
|
|
||||||
var awX = template.User.Xp.Awarded.Pos.X
|
|
||||||
- (Math.Max(0, stats.FullGuildStats.AwardedXp.ToString().Length - 2) * 5);
|
|
||||||
var awY = template.User.Xp.Awarded.Pos.Y;
|
|
||||||
img.Mutate(x => x.DrawText($"({sign}{stats.FullGuildStats.AwardedXp})",
|
|
||||||
_fonts.NotoSans.CreateFont(template.User.Xp.Awarded.FontSize, FontStyle.Bold),
|
|
||||||
Brushes.Solid(template.User.Xp.Awarded.Color),
|
|
||||||
outlinePen,
|
|
||||||
new(awX, awY)));
|
|
||||||
}
|
|
||||||
|
|
||||||
var rankPen = new SolidPen(Color.White, 1);
|
var rankPen = new SolidPen(Color.White, 1);
|
||||||
//ranking
|
//ranking
|
||||||
if (template.User.GlobalRank.Show)
|
if (template.User.GlobalRank.Show)
|
||||||
|
@ -1671,6 +1657,29 @@ public class XpService : IEService, IReadyExecutor, IExecNoCommand
|
||||||
&& (guildUsers == null || guildUsers.Contains(x.UserId)))
|
&& (guildUsers == null || guildUsers.Contains(x.UserId)))
|
||||||
.CountAsyncLinqToDB();
|
.CountAsyncLinqToDB();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task SetLevelAsync(ulong guildId, ulong userId, int level)
|
||||||
|
{
|
||||||
|
var lvlStats = LevelStats.CreateForLevel(level);
|
||||||
|
await using var ctx = _db.GetDbContext();
|
||||||
|
await ctx.GetTable<UserXpStats>()
|
||||||
|
.InsertOrUpdateAsync(() => new()
|
||||||
|
{
|
||||||
|
GuildId = guildId,
|
||||||
|
UserId = userId,
|
||||||
|
AwardedXp = 0,
|
||||||
|
Xp = lvlStats.TotalXp,
|
||||||
|
NotifyOnLevelUp = XpNotificationLocation.None,
|
||||||
|
DateAdded = DateTime.UtcNow
|
||||||
|
}, (old) => new()
|
||||||
|
{
|
||||||
|
Xp = lvlStats.TotalXp
|
||||||
|
}, () => new()
|
||||||
|
{
|
||||||
|
GuildId = guildId,
|
||||||
|
UserId = userId
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum BuyResult
|
public enum BuyResult
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class EllieEmbedBuilder : EmbedBuilder
|
||||||
var bcColors = bcsData.Data.Color;
|
var bcColors = bcsData.Data.Color;
|
||||||
_okColor = guildColors?.Ok ?? bcColors.Ok.ToDiscordColor();
|
_okColor = guildColors?.Ok ?? bcColors.Ok.ToDiscordColor();
|
||||||
_errorColor = guildColors?.Error ?? bcColors.Error.ToDiscordColor();
|
_errorColor = guildColors?.Error ?? bcColors.Error.ToDiscordColor();
|
||||||
_pendingColor = guildColors?.Pending ?? bcColors.Pending.ToDiscordColor();
|
_pendingColor = guildColors?.Warn ?? bcColors.Pending.ToDiscordColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
public EmbedBuilder WithOkColor()
|
public EmbedBuilder WithOkColor()
|
||||||
|
|
|
@ -108,7 +108,7 @@ public sealed class GuildColorsService : IReadyExecutor, IGuildColorsService, IE
|
||||||
{
|
{
|
||||||
_colors[guildId] = _colors[guildId] with
|
_colors[guildId] = _colors[guildId] with
|
||||||
{
|
{
|
||||||
Pending = color?.ToDiscordColor()
|
Warn = color?.ToDiscordColor()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,4 +10,4 @@ public interface IGuildColorsService
|
||||||
Task SetPendingColor(ulong guildId, Rgba32? color);
|
Task SetPendingColor(ulong guildId, Rgba32? color);
|
||||||
}
|
}
|
||||||
|
|
||||||
public record struct Colors(Color? Ok, Color? Pending, Color? Error);
|
public record struct Colors(Color? Ok, Color? Warn, Color? Error);
|
||||||
|
|
|
@ -1121,6 +1121,8 @@ xpshopbuy:
|
||||||
- xpshopbuy
|
- xpshopbuy
|
||||||
xpshopuse:
|
xpshopuse:
|
||||||
- xpshopuse
|
- xpshopuse
|
||||||
|
xplevelset:
|
||||||
|
- xplevelset
|
||||||
clubcreate:
|
clubcreate:
|
||||||
- clubcreate
|
- clubcreate
|
||||||
clubtransfer:
|
clubtransfer:
|
||||||
|
|
|
@ -4820,4 +4820,14 @@ servercolorpending:
|
||||||
- '#ffff00'
|
- '#ffff00'
|
||||||
params:
|
params:
|
||||||
- color:
|
- color:
|
||||||
desc: "The hex of the color to set"
|
desc: "The hex of the color to set"
|
||||||
|
xplevelset:
|
||||||
|
desc: |-
|
||||||
|
Sets the level of the user you specify.
|
||||||
|
ex:
|
||||||
|
- '10 @User'
|
||||||
|
params:
|
||||||
|
- level:
|
||||||
|
desc: "The level to set the user to."
|
||||||
|
- user:
|
||||||
|
desc: "The user to set the level of."
|
|
@ -1137,5 +1137,6 @@
|
||||||
"server_not_found": "Server not found.",
|
"server_not_found": "Server not found.",
|
||||||
"server_color_set": "Successfully set a new server color.",
|
"server_color_set": "Successfully set a new server color.",
|
||||||
"lasts_until": "Lasts Until",
|
"lasts_until": "Lasts Until",
|
||||||
"winners_count": "Winners"
|
"winners_count": "Winners",
|
||||||
|
"level_set": "Level of user {0} set to {1} on this server."
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue