This commit is contained in:
Skillz4Killz
2021-04-13 17:59:19 +00:00
committed by GitHub
parent c2f2afb211
commit 9446960bb0
8 changed files with 18 additions and 18 deletions
+2 -2
View File
@@ -11,12 +11,12 @@ export async function getChannelWebhooks(channelId: string) {
const result = (await rest.runMethod( const result = (await rest.runMethod(
"get", "get",
endpoints.CHANNEL_WEBHOOKS(channelId) endpoints.CHANNEL_WEBHOOKS(channelId),
)) as DiscordWebhook[]; )) as DiscordWebhook[];
return new Collection( return new Collection(
result result
.map((webhook) => snakeKeysToCamelCase<Webhook>(webhook)) .map((webhook) => snakeKeysToCamelCase<Webhook>(webhook))
.map((webhook) => [webhook.id, webhook]) .map((webhook) => [webhook.id, webhook]),
); );
} }
+5 -5
View File
@@ -12,7 +12,7 @@ import { endpoints } from "../../util/constants.ts";
export async function getChannels(guildId: string, addToCache = true) { export async function getChannels(guildId: string, addToCache = true) {
const result = (await rest.runMethod( const result = (await rest.runMethod(
"get", "get",
endpoints.GUILD_CHANNELS(guildId) endpoints.GUILD_CHANNELS(guildId),
)) as DiscordChannel[]; )) as DiscordChannel[];
return new Collection( return new Collection(
@@ -21,19 +21,19 @@ export async function getChannels(guildId: string, addToCache = true) {
result.map(async (res) => { result.map(async (res) => {
const discordenoChannel = await structures.createDiscordenoChannel( const discordenoChannel = await structures.createDiscordenoChannel(
res, res,
guildId guildId,
); );
if (addToCache) { if (addToCache) {
await cacheHandlers.set( await cacheHandlers.set(
"channels", "channels",
discordenoChannel.id, discordenoChannel.id,
discordenoChannel discordenoChannel,
); );
} }
return discordenoChannel; return discordenoChannel;
}) }),
) )
).map((c) => [c.id, c]) ).map((c) => [c.id, c]),
); );
} }
+1 -1
View File
@@ -30,5 +30,5 @@ export async function getEmojis(guildId: string, addToCache = true) {
cacheHandlers.set("guilds", guildId, guild); cacheHandlers.set("guilds", guildId, guild);
} }
return new Collection(result.map(e => [e.id!, e])); return new Collection(result.map((e) => [e.id!, e]));
} }
+2 -2
View File
@@ -11,12 +11,12 @@ export async function getChannelInvites(channelId: string) {
const result = (await rest.runMethod( const result = (await rest.runMethod(
"get", "get",
endpoints.CHANNEL_INVITES(channelId) endpoints.CHANNEL_INVITES(channelId),
)) as DiscordInvite[]; )) as DiscordInvite[];
return new Collection( return new Collection(
result result
.map((invite) => snakeKeysToCamelCase<Invite>(invite)) .map((invite) => snakeKeysToCamelCase<Invite>(invite))
.map((invite) => [invite.code, invite]) .map((invite) => [invite.code, invite]),
); );
} }
+2 -2
View File
@@ -11,12 +11,12 @@ export async function getInvites(guildId: string) {
const result = (await rest.runMethod( const result = (await rest.runMethod(
"get", "get",
endpoints.GUILD_INVITES(guildId) endpoints.GUILD_INVITES(guildId),
)) as DiscordInvite[]; )) as DiscordInvite[];
return new Collection( return new Collection(
result result
.map((invite) => snakeKeysToCamelCase<Invite>(invite)) .map((invite) => snakeKeysToCamelCase<Invite>(invite))
.map((invite) => [invite.code, invite]) .map((invite) => [invite.code, invite]),
); );
} }
+2 -2
View File
@@ -14,12 +14,12 @@ export async function getRoles(guildId: string) {
const result = (await rest.runMethod( const result = (await rest.runMethod(
"get", "get",
endpoints.GUILD_ROLES(guildId) endpoints.GUILD_ROLES(guildId),
)) as DiscordRole[]; )) as DiscordRole[];
return new Collection( return new Collection(
result result
.map((role) => snakeKeysToCamelCase<Role>(role)) .map((role) => snakeKeysToCamelCase<Role>(role))
.map((role) => [role.id, role]) .map((role) => [role.id, role]),
); );
} }
+2 -2
View File
@@ -14,13 +14,13 @@ export async function getGuildTemplates(guildId: string) {
const templates = (await rest.runMethod( const templates = (await rest.runMethod(
"get", "get",
endpoints.GUILD_TEMPLATES(guildId) endpoints.GUILD_TEMPLATES(guildId),
)) as DiscordTemplate[]; )) as DiscordTemplate[];
return new Collection( return new Collection(
templates.map((template) => [ templates.map((template) => [
template.code, template.code,
structures.createTemplateStruct(template), structures.createTemplateStruct(template),
]) ]),
); );
} }
+2 -2
View File
@@ -11,12 +11,12 @@ export async function getWebhooks(guildId: string) {
const result = (await rest.runMethod( const result = (await rest.runMethod(
"get", "get",
endpoints.GUILD_WEBHOOKS(guildId) endpoints.GUILD_WEBHOOKS(guildId),
)) as DiscordWebhook[]; )) as DiscordWebhook[];
return new Collection( return new Collection(
result result
.map((webhook) => snakeKeysToCamelCase<Webhook>(webhook)) .map((webhook) => snakeKeysToCamelCase<Webhook>(webhook))
.map((webhook) => [webhook.id, webhook]) .map((webhook) => [webhook.id, webhook]),
); );
} }