在discord.js中编辑画布附件

编程入门 行业动态 更新时间:2024-10-25 18:32:16

在discord.js中编辑<a href=https://www.elefans.com/category/jswz/34/1766074.html style=画布附件"/>

在discord.js中编辑画布附件

我正在尝试使用discord.js和Canvas创建各种游戏。我最近从本教程中学到了Canvas:/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画布,但是不确定如何处理此发送的附件。如果没有[[absolutely无法编辑此附件,我将如何删除第一个附件(由attachid给出的附件)?

如果有任何疑问,或希望我提供更多代码,请告诉我! 回答如下:Discord API不支持带有其他附件的消息版本。因此,如果邮件已经发送,则无法添加,删除或编辑附件(可以尝试使用自己的帐户,该邮件将无法使用)。您唯一的方法是删除邮件,然后使用其他附件重新发送...这里有一份建议提交给Discord:https://support.discordapp/hc/en-us/community/posts/360041728292-Edit-sent-files

更多推荐

在discord.js中编辑画布附件

本文发布于:2024-05-06 22:53:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1753921.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:画布   附件   编辑   discord   js

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!