const { MessageActionRow, MessageButton, MessageEmbed } = require("discord.js");
const config = require("../../botconfig/config.json");
const ee = require("../../botconfig/embed.json");
const settings = require("../../botconfig/settings.json");
module.exports = {
name: "reigster",
description: "Are you wanna register?",
cooldown: 0,
memberpermissions: [],
requiredroles: [],
alloweduserids: [],
options: [],
run: async (client, interaction) => {
try{
const { member, channelId, guildId, applicationId,
commandName, deferred, replied, ephemeral,
options, id, createdTimestamp
} = interaction;
const { guild } = member;
//const EmbedTitle = options.getString("title");
//const EmbedDescription = options.getString("description");
const EmbedColor = options.getString("color");
//let UserOption = options.getUser("OPTIONNAME");
//const ChannelOption = options.getChannel("in_where");
//let RoleOption = options.getRole("OPTIONNAME");
//const channel = ["GUILD_PRIVATE_THREAD ", "GUILD_PUBLIC_THREAD ", "GUILD_NEWS_THREAD ", "GUILD_NEWS", "GUILD_TEXT"].includes(ChannelOption.type) ? ChannelOption : guild.channels.cache.get(channelId);
const row = new MessageActionRow()
.addComponents(
new MessageButton()
.setCustomId('reigster')
.setLabel('가입')
.setStyle('SUCCESS'),
new MessageButton()
.setCustomId('cancel')
.setLabel('취소')
.setStyle('SECONDARY'),
);
let embed_register_try = new MessageEmbed().setColor(EmbedColor ? EmbedColor : "BLUEPLE")
.addFields(
{ name: 'name1', value: 'values2' },
{ name: 'name2', value: 'values2' }
)
let embed_register = new MessageEmbed().setColor(EmbedColor ? EmbedColor : "BLURPLE")
.setTitle(" ")
.setDescription("talking")
let embed_cancel = new MessageEmbed().setColor(EmbedColor ? EmbedColor : "BLURPLE")
.setTitle(" ")
.setDescription("canceled")
await interaction.reply({embeds: [embed_register_try], components: [row] });
const collector = interaction.channel.createMessageComponentCollector({
time: 60 * 1000,
});
collector.on("collect", async(interaction) => {
if (interaction.customId === "register") {
interaction.editReply({embeds: [embed_register]});
}
})
} catch (e) {
console.log(String(e.stack).bgRed)
}
}
}
#button interaction with slash command
13 messages · Page 1 of 1 (latest)
• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.
interaction.update inside the collector instead of editReply
Also, you should share more useful information rather than just code
ahh.. sorry,
first try slash command can show embed with button
after try to click button no response
Because reigster isn’t the same as register
customId of your button (and also name of your command apparently)
await interaction.reply({embeds: [embed_register_try], components: [row] });
client.on('interactionCreate', interaction => {
if (!interaction.isButton()) return;
if (interaction.customId == "reigster") {
// Do what you want with button 'id1'.
interaction.editReply({ embeds: [embed_register] })
}
});
i gonna changed code and see under error
[Symbol(code)]: 'INTERACTION_NOT_REPLIED'
Why did you register a new interactionCreate listener in there? That’s making it worse… your collector was fine, just your customId wasn’t
ahh.. thx finally i solved!
and.. another question.. if you can help.. i hope.
Now I gonna do index.js with mysql connection.
if i wanna use command js file with index connection.
load index.js on command files or
reconnect db on command files?
let con = createConnection(config.mysql);
con.connect(err => {
if (err) return console.log(err);
console.log(`MySQL 연결 완료`);
})
on index.js
Export the con from that file and import in commands. Or pass it to your commands when you call them