Anyone know why my command isnt working?

14 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Ashura
Ashura2y ago
no errors just app didnt respond
Syjalo
Syjalo2y ago
You should use collector to collect the modal interaction
d.js docs
d.js docs2y ago
method ChatInputCommandInteraction#awaitModalSubmit() Collects a single modal submit interaction that passes the filter. The Promise will reject if the time expires.
Syjalo
Syjalo2y ago
And you also should show the modal to collect it interaction.showModal(modal)
Syjalo
Syjalo2y ago
Also I recommend you to watch this video https://youtu.be/CFRhGnuXG-4
CodeAesthetic
YouTube
Why You Shouldn't Nest Your Code
I'm a Never Nester and you should too. Access to code examples, discord, song names and more at https://www.patreon.com/codeaesthetic Correction: At 2:20 the inversion should be "less than or equal", not "less than"
Ashura
Ashura2y ago
ok , thank u y i did a horrible code , im a bit new to coding so i thought it was the only solution , but when i searched bout it i found the switch thing and it makes my code much cleaner , thx for commenting about it
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Ashura
Ashura2y ago
. @syjalo whats the difference beetween the collector and this?
client.on(Events.InteractionCreate, async interaction => {
if (!interaction.isChatInputCommand()) return;

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

// TODO: Add components to modal...
}
});
client.on(Events.InteractionCreate, async interaction => {
if (!interaction.isChatInputCommand()) return;

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

// TODO: Add components to modal...
}
});
Squid
Squid2y ago
Collectors are temporary and have filters and timers, designed to be used as follow-ups to things like commands client event listeners listen for the event until the bot restarts; when used in command files, the first command file creates 1 listener, and when the command is ran again, another listener is created. This means you end up having 2 listeners at once, both responding to the same new interactions, and they will continue to increase in amount as the command is used again.
Ashura
Ashura2y ago
oh , thank u
Ashura
Ashura2y ago
is this right?
Squid
Squid2y ago
You need to define two separate interactions: the original interaction from the slash command, and the modal submit interaction from the modal collector