mirror of
https://github.com/aydenjahola/discord-multipurpose-bot.git
synced 2024-11-23 09:15:56 +00:00
economy: forgot to add the streak to schema, and adjust shop logic with categories and type
This commit is contained in:
parent
81cfdd4b21
commit
e4e6135a21
5 changed files with 37 additions and 2 deletions
|
@ -22,10 +22,12 @@ module.exports = {
|
||||||
userEconomy = await UserEconomy.create({
|
userEconomy = await UserEconomy.create({
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
guildId: guild.id,
|
guildId: guild.id,
|
||||||
|
streak: 0, // Initialize streak
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
|
|
||||||
if (userEconomy.lastDaily && now - userEconomy.lastDaily < oneDay) {
|
if (userEconomy.lastDaily && now - userEconomy.lastDaily < oneDay) {
|
||||||
const remainingTime =
|
const remainingTime =
|
||||||
new Date(userEconomy.lastDaily.getTime() + oneDay) - now;
|
new Date(userEconomy.lastDaily.getTime() + oneDay) - now;
|
||||||
|
@ -49,8 +51,13 @@ module.exports = {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let reward = dailyBaseReward + userEconomy.streak * streakBonus;
|
if (userEconomy.lastDaily && now - userEconomy.lastDaily >= oneDay) {
|
||||||
|
userEconomy.streak = 0;
|
||||||
|
}
|
||||||
|
|
||||||
userEconomy.streak += 1;
|
userEconomy.streak += 1;
|
||||||
|
|
||||||
|
let reward = dailyBaseReward + userEconomy.streak * streakBonus;
|
||||||
userEconomy.lastDaily = now;
|
userEconomy.lastDaily = now;
|
||||||
userEconomy.balance += reward;
|
userEconomy.balance += reward;
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,9 @@ module.exports = {
|
||||||
const price = Math.floor(item.price * discount);
|
const price = Math.floor(item.price * discount);
|
||||||
const discountText = discount < 1 ? " (Discounted!)" : "";
|
const discountText = discount < 1 ? " (Discounted!)" : "";
|
||||||
|
|
||||||
return `${item.name} - **${price}** coins${discountText} - Rarity: ${item.rarity}`;
|
return `${item.name} - **${price}** coins${discountText} - Rarity: ${
|
||||||
|
item.rarity
|
||||||
|
} - Type: ${item.type} - Category: ${item.category || "N/A"}`;
|
||||||
});
|
});
|
||||||
|
|
||||||
const shopEmbed = new EmbedBuilder()
|
const shopEmbed = new EmbedBuilder()
|
||||||
|
|
|
@ -11,6 +11,8 @@ const shopItemSchema = new mongoose.Schema({
|
||||||
enum: ["Common", "Rare", "Epic", "Legendary"],
|
enum: ["Common", "Rare", "Epic", "Legendary"],
|
||||||
default: "Common",
|
default: "Common",
|
||||||
},
|
},
|
||||||
|
type: { type: String, required: true },
|
||||||
|
category: { type: String },
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = mongoose.model("ShopItem", shopItemSchema);
|
module.exports = mongoose.model("ShopItem", shopItemSchema);
|
||||||
|
|
|
@ -6,6 +6,7 @@ const userEconomySchema = new mongoose.Schema({
|
||||||
balance: { type: Number, default: 200 },
|
balance: { type: Number, default: 200 },
|
||||||
lastDaily: { type: Date, default: null },
|
lastDaily: { type: Date, default: null },
|
||||||
lastWork: { type: Date, default: null },
|
lastWork: { type: Date, default: null },
|
||||||
|
streak: { type: Number, default: 0 },
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = mongoose.model("UserEconomy", userEconomySchema);
|
module.exports = mongoose.model("UserEconomy", userEconomySchema);
|
||||||
|
|
|
@ -2,6 +2,7 @@ const ShopItem = require("../models/ShopItem");
|
||||||
|
|
||||||
async function seedShopItems(guildId) {
|
async function seedShopItems(guildId) {
|
||||||
const items = [
|
const items = [
|
||||||
|
// Valorant Skins
|
||||||
{
|
{
|
||||||
itemId: "prime_vandal",
|
itemId: "prime_vandal",
|
||||||
name: "Prime Vandal",
|
name: "Prime Vandal",
|
||||||
|
@ -9,6 +10,8 @@ async function seedShopItems(guildId) {
|
||||||
description:
|
description:
|
||||||
"A futuristic skin for the Vandal with a sleek design and special effects.",
|
"A futuristic skin for the Vandal with a sleek design and special effects.",
|
||||||
rarity: "Rare",
|
rarity: "Rare",
|
||||||
|
type: "Skin",
|
||||||
|
category: "Valorant",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
itemId: "reaver_vandal",
|
itemId: "reaver_vandal",
|
||||||
|
@ -17,6 +20,8 @@ async function seedShopItems(guildId) {
|
||||||
description:
|
description:
|
||||||
"One of the most popular Vandal skins with a haunting aesthetic and special animations.",
|
"One of the most popular Vandal skins with a haunting aesthetic and special animations.",
|
||||||
rarity: "Epic",
|
rarity: "Epic",
|
||||||
|
type: "Skin",
|
||||||
|
category: "Valorant",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
itemId: "sovereign_ghost",
|
itemId: "sovereign_ghost",
|
||||||
|
@ -25,6 +30,8 @@ async function seedShopItems(guildId) {
|
||||||
description:
|
description:
|
||||||
"Golden elegance for the Ghost pistol with unique sound effects.",
|
"Golden elegance for the Ghost pistol with unique sound effects.",
|
||||||
rarity: "Common",
|
rarity: "Common",
|
||||||
|
type: "Skin",
|
||||||
|
category: "Valorant",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
itemId: "araxys_operator",
|
itemId: "araxys_operator",
|
||||||
|
@ -33,6 +40,8 @@ async function seedShopItems(guildId) {
|
||||||
description:
|
description:
|
||||||
"A top-tier sniper skin with alien-like animations and sound effects.",
|
"A top-tier sniper skin with alien-like animations and sound effects.",
|
||||||
rarity: "Legendary",
|
rarity: "Legendary",
|
||||||
|
type: "Skin",
|
||||||
|
category: "Valorant",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
itemId: "glitchpop_bulldog",
|
itemId: "glitchpop_bulldog",
|
||||||
|
@ -41,7 +50,11 @@ async function seedShopItems(guildId) {
|
||||||
description:
|
description:
|
||||||
"A flashy skin for the Bulldog with vibrant colors and cyberpunk vibe.",
|
"A flashy skin for the Bulldog with vibrant colors and cyberpunk vibe.",
|
||||||
rarity: "Rare",
|
rarity: "Rare",
|
||||||
|
type: "Skin",
|
||||||
|
category: "Valorant",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// CS2 Skins
|
||||||
{
|
{
|
||||||
itemId: "dragon_lore_awp",
|
itemId: "dragon_lore_awp",
|
||||||
name: "AWP Dragon Lore",
|
name: "AWP Dragon Lore",
|
||||||
|
@ -49,6 +62,8 @@ async function seedShopItems(guildId) {
|
||||||
description:
|
description:
|
||||||
"A legendary skin for the AWP with dragon designs, a rare and coveted item.",
|
"A legendary skin for the AWP with dragon designs, a rare and coveted item.",
|
||||||
rarity: "Legendary",
|
rarity: "Legendary",
|
||||||
|
type: "Skin",
|
||||||
|
category: "CS2",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
itemId: "ak47_redline",
|
itemId: "ak47_redline",
|
||||||
|
@ -57,6 +72,8 @@ async function seedShopItems(guildId) {
|
||||||
description:
|
description:
|
||||||
"A simple yet iconic AK-47 skin with red and black color scheme.",
|
"A simple yet iconic AK-47 skin with red and black color scheme.",
|
||||||
rarity: "Common",
|
rarity: "Common",
|
||||||
|
type: "Skin",
|
||||||
|
category: "CS2",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
itemId: "m4a4_howl",
|
itemId: "m4a4_howl",
|
||||||
|
@ -65,6 +82,8 @@ async function seedShopItems(guildId) {
|
||||||
description:
|
description:
|
||||||
"A rare and valuable skin for the M4A4 with a striking wolf design.",
|
"A rare and valuable skin for the M4A4 with a striking wolf design.",
|
||||||
rarity: "Epic",
|
rarity: "Epic",
|
||||||
|
type: "Skin",
|
||||||
|
category: "CS2",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
itemId: "desert_eagle_kumicho_dragon",
|
itemId: "desert_eagle_kumicho_dragon",
|
||||||
|
@ -73,6 +92,8 @@ async function seedShopItems(guildId) {
|
||||||
description:
|
description:
|
||||||
"A Desert Eagle skin with an intricate dragon design and a metallic finish.",
|
"A Desert Eagle skin with an intricate dragon design and a metallic finish.",
|
||||||
rarity: "Rare",
|
rarity: "Rare",
|
||||||
|
type: "Skin",
|
||||||
|
category: "CS2",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
itemId: "usp_kill_confirmed",
|
itemId: "usp_kill_confirmed",
|
||||||
|
@ -81,6 +102,8 @@ async function seedShopItems(guildId) {
|
||||||
description:
|
description:
|
||||||
"A detailed skin for the USP-S with a unique comic-style design.",
|
"A detailed skin for the USP-S with a unique comic-style design.",
|
||||||
rarity: "Epic",
|
rarity: "Epic",
|
||||||
|
type: "Skin",
|
||||||
|
category: "CS2",
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue