Home > front end >  Discord.js invalid form body: value "voiceChannel" is not snofwlake
Discord.js invalid form body: value "voiceChannel" is not snofwlake

Time:02-10

I'm trying to code a music bot, and I coded a system that understands if the channel to join is valid or not, but when I input an invalid channel, the bot crashes and gives me this error: Invalid form body, channel_id: Value "args[0]" is not snowflake. What can I do? Code:

module.exports = {
    name: "join",
    aliases: ["j", "move"],

    async execute (client, message, args, Discord) {

        let voiceChannel = message.member.voice.channel;

        if (args[0]) {

            voiceChannel = await client.channels.fetch(args[0]);

            if (!Discord.Constants.VoiceBasedChannelTypes.includes(voiceChannel?.type)) {
                
                return message.reply(`Sadly, ${args[0]} is kinda not a valid voice channel :(`);
            }
        }
        
        if (!voiceChannel) return message.reply("You have to be in a voice channel you dummy!            
  •  Tags:  
  • Related