Resident Of Prey
Explore posts from serversDIAdiscord.js - Imagine an app
•Created by Resident Of Prey on 5/6/2024 in #djs-questions
AutoComplete Problem
before:-
after code:-
the autocomplete option named tag does not show any options, it used to show earlier but then i added the hidden option and a switch statement then it stopped working
async autocomplete(interaction: AutocompleteInteraction) {
const focusedValue = interaction.options.getFocused();
try {
const choices = Docs.filter((tag: TagData) => tag.name.startsWith(focusedValue));
await interaction.respond(
choices.map((choice: TagData) => ({ name: choice.name, value: choice.name }))
);
} catch (error) {
await interaction.respond([{ name: "Error loading tags", value: "" }]);
}
},
async autocomplete(interaction: AutocompleteInteraction) {
const focusedValue = interaction.options.getFocused();
try {
const choices = Docs.filter((tag: TagData) => tag.name.startsWith(focusedValue));
await interaction.respond(
choices.map((choice: TagData) => ({ name: choice.name, value: choice.name }))
);
} catch (error) {
await interaction.respond([{ name: "Error loading tags", value: "" }]);
}
},
async autocomplete(interaction: AutocompleteInteraction) {
const focusedValue = interaction.options.getFocused(true);
switch (focusedValue.name) {
case "tag":
try {
const choices = Docs.filter((tag: TagData) => tag.name.startsWith(focusedValue.name));
await interaction.respond(
choices.map((choice: TagData) => ({ name: choice.name, value: choice.name }))
);
} catch (error) {
await interaction.respond([{ name: "Error loading tags", value: "" }]);
}
break;
case "hidden":
const choices = ["True", "False"];
await interaction.respond(
choices.map((choice) => ({ name: choice, value: choice }))
);
break;
default:
break;
}
},
async autocomplete(interaction: AutocompleteInteraction) {
const focusedValue = interaction.options.getFocused(true);
switch (focusedValue.name) {
case "tag":
try {
const choices = Docs.filter((tag: TagData) => tag.name.startsWith(focusedValue.name));
await interaction.respond(
choices.map((choice: TagData) => ({ name: choice.name, value: choice.name }))
);
} catch (error) {
await interaction.respond([{ name: "Error loading tags", value: "" }]);
}
break;
case "hidden":
const choices = ["True", "False"];
await interaction.respond(
choices.map((choice) => ({ name: choice, value: choice }))
);
break;
default:
break;
}
},
4 replies
DIAdiscord.js - Imagine an app
•Created by Resident Of Prey on 2/5/2024 in #djs-questions
collector problems and error
code:-
it throws a long error in the entire collector callback saying
const row = new ActionRowBuilder<ButtonBuilder>().addComponents(bttn1, bttn2);
const reply = await interaction.reply({
content: "Proceed Ban?",
components: [row]
})
const collector = reply.createMessageComponentCollector({ componentType: ComponentType.Button })
collector.on("collect", async (i: ButtonInteraction) => {
switch (i.customId) {
case "confirmBan": {
if (i.user.id !== interaction.user.id) {
return await i.reply({
content: "You are not permitted to use this button!",
ephemeral: true
})
}
await interaction.guild?.bans.create(user)
await i.update({
content: `Confirmed ban for ${user}\nThey are gone!`,
components: []
})
}
break;
const row = new ActionRowBuilder<ButtonBuilder>().addComponents(bttn1, bttn2);
const reply = await interaction.reply({
content: "Proceed Ban?",
components: [row]
})
const collector = reply.createMessageComponentCollector({ componentType: ComponentType.Button })
collector.on("collect", async (i: ButtonInteraction) => {
switch (i.customId) {
case "confirmBan": {
if (i.user.id !== interaction.user.id) {
return await i.reply({
content: "You are not permitted to use this button!",
ephemeral: true
})
}
await interaction.guild?.bans.create(user)
await i.update({
content: `Confirmed ban for ${user}\nThey are gone!`,
components: []
})
}
break;
No overload matches this call.
Overload 1 of 3, '(event: "end", listener: (collected: Collection<string, ButtonInteraction<CacheType>>, reason: string) => Awaitable<void>): InteractionCollector<...>', gave the following error.
Argument of type '"collect"' is not assignable to parameter of type '"end"'.
Overload 2 of 3, '(event: "dispose" | "collect" | "ignore", listener: (interaction: ButtonInteraction<CacheType>) => Awaitable<void>): InteractionCollector<ButtonInteraction<CacheType>>', gave the following error.
No overload matches this call.
Overload 1 of 3, '(event: "end", listener: (collected: Collection<string, ButtonInteraction<CacheType>>, reason: string) => Awaitable<void>): InteractionCollector<...>', gave the following error.
Argument of type '"collect"' is not assignable to parameter of type '"end"'.
Overload 2 of 3, '(event: "dispose" | "collect" | "ignore", listener: (interaction: ButtonInteraction<CacheType>) => Awaitable<void>): InteractionCollector<ButtonInteraction<CacheType>>', gave the following error.
2 replies
DIAdiscord.js - Imagine an app
•Created by Resident Of Prey on 2/2/2024 in #djs-questions
Modal submit problem
look this is my collector, which collects message from a button
and this is the modal inside of the collector:
when i open this modal and click somewhere on the screen, that means to disappear it and execute the modal again, it throws this error
const msg = await thread.send({ content: null, embeds: [embed], components: [row] });
message.reply({
content: `created a new thread, <#${thread.id}>`
})
const collector = await msg.createMessageComponentCollector();
collector.on('collect', async (m) => {
const msg = await thread.send({ content: null, embeds: [embed], components: [row] });
message.reply({
content: `created a new thread, <#${thread.id}>`
})
const collector = await msg.createMessageComponentCollector();
collector.on('collect', async (m) => {
await m.showModal(modal).catch(console.error);
const modalSubmit = await m.awaitModalSubmit({
filter: async (mm) => mm.user.id === message.author.id && mm.customId == message.id,
time: 1_800_000
});
await m.showModal(modal).catch(console.error);
const modalSubmit = await m.awaitModalSubmit({
filter: async (mm) => mm.user.id === message.author.id && mm.customId == message.id,
time: 1_800_000
});
DiscordAPIError[10062]: Unknown interaction
at handleErrors (G:\#BotBackups\BeastCorp\node_modules\@discordjs\rest\dist\index.js:687:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async BurstHandler.runRequest (G:\#BotBackups\BeastCorp\node_modules\@discordjs\rest\dist\index.js:786:23)
at async _REST.request (G:\#BotBackups\BeastCorp\node_modules\@discordjs\rest\dist\index.js:1218:22)
at async ModalSubmitInteraction.reply (G:\#BotBackups\BeastCorp\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:111:5)
at async InteractionCollector.<anonymous> (G:\#BotBackups\BeastCorp\src\prefix-commands\thread.js:115:23) {
requestBody: { files: [], json: { type: 4, data: [Object] } },
rawError: { message: 'Unknown interaction', code: 10062 },
code: 10062,
status: 404,
method: 'POST',
DiscordAPIError[10062]: Unknown interaction
at handleErrors (G:\#BotBackups\BeastCorp\node_modules\@discordjs\rest\dist\index.js:687:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async BurstHandler.runRequest (G:\#BotBackups\BeastCorp\node_modules\@discordjs\rest\dist\index.js:786:23)
at async _REST.request (G:\#BotBackups\BeastCorp\node_modules\@discordjs\rest\dist\index.js:1218:22)
at async ModalSubmitInteraction.reply (G:\#BotBackups\BeastCorp\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:111:5)
at async InteractionCollector.<anonymous> (G:\#BotBackups\BeastCorp\src\prefix-commands\thread.js:115:23) {
requestBody: { files: [], json: { type: 4, data: [Object] } },
rawError: { message: 'Unknown interaction', code: 10062 },
code: 10062,
status: 404,
method: 'POST',
21 replies
SIASapphire - Imagine a framework
•Created by Resident Of Prey on 10/11/2023 in #discordjs-support
help needed regarding prefix handler
hey i have (tried) to make a prefix command handler for my bot, down is my code for it, the bot boots up normally but idk why it doesn't react to the commands
messageCreate.js
handlePrefixes.js
pingPrefix.js
5 replies
SIASapphire - Imagine a framework
•Created by Resident Of Prey on 9/12/2023 in #discordjs-support
problems submitting modals
const { ModalBuilder, TextInputBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, PermissionsBitField, TextInputStyle } = require("discord.js");
const Fighter = require(`../../schemas/users`);
const mongoose = require('mongoose');
module.exports = {
data: {
name: 'randomOne'
},
async execute(interaction, client) {
const modal = new ModalBuilder()
.setCustomId("registerOne")
.setTitle("Register Yourself");
const textInput = new TextInputBuilder()
.setCustomId("in-game-name")
.setLabel("In-Game Name")
.setPlaceholder("Enter your in-game name")
.setRequired(true)
.setStyle(TextInputStyle.Short);
const one = new ActionRowBuilder().addComponents(textInput);
modal.addComponents(one, two, three);
await interaction.showModal(modal);
interaction.client.on("modalResponse", async (modalInteraction) => {
if (modalInteraction.customId === "registerOne") {
const inGameName = modalInteraction.fields.getTextInputValue("in-game-name");
await interaction.followUp({
content: `Your In-Game Name: ${inGameName}`,
ephemeral: true
});
}
});
},
};
const { ModalBuilder, TextInputBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, PermissionsBitField, TextInputStyle } = require("discord.js");
const Fighter = require(`../../schemas/users`);
const mongoose = require('mongoose');
module.exports = {
data: {
name: 'randomOne'
},
async execute(interaction, client) {
const modal = new ModalBuilder()
.setCustomId("registerOne")
.setTitle("Register Yourself");
const textInput = new TextInputBuilder()
.setCustomId("in-game-name")
.setLabel("In-Game Name")
.setPlaceholder("Enter your in-game name")
.setRequired(true)
.setStyle(TextInputStyle.Short);
const one = new ActionRowBuilder().addComponents(textInput);
modal.addComponents(one, two, three);
await interaction.showModal(modal);
interaction.client.on("modalResponse", async (modalInteraction) => {
if (modalInteraction.customId === "registerOne") {
const inGameName = modalInteraction.fields.getTextInputValue("in-game-name");
await interaction.followUp({
content: `Your In-Game Name: ${inGameName}`,
ephemeral: true
});
}
});
},
};
8 replies