MongoDB cant get an item to be added to a shop schema

hi, so basically im very lost, im trying to make it so a bot can have a custom shop with itemName, itemPrice and itemDescription, my shopItemModel.js:
const { Schema, model } = require("mongoose");

const shopItemSchema = new Schema({
itemName: String, // Name of the item
itemPrice: Number, // Price of the item
itemDescription: String, // Description of the item
});

module.exports = model("ShopItem", shopItemSchema, "itemShop");
const { Schema, model } = require("mongoose");

const shopItemSchema = new Schema({
itemName: String, // Name of the item
itemPrice: Number, // Price of the item
itemDescription: String, // Description of the item
});

module.exports = model("ShopItem", shopItemSchema, "itemShop");
the add-shop-item.js code:
// commands/additem.js

const { CommandInteraction, MessageEmbed } = require('discord.js');
const ShopItem = require('../../schemas/shopItemModel');

module.exports = {
data: {
name: 'add-shop-item',
description: 'Add an item to the shop',
options: [
{
name: 'name',
type: 'STRING',
description: 'Name of the item',
required: true,
},
{
name: 'price',
type: 'INTEGER',
description: 'Price of the item',
required: true,
},
{
name: 'description',
type: 'STRING',
description: 'Description of the item',
required: true,
},
],
},
async execute(interaction) {
try {
const itemName = interaction.options.getString('name');
const itemPrice = interaction.options.getInteger('price');
const itemDescription = interaction.options.getString('description');

const newItem = new ShopItem({
itemName,
itemPrice,
itemDescription,
});

await newItem.save();

const embed = new MessageEmbed()
.setTitle('Item Added to Shop')
.setColor('#27ae60')
.setDescription(`Item: ${itemName}\nPrice: $${itemPrice}\nDescription: ${itemDescription}`);

await interaction.reply({ embeds: [embed] });
} catch (error) {
console.error(error);
await interaction.reply('An error occurred while adding the item to the shop.');
}
},
};
// commands/additem.js

const { CommandInteraction, MessageEmbed } = require('discord.js');
const ShopItem = require('../../schemas/shopItemModel');

module.exports = {
data: {
name: 'add-shop-item',
description: 'Add an item to the shop',
options: [
{
name: 'name',
type: 'STRING',
description: 'Name of the item',
required: true,
},
{
name: 'price',
type: 'INTEGER',
description: 'Price of the item',
required: true,
},
{
name: 'description',
type: 'STRING',
description: 'Description of the item',
required: true,
},
],
},
async execute(interaction) {
try {
const itemName = interaction.options.getString('name');
const itemPrice = interaction.options.getInteger('price');
const itemDescription = interaction.options.getString('description');

const newItem = new ShopItem({
itemName,
itemPrice,
itemDescription,
});

await newItem.save();

const embed = new MessageEmbed()
.setTitle('Item Added to Shop')
.setColor('#27ae60')
.setDescription(`Item: ${itemName}\nPrice: $${itemPrice}\nDescription: ${itemDescription}`);

await interaction.reply({ embeds: [embed] });
} catch (error) {
console.error(error);
await interaction.reply('An error occurred while adding the item to the shop.');
}
},
};
No description
No description
No description
3 Replies
d.js toolkit
d.js toolkit15mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by staff
NNKtv28
NNKtv28OP15mo ago
it is
chewie
chewie15mo ago
its not djs related anyway
Want results from more Discord servers?
Add your server