'Command doesn't work, No error, and bot doesn't crash
I need some help please,
When I click on the button Submit, it doesn't do what I want it to, it doesn't show up with any errors, and the bot doesn't crash so I'm not sure how to fix it.
This has never happened to me before so I'm just wondering I'm someone could point me in the right direction.
Suggest.js :
const { ButtonInteraction, MessageEmbed } = require("discord.js");
const DB = require('../Structures/Handlers/Schemas/SuggestDB');
const { APPLICATIONID } = require("../Structures/config.json")
const Embed1 = require('../Commands/Suggest/suggestion');
module.exports = {
name: "interactionCreate",
/**
*
* @param {ButtonInteraction} interaction
*/
async execute(interaction) {
if(!interaction.isButton()) return;
const { guildId, customId, message } = interaction;
DB.findOne({GuildID: guildId, MessageID: message.id}, async(err, data) => {
if(err) throw err;
if(!data) return interaction.reply({content: "No data was found in the database", ephemeral: true});
const Embed = message.embeds[0];
if(!Embed) return;
switch(customId) {
case "Submit" : {
await guild.channels.cache
.get(APPLICATIONID)
.send({ embeds: [Embed1] });
}
}
})
}
}
Suggestion.js
const { CommandInteraction, MessageEmbed, MessageActionRow, MessageButton, ButtonInteraction }
= require("discord.js");
const DB = require("../../Structures/Handlers/Schemas/SuggestDB");
module.exports = {
name:"suggest",
description: "Suggest",
options: [
{
name: "suggestion",
description: "Describe your suggestion",
type: "STRING",
required: true
}
],
/**
*
* @param {CommandInteraction} interaction
* @param {ButtonInteraction} interaction1
*/
async execute(interaction) {
const { options, guildId, member, user } = interaction;
const Suggestion = options.getString("suggestion");
const Embed1 = new MessageEmbed()
.setColor("AQUA")
.setAuthor(user.tag, user.displayAvatarURL({dynamic: true}))
.addFields(
{name: "Suggestion", value: Suggestion, inline: false}
)
.setTimestamp()
const row = new MessageActionRow();
row.addComponents(
new MessageButton()
.setCustomId("Submit")
.setLabel("Submit")
.setStyle("PRIMARY")
.setEmoji("📩"),
)
try {
const M = await interaction.reply({embeds: [Embed1], components: [row], fetchReply: true});
await DB.create({GuildID: guildId, MessageID: M.id, Details: [
{
MemberID: member.id,
Suggestion: Suggestion
}
]})
} catch (err) {
console.log(err)
}
},
};
Any help is appreciated. If you need any more information / code files, just reply and I'll will add it straight away.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
