下面的错误类型错误:无法读取未定义的属性(读取"通道")



我有这个小问题,我得到无法读取未定义错误的属性,但我不知道问题在哪里。有人能帮我解决这个问题吗?

const Discord = require('discord.js');
const client = new Discord.Client({ intents: ["GUILDS", "GUILD_MESSAGES"] }, { partials: ["MESSAGE", "CHANNEL", "REACTION" ]})
const { prefix, token } = require ('./config.json');
const fs = require('fs');

client.commands = new Discord.Collection();

const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
client.commands.set(command.name, command);
}
var serverID  = '832712939457871882';
var channelID = '832712940562022480';
var messageID = '833299637996748800';
var categoryID= '833295884992643102';
client.on('ready', () => {
console.log("[+] bot is up!")
//Ticket module
client.guilds.cache.get(serverID) //serverID
.channels.cache.get(channelID) //channelID
.messages.fetch(messageID).then(msg => msg.react('🎟️')) //messageID
});

误差

C:UsersMIG TECNICADesktopdbotrpindex.js:35
.channels.cache.get(channelID) //channelID
^
TypeError: Cannot read properties of undefined (reading 'channels')

使用client.guilds.fetch(‘guild id here’).channels.cache.find(c => c.id === ‘channel id here’).messages.fetch(‘message id here’).then(msg => { msg.react(‘emoji here’); });

相关内容

最新更新