Sincerely, alxx ᴬᴳ
Sincerely, alxx ᴬᴳ
DIdiscord.js - Imagine ❄
Created by Sincerely, alxx ᴬᴳ on 11/9/2024 in #djs-questions
select menu
two parts since I hit max
8 replies
DIdiscord.js - Imagine ❄
Created by Sincerely, alxx ᴬᴳ on 11/9/2024 in #djs-questions
select menu
try {
// Handle remove-all
if (selectedValues.includes('remove-all')) {
// Filter out roles that the member already has in this category
const rolesToRemove = categoryRoleIds.filter(roleId => member.roles.cache.has(roleId));

if (rolesToRemove.length > 0) {
await member.roles.remove(rolesToRemove);
await interaction.editReply({ content: 'All roles in this category have been removed.' });
} else {
await interaction.editReply({ content: 'You do not have any roles from this category.' });
}
} else {
// Process each selected value
for (const selectedValue of selectedValues) {
// Ensure we're working with a valid role ID
const selectedRoleId = selectedValue.split('-')[1];

if (selectedRoleId) {
// Filter out the current role from the category before removing the others
const previousRoleIds = categoryRoleIds.filter(id => id !== selectedRoleId);
const rolesToRemove = previousRoleIds.filter(roleId => member.roles.cache.has(roleId));

if (rolesToRemove.length > 0) {
await member.roles.remove(rolesToRemove);
}

await member.roles.add(selectedRoleId);
}
}
await interaction.editReply({ content: 'Your selected roles have been updated!' });
}
} catch (error) {
console.error(error);
await interaction.editReply({ content: 'There was an error updating your roles.' });
}
});
try {
// Handle remove-all
if (selectedValues.includes('remove-all')) {
// Filter out roles that the member already has in this category
const rolesToRemove = categoryRoleIds.filter(roleId => member.roles.cache.has(roleId));

if (rolesToRemove.length > 0) {
await member.roles.remove(rolesToRemove);
await interaction.editReply({ content: 'All roles in this category have been removed.' });
} else {
await interaction.editReply({ content: 'You do not have any roles from this category.' });
}
} else {
// Process each selected value
for (const selectedValue of selectedValues) {
// Ensure we're working with a valid role ID
const selectedRoleId = selectedValue.split('-')[1];

if (selectedRoleId) {
// Filter out the current role from the category before removing the others
const previousRoleIds = categoryRoleIds.filter(id => id !== selectedRoleId);
const rolesToRemove = previousRoleIds.filter(roleId => member.roles.cache.has(roleId));

if (rolesToRemove.length > 0) {
await member.roles.remove(rolesToRemove);
}

await member.roles.add(selectedRoleId);
}
}
await interaction.editReply({ content: 'Your selected roles have been updated!' });
}
} catch (error) {
console.error(error);
await interaction.editReply({ content: 'There was an error updating your roles.' });
}
});
8 replies
DIdiscord.js - Imagine ❄
Created by Sincerely, alxx ᴬᴳ on 11/9/2024 in #djs-questions
select menu
// Interaction handler
client.on('interactionCreate', async (interaction) => {
if (!interaction.isStringSelectMenu()) return;

await interaction.deferReply({ ephemeral: true }); // Defer the interaction to prevent timeout

const member = await interaction.guild.members.fetch(interaction.user.id);
const selectedValues = interaction.values;
let categoryRoleIds = [];

switch (interaction.customId) {
case 'pronouns':
categoryRoleIds = ['1256314021221761065', '1256313952720257176', '1256314088116719707', '1256314120467255306'];
break;
case 'sexuality':
categoryRoleIds = ['1256314313623343198', '1256314391867949258', '1256314450173235230'];
break;
case 'continent':
categoryRoleIds = ['1256314957033766973', '1256314999723397200', '1256315100650799184', '1256314912448315434', '1256315138097676340', '1256314749637886093', '1256315061547569274'];
break;
case 'zodiac':
categoryRoleIds = ['1256315831575384256', '1256315877310206062', '1256315915709055047', '1256315953038364792', '1256315980989202457', '1256316013234880553', '1256316050379771965', '1256316085607731271', '1256316142373572688', '1256316196970696765', '1256316252918513724', '1256316326566297674'];
break;
case 'dm_status':
categoryRoleIds = ['1256315493154033745', '1256315595507503154', '1256315435222306876'];
break;
case 'age_range':
categoryRoleIds = ['1256314534004658269', '1256314633149743164'];
break;
}
// Interaction handler
client.on('interactionCreate', async (interaction) => {
if (!interaction.isStringSelectMenu()) return;

await interaction.deferReply({ ephemeral: true }); // Defer the interaction to prevent timeout

const member = await interaction.guild.members.fetch(interaction.user.id);
const selectedValues = interaction.values;
let categoryRoleIds = [];

switch (interaction.customId) {
case 'pronouns':
categoryRoleIds = ['1256314021221761065', '1256313952720257176', '1256314088116719707', '1256314120467255306'];
break;
case 'sexuality':
categoryRoleIds = ['1256314313623343198', '1256314391867949258', '1256314450173235230'];
break;
case 'continent':
categoryRoleIds = ['1256314957033766973', '1256314999723397200', '1256315100650799184', '1256314912448315434', '1256315138097676340', '1256314749637886093', '1256315061547569274'];
break;
case 'zodiac':
categoryRoleIds = ['1256315831575384256', '1256315877310206062', '1256315915709055047', '1256315953038364792', '1256315980989202457', '1256316013234880553', '1256316050379771965', '1256316085607731271', '1256316142373572688', '1256316196970696765', '1256316252918513724', '1256316326566297674'];
break;
case 'dm_status':
categoryRoleIds = ['1256315493154033745', '1256315595507503154', '1256315435222306876'];
break;
case 'age_range':
categoryRoleIds = ['1256314534004658269', '1256314633149743164'];
break;
}
8 replies
DIdiscord.js - Imagine ❄
Created by Sincerely, alxx ᴬᴳ on 11/9/2024 in #djs-questions
select menu
heres my handler:
8 replies
DIdiscord.js - Imagine ❄
Created by Sincerely, alxx ᴬᴳ on 11/9/2024 in #djs-questions
Bot crashing after string gives role
i fixed it but now my interaction handler isnt working, giving the roles works but when I try to remove the roles it just says there was an error in my code and sends this into the console:
DiscordAPIError[50035]: Invalid Form Body
role_id[NUMBER_TYPE_COERCE]: Value "all" is not snowflake.
at handleErrors (C:\Users\alexe\AGU Bot\node_modules\@discordjs\rest\dist\index.js:727:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (C:\Users\alexe\AGU Bot\node_modules\@discordjs\rest\dist\index.js:1128:23)
at async SequentialHandler.queueRequest (C:\Users\alexe\AGU Bot\node_modules\@discordjs\rest\dist\index.js:959:14)
at async _REST.request (C:\Users\alexe\AGU Bot\node_modules\@discordjs\rest\dist\index.js:1272:22)
at async GuildMemberRoleManager.add (C:\Users\alexe\AGU Bot\node_modules\discord.js\src\managers\GuildMemberRoleManager.js:131:7)
at async Client.<anonymous> (C:\Users\alexe\AGU Bot\src\roles.js:558:21) {
requestBody: { files: undefined, json: undefined },
rawError: {
message: 'Invalid Form Body',
code: 50035,
errors: { role_id: [Object] }
},
code: 50035,
status: 400,
method: 'PUT',
url: 'https://discord.com/api/v10/guilds/1256302762157932655/members/1016447282176077925/roles/all'
}
DiscordAPIError[50035]: Invalid Form Body
role_id[NUMBER_TYPE_COERCE]: Value "all" is not snowflake.
at handleErrors (C:\Users\alexe\AGU Bot\node_modules\@discordjs\rest\dist\index.js:727:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (C:\Users\alexe\AGU Bot\node_modules\@discordjs\rest\dist\index.js:1128:23)
at async SequentialHandler.queueRequest (C:\Users\alexe\AGU Bot\node_modules\@discordjs\rest\dist\index.js:959:14)
at async _REST.request (C:\Users\alexe\AGU Bot\node_modules\@discordjs\rest\dist\index.js:1272:22)
at async GuildMemberRoleManager.add (C:\Users\alexe\AGU Bot\node_modules\discord.js\src\managers\GuildMemberRoleManager.js:131:7)
at async Client.<anonymous> (C:\Users\alexe\AGU Bot\src\roles.js:558:21) {
requestBody: { files: undefined, json: undefined },
rawError: {
message: 'Invalid Form Body',
code: 50035,
errors: { role_id: [Object] }
},
code: 50035,
status: 400,
method: 'PUT',
url: 'https://discord.com/api/v10/guilds/1256302762157932655/members/1016447282176077925/roles/all'
}
24 replies
DIdiscord.js - Imagine ❄
Created by Sincerely, alxx ᴬᴳ on 11/9/2024 in #djs-questions
Bot crashing after string gives role
hm ty I'll look into it!
24 replies
DIdiscord.js - Imagine ❄
Created by Sincerely, alxx ᴬᴳ on 11/9/2024 in #djs-questions
Bot crashing after string gives role
But the string menu is from the roles command which is in roles.js, so would I just delete the reply their then?
24 replies
DIdiscord.js - Imagine ❄
Created by Sincerely, alxx ᴬᴳ on 11/9/2024 in #djs-questions
Bot crashing after string gives role
how would I fix that?
24 replies
DIdiscord.js - Imagine ❄
Created by Sincerely, alxx ᴬᴳ on 11/9/2024 in #djs-questions
Bot crashing after string gives role
line 225*
24 replies
DIdiscord.js - Imagine ❄
Created by Sincerely, alxx ᴬᴳ on 11/9/2024 in #djs-questions
Bot crashing after string gives role
and 225 has an interaction reply
24 replies
DIdiscord.js - Imagine ❄
Created by Sincerely, alxx ᴬᴳ on 11/9/2024 in #djs-questions
Bot crashing after string gives role
It says its already replied to here even though it's not in colors.js, its in roles.js:
at async Client.<anonymous> (C:\Users\alexe\AGU Bot\src\colors.js:225:13) {
at async Client.<anonymous> (C:\Users\alexe\AGU Bot\src\colors.js:225:13) {
24 replies
DIdiscord.js - Imagine ❄
Created by Sincerely, alxx ᴬᴳ on 11/9/2024 in #djs-questions
Bot crashing after string gives role
so wait
24 replies
DIdiscord.js - Imagine ❄
Created by Sincerely, alxx ᴬᴳ on 11/9/2024 in #djs-questions
Bot crashing after string gives role
and I can't figure out what to do with debugging
24 replies
DIdiscord.js - Imagine ❄
Created by Sincerely, alxx ᴬᴳ on 11/9/2024 in #djs-questions
Bot crashing after string gives role
I have djs version 14.16
24 replies
DIdiscord.js - Imagine ❄
Created by Sincerely, alxx ᴬᴳ on 11/9/2024 in #djs-questions
Bot crashing after string gives role
Error:
DiscordAPIError[40060]: Interaction has already been acknowledged.
at handleErrors (C:\Users\alexe\AGU Bot\node_modules\@discordjs\rest\dist\index.js:727:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async BurstHandler.runRequest (C:\Users\alexe\AGU Bot\node_modules\@discordjs\rest\dist\index.js:831:23)
at async _REST.request (C:\Users\alexe\AGU Bot\node_modules\@discordjs\rest\dist\index.js:1272:22)
at async StringSelectMenuInteraction.reply (C:\Users\alexe\AGU Bot\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:115:5)
at async Client.<anonymous> (C:\Users\alexe\AGU Bot\src\colors.js:225:13) {
requestBody: { files: [], json: { type: 4, data: [Object] } },
rawError: {
message: 'Interaction has already been acknowledged.',
code: 40060
},
code: 40060,
status: 400,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/1304624064597459054/aW50ZXJhY3Rpb246MTMwNDYyNDA2NDU5NzQ1OTA1NDpiYVNudnphcDNLYXE4aEs4cDJIMUd2ajIzU1pSeGpXZllDVVlxNTREcVRld3VyUno0aHMzSWoyeXF3OExYSHhENUR5WjRPMVBRem1JOUNXZDh2VmZFR2FoSE91TUx2RnRCanY0ZGYxOHB1MTljNUFuZnRMYmMybDNma2EwSFp4Tg/callback'
}
node:events:497
throw er; // Unhandled 'error' event
^

Error [InteractionAlreadyReplied]: The reply to this interaction has already been sent or deferred.
at StringSelectMenuInteraction.reply (C:\Users\alexe\AGU Bot\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:105:46)
at Client.<anonymous> (C:\Users\alexe\AGU Bot\src\colors.js:228:31)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:402:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21) {
code: 'InteractionAlreadyReplied'
}

Node.js v20.18.0
[nodemon] app crashed - waiting for file changes before starting...
DiscordAPIError[40060]: Interaction has already been acknowledged.
at handleErrors (C:\Users\alexe\AGU Bot\node_modules\@discordjs\rest\dist\index.js:727:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async BurstHandler.runRequest (C:\Users\alexe\AGU Bot\node_modules\@discordjs\rest\dist\index.js:831:23)
at async _REST.request (C:\Users\alexe\AGU Bot\node_modules\@discordjs\rest\dist\index.js:1272:22)
at async StringSelectMenuInteraction.reply (C:\Users\alexe\AGU Bot\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:115:5)
at async Client.<anonymous> (C:\Users\alexe\AGU Bot\src\colors.js:225:13) {
requestBody: { files: [], json: { type: 4, data: [Object] } },
rawError: {
message: 'Interaction has already been acknowledged.',
code: 40060
},
code: 40060,
status: 400,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/1304624064597459054/aW50ZXJhY3Rpb246MTMwNDYyNDA2NDU5NzQ1OTA1NDpiYVNudnphcDNLYXE4aEs4cDJIMUd2ajIzU1pSeGpXZllDVVlxNTREcVRld3VyUno0aHMzSWoyeXF3OExYSHhENUR5WjRPMVBRem1JOUNXZDh2VmZFR2FoSE91TUx2RnRCanY0ZGYxOHB1MTljNUFuZnRMYmMybDNma2EwSFp4Tg/callback'
}
node:events:497
throw er; // Unhandled 'error' event
^

Error [InteractionAlreadyReplied]: The reply to this interaction has already been sent or deferred.
at StringSelectMenuInteraction.reply (C:\Users\alexe\AGU Bot\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:105:46)
at Client.<anonymous> (C:\Users\alexe\AGU Bot\src\colors.js:228:31)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:402:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21) {
code: 'InteractionAlreadyReplied'
}

Node.js v20.18.0
[nodemon] app crashed - waiting for file changes before starting...
24 replies
DIdiscord.js - Imagine ❄
Created by Sincerely, alxx ᴬᴳ on 11/9/2024 in #djs-questions
Bot crashing after string gives role
sorry
24 replies
DIdiscord.js - Imagine ❄
Created by Sincerely, alxx ᴬᴳ on 11/9/2024 in #djs-questions
Bot crashing after string gives role
one second
24 replies
DIdiscord.js - Imagine ❄
Created by Sincerely, alxx ᴬᴳ on 11/3/2024 in #djs-questions
Slash commands not being created
tysmm
44 replies
DIdiscord.js - Imagine ❄
Created by Sincerely, alxx ᴬᴳ on 11/3/2024 in #djs-questions
Slash commands not being created
nvmm it worked
44 replies
DIdiscord.js - Imagine ❄
Created by Sincerely, alxx ᴬᴳ on 11/3/2024 in #djs-questions
Slash commands not being created
thank you both, it made my code less messy but my commandds still dont get created
44 replies