From 185db61887f6cbac5fe87276e8111b53823801d5 Mon Sep 17 00:00:00 2001 From: Skillz Date: Sun, 27 Dec 2020 10:54:20 -0500 Subject: [PATCH] add member.mention and member.avatarURL --- src/api/structures/member.ts | 26 +++++++++++++++++++++++++- src/bot.ts | 4 ++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/api/structures/member.ts b/src/api/structures/member.ts index 78c1a6afd..f495d3eff 100644 --- a/src/api/structures/member.ts +++ b/src/api/structures/member.ts @@ -14,14 +14,30 @@ import { addRole, editMember, kick, + rawAvatarURL, removeRole, sendDirectMessage, } from "../handlers/member.ts"; import { Guild } from "./guild.ts"; const baseMember: Partial = { - // METHODS + get avatarURL() { + return rawAvatarURL(this.id!, this.discriminator!, this.avatar!); + }, + get mention() { + return `<@!${this.id!}>`; + }, + // METHODS + makeAvatarURL(size, format) { + return rawAvatarURL( + this.id, + this.discriminator!, + this.avatar!, + size, + format, + ); + }, guild(guildID) { return cache.guilds.get(guildID); }, @@ -137,8 +153,16 @@ export interface Member { /** The guild related data mapped by guild id */ guilds: Collection; + // GETTERS + /** The avatar url using the default format and size. */ + avatarURL: string; + /** The mention string for this member */ + mention: string; + // METHODS + /** Returns the avatar url for this member and can be dynamically modified with a size or format */ + makeAvatarURL(size: ImageSize, format: ImageFormat): string; /** Returns the guild for this guildID */ guild(guildID: string): Guild | undefined; /** Get the nickname or the username if no nickname */ diff --git a/src/bot.ts b/src/bot.ts index 85f5b4992..366cf0272 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -66,8 +66,8 @@ export async function startBot(config: BotConfig) { export function updateEventHandlers(newEventHandlers: EventHandlers) { eventHandlers = { ...eventHandlers, - ...newEventHandlers - } + ...newEventHandlers, + }; } /** INTERNAL LIB function used to set the bot ID once the READY event is sent by Discord. */