Discord slash command "interaction failed"

I am following a tutorial for discord slash commands on V13 and there are no errors when I run the but but when I go to do /ping it says interaction failed. I went through the permissions needed on the docs but it looked like I go all the permissions needed to run it which are bot and application commands.

Here is my code for the bot:

import DiscordJS, { Intents, Interaction } from 'discord.js'
import dotenv from 'dotenv'

const client = new DiscordJS.Client({
    intents: [

client.on('ready', () => {
    console.log('The bot is ready')

    const guildID = '906389171806040114'
    const guild = client.guilds.cache.get(guildID)
    let commands

    if (guild) {
        commands = guild.commands
    } else {
        commands = client.application?.commands

        name: 'pig',
        description: 'Replies with pong',


client.on('interactCreate', async (Interaction) => {
    if (!Interaction.isCommand()) {

    const { commandName, options } = Interaction

    if ( commandName === 'pig') {
            content: 'pong',
            ephemeral: true,


Source: JavaSript – Stack Overflow

November 21, 2021
Category : News
Tags: discord | discord.js | javascript | node.js

Leave a Reply

Your email address will not be published. Required fields are marked *

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.