add member.mention and member.avatarURL

This commit is contained in:
Skillz
2020-12-27 10:54:20 -05:00
parent aacb3d9927
commit 185db61887
2 changed files with 27 additions and 3 deletions
+25 -1
View File
@@ -14,14 +14,30 @@ import {
addRole, addRole,
editMember, editMember,
kick, kick,
rawAvatarURL,
removeRole, removeRole,
sendDirectMessage, sendDirectMessage,
} from "../handlers/member.ts"; } from "../handlers/member.ts";
import { Guild } from "./guild.ts"; import { Guild } from "./guild.ts";
const baseMember: Partial<Member> = { const baseMember: Partial<Member> = {
// 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) { guild(guildID) {
return cache.guilds.get(guildID); return cache.guilds.get(guildID);
}, },
@@ -137,8 +153,16 @@ export interface Member {
/** The guild related data mapped by guild id */ /** The guild related data mapped by guild id */
guilds: Collection<string, GuildMember>; guilds: Collection<string, GuildMember>;
// GETTERS
/** The avatar url using the default format and size. */
avatarURL: string;
/** The mention string for this member */
mention: string;
// METHODS // 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 */ /** Returns the guild for this guildID */
guild(guildID: string): Guild | undefined; guild(guildID: string): Guild | undefined;
/** Get the nickname or the username if no nickname */ /** Get the nickname or the username if no nickname */
+2 -2
View File
@@ -66,8 +66,8 @@ export async function startBot(config: BotConfig) {
export function updateEventHandlers(newEventHandlers: EventHandlers) { export function updateEventHandlers(newEventHandlers: EventHandlers) {
eventHandlers = { eventHandlers = {
...eventHandlers, ...eventHandlers,
...newEventHandlers ...newEventHandlers,
} };
} }
/** INTERNAL LIB function used to set the bot ID once the READY event is sent by Discord. */ /** INTERNAL LIB function used to set the bot ID once the READY event is sent by Discord. */