mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-10 17:28:27 -04:00
Guild XP is no longer opt-in. Only global xp
This commit is contained in:
@@ -212,8 +212,43 @@ public class XpService : INService, IReadyExecutor, IExecNoCommand
|
|||||||
Xp = old.Xp + group.Key
|
Xp = old.Xp + group.Key
|
||||||
},
|
},
|
||||||
(_, n) => n);
|
(_, n) => n);
|
||||||
|
|
||||||
gxps.AddRange(items);
|
gxps.AddRange(items);
|
||||||
|
|
||||||
|
var missingUserIds = group.Where(userId => !items.Any(x => x.UserId == userId)).ToArray();
|
||||||
|
foreach (var userId in missingUserIds)
|
||||||
|
{
|
||||||
|
await ctx
|
||||||
|
.UserXpStats
|
||||||
|
.ToLinqToDBTable()
|
||||||
|
.InsertOrUpdateAsync(() => new UserXpStats()
|
||||||
|
{
|
||||||
|
UserId = userId,
|
||||||
|
GuildId = guildId,
|
||||||
|
Xp = group.Key,
|
||||||
|
DateAdded = DateTime.UtcNow,
|
||||||
|
AwardedXp = 0,
|
||||||
|
NotifyOnLevelUp = XpNotificationLocation.None
|
||||||
|
},
|
||||||
|
_ => new()
|
||||||
|
{
|
||||||
|
|
||||||
|
},
|
||||||
|
() => new()
|
||||||
|
{
|
||||||
|
UserId = userId
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (missingUserIds.Length > 0)
|
||||||
|
{
|
||||||
|
var missingItems = await ctx.UserXpStats
|
||||||
|
.ToLinqToDBTable()
|
||||||
|
.Where(x => missingUserIds.Contains(x.UserId))
|
||||||
|
.ToArrayAsyncLinqToDB();
|
||||||
|
|
||||||
|
gxps.AddRange(missingItems);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user