我有以下(打字稿)代碼片段,它生成一個嵌入以回應互動,并發送它:
const embed = await this.generateEmbed(...);
await interaction.reply({embeds: [embed]});
const sentMessage: Message = <Message<boolean>> await interaction.fetchReply();
await sentMessage.react('?');
但是,這在運行時失敗,因為TypeError: sentMessage.react is not a function.
這在 discord.js 檔案中有一些解釋:
如果 webhook 被實體化為 WebhookClient 或者通道未快取,則回傳原始訊息資料,否則將回傳一條訊息
但是,即使我快取了所有內容,也會發生這種情況:
const bot = new Client({
makeCache: Options.cacheEverything(),
...
});
另請注意,我沒有使用WebhookClient此處。
為什么CommandInteraction.reply()在這里回傳原始訊息,我怎樣才能讓它回傳一個完整的Message物件,以便我可以使用該.react()方法?
uj5u.com熱心網友回復:
我已經做了很多測驗,我得出的結論是,這是因為你沒有請求GUILDS意圖。我假設在沒有GUILDS意圖的情況下,GuildChannel無法快取 ,也無法快取Message,因此它從 API 回傳原始資料。
const { Client, Intents } = require('discord.js');
const bot = new Client({
intents: [Intents.FLAGS.GUILDS],
...
})
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/400032.html
標籤:javascript 不和谐 不和谐.js
下一篇:如何從按鈕上的回圈中獲取id
