From d5b2b62a4434e1af5ca3ddcdb651cc2e33e324a1 Mon Sep 17 00:00:00 2001 From: Elysia <71698422+aiko-chan-ai@users.noreply.github.com> Date: Tue, 21 Feb 2023 19:01:26 +0700 Subject: [PATCH] feat(Guild): topEmojis --- src/structures/Guild.js | 20 ++++++++++++++++++++ typings/index.d.ts | 1 + 2 files changed, 21 insertions(+) diff --git a/src/structures/Guild.js b/src/structures/Guild.js index c2f13c9..408276b 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -1684,6 +1684,26 @@ class Guild extends AnonymousGuild { }; } + /** + * Get the top emojis of this guild. + * @returns {Promise>} + */ + topEmojis() { + return new Promise((resolve, reject) => { + this.client.api + .guilds(this.id) + ['top-emojis'].get() + .then(data => { + const emojis = new Collection(); + for (const emoji of data.items) { + emojis.set(emoji.emoji_rank, this.emojis.cache.get(emoji.emoji_id)); + } + resolve(emojis); + }) + .catch(reject); + }); + } + /** * Creates a collection of this guild's roles, sorted by their position and ids. * @returns {Collection} diff --git a/typings/index.d.ts b/typings/index.d.ts index 2918811..332697e 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1340,6 +1340,7 @@ export class Guild extends AnonymousGuild { private _sortedChannels(channel: NonThreadGuildBasedChannel): Collection; public readonly afkChannel: VoiceChannel | null; + public topEmojis(): Promise>; public afkChannelId: Snowflake | null; public afkTimeout: number; public applicationId: Snowflake | null;