Mocus
Explore posts from serversDIAdiscord.js - Imagine an app
•Created by Mocus on 8/27/2023 in #djs-questions
slash command not appearing
made a slash command, it's not appearing when i bring the bot online,
const { Client, Intents, MessageEmbed, MessageSelectMenu } = require('discord.js');
require('dotenv').config();
const dungeons = [
{
label: 'Brackenhide Hollow',
value: 'BH'
},
{
label: 'Halls of Infusion',
value: 'HoI'
},
// Add other dungeons here
];
const client = new Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES
]
});
client.once('ready', () => {
console.log(`Logged in as ${client.user.tag}`);
});
client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;
const command = interaction.commandName;
if (command === 'ping') {
const embed = new MessageEmbed()
.setColor('#FF0000')
.setDescription('Pong! This is a red response.');
const row = new MessageActionRow()
.addComponents(
new MessageSelectMenu()
.setCustomId('select')
.setPlaceholder('Select a dungeon')
.addOptions(dungeons.map(dungeon => ({ label: dungeon.label, value: dungeon.value })))
);
await interaction.reply({ embeds: [embed], components: [row] });
}
// ...
});
client.on('interactionCreate', async interaction => {
if (interaction.isSelectMenu()) {
if (interaction.customId === 'select') {
const selectedDungeons = interaction.values
.map(value => dungeons.find(dungeon => dungeon.value === value))
.map(dungeon => dungeon.label);
await interaction.reply(`You selected: ${selectedDungeons.join(', ')}`);
}
}
});
client.login(process.env.BOT_TOKEN);
const { Client, Intents, MessageEmbed, MessageSelectMenu } = require('discord.js');
require('dotenv').config();
const dungeons = [
{
label: 'Brackenhide Hollow',
value: 'BH'
},
{
label: 'Halls of Infusion',
value: 'HoI'
},
// Add other dungeons here
];
const client = new Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES
]
});
client.once('ready', () => {
console.log(`Logged in as ${client.user.tag}`);
});
client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;
const command = interaction.commandName;
if (command === 'ping') {
const embed = new MessageEmbed()
.setColor('#FF0000')
.setDescription('Pong! This is a red response.');
const row = new MessageActionRow()
.addComponents(
new MessageSelectMenu()
.setCustomId('select')
.setPlaceholder('Select a dungeon')
.addOptions(dungeons.map(dungeon => ({ label: dungeon.label, value: dungeon.value })))
);
await interaction.reply({ embeds: [embed], components: [row] });
}
// ...
});
client.on('interactionCreate', async interaction => {
if (interaction.isSelectMenu()) {
if (interaction.customId === 'select') {
const selectedDungeons = interaction.values
.map(value => dungeons.find(dungeon => dungeon.value === value))
.map(dungeon => dungeon.label);
await interaction.reply(`You selected: ${selectedDungeons.join(', ')}`);
}
}
});
client.login(process.env.BOT_TOKEN);
11 replies