【发布时间】:2021-06-16 09:49:23
【问题描述】:
有在 DiscordJS 上编辑消息的方法
【问题讨论】:
-
这里有您要解决的问题吗?
-
不,这是一个教程。我试图这样做,但没有找到任何解决方案。所以当我发现我发表了它
-
那么请编辑您的问题并提供答案。 See here for info
标签: node.js discord.js
有在 DiscordJS 上编辑消息的方法
【问题讨论】:
标签: node.js discord.js
为此,我们只需要将它传递给函数,即客户端变量。
exports.myNewFunction = async function myNewTestFunction(client)
首先,为了使用 Discord.JS API 编辑消息,我们需要找到服务器的 GuildID。
const guild = client.guilds.cache.get(`Your Guild ID`);
现在,我们需要找到消息所在的频道。为此,我们将使用频道 ID
const channel = guild.channels.cache.find(c => c.id === `Your message Channel` && c.type === 'text');
最后,让我们进入消息的编辑部分。为此,我们只需要提供您要编辑的消息的 ID。
channel.messages.fetch(`Your Message ID`).then(message => {
message.edit("New message Text");
}).catch(err => {
console.error(err);
});
【讨论】: