'RangeError [BITFIELD_INVALID]: Invalid bitfield flag or number. when I try to save a channel in my command

if(!message.guild.me.hasPermission("SEND_MESSAGES")) {
        return
    }
    if(!message.guild.me.hasPermission("VIEW_CHANNEL")) {
        return message.channel.send("I don't have `VIEW_CHANNEL` permission.")
    }
    if(!message.member.hasPermission("ADMINISTRATOR")) {
        return message.channel.send("You don't have permissions to do that.")
    }
 const e = args[0]
 const ER = message.mentions.channels.first()
 if(!e) {
     //return message.channel.send("You must enter a channel.")
 }
if(ER) {
    db.set(`${message.guild.id}.mch`,ER.id)
    //message.channel.send("Channel has been set.")
} else {
    if(message.guild.channels.cache.get(e)) {
        const channel = message.guild.channels.cache.get(e)
        db.set(`${message.guild.id}.wch`,e)
       // message.channel.send("Channel has been successfully set.")
    }
}

Hi, I'm trying to make a data command that saves channel's ID but whenever I execute this command it gives the error (title of the question), how can I solve it?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source