javascript - Discord.Client 不是构造函数
问题描述
我正在使用 discord.js 12.3.0 webpack
到目前为止,这是我的代码
<script type="text/javascript">
const Discord = ('https://raw.githubusercontent.com/discordjs/discord.js/webpack/discord.12.3.0.min.js');
const client = new Discord.Client();
client.on('message', message => {
console.log(message.content);
});
client.login('. . .');
</script>
我的目标是让网站显示机器人的所有信息,但我无法使用机器人登录。
这是我的错误:
index.html:12 Uncaught TypeError: Discord.Client is not a constructor
at index.html:12
(anonymous) @ index.html:12
index.html:8 Cross-Origin Read Blocking (CORB) blocked cross-origin response https://raw.githubusercontent.com/discordjs/discord.js/webpack/discord.12.3.0.min.js with MIME type text/plain. See https://www.chromestatus.com/feature/5629709824032768 for more details.
解决方案
这是CORS问题。尝试<script src="..."></script>
推荐阅读
- firebase - 添加另一个方法后 dispatch() 和 if-else 语句出现问题
- inno-setup - 如何在 Inno Setup 中根据操作系统版本选择要复制的文件?
- javascript - 就像我们在节点 js 中有 readFileSync 函数一样,我需要 http.getSync - http.get() 的包装器以使其同步
- javascript - 导出 Promise API 调用以进行重用
- python-3.x - 以下代码片段的高效实现
- android - LiveData、MutableLiveData 之间的区别
- android - 什么是在 Android Studio 中指示 AGPBI 错误?
- dialogflow-es - 使用 api 上传意图时无法从用户短语中提取实体
- hyperledger-composer - 使用查询功能如何获取资产总量?
- javascript - Angular 6反应形式输入值到大写