formatting

This commit is contained in:
BinotaLIU
2020-05-16 20:35:25 +08:00
parent ded7c3c395
commit 8a8ba17889
6 changed files with 13 additions and 14 deletions

1
mod.ts
View File

@@ -17,7 +17,6 @@ Client({
if (!message.guild_id) return;
const guild = cache.guilds.get(message.guild_id);
if (!guild) return logYellow("no guild");
}
}
},

View File

@@ -60,7 +60,7 @@ export const RequestManager = {
},
};
function createRequestBody (body: any, method?: RequestMethod) {
function createRequestBody(body: any, method?: RequestMethod) {
return {
headers: {
Authorization: authorization,
@@ -72,7 +72,7 @@ function createRequestBody (body: any, method?: RequestMethod) {
body: JSON.stringify(body),
method: method?.toUpperCase(),
};
};
}
async function checkRatelimits(url: string) {
const ratelimited = ratelimitedPaths.get(url);
@@ -109,7 +109,7 @@ async function runMethod(
) {
if (retryCount > 10) throw new Error(Errors.RATE_LIMIT_RETRY_MAXED);
await delay(json.retry_after);
return runMethod(method, url, body, retryCount++)
return runMethod(method, url, body, retryCount++);
}
return resolve(json);
@@ -124,7 +124,7 @@ async function runMethod(
processQueue();
}
});
};
}
function processHeaders(url: string, headers: Headers) {
// If a rate limit response is encountered this will become true and returned
@@ -160,4 +160,4 @@ function processHeaders(url: string, headers: Headers) {
// Returns a boolean to check if we need to request again once the rate limit resets
return ratelimited;
};
}

View File

@@ -252,11 +252,13 @@ export const createGuild = (data: CreateGuildPayload) => {
return RequestManager.post(endpoints.GUILD_PRUNE(data.id), { days });
},
fetchMembers: (options?: FetchMembersOptions) => {
if (!(identifyPayload.intents & Intents.GUILD_MEMBERS)) throw new Error(Errors.MISSING_INTENT_GUILD_MEMBERS)
if (!(identifyPayload.intents & Intents.GUILD_MEMBERS)) {
throw new Error(Errors.MISSING_INTENT_GUILD_MEMBERS);
}
return new Promise((resolve) => {
requestAllMembers(data.id, resolve, guild.memberCount, options)
})
requestAllMembers(data.id, resolve, guild.memberCount, options);
});
},
/** Returns the audit logs for the guild. Requires VIEW AUDIT LOGS permission */
getAuditLogs: (options: GetAuditLogsOptions) => {

View File

@@ -14,7 +14,7 @@ export function createMessage(data: MessageCreateOptions) {
return {
...data,
raw: data,
mentions: data.mentions.map(user => createUser(user)),
mentions: data.mentions.map((user) => createUser(user)),
author: createUser({ ...data.author, avatar: data.author.avatar || "" }),
timestamp: Date.parse(data.timestamp),
editedTimestamp: data.edited_timestamp

View File

@@ -22,5 +22,5 @@ export enum Errors {
NICKNAMES_MAX_LENGTH = "NICKNAMES_MAX_LENGTH",
PRUNE_MIN_DAYS = "PRUNE_MIN_DAYS",
RATE_LIMIT_RETRY_MAXED = "RATE_LIMIT_RETRY_MAXED",
MISSING_INTENT_GUILD_MEMBERS = "MISSING_INTENT_GUILD_MEMBERS"
MISSING_INTENT_GUILD_MEMBERS = "MISSING_INTENT_GUILD_MEMBERS",
}

View File

@@ -5,7 +5,5 @@ export const formatImageURL = (
size: ImageSize = 128,
format?: ImageFormats,
) => {
return `${url}.${
format || url.includes("/a_") ? "gif" : "jpg"
}?size=${size}`;
return `${url}.${format || url.includes("/a_") ? "gif" : "jpg"}?size=${size}`;
};