So i just copy this off from youtube because i want to see how mongodb n button works but its not responding somehow
this is the code to create the data or sort
const { SlashCommandBuilder, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js')
const ecoschema = require('../../schema/ecoschema.js')
module.exports = {
data: new SlashCommandBuilder()
.setName('economy') // Name Of Slash Command
.setDescription('create economy account'), // Description Of Slash Command
async execute(interaction, client) {
const { user, guild } = interaction;
let Data = ecoschema.findOne({ Guild: interaction.guild.id, User: interaction.user.id})
const embed = new EmbedBuilder()
.setColor('Random')
.setTitle('Account')
.setDescription('Choose your option')
.addFields({ name: "Create", value: "Create your account"})
.addFields({ name: "Delete", value: "Delete your account"})
const embed2 = new EmbedBuilder()
.setColor('Random')
.setTitle('Created your account')
.setDescription('Account Created')
.addFields({ name: "Success", value: "Your account has been created! You got 100$ as a result"})
.setFooter({ text: `Requested by ${interaction.user.username}`})
.setTimestamp()
const embed3 = new EmbedBuilder()
.setColor('Random')
.setTitle('Deleted your account')
.setDescription('Account Deletion ')
.addFields({ name: "Success", value: "Your account has been delete"})
const button = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId('page1')
.setEmoji('✅')
.setLabel('Create')
.setStyle(ButtonStyle.Success),
new ButtonBuilder()
.setCustomId('page2')
.setEmoji('❌')
.setLabel('Delete')
.setStyle(ButtonStyle.Danger),
)
const message = await interaction.reply({ embeds: , components: [button] });
const collector = await message.createMessageComponentCollector();
collector.on(`collect`, async i =>{
if (i.customID === 'page1') {
if (i.user.id !== interaction.id ){
return i.reply({ content: `Only ${interaction.user.tag} can use this button`, ephemereal: true})
}
Data = new ecoschema({
Guild : interaction.guild.id,
User : user.id,
Bank : 0,
Wallet : 1000
})
await Data.save();
await i.update({ embeds: [embed2], components: [] })
}
if (i.customID === 'page2') {
if (i.user.id !== interaction.id ){
return i.reply({ content: `Only ${interaction.user.tag} can use this button`, ephemereal: true})
}
await Data.deleteMany();
await i.update({ embeds: [embed3], components: [] });
}
})
}
}
and here is my schema
const {model, schema, Schema} = require('mongoose');
let ecoschema = new Schema({
GuildID : String,
UserID : String,
Bank : String,
Wallet : String,
});
module.exports = model('ecoschema', ecoschema)
here is the result
heres my terminal
I just want to see the solution for it
if anyone can help i would greatly appreciated ahaaa