Problem with the v14.15.1

Hey guys, i installed the new version of discord.js but when i'm starting my bot that return automatically an error on my console, if i keep the v14.14.1 that work, but i need the polls things , anyone can help me plz ?
6 Replies
d.js toolkit
d.js toolkit8mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
Lucas
LucasOP8mo ago
const Discord = require("discord.js")
const { REST } = require("@discordjs/rest")
const { Routes } = require("discord.js")


module.exports = async (bot) => {

let commands = [];

bot.commands.forEach( async command => {

let slashcommand = new Discord.SlashCommandBuilder()
.setName(command.name)
.setDescription(command.description)
.setDMPermission(command.dm)
.setDefaultMemberPermissions(command.permission === "Aucune" ? null : command.permission)

if(command.options?.length >= 1) {
for(let i = 0; i < command.options.length; i++) {
console.log(command.options[i])
if(command.options[i].type === "string") slashcommand[`add${command.options[i].type.slice(0, 1).toUpperCase() + command.options[i].type.slice(1, command.options[i].type.length )}Option`](option => option.setName(command.options[i].name).setDescription(command.options[i].description).setAutocomplete(command.options[i].autocomplete).setRequired(command.options[i].required))
else slashcommand[`add${command.options[i].type.slice(0, 1).toUpperCase() + command.options[i].type.slice(1, command.options[i].type.length )}Option`](option => option.setName(command.options[i].name).setDescription(command.options[i].description).setRequired(command.options[i].required))
}
}
await commands.push(slashcommand)
})

const rest = new REST({version: 10}).setToken(bot.token)

await rest.put(Routes.applicationCommands(bot.user.id), {body: commands})
console.log(("[LOAD] - Les slashs commandes sont crées avec succès !!").bold.magenta)
}
const Discord = require("discord.js")
const { REST } = require("@discordjs/rest")
const { Routes } = require("discord.js")


module.exports = async (bot) => {

let commands = [];

bot.commands.forEach( async command => {

let slashcommand = new Discord.SlashCommandBuilder()
.setName(command.name)
.setDescription(command.description)
.setDMPermission(command.dm)
.setDefaultMemberPermissions(command.permission === "Aucune" ? null : command.permission)

if(command.options?.length >= 1) {
for(let i = 0; i < command.options.length; i++) {
console.log(command.options[i])
if(command.options[i].type === "string") slashcommand[`add${command.options[i].type.slice(0, 1).toUpperCase() + command.options[i].type.slice(1, command.options[i].type.length )}Option`](option => option.setName(command.options[i].name).setDescription(command.options[i].description).setAutocomplete(command.options[i].autocomplete).setRequired(command.options[i].required))
else slashcommand[`add${command.options[i].type.slice(0, 1).toUpperCase() + command.options[i].type.slice(1, command.options[i].type.length )}Option`](option => option.setName(command.options[i].name).setDescription(command.options[i].description).setRequired(command.options[i].required))
}
}
await commands.push(slashcommand)
})

const rest = new REST({version: 10}).setToken(bot.token)

await rest.put(Routes.applicationCommands(bot.user.id), {body: commands})
console.log(("[LOAD] - Les slashs commandes sont crées avec succès !!").bold.magenta)
}
Load Slash Command + Error :
else slashcommand[`add${command.options[i].type.slice(0, 1).toUpperCase() + command.options[i].type.slice(1, command.options[i].type.length )}Option`](option => option.setName(command.options[i].name).setDescription(command.options[i].description).setRequired(command.options[i].required))
^

TypeError: Cannot read properties of undefined (reading 'slice')
at C:\Users\lucas\OneDrive\Bureau\DISCORD OFF BOT\Loaders\loadSlashCommands.js:22:65
at module.exports (C:\Users\lucas\OneDrive\Bureau\DISCORD OFF BOT\Loaders\loadSlashCommands.js:10:18)
at module.exports (C:\Users\lucas\OneDrive\Bureau\DISCORD OFF BOT\Events\ready.js:8:11)
at Client.emit (node:events:518:28)
at WebSocketManager.triggerClientReady (C:\Users\lucas\OneDrive\Bureau\DISCORD OFF BOT\node_modules\discord.js\src\client\websocket\WebSocketManager.js:388:17)
at WebSocketManager.checkShardsReady (C:\Users\lucas\OneDrive\Bureau\DISCORD OFF BOT\node_modules\discord.js\src\client\websocket\WebSocketManager.js:371:10)
at WebSocketShard.<anonymous> (C:\Users\lucas\OneDrive\Bureau\DISCORD OFF BOT\node_modules\discord.js\src\client\websocket\WebSocketManager.js:201:16)
at WebSocketShard.emit (node:events:518:28)
at WebSocketShard.checkReady (C:\Users\lucas\OneDrive\Bureau\DISCORD OFF BOT\node_modules\discord.js\src\client\websocket\WebSocketShard.js:181:12)
else slashcommand[`add${command.options[i].type.slice(0, 1).toUpperCase() + command.options[i].type.slice(1, command.options[i].type.length )}Option`](option => option.setName(command.options[i].name).setDescription(command.options[i].description).setRequired(command.options[i].required))
^

TypeError: Cannot read properties of undefined (reading 'slice')
at C:\Users\lucas\OneDrive\Bureau\DISCORD OFF BOT\Loaders\loadSlashCommands.js:22:65
at module.exports (C:\Users\lucas\OneDrive\Bureau\DISCORD OFF BOT\Loaders\loadSlashCommands.js:10:18)
at module.exports (C:\Users\lucas\OneDrive\Bureau\DISCORD OFF BOT\Events\ready.js:8:11)
at Client.emit (node:events:518:28)
at WebSocketManager.triggerClientReady (C:\Users\lucas\OneDrive\Bureau\DISCORD OFF BOT\node_modules\discord.js\src\client\websocket\WebSocketManager.js:388:17)
at WebSocketManager.checkShardsReady (C:\Users\lucas\OneDrive\Bureau\DISCORD OFF BOT\node_modules\discord.js\src\client\websocket\WebSocketManager.js:371:10)
at WebSocketShard.<anonymous> (C:\Users\lucas\OneDrive\Bureau\DISCORD OFF BOT\node_modules\discord.js\src\client\websocket\WebSocketManager.js:201:16)
at WebSocketShard.emit (node:events:518:28)
at WebSocketShard.checkReady (C:\Users\lucas\OneDrive\Bureau\DISCORD OFF BOT\node_modules\discord.js\src\client\websocket\WebSocketShard.js:181:12)
Svitkona
Svitkona8mo ago
what is bot.commands in this case
Lucas
LucasOP8mo ago
bot.commands = new Discord.Collection()
bot.commands = new Discord.Collection()
Svitkona
Svitkona8mo ago
@Lucas what is the output of the log call inside the for loop?
Lucas
LucasOP8mo ago
my options
{
type: 'string',
name: 'boisson',
description: 'test boire',
required: true,
autocomplete: true
}
{
type: 'string',
name: 'manger',
description: 'test manger',
required: false,
autocomplete: true
}
{
type: 'channel',
name: 'salon',
description: 'Le channel à unlock',
required: true,
autocomplete: false
}
{
type: 'role',
name: 'role',
description: 'Le role à unlock',
required: true,
autocomplete: false
}
{
type: 'string',
name: 'boisson',
description: 'test boire',
required: true,
autocomplete: true
}
{
type: 'string',
name: 'manger',
description: 'test manger',
required: false,
autocomplete: true
}
{
type: 'channel',
name: 'salon',
description: 'Le channel à unlock',
required: true,
autocomplete: false
}
{
type: 'role',
name: 'role',
description: 'Le role à unlock',
required: true,
autocomplete: false
}
and a lot of more all of them have a type property
Want results from more Discord servers?
Add your server