i get this error but i don't have any problem wih my code

i get this error but i don't have any problem wih my code
No description
10 Replies
d.js toolkit
d.js toolkit6mo 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
Coywolfboy
Coywolfboy6mo ago
this is my code
const { Client, Intents, MessageEmbed } = require('discord.js');
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const { ModalBuilder, TextInputBuilder, TextInputStyle, MessageActionRow } = require('discord-buttons');


const clientId = '11';
const guildId = '11';

const commands = [
{
name: 'ping',
description: 'Replies with Pong!'
},
{
name: 'saay',
description: 'ffff!'
},
];

const client = new Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.MESSAGE_CONTENT,
],
});

const commandsRest = new REST({ version: '9' }).setToken('MTE4Mj');

client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;

if (interaction.commandName === 'saay') {
const modal = new ModalBuilder()
.setCustomId('myModal')
.setTitle('Say Modal');

const favoriteColorInput = new TextInputBuilder()
.setCustomId('favoriteColorInput')
.setLabel("Please enter your message below.")
.setStyle(TextInputStyle.Short);

const hobbiesInput = new TextInputBuilder()
.setCustomId('hobbiesInput')
.setLabel("What's some of your favorite hobbies?")
.setStyle(TextInputStyle.Paragraph);

const firstActionRow = new MessageActionRow().addComponents(favoriteColorInput);
const secondActionRow = new MessageActionRow().addComponents(hobbiesInput);

modal.addComponents(firstActionRow, secondActionRow);
const reply = await interaction.reply({ content: 'Say something:', components: [modal], fetchReply: true });

const collector = interaction.channel.createMessageComponentCollector({
filter: i => i.isMessageComponent() && i.customId === 'myModal' && i.message.id === reply.id,
time: 30000, // Adjust the time limit as needed
});

collector.on('collect', async i => {
const firstInput = i.values[0]; // Value from the firstActionRow
const secondInput = i.values[1]; // Value from the secondActionRow

const embed = new MessageEmbed()
.setColor('#00ff00')
.setTitle('Modal Builder Result')
.addField('Favorite Color:', firstInput)
.addField('Favorite Hobbies:', secondInput);

await interaction.followUp({ embeds: [embed] });
});

collector.on('end', collected => {
if (collected.size === 0) {
interaction.followUp('You did not provide the required input. The command has been canceled.');
}
});
}
});

(async () => {
console.log('Started refreshing application (/) commands.');

try {
await commandsRest.put(
Routes.applicationGuildCommands(clientId, guildId),
{ body: commands },
);

console.log('Successfully reloaded application (/) commands.');
} catch (error) {
console.error(error);
}
});

client.login('MTE4Mj')
const { Client, Intents, MessageEmbed } = require('discord.js');
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const { ModalBuilder, TextInputBuilder, TextInputStyle, MessageActionRow } = require('discord-buttons');


const clientId = '11';
const guildId = '11';

const commands = [
{
name: 'ping',
description: 'Replies with Pong!'
},
{
name: 'saay',
description: 'ffff!'
},
];

const client = new Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.MESSAGE_CONTENT,
],
});

const commandsRest = new REST({ version: '9' }).setToken('MTE4Mj');

client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;

if (interaction.commandName === 'saay') {
const modal = new ModalBuilder()
.setCustomId('myModal')
.setTitle('Say Modal');

const favoriteColorInput = new TextInputBuilder()
.setCustomId('favoriteColorInput')
.setLabel("Please enter your message below.")
.setStyle(TextInputStyle.Short);

const hobbiesInput = new TextInputBuilder()
.setCustomId('hobbiesInput')
.setLabel("What's some of your favorite hobbies?")
.setStyle(TextInputStyle.Paragraph);

const firstActionRow = new MessageActionRow().addComponents(favoriteColorInput);
const secondActionRow = new MessageActionRow().addComponents(hobbiesInput);

modal.addComponents(firstActionRow, secondActionRow);
const reply = await interaction.reply({ content: 'Say something:', components: [modal], fetchReply: true });

const collector = interaction.channel.createMessageComponentCollector({
filter: i => i.isMessageComponent() && i.customId === 'myModal' && i.message.id === reply.id,
time: 30000, // Adjust the time limit as needed
});

collector.on('collect', async i => {
const firstInput = i.values[0]; // Value from the firstActionRow
const secondInput = i.values[1]; // Value from the secondActionRow

const embed = new MessageEmbed()
.setColor('#00ff00')
.setTitle('Modal Builder Result')
.addField('Favorite Color:', firstInput)
.addField('Favorite Hobbies:', secondInput);

await interaction.followUp({ embeds: [embed] });
});

collector.on('end', collected => {
if (collected.size === 0) {
interaction.followUp('You did not provide the required input. The command has been canceled.');
}
});
}
});

(async () => {
console.log('Started refreshing application (/) commands.');

try {
await commandsRest.put(
Routes.applicationGuildCommands(clientId, guildId),
{ body: commands },
);

console.log('Successfully reloaded application (/) commands.');
} catch (error) {
console.error(error);
}
});

client.login('MTE4Mj')
Harnes
Harnes6mo ago
discord-buttons isnt related to discord.js also discord.js supports modals and buttons itself you dont need to use third party packages
Coywolfboy
Coywolfboy6mo ago
do you mean to install it?
Harnes
Harnes6mo ago
and this code looks like v13 or even v12 update to v14
Coywolfboy
Coywolfboy6mo ago
ok
Harnes
Harnes6mo ago
no, I meant that this package does not come from discord.js team
Coywolfboy
Coywolfboy6mo ago
ah
Harnes
Harnes6mo ago
discord.js supports modals and buttons itself so you dont need to use that
Coywolfboy
Coywolfboy6mo ago
thank you it works 831375336226160640