Wishlist: Implement Patreon perks for wishlist slots

This commit is contained in:
2023-04-03 17:16:23 +02:00
parent c48aa8b34f
commit fdf5a4074b
2 changed files with 15 additions and 5 deletions

View File

@@ -1,6 +1,7 @@
const { SlashCommandBuilder } = require("discord.js"); const { SlashCommandBuilder, IntegrationApplication } = require("discord.js");
const { Wishlist, Character } = require("../models"); const { Wishlist, Character } = require("../models");
const UserUtils = require("../util/users"); const UserUtils = require("../util/users");
const { BASE_VALUES } = require("../config/constants");
module.exports = { module.exports = {
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
@@ -48,9 +49,13 @@ module.exports = {
wishlist.Characters = [] wishlist.Characters = []
await interaction.channel.send("Created new wishlist"); await interaction.channel.send("Created new wishlist");
} }
let patreonSlots = (await UserUtils.getPatreonPerks(interaction.client, user))['perks']?.['modifiers']['wishlist'] || 0;
let slotasAvailable = BASE_VALUES.wishlist_slots + patreonSlots;
switch (interaction.options.getSubcommand()) { switch (interaction.options.getSubcommand()) {
case "view": case "view":
let reply = `Wishlist entries (${wishlist.Characters.length}/5 used):\n`; let reply = `Wishlist entries (${wishlist.Characters.length}/${slotasAvailable} used):\n`;
wishlist.Characters.forEach(character => { wishlist.Characters.forEach(character => {
reply += `${character.name} \n`; reply += `${character.name} \n`;
}); });
@@ -65,13 +70,13 @@ module.exports = {
if (await wishlist.hasCharacter(character)) { if (await wishlist.hasCharacter(character)) {
await wishlist.removeCharacter(character) await wishlist.removeCharacter(character)
await interaction.editReply(`Removed ${character.name} from your wishlist! ${wishlist.Characters.length-1}/5 used`); await interaction.editReply(`Removed ${character.name} from your wishlist! ${wishlist.Characters.length-1}/${slotasAvailable} used`);
} else { } else {
if (wishlist.Characters.length < 5) { if (wishlist.Characters.length < 5) {
await wishlist.addCharacter(character); await wishlist.addCharacter(character);
await interaction.editReply(`Added ${character.name} to your wishlist! ${wishlist.Characters.length+1}/5 used`); await interaction.editReply(`Added ${character.name} to your wishlist! ${wishlist.Characters.length+1}/${slotasAvailable} used`);
} else { } else {
await interaction.editReply(`You have no remaining wishlist slots! ${wishlist.Characters.length}`); await interaction.editReply(`You have no remaining wishlist slots! ${wishlist.Characters.length}/${slotasAvailable} used`);
} }
} }
break; break;

View File

@@ -62,6 +62,10 @@ const QUALITY_VALUES = {
} }
} }
const BASE_VALUES = {
wishlist_slots : 5
}
const DAILY_REWARDS = { const DAILY_REWARDS = {
primary_currency : 250, primary_currency : 250,
secondary_currency : 5, secondary_currency : 5,
@@ -126,5 +130,6 @@ exports.CURRENCY_SYMBOLS = CURRENCY_SYMBOLS;
exports.QUALITY_SYMBOLS = QUALITY_SYMBOLS; exports.QUALITY_SYMBOLS = QUALITY_SYMBOLS;
exports.CURRENCY_NAMES = CURRENCY_NAMES; exports.CURRENCY_NAMES = CURRENCY_NAMES;
exports.QUALITY_VALUES = QUALITY_VALUES; exports.QUALITY_VALUES = QUALITY_VALUES;
exports.BASE_VALUES = BASE_VALUES;
exports.DAILY_REWARDS = DAILY_REWARDS; exports.DAILY_REWARDS = DAILY_REWARDS;
exports.PATREON = PATREON; exports.PATREON = PATREON;