![](/img/trans.png)
[英]discord.js using axios: TypeError: Cannot read properties of undefined (reading 'ephemeral')
[英]discord-modals TypeError: Cannot read properties of undefined (reading 'EPHEMERAL')
我正在使用 package discord-modals
modals 通過我的 discord 機器人創建更好的模態。
當我想回復SlashCommandInteraction
(實際上是modalResponse
監聽事件)時,我無法使回復短暫。 當我刪除ephemeral
布爾時,它工作得很好。 但我不明白為什么它不適用於正常的回復操作。
await event.reply({content: `${replymsg}`, ephemeral: true});
因此,如果我使用它,我會收到以下錯誤:
TypeError: Cannot read properties of undefined (reading 'EPHEMERAL')
at ModalSubmitInteraction.reply (C:\Users\david_h7tqe3i\WebstormProjects\musicbottest\node_modules\discord-modals\src\v14\interfaces\InteractionResponses.js:51:57)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Client.<anonymous> (C:\Users\david_h7tqe3i\WebstormProjects\musicbottest\src\index.js:107:9)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:384:10)
at processTicksAndRejections (node:internal/process/task_queues:85:21)
Process finished with exit code 1
如果我使用以下代碼,它可以工作:
await event.reply({content: `${replymsg}`});
discord-modals
中有一個錯誤。 它使用MessageFlags.FLAGS.EPHEMERAL
,但MessageFlags.FLAGS
undefined
。 為了快速修復,您可以編輯node_modules/discord-modals/src/v14/interfaces/InteractionResponses.js
並在第 51 行替換
data.flags = options.ephemeral ? MessageFlags.FLAGS.EPHEMERAL : undefined;
和
data.flags = options.ephemeral ? MessageFlags.Ephemeral : undefined;
我也開了一個 PR ,希望維護者能盡快接受。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.