From 5537cec29a0d512cae5509c39a00d71dcf9c6c35 Mon Sep 17 00:00:00 2001 From: WatDuhHekBro <44940783+WatDuhHekBro@users.noreply.github.com> Date: Fri, 1 Jan 2021 19:44:43 -0600 Subject: [PATCH] Removed structure redundancy and saves to data/ --- .gitignore | 1 - src/core/lib.ts | 17 +++++------------ src/core/structures.ts | 2 -- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index db69620..a3becd9 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,6 @@ test* !test/ *.bat desktop.ini -emote-registry.json # Logs logs diff --git a/src/core/lib.ts b/src/core/lib.ts index ad7dba6..7a12538 100644 --- a/src/core/lib.ts +++ b/src/core/lib.ts @@ -1,4 +1,3 @@ -import {writeFileSync} from "fs"; import {GenericWrapper, NumberWrapper, StringWrapper, ArrayWrapper} from "./wrappers"; import {Client, Message, TextChannel, DMChannel, NewsChannel, Guild, User, GuildMember, Permissions} from "discord.js"; import chalk from "chalk"; @@ -163,28 +162,22 @@ export function botHasPermission(guild: Guild | null, permission: number): boole } export function updateGlobalEmoteRegistry(): void { - const data: EmoteRegistryDump = {version: 1, list: []}; + const list: EmoteRegistryDumpEntry[] = []; + for (const guild of client.guilds.cache.values()) { - $.debug(client.guilds.cache.size); for (const emote of guild.emojis.cache.values()) { - $.debug(client.emojis.cache.size); - console.log("HELLO?!"); - data.list.push({ - ref: emote.name, + list.push({ id: emote.id, name: emote.name, requires_colons: emote.requiresColons || false, animated: emote.animated, url: emote.url, - guild_id: emote.guild.name, guild_name: emote.guild.name }); } } - const sData = JSON.stringify(data); - $.debug(data); - $.debug(sData); - writeFileSync("emote-registry.json", sData); + + FileManager.write("emote-registry", {version: 1, list}, true); } // Pagination function that allows for customization via a callback. diff --git a/src/core/structures.ts b/src/core/structures.ts index 0d78e13..a921931 100644 --- a/src/core/structures.ts +++ b/src/core/structures.ts @@ -108,13 +108,11 @@ export function getPrefix(guild: DiscordGuild | null): string { } export interface EmoteRegistryDumpEntry { - ref: string; id: Snowflake; name: string; requires_colons: boolean; animated: boolean; url: string; - guild_id: Snowflake; guild_name: string; }