2021-03-31 02:56:25 +00:00
|
|
|
import {client} from "../index";
|
2021-04-05 04:35:12 +00:00
|
|
|
import FileManager from "./storage";
|
2021-04-08 21:43:58 +00:00
|
|
|
import {EmoteRegistryDump} from "../structures";
|
2021-03-31 02:56:25 +00:00
|
|
|
|
|
|
|
function updateGlobalEmoteRegistry(): void {
|
|
|
|
const data: EmoteRegistryDump = {version: 1, list: []};
|
|
|
|
|
|
|
|
for (const guild of client.guilds.cache.values()) {
|
2021-12-29 20:17:39 +00:00
|
|
|
guild.fetch().then((g) => {
|
|
|
|
for (const emote of g.emojis.cache.values()) {
|
|
|
|
data.list.push({
|
|
|
|
ref: emote.name,
|
|
|
|
id: emote.id,
|
|
|
|
name: emote.name,
|
|
|
|
requires_colons: emote.requiresColons ?? false,
|
|
|
|
animated: emote.animated ?? false,
|
|
|
|
url: emote.url,
|
|
|
|
guild_id: emote.guild.name,
|
|
|
|
guild_name: emote.guild.name
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2021-03-31 02:56:25 +00:00
|
|
|
}
|
|
|
|
|
2021-05-06 13:30:51 +00:00
|
|
|
FileManager.open("data/public"); // generate folder if it doesn't exist
|
2021-04-22 09:45:44 +00:00
|
|
|
FileManager.write("public/emote-registry", data, true);
|
2021-03-31 02:56:25 +00:00
|
|
|
}
|
|
|
|
|
2021-05-08 13:32:45 +00:00
|
|
|
client.on("emojiCreate", updateGlobalEmoteRegistry);
|
|
|
|
client.on("emojiDelete", updateGlobalEmoteRegistry);
|
|
|
|
client.on("emojiUpdate", updateGlobalEmoteRegistry);
|
|
|
|
client.on("guildCreate", updateGlobalEmoteRegistry);
|
|
|
|
client.on("guildDelete", updateGlobalEmoteRegistry);
|
|
|
|
client.on("ready", updateGlobalEmoteRegistry);
|