From 2ae83846844ccc0880f759c361cce27ab2ac072b Mon Sep 17 00:00:00 2001 From: theimperious1 Date: Sun, 10 Nov 2024 05:10:47 -0500 Subject: [PATCH 1/2] Add premium member to RPG market. Several other changes. --- src/discord/commands/guild/d.rpg.ts | 80 ++++++++++++++++++++--------- 1 file changed, 57 insertions(+), 23 deletions(-) diff --git a/src/discord/commands/guild/d.rpg.ts b/src/discord/commands/guild/d.rpg.ts index 674afa68b..5a6526183 100644 --- a/src/discord/commands/guild/d.rpg.ts +++ b/src/discord/commands/guild/d.rpg.ts @@ -102,6 +102,20 @@ const items = { // effect_value: '0.1', // emoji: 'itemBonus', }, + PremiumMember: { + // eslint-disable-next-line sonarjs/no-duplicate-string + label: 'Premium Membership', + value: 'PremiumMembership', + description: 'Bumps you up the member list and gives discounts in the market', + quantity: 1, + weight: 0, + cost: 69420, + equipped: false, + consumable: true, + effect: 'role', + effect_value: 'PremiumMembership', + emoji: 'itemFlair', + }, }, fonts: { AbrilFatFace: { @@ -1642,7 +1656,8 @@ export async function rpgMarketInventory( for (const [category, categoryItems] of Object.entries(items)) { for (const item of Object.values(categoryItems)) { - if (!inventoryData.find(i => i.value === item.value)) { + if (!inventoryData.find(i => i.value === item.value) + && !(item.value === 'PremiumMembership' && member?.roles.cache.has(env.ROLE_PREMIUM))) { marketInventory.push({ label: `${item.label} - ${(item.cost - (discount * item.cost))} TT$`, value: item.value, @@ -2080,7 +2095,8 @@ export async function rpgMarketAccept( persona_id: personaData.id, }, }); - if (inventoryData.length >= 20) { + + if (inventoryData.length >= 20 && (itemData.value !== 'PremiumMembership')) { const { embeds, components } = await rpgMarketChange(interaction); // This grossness takes the APIEmbed object, turns it into a JSON object, and pulls the description @@ -2151,27 +2167,29 @@ export async function rpgMarketAccept( update: personaData, }); - // Add the item to the user's inventory - const newItem = { - persona_id: personaData.id, - label: itemData.label, - value: itemData.value, - description: itemData.description, - quantity: itemData.quantity, - weight: itemData.weight, - cost: itemData.cost, - equipped: itemData.equipped, - consumable: itemData.consumable, - effect: itemData.effect, - effect_value: itemData.effect_value, - emoji: itemData.emoji, - } as rpg_inventory; - // log.debug(F, `personaInventory: ${JSON.stringify(newItem, null, 2)}`); - - // await inventorySet(newItem); - await db.rpg_inventory.create({ - data: newItem, - }); + if (itemData.value !== 'PremiumMembership') { + // Add the item to the user's inventory + const newItem = { + persona_id: personaData.id, + label: itemData.label, + value: itemData.value, + description: itemData.description, + quantity: itemData.quantity, + weight: itemData.weight, + cost: itemData.cost, + equipped: itemData.equipped, + consumable: itemData.consumable, + effect: itemData.effect, + effect_value: itemData.effect_value, + emoji: itemData.emoji, + } as rpg_inventory; + // log.debug(F, `personaInventory: ${JSON.stringify(newItem, null, 2)}`); + + // await inventorySet(newItem); + await db.rpg_inventory.create({ + data: newItem, + }); + } // if the item is a background or font, automatically equip it and unequip the other items of the same type if (itemData.effect === 'background' || itemData.effect === 'font') { @@ -2235,6 +2253,22 @@ export async function rpgMarketAccept( embedInfoText = 'Your flair has been equipped! Use `/rpg flair` to change your flair, or head Home to unequip it.'; } + if (itemData.value === 'PremiumMembership') { + try { + (interaction.member as GuildMember)?.roles.add(env.ROLE_PREMIUM); + } catch (err) { + personaData.tokens += itemCost; + + await db.personas.upsert({ + where: { + id: personaData.id, + }, + create: personaData, + update: personaData, + }); + } + } + const { embeds, components } = await rpgMarketChange(interaction); // This grossness takes the APIEmbed object, turns it into a JSON object, and pulls the description From 576cc0db193a6eb1a9234af397addfd49891286d Mon Sep 17 00:00:00 2001 From: Hipperooni Date: Mon, 11 Nov 2024 18:02:48 +1100 Subject: [PATCH 2/2] Update cost and icon for premium member item This looks to be ready to go live --- src/discord/commands/guild/d.rpg.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/discord/commands/guild/d.rpg.ts b/src/discord/commands/guild/d.rpg.ts index 5a6526183..c5a408633 100644 --- a/src/discord/commands/guild/d.rpg.ts +++ b/src/discord/commands/guild/d.rpg.ts @@ -104,17 +104,17 @@ const items = { }, PremiumMember: { // eslint-disable-next-line sonarjs/no-duplicate-string - label: 'Premium Membership', + label: 'Premium Member Role', value: 'PremiumMembership', - description: 'Bumps you up the member list and gives discounts in the market', + description: 'Grants the Premium Member role', quantity: 1, weight: 0, - cost: 69420, + cost: 25000, equipped: false, consumable: true, effect: 'role', effect_value: 'PremiumMembership', - emoji: 'itemFlair', + emoji: 'itemPremium', }, }, fonts: {