TypeError:无法读取未定义的属性“MessageEmbed" [英] TypeError: Cannot read property 'MessageEmbed' of undefined
问题描述
我正在 Discord.js 中创建一个 Discord 机器人,我需要你的+帮助".+help
命令将显示包含所有相关命令的嵌入.但是,当我进行嵌入时,我得到了这个错误.
I am creating a Discord bot in Discord.js and I need your "+help". The +help
command will display an embed containing all the relevant commands. However, when I make the embed, I get this error.
TypeError: Cannot read property 'MessageEmbed' of undefined
如果你好奇,这是我在 help.js
中的代码:
If you are curious, here is my code in help.js
:
module.exports = {
name: "help",
description: "Help embed.",
execute(message, args, Discord) {
const Help = new Discord.MessageEmbed()
.setColor("red")
.setTitle("Command List")
.setAuthor("Bots for Guilds")
.setDescription("List of all commands with BFG software")
.addFields (
{name: "`+help`", value: "Shows all the commands."},
{name: "`+ping`", value: "Ping-pong command: you write `+ping`, and the bot responds "pong!""},
{name: "`+cheenta`", value: "Gives a link to my presentation at Cheenta Bose Olympiad Round 7."},
{name: "`+whoisatharv`", value: "Gives information about me."},
{name: "`+youtube`", value: "Give my YouTube Channel link."}
);
message.channel.send(Help);
}
}
并且 help.js
正在使用命令处理程序连接到我的源文件 (main.js
):
And help.js
is being connected to my source file (main.js
) with a command handler:
else if (command === "help") {
client.commands.get("help").execute(message, args);
}
(else if
是因为命令比较多.)
(The else if
is because there are more commands.)
你能帮帮我吗?
推荐答案
根据@Tyler2P的评论,我在execute()
函数中使用了Discord
对象>help.js,但是我没有在client.commands.get().execute()
中main.js
.
According to @Tyler2P's comment, I used Discord
object in the execute()
function in help.js
, but I did not in client.commands.get().execute()
in main.js
.
这篇关于TypeError:无法读取未定义的属性“MessageEmbed"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!