#help
1 messages · Page 1 of 1 (latest)
👀
fetch all commands with await client.application.commands.fetch()
that returns a Collection of commands
he is using message commands
oh?
He just don't know how to create an array out side of for loop...
@twilit jungle you got a command handler?
ig
const commandFiles = readdirSync('./commands').filter((file) => file.endsWith('.js'))
for (const file of commandFiles) {
const command = require(`./commands/${file}`)
client.commands.set(command.name, command)
delete require.cache[require.resolve(`./commands/${file}`)]
}
then use client.commands to array
[...client.commands.values()]
what
const { Client, Message, Interaction, MessageEmbed, MessageActionRow, MessageButton } = require('discord.js')
const db = require('quick.db')
const paginationEmbed = require('discordjs-button-pagination')
const fs = require('fs');
const length = fs.readdirSync('./commands').length
module.exports = {
name: 'commands',
async execute(client, message, args) {
let prefix = await db.fetch(`prefix_${message.guild.id}`)
if (prefix == null) {
prefix = 'skune'
} else {
prefix = prefix
}
let commandsEmbed = new MessageEmbed()
.setColor('#679ad8')
.setDescription(`\`\`\`${client.commands.values().toString()}\n\`\`\``)
message.channel.send({ embeds: [commandsEmbed] })
}
}
is it correct