javascript - 如何使用我的机器人修复此“附件不是构造函数”错误?
问题描述
当我为 Discord 制作机器人并尝试附加图像时,由于这个错误我不能
这是一个运行在 Discord 上的机器人,Discord.js
我一开始就尝试了 const Attachment,但是没有用,在代码中删除 new 和 const 也没有用
case 'about':
message.channel.send('I am Damabot, developed by Damadion!')
const attachment = new Attachment('./DidYouThinkIAmTheRealFace.png')
message.channel.send('I am Damabot, developed by Damadion!' + attachment)
console.log('Bot successfully replied')
break;
我希望它发送附件,但它没有发送此错误
解决方案
你可以这样做:
message.channel.send('I am Damabot, developed by Damadion!', { files: ['./DidYouThinkIAmTheRealFace.png'] });
它将文件直接添加到消息中,因此您不必创建附件。我用这个我的 BOT,它工作得很好。
推荐阅读
- python - Python Selenium 绘制带有子元素的 ul 并对其进行编程以根据用户输入选择正确的简单方法
- python - "Domain error in arguments." with "stats.beta.rvs"
- php - PHP检查获取的url是否在url中的特定位置有数字
- android - 简单的 Kotlin 数据保存
- c# - SetContentView(在 OnPause 后 OnResume 时)没有看到最后的内容
- python - 从 Keras 加载 InceptionV3 时负责显示 ETA 的程序
- r - 为什么操作按钮无法正常工作,以及如何在我的应用程序中添加进度条?
- c# - 使用 SelectList 从 DropDownList 中获取 AspNetUsers 的 ID
- java - Android Gotev Upload Image Bad notification for startForeground: java.lang.RuntimeException: invalid channel for service notification
- qqmlcomponent - QML如何通过单击listView代表内定义的复选框来获取ListView中的索引号?