fixed .shop commands

This commit is contained in:
Toastie 2025-03-23 15:53:06 +13:00
parent 16025b74e3
commit d26efb3c8c
Signed by: toastie_t0ast
GPG key ID: 0861BE54AD481DC7

View file

@ -332,17 +332,18 @@ public partial class Gambling
Type = ShopEntryType.Role, Type = ShopEntryType.Role,
AuthorId = ctx.User.Id, AuthorId = ctx.User.Id,
RoleId = role.Id, RoleId = role.Id,
RoleName = role.Name RoleName = role.Name,
GuildId = ctx.Guild.Id,
}; };
await using (var uow = _db.GetDbContext()) await using (var uow = _db.GetDbContext())
{ {
var entries = new IndexedCollection<ShopEntry>(await uow.Set<ShopEntry>() var entries = new IndexedCollection<ShopEntry>(await uow.Set<ShopEntry>()
.Where(x => x.GuildId == ctx.Guild.Id) .Where(x => x.GuildId == ctx.Guild.Id)
.Include(x => x.Items) .Include(x => x.Items)
.ToListAsyncEF()) .ToListAsyncEF());
{
entry entries.Add(entry);
}; uow.Add(entry);
await uow.SaveChangesAsync(); await uow.SaveChangesAsync();
} }
@ -363,7 +364,8 @@ public partial class Gambling
Price = price, Price = price,
Type = ShopEntryType.List, Type = ShopEntryType.List,
AuthorId = ctx.User.Id, AuthorId = ctx.User.Id,
Items = new() Items = new(),
GuildId = ctx.Guild.Id
}; };
await using (var uow = _db.GetDbContext()) await using (var uow = _db.GetDbContext())
{ {
@ -440,7 +442,7 @@ public partial class Gambling
var items = await uow.Set<ShopEntry>() var items = await uow.Set<ShopEntry>()
.Where(x => x.GuildId == ctx.Guild.Id) .Where(x => x.GuildId == ctx.Guild.Id)
.Include(x => x.Items) .Include(x => x.Items)
.ToListAsyncLinqToDB(); .ToListAsyncEF();
var entries = new IndexedCollection<ShopEntry>(items); var entries = new IndexedCollection<ShopEntry>(items);
removed = entries.ElementAtOrDefault(index); removed = entries.ElementAtOrDefault(index);