I am trying to get channel with an id or mention, the code itself works but when user gives wrong ID it says: TypeError: Cannot read properties of undefined (reading ‘catch’)
Can anyone help me?
I tried this:
message.guild.channels.cache.find(channel => channel.id == args[0]).catch(err => {});
And this:
message.guild.channels.cache.get(args[0]).catch(err => {});
These both things give me error.
Heres the code:
if (args[0].startsWith("<#")) channel = message.mentions.channels.first();
else channel = message.guild.channels.cache.get(args[0]).catch(err => {
//do stuff
})