szalik.dev
DIAdiscord.js - Imagine an app
•Created by szalik.dev on 1/8/2024 in #djs-questions
Creating multiple selects command
Hi, i'm currently trying to create a command which utilizes select function, i want to collect 2-3 values one after another but when i try to send new select using .editReply it keeps loading and throws interaction failed, video attached, code below
async execute(interaction) {
const ChannelSelect = new ActionRowBuilder()
.addComponents(
new ChannelSelectMenuBuilder()
.setCustomId('verifychannel')
.setPlaceholder('Select channel')
);
const RoleSelect = new ActionRowBuilder()
.addComponents(
new RoleSelectMenuBuilder()
.setCustomId('verifiedrole')
.setPlaceholder('Select role')
);
await interaction.reply({
content: 'Plase select verify channel!',
components: [ChannelSelect],
ephemeral: true
});
const ChannelCollector = interaction.channel.createMessageComponentCollector({
componentType: ComponentType.ChannelSelect,
time: 15000
});
ChannelCollector.on('collect', async (i) => {
if (i.user.id === interaction.user.id) {
if (i.customId === 'verifychannel') {
channel = i.channels.first();
await interaction.editReply({
content: 'Plase specified verified role!',
components: [RoleSelect]
});
}
} else {
i.reply({
content: `This select menu isn't for you!`,
ephemeral: true
});
}
});
const RoleCollector = interaction.channel.createMessageComponentCollector({
componentType: ComponentType.RoleSelect,
time: 15000
});
RoleCollector.on('collect', async (i) => {
if (i.user.id === interaction.user.id) {
if (i.customId === 'verifiedrole') {
if (channel) {
await interaction.editReply({
content: `Data collected, creating verify button in #${channel.name}!`,
components: []
});
} else {
await interaction.editReply({
content: `Channel wasn't specified, exiting creator.`,
components: []
});
}
}
} else {
i.reply({
content: `This select menu isn't for you!`,
ephemeral: true
});
}
});
async execute(interaction) {
const ChannelSelect = new ActionRowBuilder()
.addComponents(
new ChannelSelectMenuBuilder()
.setCustomId('verifychannel')
.setPlaceholder('Select channel')
);
const RoleSelect = new ActionRowBuilder()
.addComponents(
new RoleSelectMenuBuilder()
.setCustomId('verifiedrole')
.setPlaceholder('Select role')
);
await interaction.reply({
content: 'Plase select verify channel!',
components: [ChannelSelect],
ephemeral: true
});
const ChannelCollector = interaction.channel.createMessageComponentCollector({
componentType: ComponentType.ChannelSelect,
time: 15000
});
ChannelCollector.on('collect', async (i) => {
if (i.user.id === interaction.user.id) {
if (i.customId === 'verifychannel') {
channel = i.channels.first();
await interaction.editReply({
content: 'Plase specified verified role!',
components: [RoleSelect]
});
}
} else {
i.reply({
content: `This select menu isn't for you!`,
ephemeral: true
});
}
});
const RoleCollector = interaction.channel.createMessageComponentCollector({
componentType: ComponentType.RoleSelect,
time: 15000
});
RoleCollector.on('collect', async (i) => {
if (i.user.id === interaction.user.id) {
if (i.customId === 'verifiedrole') {
if (channel) {
await interaction.editReply({
content: `Data collected, creating verify button in #${channel.name}!`,
components: []
});
} else {
await interaction.editReply({
content: `Channel wasn't specified, exiting creator.`,
components: []
});
}
}
} else {
i.reply({
content: `This select menu isn't for you!`,
ephemeral: true
});
}
});
11 replies
DIAdiscord.js - Imagine an app
•Created by szalik.dev on 1/28/2023 in #djs-questions
d.js not able to fetch message from channel.
For some reason i came upon this error while trying to fetch message from channel
error:
code (it is inside async function):
data:
Message is in that channel, bot has perms, Intents are there as well. I'm clueless on why it won't load when everything is fine
(C:\Users\szalikdev\Documents\GitHub\discord-bot-rewritten\node_modules\@discordjs\rest\dist\index.js:667:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.queueRequest (C:\Users\szalikdev\Documents\GitHub\discord-bot-rewritten\node_modules\@discordjs\rest\dist\index.js:464:14)
at async REST.request (C:\Users\szalikdev\Documents\GitHub\discord-bot-rewritten\node_modules\@discordjs\rest\dist\index.js:910:22)
at async MessageManager._fetchSingle (C:\Users\szalikdev\Documents\GitHub\discord-bot-rewritten\node_modules\discord.js\src\managers\MessageManager.js:101:18)
at async InteractionCollector.<anonymous> (C:\Users\szalikdev\Documents\GitHub\discord-bot-rewritten\commands\reaction.js:220:23) {
requestBody: { files: undefined, json: undefined },
rawError: { message: 'Unknown Message', code: 10008 },
code: 10008,
status: 404,
method: 'GET',
url: 'https://discord.com/api/v10/channels/923718926507077672/messages/1069025646874988554'
}
(C:\Users\szalikdev\Documents\GitHub\discord-bot-rewritten\node_modules\@discordjs\rest\dist\index.js:667:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.queueRequest (C:\Users\szalikdev\Documents\GitHub\discord-bot-rewritten\node_modules\@discordjs\rest\dist\index.js:464:14)
at async REST.request (C:\Users\szalikdev\Documents\GitHub\discord-bot-rewritten\node_modules\@discordjs\rest\dist\index.js:910:22)
at async MessageManager._fetchSingle (C:\Users\szalikdev\Documents\GitHub\discord-bot-rewritten\node_modules\discord.js\src\managers\MessageManager.js:101:18)
at async InteractionCollector.<anonymous> (C:\Users\szalikdev\Documents\GitHub\discord-bot-rewritten\commands\reaction.js:220:23) {
requestBody: { files: undefined, json: undefined },
rawError: { message: 'Unknown Message', code: 10008 },
code: 10008,
status: 404,
method: 'GET',
url: 'https://discord.com/api/v10/channels/923718926507077672/messages/1069025646874988554'
}
const channel = data[1].value;
const message_id = data[2].value;
const message = await channel.messages.fetch(message_id);
console.log(message);
const channel = data[1].value;
const message_id = data[2].value;
const message = await channel.messages.fetch(message_id);
console.log(message);
[
{ key: 'emoji', value: '�' },
{
key: 'channel_id',
value: TextChannel {
type: 0,
guild: [Guild],
guildId: '892722239089278996',
parentId: '923718817866199050',
permissionOverwrites: [PermissionOverwriteManager],
messages: [MessageManager],
threads: [GuildTextThreadManager],
nsfw: false,
flags: [ChannelFlagsBitField],
id: '923718926507077672',
name: 'polish',
rawPosition: 34,
topic: null,
lastMessageId: '1069022546311262228',
rateLimitPerUser: 0
}
},
{ key: 'message_id', value: '1069022546311262228' },
{ key: 'action_type', value: 'toggle' },
{ key: 'role_id', value: '917391022990954507' }
]
[
{ key: 'emoji', value: '�' },
{
key: 'channel_id',
value: TextChannel {
type: 0,
guild: [Guild],
guildId: '892722239089278996',
parentId: '923718817866199050',
permissionOverwrites: [PermissionOverwriteManager],
messages: [MessageManager],
threads: [GuildTextThreadManager],
nsfw: false,
flags: [ChannelFlagsBitField],
id: '923718926507077672',
name: 'polish',
rawPosition: 34,
topic: null,
lastMessageId: '1069022546311262228',
rateLimitPerUser: 0
}
},
{ key: 'message_id', value: '1069022546311262228' },
{ key: 'action_type', value: 'toggle' },
{ key: 'role_id', value: '917391022990954507' }
]
7 replies