War
War
DIAdiscord.js - Imagine an app
Created by War on 1/15/2024 in #djs-questions
Collectors crashing bot
await buttonInteraction.showModal(modal);
// Collect a modal submit interaction
const filter = (inter: ModalSubmitInteraction): boolean => inter.message!.id === buttonInteraction.message.id;
let modalSubmit: ModalSubmitInteraction;
try {
modalSubmit = await buttonInteraction.awaitModalSubmit({ filter, time: 30_000 });
}
catch (error) {
await buttonInteraction.followUp({ content :'You did not reply in time!', ephemeral : true });
return;
}
await buttonInteraction.showModal(modal);
// Collect a modal submit interaction
const filter = (inter: ModalSubmitInteraction): boolean => inter.message!.id === buttonInteraction.message.id;
let modalSubmit: ModalSubmitInteraction;
try {
modalSubmit = await buttonInteraction.awaitModalSubmit({ filter, time: 30_000 });
}
catch (error) {
await buttonInteraction.followUp({ content :'You did not reply in time!', ephemeral : true });
return;
}
In this case when you: 1. click on button (modal shows up) 2. cancel modal 3. click on button again (modal shows up) 4. fill modal and submit Handled error:
DiscordAPIError[10062]: Unknown interaction
0|index | at handleErrors (/Users/ayeman/Documents/GitHub/currency-bot/node_modules/@discordjs/rest/dist/index.js:687:13)
0|index | at processTicksAndRejections (node:internal/process/task_queues:96:5)
0|index | at async BurstHandler.runRequest (/Users/ayeman/Documents/GitHub/currency-bot/node_modules/@discordjs/rest/dist/index.js:786:23)
0|index | at async _REST.request (/Users/ayeman/Documents/GitHub/currency-bot/node_modules/@discordjs/rest/dist/index.js:1218:22)
DiscordAPIError[10062]: Unknown interaction
0|index | at handleErrors (/Users/ayeman/Documents/GitHub/currency-bot/node_modules/@discordjs/rest/dist/index.js:687:13)
0|index | at processTicksAndRejections (node:internal/process/task_queues:96:5)
0|index | at async BurstHandler.runRequest (/Users/ayeman/Documents/GitHub/currency-bot/node_modules/@discordjs/rest/dist/index.js:786:23)
0|index | at async _REST.request (/Users/ayeman/Documents/GitHub/currency-bot/node_modules/@discordjs/rest/dist/index.js:1218:22)
unhandled error:
0|index | /Users/ayeman/Documents/GitHub/currency-bot/node_modules/@discordjs/rest/dist/index.js:687
0|index | throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
0|index | ^
0|index | DiscordAPIError[10008]: Unknown Message
0|index | /Users/ayeman/Documents/GitHub/currency-bot/node_modules/@discordjs/rest/dist/index.js:687
0|index | throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
0|index | ^
0|index | DiscordAPIError[10008]: Unknown Message
8 replies
DIAdiscord.js - Imagine an app
Created by War on 1/14/2024 in #djs-questions
RoleSelectMenuInteraction Component Collector not working
const firstActionRowButton = new ActionRowBuilder<RoleSelectMenuBuilder>().addComponents(roleSelect);
const response = await buttonInteraction.reply({ content: 'Select a staff role. Individuals with staff will have printing, unprinting and other control over the currency.', components: [firstActionRowButton], ephemeral : true });

let roleInteraction: RoleSelectMenuInteraction ;
try {
roleInteraction = await response.awaitMessageComponent({ time: 60_000 }) as RoleSelectMenuInteraction;
console.log('HERE');
}
catch (error) {
await buttonInteraction.editReply({ content :'Timed out.', components: [] });
return;
}
const firstActionRowButton = new ActionRowBuilder<RoleSelectMenuBuilder>().addComponents(roleSelect);
const response = await buttonInteraction.reply({ content: 'Select a staff role. Individuals with staff will have printing, unprinting and other control over the currency.', components: [firstActionRowButton], ephemeral : true });

let roleInteraction: RoleSelectMenuInteraction ;
try {
roleInteraction = await response.awaitMessageComponent({ time: 60_000 }) as RoleSelectMenuInteraction;
console.log('HERE');
}
catch (error) {
await buttonInteraction.editReply({ content :'Timed out.', components: [] });
return;
}
7 replies
DIAdiscord.js - Imagine an app
Created by War on 9/17/2023 in #djs-questions
Cache growing too huge too fast for interacting with members in a role
I have a bot that sends money to a specified role at a certain time of the day. I'd like to send money to all the individuals inside a role. Currently I'm using the following fetches per guild:
guild = await client.guilds.fetch(guildId);
...
if (guild.memberCount !== guild.members.cache.size) {
await guild.members.fetch();
}
guild = await client.guilds.fetch(guildId);
...
if (guild.memberCount !== guild.members.cache.size) {
await guild.members.fetch();
}
This unfortunatly loads all the thousands of users into the bot, making it crash. Is there a more efficient way to get the members of a role? I only need the userIDs of people inside a role without caching all the members on a guild. Thank you for the help!
110 replies
DIAdiscord.js - Imagine an app
Created by War on 8/18/2023 in #djs-questions
Best way to get userIds in a role without hitting API limit Hourly
I have to get all the userIDs that have a role in a guild on an Hourly basis. It only returns the members in cache that have it. In order to get the updated userIDs every hour: - Do I have to fetch all members ever hour? - What if the role has more than 1000 people?
6 replies