无法读取未定义的属性“ MessageEmbed”

时间:2020-10-03 05:19:08

标签: javascript node.js discord.js

创建了禁止成员的Discord机器人 我更喜欢在禁止某人后回复嵌入的消息,但我所能做的只是一条正常消息 我不知道为什么即使我拥有最新的discord.js(v12),也无法创建嵌入

我得到了错误:

<ListView Name="listViewResults"
          ItemsSource="{Binding Results}"
          SelectedItem="{Binding CurrentLog}"/>

这是我的代码:

C:\Users\oussa\OneDrive\Bureau\Discord Bot\index.js:45
  const BanEmbed = new Discord.MessageEmbed()
                               ^

TypeError: Cannot read property 'MessageEmbed' of undefined

1 个答案:

答案 0 :(得分:2)

错误在于您的解构分配。 <IfModule mod_ssl.c> <VirtualHost *:443> ServerName apiws.mydomain.com ServerAlias apiws.mydomain.com DocumentRoot /var/www/html ErrorLog /var/log/httpd/error.log CustomLog /var/log/httpd/requests.log combined <Location /api/> ProxyPass http://localhost:5000/ ProxyPassReverse http://localhost:5000/ ProxyPass ws://localhost:5000/ Require all granted </Location> SSLCertificateFile /etc/letsencrypt/live/apiws.mydomain.com/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/apiws.mydomain.com/privkey.pem Include /etc/letsencrypt/options-ssl-apache.conf </VirtualHost> 不是discord.js的属性,因此为何未定义。您最可能想要:

Discord

然后像这样实现它

const { Client, Attachment, Message, MessageEmbed } = require("discord.js");

旁注,const BanEmbed = new MessageEmbed() 也不是discord.js的有效属性,因此您很可能希望将其更改为Attachment

API文档:https://discord.js.org/#/docs/main/stable/class/MessageAttachment