Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

242
Views
DisTubeError [INVALID_TYPE]: Expected 'number' for 'volume', but got '50' discord.js V13

I am trying to make a Discord music bot. All the code work fine but in the Volume command, I get this error when I execute !volume 50 :

throw new __1.DisTubeError("INVALID_TYPE", "number", volume, "volume");
                  ^
DisTubeError [INVALID_TYPE]: Expected 'number' for 'volume', but got '50'

This is my code :

const { guild, channel, member } = message;
if (
  member.roles.cache.has('926674590200123502') ||
  member.roles.cache.has('945435842258808862') ||
  member.roles.cache.has('928717168001024020') ||
  member.roles.cache.has('935939126123974726') ||
  member.permissions.has(Permissions.FLAGS.ADMINISTRATOR)
) {
  const voicechannel = member.voice.channel;

  if (!voicechannel)
    return message.reply(
      'You must be in a voice channel to use Music commands',
    );

  if (guild.me.voice.channelID && voicechannel.id !== guild.me.voice.channelID)
    return message.reply(
      `I am already playing music in <#${guild.me.voice.channelID}>`,
    );

  const volume = args[0];

  if (volume > 100 || volume < 1)
    return message.reply('the volume must be a number between 1 and 100');

  await client.distube.setVolume(voicechannel, volume);
  await message.reply(`๐Ÿ”Š volume set to ${volume}`);
} else return message.reply("You can't use this command");

about 4 years ago ยท Juan Pablo Isaza
1 answers
Answer question

0

It's because '50' is not a number but a string. Try to parse it first:

const volume = parseInt(args[0], 10);

if (isNaN(volume)) 
  return message.reply('Volume must be a valid number');
if (volume > 100 || volume < 1 )
  return message.reply('Volume must be a number between 1 and 100');
about 4 years ago ยท Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
ยฉ 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!