我想要什么:
我想让这个间隔每分钟编辑一次消息,以更新我的 Fivem 服务器的服务器统计信息,尽管我不知道如何编辑消息。我尝试了多种方法,我想知道我是否声明channelStat
不正确,或者编辑消息的方法与discord.js
我尝试的方法不同。
任何帮助将不胜感激。
我已经尝试过.edit()
代码示例中的函数
代码:
var serverStats = setInterval(function () {
const channelStat = client.channels.cache.get('902678733977157632').messages.fetch('902682557789908992')
Gamedig.query({
type: 'fivem',
host: config.ipabs,
port: config.port
}).then((state) => {
const embed = new Discord.MessageEmbed()
.setTitle('Logic RP Stats:')
.setImage('https://images-ext-2.discordapp.net/external/PaPGVPWBJVWcsboWGg9IWOfE0U0QSj1sb3UEwYIHYcA/https/images-ext-1.discordapp.net/external/zcWeRc4OUGdU4UKejuGPzrBt2CvqZY8iIqPZtcrUc84/https/images-ext-2.discordapp.net/external/QyWWFfOXuBL0VfdsZNJJdwoLQKQcvmpXo9IHRZoDM6U/https/cdn-longterm.mee6.xyz/plugins/reaction_roles/images/873023096611799080/911344681e6437aff9cc5e8a6660412e8733a43cde7dc38d01649a557a5e46d8.gif')
.addFields(
{
name: "Status:",
value: `Online`,
inline: true
},
{
name: "Queue:",
value: `${state}`,
inline: true
},
{
name: "IP:",
value: `${state.connect}`,
inline: true
},
{
name: "Next Restart:",
value: `12:00 PM EST`,
inline: true
},
{
name: "Players:",
value: `${state.raw.clients}/${state.maxplayers}`,
inline: true
},
{
name: "Ping:",
value: `${state.ping}`,
inline: true
},
{
name: "Inhabitants:",
value: liste,
inline: false
},
)
.setColor(`AQUA`)
.setFooter(`Logic RP | ${versionNumber}`)
channelStat.edit({embeds: [embed]})
}).catch((error) => {
const embed = new Discord.MessageEmbed()
.setTitle('The Server Is Currently Down')
.setImage('https://images-ext-2.discordapp.net/external/PaPGVPWBJVWcsboWGg9IWOfE0U0QSj1sb3UEwYIHYcA/https/images-ext-1.discordapp.net/external/zcWeRc4OUGdU4UKejuGPzrBt2CvqZY8iIqPZtcrUc84/https/images-ext-2.discordapp.net/external/QyWWFfOXuBL0VfdsZNJJdwoLQKQcvmpXo9IHRZoDM6U/https/cdn-longterm.mee6.xyz/plugins/reaction_roles/images/873023096611799080/911344681e6437aff9cc5e8a6660412e8733a43cde7dc38d01649a557a5e46d8.gif')
.setColor('AQUA')
.setFooter(`Logic RP | ${versionNumber}`)
channelStat.edit({embeds: [embed]})
});
}, 60000);