繁体   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