最新消息: 电脑我帮您提供丰富的电脑知识,编程学习,软件下载,win7系统下载。

在discord.js中编辑画布附件

IT培训 admin 11浏览 0评论

在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中编辑画布附件

我正在尝试使用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

与本文相关的文章

发布评论

评论列表 (0)

  1. 暂无评论