wait 5-10 min to re-add emoji

This commit is contained in:
Lamp 2019-08-05 00:39:27 +00:00
parent a3fc575f46
commit a08b197076
1 changed files with 15 additions and 1 deletions

View File

@ -86,8 +86,22 @@
// persistent emojis
dClient.on("local_emojiDelete", async emoji => {
console.log("emoji deleted:", emoji.name, emoji.url);
if (global.disableEmojiProtection) return;
if (emoji.name.toLowerCase().includes('delete')) return;
async function readdEmoji() {
await emoji.guild.emojis.create(emoji.url, emoji.name);
delete readdEmoji;
}
// re-add emoji in 5 to 10 minutes
setTimeout(() => {
if (readdEmoji) readdEmoji();
}, 300000 + Math.random() * 300000);
// wouldn't want emoji to be lost if process is stopped before timeout ends
exitHook(callback => {
if (readdEmoji) readdEmoji().then(() => callback());
else callback();
});
});