Removed structure redundancy and saves to data/

This commit is contained in:
WatDuhHekBro 2021-01-01 19:44:43 -06:00
parent 68d8eed4ed
commit 5537cec29a
3 changed files with 5 additions and 15 deletions

1
.gitignore vendored
View File

@ -7,7 +7,6 @@ test*
!test/
*.bat
desktop.ini
emote-registry.json
# Logs
logs

View File

@ -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.

View File

@ -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;
}