const path = require('node:path')
const fs = require('node:fs')
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord.js');
const { clientId, token } = require('./config.json');
const commands = [];
const commandsPath = path.join(__dirname, 'commands');
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
const command = require(filePath);
commands.push(command.data.toJSON());
}
const rest = new REST({ version: '10' }).setToken(token);
rest.put(Routes.applicationCommands(clientId), { body: commands })
.then(() => console.log('Successfully registered application commands.'))
.catch(console.error);
/home/nikita/apkdownloaderbot/node_modules/@sapphire/shapeshift/dist/index.js:76
throw this.error;
^
ValidationError: Expected a string primitive
at StringValidator.handle (/home/nikita/apkdownloaderbot/node_modules/@sapphire/shapeshift/dist/index.js:1666:70)
at StringValidator.parse (/home/nikita/apkdownloaderbot/node_modules/@sapphire/shapeshift/dist/index.js:142:88)
at validateName (/home/nikita/apkdownloaderbot/node_modules/@discordjs/builders/dist/interactions/slashCommands/Assertions.cjs:11:17)
at Object.validateRequiredParameters (/home/nikita/apkdownloaderbot/node_modules/@discordjs/builders/dist/interactions/slashCommands/Assertions.cjs:26:3)
at SlashCommandUserOption.runRequiredValidations (/home/nikita/apkdownloaderbot/node_modules/@discordjs/builders/dist/interactions/slashCommands/mixins/ApplicationCommandOptionBase.cjs:19:16)
at SlashCommandUserOption.toJSON (/home/nikita/apkdownloaderbot/node_modules/@discordjs/builders/dist/interactions/slashCommands/options/user.cjs:14:10)
at /home/nikita/apkdownloaderbot/node_modules/@discordjs/builders/dist/interactions/slashCommands/SlashCommandBuilder.cjs:37:52
at Array.map (<anonymous>)
at MixedClass.toJSON (/home/nikita/apkdownloaderbot/node_modules/@discordjs/builders/dist/interactions/slashCommands/SlashCommandBuilder.cjs:37:29)
at Object.<anonymous> (/home/nikita/apkdownloaderbot/deploy_commands.js:14:32) {
validator: 's.string',
given: undefined
}
Node.js v18.7.0
.setNameLocalizations
и .setDescriptionLocalizations
{
data: {
name: 'google',
description: 'Гугл для неумелых',
options: [ [Object] ],
default_permission: undefined,
default_member_permissions: undefined,
dm_permission: undefined
},
execute: [AsyncFunction: execute]
}
{
data: {
name: 'help',
description: 'Получите помощь по боту',
options: [],
default_permission: undefined,
default_member_permissions: undefined,
dm_permission: undefined
},
execute: [AsyncFunction: execute]
}
{
data: {
name: 'user',
description: 'Get information about user',
options: [ [SlashCommandUserOption] ],
default_permission: undefined,
default_member_permissions: undefined,
dm_permission: undefined,
name_localizations: {
'en-US': 'user',
'en-GB': 'user',
ru: 'юзер',
'es-ES': 'usuario',
fr: 'utilisateur'
},
description_localizations: {
ru: 'Получите информацию о пользователе',
'en-US': 'Get information about user',
'en-GB': 'Get information about user',
'es-ES': 'Obtener información sobre la usuario',
fr: "Obtenir des informations sur l'utilisateur"
}
},
execute: [AsyncFunction: execute]
}