Search code examples
discordbotstypeerror

.setname is not a function in discord.js


I have finished completing the code for my bot from a tutorial on YouTube: https://www.youtube.com/watch?v=fN29HIaoHLU

Here is the entire code on replt.it: https://replit.com/@TylerLanier/Comusity-Bot#slash/info.js:6:4

And I am getting this error: TypeError: (intermediate value).setname is not a function at "..."

Here is the code at slash/info.js:

module.exports = {
  data: new SlashCommandBuilder()
      .setname("info")
      .setDescription("Displays info about the currently playing song"),
  run: async ({client, interaction}) => {
      const queue = client.player.getQueue(interaction.guildId)

      if(!queue)
          return await interaction.editReply("There are no songs in the queue")
      let bar = queue.createProgressBar({
          queue: false,
          length: 19
      })

      const song = queue.current
    
      await interaction.editReply({
          embeds: [
              new MessageEmbed()
                  .setThumbnail(song.thumbnail)
                  .setDescription(`Currently Playing [${song.title}](${song.url})\n\n` + bar)
          ],
      })
  },
}

Solution

  • The reason behind the error is a capitalisation mistake when you use .setname(). It needs to be .setName() with a capital N. This is why you need to go through your code just to check the spelling of each function and variable you call. You will also have to change this incorrect spelling in every command except the play command as in each file, you are using .setname()