why cant i see my slash command when i test it? its not working

const { Client, Intents } = require('discord.js');

const client = new Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_VOICE_STATES
]
});

client.once('ready', () => {
console.log('Looker initialised');
});

client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;

const { commandName } = interaction;

if (commandName === 'createvoice') {
await createVoiceChannel(interaction);
}
});

async function createVoiceChannel(interaction) {
const guild = interaction.guild;
const membersCount = guild.memberCount;

try {
const channel = await guild.channels.create(`MEMBERS: ${membersCount}`, {
type: 'GUILD_VOICE',
parent: 'YOUR_PARENT_CATEGORY_ID',
permissionOverwrites: [
{
id: guild.roles.everyone,
deny: ['CONNECT']
},
]
});

await interaction.reply(`Voice channel created: ${channel.name}`);
} catch (error) {
console.error('Error creating voice channel:', error);
await interaction.reply('Failed to create voice channel.');
}
}
const { Client, Intents } = require('discord.js');

const client = new Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_VOICE_STATES
]
});

client.once('ready', () => {
console.log('Looker initialised');
});

client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;

const { commandName } = interaction;

if (commandName === 'createvoice') {
await createVoiceChannel(interaction);
}
});

async function createVoiceChannel(interaction) {
const guild = interaction.guild;
const membersCount = guild.memberCount;

try {
const channel = await guild.channels.create(`MEMBERS: ${membersCount}`, {
type: 'GUILD_VOICE',
parent: 'YOUR_PARENT_CATEGORY_ID',
permissionOverwrites: [
{
id: guild.roles.everyone,
deny: ['CONNECT']
},
]
});

await interaction.reply(`Voice channel created: ${channel.name}`);
} catch (error) {
console.error('Error creating voice channel:', error);
await interaction.reply('Failed to create voice channel.');
}
}
10 Replies
d.js toolkit
d.js toolkit8mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
King
KingOP8mo ago
ping me if u have a solution
darp
darp8mo ago
define "its not working"
King
KingOP8mo ago
look lemme show u smt
King
KingOP8mo ago
No description
No description
King
KingOP8mo ago
its on but theres no command
darp
darp8mo ago
restart discord?
King
KingOP8mo ago
still nothing how i do that
d.js docs
d.js docs8mo ago
:guide: Creating Your Bot: Registering slash commands The command deployment script, to register your slash commands with Discord so they appear in the interface. read more
King
KingOP8mo ago
tahnmsk thanks
Want results from more Discord servers?
Add your server