簡體   English   中英

在 discord.js 中編輯畫布附件

[英]Editing Canvas Attachment in discord.js

我正在嘗試使用 discord.js 和 Canvas 創建各種游戲。 我最近從本教程中了解到 Canvas: https : //discordjs.guide/popular-topics/canvas.html 我按照這個例子的大部分來創建畫布。

我想要做的是能夠編輯附件,或在 setInterval() 中用新附件替換它。 我似乎無法弄清楚如何編輯附件,因為我已經嘗試過:

//attachid = The id for the canvas attachment; channel is the name of the channel the canvas was set in
bot.login(token).then(() => {
    setInterval(function() { //Start an interval after logging in...
        if(canvas !== null) { //If the canvas was created...
            //Edit canvas here
            var attachment = new Discord.Attachment(canvas.toBuffer) //Create a new canvas attachment
            //The fetchMessage below is where I am having issue
            channel.fetchMessage(attachid).then(msg => msg.edit(attachment));
        }
    }, 1000);
});

我已經知道如何使用畫布本身,因為它類似於 HTML5 畫布,但我不確定如何操作這個發送的附件。 如果絕對無法編輯此附件,我將如何刪除第一個附件(attachid 給出的附件)?

如果您有任何問題,或者希望我提供更多代碼,請告訴我!

Discord API 不支持帶有其他附件的消息版本。 因此,如果郵件已經發送,您將無法添加、刪除或編輯附件(您可以使用自己的帳戶嘗試,它不起作用)。 您擁有的唯一方法是刪除該郵件並使用另一個附件重新發送...
這里有一個建議提交給 Discord: https : //support.discordapp.com/hc/en-us/community/posts/360041728292-Edit-sent-files

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM