.waifulb will no longer show #0000 discriminators, for real this time

This commit is contained in:
Toastie (DCS Team) 2024-10-08 14:03:38 +13:00
parent db8885739f
commit 9f97badfc7
Signed by: toastie_t0ast
GPG key ID: 27F3B6855AFD40A4
4 changed files with 23 additions and 21 deletions

View file

@ -252,18 +252,18 @@ public partial class Gambling
var claimer = "no one"; var claimer = "no one";
string status; string status;
var waifuUsername = w.Username.TrimTo(20); var waifuUsername = w.WaifuName.TrimTo(20);
var claimerUsername = w.Claimer?.TrimTo(20); var claimerUsername = w.ClaimerName?.TrimTo(20);
if (w.Claimer is not null) if (w.ClaimerName is not null)
claimer = $"{claimerUsername}#{w.ClaimerDiscrim}"; claimer = $"{claimerUsername}";
if (w.Affinity is null) if (w.Affinity is null)
status = $"... but {waifuUsername}'s heart is empty"; status = $"... but {waifuUsername}'s heart is empty";
else if (w.Affinity + w.AffinityDiscrim == w.Claimer + w.ClaimerDiscrim) else if (w.Affinity == w.ClaimerName)
status = $"... and {waifuUsername} likes {claimerUsername} too <3"; status = $"... and {waifuUsername} likes {claimerUsername} too <3";
else else
status = $"... but {waifuUsername}'s heart belongs to {w.Affinity.TrimTo(20)}#{w.AffinityDiscrim}"; status = $"... but {waifuUsername}'s heart belongs to {w.Affinity.TrimTo(20)}";
return $"**{waifuUsername}#{w.Discrim}** - claimed by **{claimer}**\n\t{status}"; return $"**{waifuUsername}** - claimed by **{claimer}**\n\t{status}";
} }
[Cmd] [Cmd]

View file

@ -40,12 +40,17 @@ public static class WaifuExtensions
.Take(count) .Take(count)
.Select(x => new WaifuLbResult .Select(x => new WaifuLbResult
{ {
Affinity = x.Affinity == null ? null : x.Affinity.Username, Affinity = x.Affinity == null
AffinityDiscrim = x.Affinity == null ? null : x.Affinity.Discriminator, ? null
Claimer = x.Claimer == null ? null : x.Claimer.Username, : x.Affinity.Username
ClaimerDiscrim = x.Claimer == null ? null : x.Claimer.Discriminator, + (x.Affinity.Discriminator != "0000" ? "#" + x.Affinity.Discriminator : ""),
Username = x.Waifu.Username, ClaimerName =
Discrim = x.Waifu.Discriminator, x.Claimer == null
? null
: x.Claimer.Username
+ (x.Claimer.Discriminator != "0000" ? "#" + x.Claimer.Discriminator : ""),
WaifuName = x.Waifu.Username
+ (x.Waifu.Discriminator != "0000" ? "#" + x.Waifu.Discriminator : ""),
Price = x.Price Price = x.Price
}) })
.ToListAsyncEF(); .ToListAsyncEF();

View file

@ -3,14 +3,11 @@ namespace EllieBot.Db.Models;
public class WaifuLbResult public class WaifuLbResult
{ {
public string Username { get; set; } public string WaifuName { get; set; }
public string Discrim { get; set; }
public string Claimer { get; set; } public string ClaimerName { get; set; }
public string ClaimerDiscrim { get; set; }
public string Affinity { get; set; } public string Affinity { get; set; }
public string AffinityDiscrim { get; set; }
public long Price { get; set; } public long Price { get; set; }
} }

View file

@ -134,10 +134,10 @@ public sealed class OtherSvc : GrpcOther.GrpcOtherBase, IEService
var reply = new WaifuLbReply(); var reply = new WaifuLbReply();
reply.Entries.AddRange(waifus.Select(x => new WaifuLbEntry() reply.Entries.AddRange(waifus.Select(x => new WaifuLbEntry()
{ {
ClaimedBy = x.Claimer ?? string.Empty, ClaimedBy = x.ClaimerName ?? string.Empty,
IsMutual = x.Claimer == x.Affinity, IsMutual = x.ClaimerName == x.Affinity,
Value = x.Price, Value = x.Price,
User = x.Username, User = x.WaifuName,
})); }));
return reply; return reply;
} }