(DISCORD.JS) 如何修复我的不和谐“cmds”命令?
Posted
技术标签:
【中文标题】(DISCORD.JS) 如何修复我的不和谐“cmds”命令?【英文标题】:(DISCORD.JS) how do i fix my discord "cmds" command? 【发布时间】:2022-01-06 19:38:36 【问题描述】:我想知道如何修复我的“cmds”命令?我似乎无法让它正常工作。它应该获取所有命令并将带有命令名称和描述的字段添加到嵌入中,但显示为this error,文件树也是here
module.exports =
name:'cmds',
description:'Literally shows the commands thats it.',
aliases:'',
execute(client,msg,args,blacklisted)
const fs = require('fs')
const MessageEmbed = require("discord.js")
const embed = new MessageEmbed()
function getCommand(cmd)
return client.commands.get(`$cmd`)
const commandFiles = fs.readdirSync('.').filter(file => file.endsWith('.js'));
for (const file of commandFiles)
const command = require(`./$file`)
embed.addField(command.name,```$command.description```)
const author = msg.author
const user = msg.mentions.members.first() || msg.author;
const useronly = msg.mentions.users.first()
if (blacklisted.includes(author.id))
msg.reply(`You have been blacklisted from using this bot. if you think this is a mistake contact the bot owner.`)
else
embed.setTitle(`Commands`)
embed.setColor('RANDOM')
msg.reply(embeds : [embed] )
【问题讨论】:
【参考方案1】:我自己解决了这个问题
function getCommand(cmd)
return client.commands.get(`$cmd`)
console.log(getCommand('avatar').name)
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
for (const file of commandFiles)
const command = require(`./$file`)
embed.addField(`$command.name`,`\`\`\ $command.description \`\`\ `)
【讨论】:
console.log(getCommand('avatar').name)
用于测试以上是关于(DISCORD.JS) 如何修复我的不和谐“cmds”命令?的主要内容,如果未能解决你的问题,请参考以下文章
如何修复“TypeError:无法读取未定义的属性 'toString'” |不和谐.js
我的不和谐机器人上的数据库(Discord.js + mysql)
如何在 discord.js 中标记播放器并接收他们的不和谐 ID