check if channel id is in guild id

Help pls

I want to check if channel id is in guild id without running a command

node = v18.13.0
djs = 14.8.0

My code (Dose not work (its for a command but i want it to run without a command))
const guild = client.guilds.resolve(guildId);
if (guild.channels.cache.get(ids.chat) === undefined) {
    console.log('not there');
}
else {
    console.log('its there');
}
Was this page helpful?