#Your code is fine Just remove this line
1 messages · Page 1 of 1 (latest)
if I remove just this line it says that the interaction is already replied because the command already has been replied to with row.
const row = new ActionRowBuilder().addComponents(
new SelectMenuBuilder()
.setCustomId('server_select')
.setPlaceholder('Select a server')
.addOptions(SERVER)
)
await interaction.reply({components: [row] ,ephemeral: true });
await interaction.deferReply({ ephemeral: true });
},
};
client.on('interactionCreate', async interaction => {
if (!interaction.isSelectMenu()) return;
if (interaction.customId === 'server_select') {
await wait(2000);
const server = interact.values[0];
await axios
.post(`${API_BASE_URL}/api/whitelist`, {
user: target.id,
userName: target.username,
server: server,
})
.then(res => {
const embed = new EmbedBuilder()
.setColor(res.data.color)
.setTitle('Whitelist | API')
.setDescription(res.data.message)
.setTimestamp()
.setFooter({
text: 'Bot by: @EnteNico',
});
interaction.editReply({
components: [],
embeds: [embed],
});
});
}
});
const row = new ActionRowBuilder().addComponents(
new SelectMenuBuilder()
.setCustomId('server_select')
.setPlaceholder('Select a server')
.addOptions(SERVER)
)
await interaction.deferReply({ ephemeral: true });
},
};
client.on('interactionCreate', async interaction => {
if (!interaction.isSelectMenu()) return;
if (interaction.customId === 'server_select') {
await wait(2000);
const server = interact.values[0];
await axios
.post(`${API_BASE_URL}/api/whitelist`, {
user: target.id,
userName: target.username,
server: server,
})
.then(res => {
const embed = new EmbedBuilder()
.setColor(res.data.color)
.setTitle('Whitelist | API')
.setDescription(res.data.message)
.setTimestamp()
.setFooter({
text: 'Bot by: @EnteNico',
});
interaction.editReply({
components: [],
embeds: [embed],
});
});
}
});``` try that
now the select menu [row] dont show up
await interaction.deferReply({ ephemeral: true });
const row = new ActionRowBuilder().addComponents(
new SelectMenuBuilder()
.setCustomId('server_select')
.setPlaceholder('Select a server')
.addOptions(SERVER)
)
await interaction.editReply({ components: [row] });
},
};
client.on('interactionCreate', async interaction => {
if (!interaction.isSelectMenu()) return;
if (interaction.customId === 'server_select') {
await wait(2000);
const server = interact.values[0];
await axios
.post(`${API_BASE_URL}/api/whitelist`, {
user: target.id,
userName: target.username,
server: server,
})
.then(res => {
const embed = new EmbedBuilder()
.setColor(res.data.color)
.setTitle('Whitelist | API')
.setDescription(res.data.message)
.setTimestamp()
.setFooter({
text: 'Bot by: @EnteNico',
});
interaction.editReply({
components: [],
embeds: [embed],
});
});
}
});```
Try that?
now the select menu shows up again but the response is missing (interaction dont work because it takes too long)
like the same problem as before :/
So what are you actually trying to achieve? I am just trying to fix random stuff at this point 
jeah i saw this
well its simple
Command with user option
open a select menu
the selct menu returns a value to a api
At the moment it seems to take to loong for the api to make a respone and the edit reply get cancelled
(im also just trying to fix that by a nearly comleted recode because the original dude have messy code that didnt really worked)
So when the user gets the menu (drop down), and they select an option, what are you wanting the bot to do? Remove the menu and replace it with a message?
replace the menu with a embed that shows the error or a success
await interaction.deferReply({ ephemeral: true });
const row = new ActionRowBuilder().addComponents(
new SelectMenuBuilder()
.setCustomId('server_select')
.setPlaceholder('Select a server')
.addOptions(SERVER)
)
await interaction.editReply({ components: [row] });
},
};
client.on('interactionCreate', async interaction => {
if (!interaction.isSelectMenu()) return;
if (interaction.customId === 'server_select') {
await interaction.message.delete()
await wait(2000);
const server = interact.values[0];
await axios
.post(`${API_BASE_URL}/api/whitelist`, {
user: target.id,
userName: target.username,
server: server,
})
.then(res => {
const embed = new EmbedBuilder()
.setColor(res.data.color)
.setTitle('Whitelist | API')
.setDescription(res.data.message)
.setTimestamp()
.setFooter({
text: 'Bot by: @EnteNico',
});
interaction.channel.send({
components: [],
embeds: [embed],
});
});
}
});```
Will something like that do?
All I did there was deleted the original message and then sent the embed afterwards.
Jeah saw that
Maiby, it's not even the timeout that's the problem.
but I have no idea what else could be the problem
Try removing the ephemeral: true
From the deferreply
same issue but the dropdown is now visible for everyone
When is the error occuring? the second you use the slash command?
i use the slash command
dropdown show up
choose option from the dropdown
interaction failed
No errors in console?
none just starting (dont added start log /message because im lazy)
Ok so add a log under if (interaction.customId === 'server_select') { and see if it get's into that part of your code
it dont get in
Change this part:
client.on('interactionCreate', async interaction => {
if (!interaction.isSelectMenu()) return;
if (interaction.customId === 'server_select') {
console.log(`I'm here!`)
await interaction.message.delete()
await wait(2000);
const server = interact.values[0];
await axios
.post(`${API_BASE_URL}/api/whitelist`, {
user: target.id,
userName: target.username,
server: server,
})
.then(res => {
const embed = new EmbedBuilder()
.setColor(res.data.color)
.setTitle('Whitelist | API')
.setDescription(res.data.message)
.setTimestamp()
.setFooter({
text: 'Bot by: @EnteNico',
});
interaction.channel.send({
components: [],
embeds: [embed],
});
});
}
});```
same as before (i add the console log there too)
Does it log anything though?
The log will tell you if it's getting to that part of the program
So does it say I'm here! in your console
nope it stays right here
https://Chaosfelix.monarchuploader.de/bMnf7LVJKeYq/WinSCP_24DqFm8jvq
this is the reason why im ehre
i dont understand it too
but i think i go to sleep now and try again tomorrow
nealy 4am now
Yeah do that, have a good one 👍
well back again
same problem as befroe just want to ask if this is normal
just logged the the interaction (dropdown menu) and it dont display the custom id
Where is the interactionCreate event listener being placed? is it in your index.js file? Or is it within a command file?
should be in the index.js
Yeah so you need to add it in that file there so instead of having the if(!interaction.IsChatInputCommand()) return line, you can make it an if/else chain so for example:
if(interaction.IsChatInputCommand()){
//do chat input things
} else if(interaction.IsSelectMenu()) {
//do those things here
}```
See what I am saying?
yes
but im not sure what you mean with
//do chat input things
client.on(Events.InteractionCreate, async interaction => {
if(interaction.IsChatInputCommand()){
return
} else if(interaction.IsSelectMenu()) {
if (interaction.customId === 'server_select') {
console.log(`I'm here!`)
because just like this nothing changed
or do you mean in the index.js?
So for example:
if(interaction.IsChatInputCommand()){
//all the stuff above that is already in the event
} else if(interaction.IsSelectMenu()) {
//the things you are trying to do now
if(interaction.customId === 'server_select){
}
}```
I am not writing it all out that would take a while 
wait im confused are we now in the command or in the index 
So you have 2 places you have client.on('interactionCreate', right?
One is in index.js
the other is in a command file
What I am saying,is move it all into the index.js one
You don't need 2
It's global, so you only need 1 of them.
Even better if you have an event handler you could have it in a seperate file.
so i shoould move this stuff to the index or just remove the ```js
client.on(Events.InteractionCreate, async interaction => {
if(interaction.IsChatInputCommand()){
return
} else if(interaction.IsSelectMenu()) { ```
not 100% just giv e me tha last % XD
i just try both otions 🙂
You have it I think? have you tried it now?
im on my way like im a bit confused if i just remove this stuff
client.on(Events.InteractionCreate, async interaction => {
if(interaction.IsChatInputCommand()){
return
} else if(interaction.IsSelectMenu()) { ```
Or if i need to move everything to index.js
but i get the point 
Only thing you need to do is in the ```js
if(interaction.IsChatInputCommand()){
}```
You need to add the stuff that was in there before like the const command = stuff. That was your command handling code.
All you are doing is merging the stuff from the 2 into 1 event listener
getting really brainafk with this (i need to translate it and use it in my brain get really difficult to understnad hot to move everything like you tried to erxplain there because its not clear for me which files you add or edit stuff in could be simply a language barrier just give me a few min)


brain working really hard right now XD
not sure if its not already smoking or in flames
Your not removing any files
Basically, you where you are creating the select menu with the command, you don't need the interactionCreate event in there.
Move it out, into your one that is in index.js
Why I am saying this:
if(interaction.IsChatInputCommand()){
//all the stuff above that is already in the event
} else if(interaction.IsSelectMenu()) {
//the things you are trying to do now
if(interaction.customId === 'server_select){
}
}```
is because everything that was in your index.js before you made the changes, needs to go inside the `IsChatInputCommand()` if statement. Like so:
```js
if(interaction.IsChatInputCommand()){
const command = client.commands.get() //etc etc
}``` and inside the `IsSelectMenu()` elseif statement you need the stuff you are trying to do now with the `customId's` and all that.
now i add this (the chat input command)
https://Chaosfelix.monarchuploader.de/DmWHydZOcQmb/Code_0TmJ38qDza
And than i have added the stuff with the custom id
https://Chaosfelix.monarchuploader.de/wEnpr9RNFVcc/Code_Yg1bhgwn66
Paste that part of the code here
here?
Just everything that is inside the client.on('interactionCreate'
client.on('interactionCreate', async interaction =>
{
if (!interaction.isChatInputCommand()) return;
const command = client.commands.get(interaction.commandName);
if (!command) return;
if(interaction.IsChatInputCommand()){
return
} else if(interaction.IsSelectMenu()) {
if (interaction.customId === 'server_select') {
console.log(`I'm here!`)
await interaction.message.delete()
await wait(2000);
const server = interact.values[0];
await axios
.post(`${API_BASE_URL}/api/whitelist`, {
user: target.id,
userName: target.username,
server: server,
})
.then(res => {
const embed = new EmbedBuilder()
.setColor(res.data.color)
.setTitle('Whitelist | API')
.setDescription(res.data.message)
.setTimestamp()
.setFooter({
text: 'Bot by: @EnteNico',
});
interaction.channel.send({
components: [],
embeds: [embed],
});
});
}
}
try
{
await command.execute(interaction);
} catch (error)
{
console.error(error);
await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
}
});
client.on('interactionCreate', async interaction =>
{
if(interaction.IsChatInputCommand()){
const command = client.commands.get(interaction.commandName);
if (!command) return;
try {
await command.execute(interaction);
} catch (error) {
console.error(error);
await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
}
} else if(interaction.IsSelectMenu()) {
if (interaction.customId === 'server_select') {
console.log(`I'm here!`)
await interaction.message.delete()
await wait(2000);
const server = interact.values[0];
await axios
.post(`${API_BASE_URL}/api/whitelist`, {
user: target.id,
userName: target.username,
server: server,
})
.then(res => {
const embed = new EmbedBuilder()
.setColor(res.data.color)
.setTitle('Whitelist | API')
.setDescription(res.data.message)
.setTimestamp()
.setFooter({
text: 'Bot by: @EnteNico',
});
interaction.channel.send({
components: [],
embeds: [embed],
});
});
}
}
});```
That should work
Because you are saying:
Right, if it's a command then do the command stuff, else if it's a select menu interaction do this stuff here.

jeah make sence
Make sure you removed the interactionCreate from your command file where the 2nd one was
Lowercase I at the beginning of isChatInputCommand sorry that was my fault
jeah all good
didnt saw that too first
ah finally 
understood most if thank you
ive got in to code to this point
(thats now the issue that we are in another file)
at this point i have a small problem that the target is not set at this point because its in the whitelist command
https://Chaosfelix.monarchuploader.de/JGy2R3F5G3rQ/Code_wAOE9yXynM
What is target though?
the user that is in the user option of the commandhttps://Chaosfelix.monarchuploader.de/Dh6FXgIhLbsB/Code_gQ1EObFK5l
Bare with me
Your going to have to re-work your code in order to use target.
You'll need to use a messageComponent collector.
It's the last bit of information.
It'll be hard work but it'll be worth it in the end.
You can use that message collector inside of the command file you have for the select menu
well i looked over google could be much more simple by a module export.
going to try that first maiby it work if not i look in the message Component
Best of luck! I hope it works for you!
jeah just trying to fix some stuff to get slowly more into js what happens i fall into the deep
So a really big thank to you for helping me with the most annoying problem im going to look throught the docs now

You're most welcome. Docs are where all the key information is, so make sure to read it well and test things out with their examples.
jeah sadly not everey issue is explained there and its opnly one method in the docs /guide
so they are not always the solution for everything


