From 6a1e0594dc55e35c0846370ff6bc7a8bd55947de Mon Sep 17 00:00:00 2001 From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> Date: Mon, 8 Mar 2021 18:40:37 +0100 Subject: rename req.userid -> req.user_id --- src/util/Constants.ts | 29 +++++++++-------------------- src/util/Member.ts | 2 +- src/util/instanceOf.ts | 2 +- 3 files changed, 11 insertions(+), 22 deletions(-) (limited to 'src/util') diff --git a/src/util/Constants.ts b/src/util/Constants.ts index 1b0e8dbf..f3a8dd67 100644 --- a/src/util/Constants.ts +++ b/src/util/Constants.ts @@ -32,9 +32,9 @@ export const Endpoints = { Emoji: (emojiID: string, format = "png") => `${root}/emojis/${emojiID}.${format}`, Asset: (name: string) => `${root}/assets/${name}`, DefaultAvatar: (discriminator: string) => `${root}/embed/avatars/${discriminator}.png`, - Avatar: (userID: string, hash: string, format = "webp", size: number, dynamic = false) => { + Avatar: (user_id: string, hash: string, format = "webp", size: number, dynamic = false) => { if (dynamic) format = hash.startsWith("a_") ? "gif" : format; - return makeImageUrl(`${root}/avatars/${userID}/${hash}`, { format, size }); + return makeImageUrl(`${root}/avatars/${user_id}/${hash}`, { format, size }); }, Banner: (guildID: string, hash: string, format = "webp", size: number) => makeImageUrl(`${root}/banners/${guildID}/${hash}`, { format, size }), @@ -42,27 +42,18 @@ export const Endpoints = { if (dynamic) format = hash.startsWith("a_") ? "gif" : format; return makeImageUrl(`${root}/icons/${guildID}/${hash}`, { format, size }); }, - AppIcon: ( - clientID: string, - hash: string, - { format = "webp", size }: { format?: string; size?: number } = {} - ) => makeImageUrl(`${root}/app-icons/${clientID}/${hash}`, { size, format }), - AppAsset: ( - clientID: string, - hash: string, - { format = "webp", size }: { format?: string; size?: number } = {} - ) => makeImageUrl(`${root}/app-assets/${clientID}/${hash}`, { size, format }), + AppIcon: (clientID: string, hash: string, { format = "webp", size }: { format?: string; size?: number } = {}) => + makeImageUrl(`${root}/app-icons/${clientID}/${hash}`, { size, format }), + AppAsset: (clientID: string, hash: string, { format = "webp", size }: { format?: string; size?: number } = {}) => + makeImageUrl(`${root}/app-assets/${clientID}/${hash}`, { size, format }), GDMIcon: (channelID: string, hash: string, format = "webp", size: number) => makeImageUrl(`${root}/channel-icons/${channelID}/${hash}`, { size, format }), Splash: (guildID: string, hash: string, format = "webp", size: number) => makeImageUrl(`${root}/splashes/${guildID}/${hash}`, { size, format }), DiscoverySplash: (guildID: string, hash: string, format = "webp", size: number) => makeImageUrl(`${root}/discovery-splashes/${guildID}/${hash}`, { size, format }), - TeamIcon: ( - teamID: string, - hash: string, - { format = "webp", size }: { format?: string; size?: number } = {} - ) => makeImageUrl(`${root}/team-icons/${teamID}/${hash}`, { size, format }), + TeamIcon: (teamID: string, hash: string, { format = "webp", size }: { format?: string; size?: number } = {}) => + makeImageUrl(`${root}/team-icons/${teamID}/${hash}`, { size, format }), }; }, invite: (root: string, code: string) => `${root}/${code}`, @@ -346,9 +337,7 @@ export const MessageTypes = [ * * REPLY * @typedef {string} SystemMessageType */ -export const SystemMessageTypes = MessageTypes.filter( - (type: string | null) => type && type !== "DEFAULT" && type !== "REPLY" -); +export const SystemMessageTypes = MessageTypes.filter((type: string | null) => type && type !== "DEFAULT" && type !== "REPLY"); /** * Bots cannot set a `CUSTOM_STATUS`, it is only for custom statuses received from users diff --git a/src/util/Member.ts b/src/util/Member.ts index 2df34073..319eab60 100644 --- a/src/util/Member.ts +++ b/src/util/Member.ts @@ -43,7 +43,7 @@ export async function addMember(user_id: bigint, guild_id: bigint, cache?: { gui guild_id: guild_id, nick: undefined, roles: [guild_id], // @everyone role - joined_at: Date.now(), + joined_at: new Date(), premium_since: undefined, deaf: false, mute: false, diff --git a/src/util/instanceOf.ts b/src/util/instanceOf.ts index bbb30c12..4f30bd46 100644 --- a/src/util/instanceOf.ts +++ b/src/util/instanceOf.ts @@ -51,7 +51,7 @@ export class Length { constructor(public type: any, public min: number, public max: number) {} check(value: string) { - if (typeof value === "string") return value.length >= this.min && value.length <= this.max; + if (typeof value === "string" || Array.isArray(value)) return value.length >= this.min && value.length <= this.max; if (typeof value === "number" || typeof value === "bigint") return value >= this.min && value <= this.max; return false; } -- cgit 1.5.1