Compare commits

..

No commits in common. "807c87d4243130e7d1c67ae6bc43f67430daa47a" and "3b9706ae944bebfdd447aa267c190558d85d6359" have entirely different histories.

3 changed files with 11 additions and 3 deletions

View file

@ -47,6 +47,14 @@ export default class Inventory extends AppBaseEntity {
return single; return single;
} }
public static async ExistsByCardNumberAndUserId(userId: string, cardNumber: string): Promise<boolean> {
const repository = AppDataSource.getRepository(Inventory);
const count = await repository.count({ where: { UserId: userId, CardNumber: cardNumber }});
return count != 0;
}
public static async FetchAllByUserId(userId: string): Promise<Inventory[]> { public static async FetchAllByUserId(userId: string): Promise<Inventory[]> {
const repository = AppDataSource.getRepository(Inventory); const repository = AppDataSource.getRepository(Inventory);

View file

@ -39,9 +39,9 @@ export default class ImageHelper {
const imageData = await Jimp.read(filePath); const imageData = await Jimp.read(filePath);
if (userId != null) { if (userId != null) {
const claimed = await Inventory.FetchOneByCardNumberAndUserId(userId, card.id); const claimed = await Inventory.ExistsByCardNumberAndUserId(userId, card.id);
if (!claimed || claimed.Quantity == 0) { if (!claimed) {
imageData.greyscale(); imageData.greyscale();
} }
} }

View file

@ -78,7 +78,7 @@ export default class SeriesHelper {
const seriesOnPage = series.splice(page * itemsPerPage, itemsPerPage); const seriesOnPage = series.splice(page * itemsPerPage, itemsPerPage);
const description = seriesOnPage const description = seriesOnPage
.map(x => `[${x.id}] ${x.name} (${x.cards.length} cards)`) .map(x => `[${x.id}] ${x.name} (x${x.cards.length})`)
.join("\n"); .join("\n");
const embed = new EmbedBuilder() const embed = new EmbedBuilder()