TypeError: Cannot read properties of undefined (reading 'fetch')
Я смотрел уроки Under Ctrl по discord.js попутно изучая базу JavaScript. В файле 01registerCommands.js с урока №7 пишется ошибка TypeError: Cannot read properties of undefined (reading 'application')
.
Код файла 01registerCommands:
const { testServer } = require('../../../config.json');
const getApplicationCommands = require('../../utils/getApplicationCommands');
const getLocalCommands = require('../../utils/getLocalCommands')
module.exports = async (client) => {
try {
const localCommands = getLocalCommands();
const applicationCommands = getApplicationCommands(client, testServer);
for (const localCommand of localCommands) {
const { name, description, options } = localCommand;
const existingCommand = await applicationCommands.cache.get(
(cmd) => cmd.name === name
);
if (existingCommand) {
if (existingCommand.deleted) {
await applicationCommands.delete(existingCommand.id);
console.log(`? Deleted command: ${name}!`);
continue;
}
if (areCommandsDifferent(existingCommand, localCommand)) {
await applicationCommands.edit(existingCommand.id, {
description,
options,
});
console.log(`? Edited command: ${name}`)
} else {
if (localCommand.deleted) {
console.log(`⏩ Skipping registering command ${name}!`);
continue;
}
}
applicationCommands.create({
name,
description,
options,
})
console.log(`✅ Command ${name} succsessfully registered!`)
}
}
} catch (error) {
console.log(`There was an error: ${error}!`);
}
};