From 3a08aa15f4b8629134c80994149575926dc2dadb Mon Sep 17 00:00:00 2001 From: TriForMine Date: Thu, 21 Oct 2021 17:38:57 +0000 Subject: [PATCH] change: prettier code --- src/helpers/guilds/create_guild.ts | 6 ++--- src/helpers/guilds/delete_guild.ts | 2 +- src/helpers/guilds/edit_guild.ts | 16 +++++------- src/helpers/guilds/edit_welcome_screen.ts | 6 ++--- src/helpers/guilds/edit_widget.ts | 2 +- src/helpers/guilds/get_audit_logs.ts | 17 +++++-------- .../guilds/get_available_voice_regions.ts | 2 +- src/helpers/guilds/get_ban.ts | 2 +- src/helpers/guilds/get_bans.ts | 2 +- src/helpers/guilds/get_guild.ts | 25 ++++++++----------- src/helpers/guilds/get_guild_preview.ts | 2 +- src/helpers/guilds/get_prune_count.ts | 15 ++++++++--- src/helpers/guilds/get_vanity_url.ts | 2 +- src/helpers/guilds/get_voice_regions.ts | 6 ++++- src/helpers/guilds/get_welcome_screen.ts | 6 ++++- src/helpers/guilds/get_widget.ts | 6 ++++- src/helpers/guilds/get_widget_image_url.ts | 6 ++++- src/helpers/guilds/get_widget_settings.ts | 2 +- src/helpers/guilds/guild_banner_url.ts | 2 +- src/helpers/guilds/guild_icon_url.ts | 6 +++-- src/helpers/guilds/guild_splash_url.ts | 2 +- src/helpers/guilds/leave_guild.ts | 2 +- src/helpers/members/send_direct_message.ts | 2 +- 23 files changed, 76 insertions(+), 63 deletions(-) diff --git a/src/helpers/guilds/create_guild.ts b/src/helpers/guilds/create_guild.ts index 819bbc355..cf651652d 100644 --- a/src/helpers/guilds/create_guild.ts +++ b/src/helpers/guilds/create_guild.ts @@ -4,7 +4,7 @@ import type { Bot } from "../../bot.ts"; /** Create a new guild. Returns a guild object on success. Fires a Guild Create Gateway event. This endpoint can be used only by bots in less than 10 guilds. */ export async function createGuild(bot: Bot, options: CreateGuild) { - const result = await bot.rest.runMethod(bot.rest,"post", bot.constants.endpoints.GUILDS, { + const result = await bot.rest.runMethod(bot.rest, "post", bot.constants.endpoints.GUILDS, { name: options.name, afk_channel_id: options.afkChannelId, afk_timeout: options.afkTimeout, @@ -15,10 +15,10 @@ export async function createGuild(bot: Bot, options: CreateGuild) { roles: options.roles, system_channel_flags: options.systemChannelFlags, system_channel_id: options.systemChannelId, - verification_level: options.verificationLevel + verification_level: options.verificationLevel, }); - const guild = bot.transformers.guild(bot, {guild: result, shardId: 0}); + const guild = bot.transformers.guild(bot, { guild: result, shardId: 0 }); // MANUALLY CACHE THE GUILD await bot.cache.guilds.set(guild.id, guild); // MANUALLY CACHE THE BOT diff --git a/src/helpers/guilds/delete_guild.ts b/src/helpers/guilds/delete_guild.ts index 3962364f0..c1c4d359b 100644 --- a/src/helpers/guilds/delete_guild.ts +++ b/src/helpers/guilds/delete_guild.ts @@ -2,5 +2,5 @@ import type { Bot } from "../../bot.ts"; /** Delete a guild permanently. User must be owner. Returns 204 No Content on success. Fires a Guild Delete Gateway event. */ export async function deleteGuild(bot: Bot, guildId: bigint) { - return await bot.rest.runMethod(bot.rest,"delete", bot.constants.endpoints.GUILDS_BASE(guildId)); + return await bot.rest.runMethod(bot.rest, "delete", bot.constants.endpoints.GUILDS_BASE(guildId)); } diff --git a/src/helpers/guilds/edit_guild.ts b/src/helpers/guilds/edit_guild.ts index e5421d38a..e40e78cec 100644 --- a/src/helpers/guilds/edit_guild.ts +++ b/src/helpers/guilds/edit_guild.ts @@ -18,16 +18,12 @@ export async function editGuild(bot: Bot, guildId: bigint, options: ModifyGuild) options.splash = await bot.utils.urlToBase64(options.splash); } - const result = await bot.rest.runMethod(bot.rest,"patch", bot.constants.endpoints.GUILDS_BASE(guildId), { - - }); + const result = await bot.rest.runMethod(bot.rest, "patch", bot.constants.endpoints.GUILDS_BASE(guildId), {}); const cached = await bot.cache.guilds.get(guildId); - return bot.transformers.guild( - bot, - { - guild: result, - shardId: cached?.shardId || Number((BigInt(result.id) >> 22n % BigInt(bot.gateway.botGatewayData.shards)).toString()) - } - ); + return bot.transformers.guild(bot, { + guild: result, + shardId: + cached?.shardId || Number((BigInt(result.id) >> 22n % BigInt(bot.gateway.botGatewayData.shards)).toString()), + }); } diff --git a/src/helpers/guilds/edit_welcome_screen.ts b/src/helpers/guilds/edit_welcome_screen.ts index 6e4a11647..7a4d517e0 100644 --- a/src/helpers/guilds/edit_welcome_screen.ts +++ b/src/helpers/guilds/edit_welcome_screen.ts @@ -10,9 +10,9 @@ export async function editWelcomeScreen(bot: Bot, guildId: bigint, options: Modi channel_id: welcomeScreen.channelId, description: welcomeScreen.description, emoji_id: welcomeScreen.emojiId, - emoji_name: welcomeScreen.emojiName - } + emoji_name: welcomeScreen.emojiName, + }; }), - description: options.description + description: options.description, }); } diff --git a/src/helpers/guilds/edit_widget.ts b/src/helpers/guilds/edit_widget.ts index 410b89331..2b17cf91e 100644 --- a/src/helpers/guilds/edit_widget.ts +++ b/src/helpers/guilds/edit_widget.ts @@ -5,7 +5,7 @@ import type { Bot } from "../../bot.ts"; export async function editWidget(bot: Bot, guildId: bigint, enabled: boolean, channelId?: string | null) { await bot.utils.requireBotGuildPermissions(bot, guildId, ["MANAGE_GUILD"]); - return await bot.rest.runMethod(bot.rest,"patch", bot.constants.endpoints.GUILD_WIDGET(guildId), { + return await bot.rest.runMethod(bot.rest, "patch", bot.constants.endpoints.GUILD_WIDGET(guildId), { enabled, channel_id: channelId, }); diff --git a/src/helpers/guilds/get_audit_logs.ts b/src/helpers/guilds/get_audit_logs.ts index 471e28f3e..e83d84c57 100644 --- a/src/helpers/guilds/get_audit_logs.ts +++ b/src/helpers/guilds/get_audit_logs.ts @@ -6,15 +6,10 @@ import type { Bot } from "../../bot.ts"; export async function getAuditLogs(bot: Bot, guildId: bigint, options?: GetGuildAuditLog) { await bot.utils.requireBotGuildPermissions(bot, guildId, ["VIEW_AUDIT_LOG"]); - return await bot.rest.runMethod( - bot.rest, - "get", - bot.constants.endpoints.GUILD_AUDIT_LOGS(guildId), - { - user_id: options.userId, - action_type: options.actionType, - before: options.before, - limit: options?.limit && options.limit >= 1 && options.limit <= 100 ? options.limit : 50, - } - ); + return await bot.rest.runMethod(bot.rest, "get", bot.constants.endpoints.GUILD_AUDIT_LOGS(guildId), { + user_id: options.userId, + action_type: options.actionType, + before: options.before, + limit: options?.limit && options.limit >= 1 && options.limit <= 100 ? options.limit : 50, + }); } diff --git a/src/helpers/guilds/get_available_voice_regions.ts b/src/helpers/guilds/get_available_voice_regions.ts index 81d0e732e..9cebbd367 100644 --- a/src/helpers/guilds/get_available_voice_regions.ts +++ b/src/helpers/guilds/get_available_voice_regions.ts @@ -3,5 +3,5 @@ import type { Bot } from "../../bot.ts"; /** Returns an array of voice regions that can be used when creating servers. */ export async function getAvailableVoiceRegions(bot: Bot) { - return await bot.rest.runMethod(bot.rest,"get", bot.constants.endpoints.VOICE_REGIONS); + return await bot.rest.runMethod(bot.rest, "get", bot.constants.endpoints.VOICE_REGIONS); } diff --git a/src/helpers/guilds/get_ban.ts b/src/helpers/guilds/get_ban.ts index 4633105c3..cfbbfa88c 100644 --- a/src/helpers/guilds/get_ban.ts +++ b/src/helpers/guilds/get_ban.ts @@ -5,5 +5,5 @@ import type { Bot } from "../../bot.ts"; export async function getBan(bot: Bot, guildId: bigint, memberId: bigint) { await bot.utils.requireBotGuildPermissions(bot, guildId, ["BAN_MEMBERS"]); - return await bot.rest.runMethod(bot.rest,"get", bot.constants.endpoints.GUILD_BAN(guildId, memberId)); + return await bot.rest.runMethod(bot.rest, "get", bot.constants.endpoints.GUILD_BAN(guildId, memberId)); } diff --git a/src/helpers/guilds/get_bans.ts b/src/helpers/guilds/get_bans.ts index 16f6fed39..95eb3882f 100644 --- a/src/helpers/guilds/get_bans.ts +++ b/src/helpers/guilds/get_bans.ts @@ -6,7 +6,7 @@ import { Collection } from "../../util/collection.ts"; export async function getBans(bot: Bot, guildId: bigint) { await bot.utils.requireBotGuildPermissions(bot, guildId, ["BAN_MEMBERS"]); - const results = await bot.rest.runMethod(bot.rest,"get", bot.constants.endpoints.GUILD_BANS(guildId)); + const results = await bot.rest.runMethod(bot.rest, "get", bot.constants.endpoints.GUILD_BANS(guildId)); return new Collection(results.map((res) => [bot.transformers.snowflake(res.user.id), res])); } diff --git a/src/helpers/guilds/get_guild.ts b/src/helpers/guilds/get_guild.ts index 3d815f2da..072567fc0 100644 --- a/src/helpers/guilds/get_guild.ts +++ b/src/helpers/guilds/get_guild.ts @@ -9,24 +9,21 @@ import type { Bot } from "../../bot.ts"; * So it does not cache the guild, you must do it manually. * */ export async function getGuild( - bot: Bot, - guildId: bigint, - options: { counts?: boolean; addToCache?: boolean } = { - counts: true, - addToCache: true, - } + bot: Bot, + guildId: bigint, + options: { counts?: boolean; addToCache?: boolean } = { + counts: true, + addToCache: true, + } ) { - const result = await bot.rest.runMethod(bot.rest,"get", bot.constants.endpoints.GUILDS_BASE(guildId), { + const result = await bot.rest.runMethod(bot.rest, "get", bot.constants.endpoints.GUILDS_BASE(guildId), { with_counts: options.counts, }); - const guild = await bot.transformers.guild( - bot, - { - guild: result, - shardId: Number((BigInt(guildId) >> 22n) % BigInt(ws.botGatewayData.shards)) - } - ); + const guild = await bot.transformers.guild(bot, { + guild: result, + shardId: Number((BigInt(guildId) >> 22n) % BigInt(ws.botGatewayData.shards)), + }); if (options.addToCache) { await bot.cache.guilds.set(guild.id, guild); diff --git a/src/helpers/guilds/get_guild_preview.ts b/src/helpers/guilds/get_guild_preview.ts index 388ee24cc..7ee1d4cfb 100644 --- a/src/helpers/guilds/get_guild_preview.ts +++ b/src/helpers/guilds/get_guild_preview.ts @@ -3,5 +3,5 @@ import type { Bot } from "../../bot.ts"; /** Returns the guild preview object for the given id. If the bot is not in the guild, then the guild must be Discoverable. */ export async function getGuildPreview(bot: Bot, guildId: bigint) { - return await bot.rest.runMethod(bot.rest,"get", bot.constants.endpoints.GUILD_PREVIEW(guildId)); + return await bot.rest.runMethod(bot.rest, "get", bot.constants.endpoints.GUILD_PREVIEW(guildId)); } diff --git a/src/helpers/guilds/get_prune_count.ts b/src/helpers/guilds/get_prune_count.ts index e160df5f3..4a23de19b 100644 --- a/src/helpers/guilds/get_prune_count.ts +++ b/src/helpers/guilds/get_prune_count.ts @@ -10,10 +10,17 @@ export async function getPruneCount(bot: Bot, guildId: bigint, options?: GetGuil await bot.utils.requireBotGuildPermissions(guildId, ["KICK_MEMBERS"]); - const result = await bot.rest.runMethod(bot.rest,"get", bot.constants.endpoints.GUILD_PRUNE(guildId), options ? { - days: options.days, - include_roles: options.includeRoles - } : {}); + const result = await bot.rest.runMethod( + bot.rest, + "get", + bot.constants.endpoints.GUILD_PRUNE(guildId), + options + ? { + days: options.days, + include_roles: options.includeRoles, + } + : {} + ); return result.pruned as number; } diff --git a/src/helpers/guilds/get_vanity_url.ts b/src/helpers/guilds/get_vanity_url.ts index 64675f86e..b1aed91d3 100644 --- a/src/helpers/guilds/get_vanity_url.ts +++ b/src/helpers/guilds/get_vanity_url.ts @@ -8,5 +8,5 @@ export async function getVanityURL(bot: Bot, guildId: bigint) { | { code: null; } - >(bot.rest,"get", bot.constants.endpoints.GUILD_VANITY_URL(guildId)); + >(bot.rest, "get", bot.constants.endpoints.GUILD_VANITY_URL(guildId)); } diff --git a/src/helpers/guilds/get_voice_regions.ts b/src/helpers/guilds/get_voice_regions.ts index b65ef53a0..d978388e9 100644 --- a/src/helpers/guilds/get_voice_regions.ts +++ b/src/helpers/guilds/get_voice_regions.ts @@ -4,7 +4,11 @@ import type { Bot } from "../../bot.ts"; /** Returns a list of voice region objects for the guild. Unlike the similar /voice route, this returns VIP servers when the guild is VIP-enabled. */ export async function getVoiceRegions(boot: Bot, guildId: bigint) { - const result = await bot.rest.runMethod(bot.rest,"get", bot.constants.endpoints.GUILD_REGIONS(guildId)); + const result = await bot.rest.runMethod( + bot.rest, + "get", + bot.constants.endpoints.GUILD_REGIONS(guildId) + ); return new Collection(result.map((region) => [region.id, region])); } diff --git a/src/helpers/guilds/get_welcome_screen.ts b/src/helpers/guilds/get_welcome_screen.ts index c627ddb82..93767c6fd 100644 --- a/src/helpers/guilds/get_welcome_screen.ts +++ b/src/helpers/guilds/get_welcome_screen.ts @@ -2,5 +2,9 @@ import type { WelcomeScreen } from "../../types/guilds/welcome_screen.ts"; import type { Bot } from "../../bot.ts"; export async function getWelcomeScreen(bot: Bot, guildId: bigint) { - return await bot.rest.runMethod(bot.rset,"get", bot.constants.endpoints.GUILD_WELCOME_SCREEN(guildId)); + return await bot.rest.runMethod( + bot.rset, + "get", + bot.constants.endpoints.GUILD_WELCOME_SCREEN(guildId) + ); } diff --git a/src/helpers/guilds/get_widget.ts b/src/helpers/guilds/get_widget.ts index 99b30d7a6..c89aa3cb3 100644 --- a/src/helpers/guilds/get_widget.ts +++ b/src/helpers/guilds/get_widget.ts @@ -9,5 +9,9 @@ export async function getWidget(bot: Bot, guildId: bigint, options?: { force: bo if (!guild?.widgetEnabled) throw new Error(bot.constants.Errors.GUILD_WIDGET_NOT_ENABLED); } - return await bot.rest.runMethod(bot.rest,"get", `${bot.constants.endpoints.GUILD_WIDGET(guildId)}.json`); + return await bot.rest.runMethod( + bot.rest, + "get", + `${bot.constants.endpoints.GUILD_WIDGET(guildId)}.json` + ); } diff --git a/src/helpers/guilds/get_widget_image_url.ts b/src/helpers/guilds/get_widget_image_url.ts index 355035898..454997a4e 100644 --- a/src/helpers/guilds/get_widget_image_url.ts +++ b/src/helpers/guilds/get_widget_image_url.ts @@ -2,7 +2,11 @@ import type { Bot } from "../../bot.ts"; import type { GetGuildWidgetImageQuery } from "../../types/guilds/get_guild_widget_image.ts"; /** Returns the widget image URL for the guild. */ -export async function getWidgetImageURL(bot: Bot, guildId: bigint, options?: GetGuildWidgetImageQuery & { force?: boolean }) { +export async function getWidgetImageURL( + bot: Bot, + guildId: bigint, + options?: GetGuildWidgetImageQuery & { force?: boolean } +) { if (!options?.force) { const guild = await bot.cache.guilds.get(guildId); if (!guild) throw new Error(bot.constants.Errors.GUILD_NOT_FOUND); diff --git a/src/helpers/guilds/get_widget_settings.ts b/src/helpers/guilds/get_widget_settings.ts index e6cb44d33..e03f2e9f4 100644 --- a/src/helpers/guilds/get_widget_settings.ts +++ b/src/helpers/guilds/get_widget_settings.ts @@ -5,5 +5,5 @@ import type { Bot } from "../../bot.ts"; export async function getWidgetSettings(bot: Bot, guildId: bigint) { await bot.utils.requireBotGuildPermissions(guildId, ["MANAGE_GUILD"]); - return await bot.rest.runMethod(bot.rest,"get", bot.constants.endpoints.GUILD_WIDGET(guildId)); + return await bot.rest.runMethod(bot.rest, "get", bot.constants.endpoints.GUILD_WIDGET(guildId)); } diff --git a/src/helpers/guilds/guild_banner_url.ts b/src/helpers/guilds/guild_banner_url.ts index 310a9aa52..a127c5920 100644 --- a/src/helpers/guilds/guild_banner_url.ts +++ b/src/helpers/guilds/guild_banner_url.ts @@ -4,7 +4,7 @@ import type { Bot } from "../../bot.ts"; /** The full URL of the banner from Discords CDN. Undefined if no banner is set. */ export function guildBannerURL( - bot: Bot, + bot: Bot, id: bigint, options: { banner?: string | bigint; diff --git a/src/helpers/guilds/guild_icon_url.ts b/src/helpers/guilds/guild_icon_url.ts index ae399abe0..562454e1f 100644 --- a/src/helpers/guilds/guild_icon_url.ts +++ b/src/helpers/guilds/guild_icon_url.ts @@ -4,7 +4,7 @@ import type { Bot } from "../../bot.ts"; /** The full URL of the icon from Discords CDN. Undefined when no icon is set. */ export function guildIconURL( - bot: Bot, + bot: Bot, id: bigint, options: { icon?: string | bigint; @@ -17,7 +17,9 @@ export function guildIconURL( ? bot.utils.formatImageURL( bot.constants.endpoints.GUILD_ICON( id, - typeof options.icon === "string" ? options.icon : bot.utils.iconBigintToHash(options.icon, options.animated ?? true) + typeof options.icon === "string" + ? options.icon + : bot.utils.iconBigintToHash(options.icon, options.animated ?? true) ), options.size || 128, options.format diff --git a/src/helpers/guilds/guild_splash_url.ts b/src/helpers/guilds/guild_splash_url.ts index aaee1f810..8a0ab20d4 100644 --- a/src/helpers/guilds/guild_splash_url.ts +++ b/src/helpers/guilds/guild_splash_url.ts @@ -4,7 +4,7 @@ import type { Bot } from "../../bot.ts"; /** The full URL of the splash from Discords CDN. Undefined if no splash is set. */ export function guildSplashURL( - bot: Bot, + bot: Bot, id: bigint, options: { splash?: string | bigint; diff --git a/src/helpers/guilds/leave_guild.ts b/src/helpers/guilds/leave_guild.ts index 28b4da5d2..06d6f1756 100644 --- a/src/helpers/guilds/leave_guild.ts +++ b/src/helpers/guilds/leave_guild.ts @@ -2,5 +2,5 @@ import type { Bot } from "../../bot.ts"; /** Leave a guild */ export async function leaveGuild(bot: Bot, guildId: bigint) { - return await bot.rest.runMethod(bot.rest,"delete", bot.constants.endpoints.GUILD_LEAVE(guildId)); + return await bot.rest.runMethod(bot.rest, "delete", bot.constants.endpoints.GUILD_LEAVE(guildId)); } diff --git a/src/helpers/members/send_direct_message.ts b/src/helpers/members/send_direct_message.ts index e1990b950..ff5262b48 100644 --- a/src/helpers/members/send_direct_message.ts +++ b/src/helpers/members/send_direct_message.ts @@ -18,7 +18,7 @@ export async function sendDirectMessage(bot: Bot, memberId: bigint, content: str recipient_id: memberId, } ); - const discordenoChannel = await bot.transformers.channel(bot, {channel: dmChannelData}); + const discordenoChannel = await bot.transformers.channel(bot, { channel: dmChannelData }); // Recreate the channel and add it under the users id await bot.cache.channels.set(memberId, discordenoChannel); dmChannel = discordenoChannel;