What I want:
I want to make this interval edit the message every minute to update the server stats for my fivem server, all though I don't know how to edit the message. I've tried multiple ways, I am wondering if I declared channelStat
incorrectly or the method to edit a message with discord.js
is different than what I am trying.
Any help would be greatly appreciated.
I've tried the .edit()
function, which is in the code sample
Code:
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);
Try this:
const channelStat = client.channels.cache.get('902678733977157632').messages.fetch('902682557789908992').then((msg)=> {
msg.edit({embeds: [embed]})
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.