TypeError: Cannot read property 'MessageEmbed' of undefined
TypeError: Cannot read property 'MessageEmbed' of undefined
我正在 Discord.js 创建一个 Discord 机器人,我需要你的“+帮助”。 +help
命令将显示包含所有相关命令的嵌入。但是,当我进行嵌入时,出现此错误。
TypeError: Cannot read property 'MessageEmbed' of undefined
如果你很好奇,这是我在 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
):
else if (command === "help") {
client.commands.get("help").execute(message, args);
}
(else if
是因为命令比较多。)
你能帮帮我吗?
根据@Tyler2P的评论,我在help.js
中的execute()
函数中使用了Discord
对象,但在main.js
中的client.commands.get().execute()
中没有使用.
尝试仅使用 MessageEmbed() 从执行中删除 Discord,例如
module.exports = {
name: "help",
description: "Help embed.",
execute(message, args) {
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);
}
}
我正在 Discord.js 创建一个 Discord 机器人,我需要你的“+帮助”。 +help
命令将显示包含所有相关命令的嵌入。但是,当我进行嵌入时,出现此错误。
TypeError: Cannot read property 'MessageEmbed' of undefined
如果你很好奇,这是我在 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
):
else if (command === "help") {
client.commands.get("help").execute(message, args);
}
(else if
是因为命令比较多。)
你能帮帮我吗?
根据@Tyler2P的评论,我在help.js
中的execute()
函数中使用了Discord
对象,但在main.js
中的client.commands.get().execute()
中没有使用.
尝试仅使用 MessageEmbed() 从执行中删除 Discord,例如
module.exports = {
name: "help",
description: "Help embed.",
execute(message, args) {
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);
}
}