I have a question I am currently upgrading my Discord bot to DISCORD JS V13. Now I’m trying to get the Chanel ID of certain Chanels, but I keep getting undifiend or 0 back. I’ve already tried to rewrite my old code from the DISCORD JS V12, but it doesn’t work. There is also not much online about DISCORD JS V13.
const path = require("path");
const fs = require('fs');
const {
Client,
Intents,
Collection
} = require('discord.js');
require("dotenv").config();
const client = new Client({
intents: [Intents.FLAGS.GUILDS]
})
const functions = fs.readdirSync("./src/functions").filter(file => file.endsWith(".js"));
const eventFiles = fs.readdirSync("./src/events").filter(file => file.endsWith(".js"));
const commandFiles = fs.readdirSync("./src/commands").filter(file => file.endsWith(".js"));
client.commands = new Collection();
client.buttons = new Collection();
(async () => {
for (file of functions) {
require(./functions/${file})(client);
}
client.handleEvents(eventFiles, "./src/events");
client.handleCommands(commandFiles, "./src/commands");
client.handleButtons();
client.login(process.env.BOT_TOKEN);
const connection = client.dbLogin();
console.log(await client.channels);
client.channels.fetch('691022255098036375')
.then(channel => console.log(channel.name))
.catch(console.error);
console.log(await client.channels.cache.get("691022255098036375")); //undefined
//client.joinHome();
})();