properly handle deleting HandleActivePlayersList prev. embeds
This commit is contained in:
1 file changed
+9
-7
+9
-7
@@ -5,6 +5,8 @@ const { SendConnectionLogs, DetectCombatLog } = require('./AdminLogsHandler');
|
|||||||
// custom util imports
|
// custom util imports
|
||||||
const { FetchServerSettings } = require('../util/NitradoAPI');
|
const { FetchServerSettings } = require('../util/NitradoAPI');
|
||||||
|
|
||||||
|
let lastSendMessage;
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
||||||
HandlePlayerLogs: async (client, guildId, stats, line) => {
|
HandlePlayerLogs: async (client, guildId, stats, line) => {
|
||||||
@@ -210,18 +212,18 @@ module.exports = {
|
|||||||
{ name: 'Status:', value: `\` ${statusEmoji} ${statusText} \``, inline: true },
|
{ name: 'Status:', value: `\` ${statusEmoji} ${statusText} \``, inline: true },
|
||||||
{ name: 'Slots:', value: `\` ${slots} \``, inline: true }
|
{ name: 'Slots:', value: `\` ${slots} \``, inline: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
const activePlayersEmbed = new EmbedBuilder()
|
const activePlayersEmbed = new EmbedBuilder()
|
||||||
.setColor(client.config.Colors.Default)
|
.setColor(client.config.Colors.Default)
|
||||||
.setTimestamp()
|
.setTimestamp()
|
||||||
.setTitle(`Players Online:`)
|
.setTitle(`Players Online:`)
|
||||||
.setDescription(des || (nodes ? "No Players Online :(" : ""))
|
.setDescription(des || (nodes ? "No Players Online :(" : ""))
|
||||||
|
|
||||||
return channel.send({ embeds: [PlayersEmbed, activePlayersEmbed] }).then(sentMessage => {
|
if (lastSendMessage) lastSendMessage.delete().catch(error => client.sendError(channel, `HandleActivePlayersList Error: \n${error}`)); // Remove previous message before reprinting
|
||||||
setTimeout(() => {
|
|
||||||
sentMessage.delete().catch(error => client.sendError(channel, `HandleActivePlayersList Error: \n${error}`));
|
return channel.send({ embeds: [PlayersEmbed, activePlayersEmbed] }).then(sentMessage =>
|
||||||
}, 360000);
|
lastSendMessage = sentMessage
|
||||||
});
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user