can anyone point out what im doing wrong here? even if i have data or no data in my database, it still returns undefined
Node ver: v16.16.0
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
const starboard_schema = require('../../Schemas/starboard-schema')
module.exports = {
data: new SlashCommandBuilder()
.setName('settings')
.setDescription(`test`),
async execute(interaction) {
const { guild } = interaction
const embed = new EmbedBuilder()
.setDescription(`No data.`)
.addFields([
{ name: `starboard`, value: `> no data`, inline: true },
]);
let data = starboard_schema.findOne({ guild: guild.id });
if (data) {
embed.setDescription(`data`)
embed.spliceFields(0, 1, { name: `starboard`, value: `> Channel: ${data.channel}, Emoji: ${data.emoji}`, inline: true });
}
await interaction.reply({ embeds: [embed], ephemeral: true })
}
}
starboard-schema.js
const mongoose = require('mongoose');
const starboard = new mongoose.Schema({
guild: String,
channel: String,
emoji: String,
count: Number,
color: String,
});
module.exports = mongoose.model('Starboard', starboard);