第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何修復(fù)我的機器人的“附件不是構(gòu)造函數(shù)”錯誤?

如何修復(fù)我的機器人的“附件不是構(gòu)造函數(shù)”錯誤?

人到中年有點甜 2021-06-19 14:01:57
當(dāng)我為 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;我希望它發(fā)送附件,但它沒有發(fā)送并發(fā)送此錯誤
查看完整描述

3 回答

?
元芳怎么了

TA貢獻1798條經(jīng)驗 獲得超7個贊

你可以這樣做:

message.channel.send('I am Damabot, developed by Damadion!', { files: ['./DidYouThinkIAmTheRealFace.png'] });

它將文件直接添加到消息中,因此您不必創(chuàng)建附件。我用這個我的 BOT,它工作得很好。


查看完整回答
反對 回復(fù) 2021-06-24
?
忽然笑

TA貢獻1806條經(jīng)驗 獲得超5個贊

對我來說,以下代碼有效:


const attachment = new Discord.MessageAttachment("url");

channel.send(attachment);

Discord.Attachment 被替換為 Discord.MessageAttachement


查看完整回答
反對 回復(fù) 2021-06-24
?
qq_花開花謝_0

TA貢獻1835條經(jīng)驗 獲得超7個贊

Attachment是 Discord.js 中的一個類。除非您對 require 語句 ( const { Attachment } = require('discord.js'))使用解構(gòu)賦值,否則Node.js 會嘗試根據(jù)代碼中的類構(gòu)造一個 Attachment 對象。當(dāng)它發(fā)現(xiàn)沒有時,它會拋出您的錯誤。


如果你想堅持構(gòu)造附件對象,你可以使用:


const attachment = new Discord.Attachment('./path/to/file.png', 'name'); // name is optional


message.channel.send('Hey there', attachment)

  .catch(console.error);

否則,您可以files像這樣使用消息的屬性:


message.channel.send('Hey there', {

  files: ['./path/to/file.png']

})

.catch(console.error);

后者允許您也發(fā)送一個嵌入(并且可能在您的嵌入中使用附件)。


查看完整回答
反對 回復(fù) 2021-06-24
  • 3 回答
  • 0 關(guān)注
  • 223 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號