fedpep
fedpep
DIAdiscord.js - Imagine a boo! 👻
Created by fedpep on 10/14/2024 in #djs-questions
How can I get an array of all the posts in a forum?
Hey there, I looked at the documentation but couldn't find anything regarding forum channels. I want to create a Slash Command that accepts a forum channel as input and then returns an array of all the posts that are in that forum. Any help would be much appreciated
25 replies
DIAdiscord.js - Imagine a boo! 👻
Created by fedpep on 9/17/2024 in #djs-questions
awaitMessageComponent doesn't wait the set time
Hey there, I'm following the guide but I can't figure out why awaitMessageComponent doesn't wait for the set time. Here's my code:
const { SlashCommandBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, ChannelType, PermissionFlagsBits } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('test')
.setDescription('Testing commands.')
.addChannelOption(option =>
option.setName('from')
.setDescription('Move members from this channel')
.addChannelTypes(ChannelType.GuildVoice, ChannelType.GuildStageVoice)
.setRequired(true))
.addChannelOption(option =>
option.setName('to')
.setDescription('Move members to this channel')
.addChannelTypes(ChannelType.GuildVoice, ChannelType.GuildStageVoice)
.setRequired(true))
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),

async execute(interaction) {

const from = interaction.options.getChannel('from');
const to = interaction.options.getChannel('to');

// Build confirmation buttons interaction
const confirm = new ButtonBuilder()
.setCustomId('confirm')
.setLabel('Confirm')
.setStyle(ButtonStyle.Success);

const cancel = new ButtonBuilder()
.setCustomId('cancel')
.setLabel('Cancel')
.setStyle(ButtonStyle.Secondary);

const row = new ActionRowBuilder()
.addComponents(cancel, confirm);

await interaction.reply({
content: `Do you want to move people from ${from} to ${to}`,
components: [row],
});

// The filter applied here ensures that only the user who triggered the original interaction can use the buttons.
const collectorFilter = i => i.user.id === interaction.user.id;

try {
const confirmation = await response.awaitMessageComponent({ filter: collectorFilter, time: 60_000 });
console.log("Success");
} catch (e) {
await interaction.editReply({ content: 'Confirmation not received within 1 minute, cancelling', components: [] });
}

},
};
const { SlashCommandBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, ChannelType, PermissionFlagsBits } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('test')
.setDescription('Testing commands.')
.addChannelOption(option =>
option.setName('from')
.setDescription('Move members from this channel')
.addChannelTypes(ChannelType.GuildVoice, ChannelType.GuildStageVoice)
.setRequired(true))
.addChannelOption(option =>
option.setName('to')
.setDescription('Move members to this channel')
.addChannelTypes(ChannelType.GuildVoice, ChannelType.GuildStageVoice)
.setRequired(true))
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),

async execute(interaction) {

const from = interaction.options.getChannel('from');
const to = interaction.options.getChannel('to');

// Build confirmation buttons interaction
const confirm = new ButtonBuilder()
.setCustomId('confirm')
.setLabel('Confirm')
.setStyle(ButtonStyle.Success);

const cancel = new ButtonBuilder()
.setCustomId('cancel')
.setLabel('Cancel')
.setStyle(ButtonStyle.Secondary);

const row = new ActionRowBuilder()
.addComponents(cancel, confirm);

await interaction.reply({
content: `Do you want to move people from ${from} to ${to}`,
components: [row],
});

// The filter applied here ensures that only the user who triggered the original interaction can use the buttons.
const collectorFilter = i => i.user.id === interaction.user.id;

try {
const confirmation = await response.awaitMessageComponent({ filter: collectorFilter, time: 60_000 });
console.log("Success");
} catch (e) {
await interaction.editReply({ content: 'Confirmation not received within 1 minute, cancelling', components: [] });
}

},
};
Here the intents in index.js
const client = new Client({ intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
] });
const client = new Client({ intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
] });
Any help would be much appreciated
14 replies