From 6ece2dc1067c18a78395b7584692aa484700af3d Mon Sep 17 00:00:00 2001 From: TriForMine Date: Mon, 18 Oct 2021 19:04:01 +0000 Subject: [PATCH] change: prettier code --- src/bot.ts | 2 +- .../integrations/delete_integration.ts | 8 ++++-- src/helpers/invites/create_invite.ts | 25 +++++++++++-------- src/helpers/invites/delete_invite.ts | 10 +++++--- src/helpers/invites/get_channel_invites.ts | 10 +++++--- src/helpers/invites/get_invite.ts | 16 +++++++----- src/helpers/invites/get_invites.ts | 9 ++++--- src/helpers/misc/edit_bot_profile.ts | 6 ++--- src/helpers/misc/edit_bot_status.ts | 4 +-- src/helpers/misc/get_gateway_bot.ts | 10 +++++--- src/helpers/misc/get_user.ts | 10 +++++--- src/helpers/oauth/get_application.ts | 8 ++++-- src/helpers/voice/connect_to_voice_channel.ts | 2 +- 13 files changed, 78 insertions(+), 42 deletions(-) diff --git a/src/bot.ts b/src/bot.ts index d24a6ebd4..39f7a29bb 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -12,7 +12,7 @@ import { highestRole, higherRolePosition, requireBotChannelPermissions, - requireBotGuildPermissions + requireBotGuildPermissions, } from "./util/permissions.ts"; import { getGatewayBot } from "./helpers/misc/get_gateway_bot.ts"; import { diff --git a/src/helpers/integrations/delete_integration.ts b/src/helpers/integrations/delete_integration.ts index 68893fd1c..75c00cc1a 100644 --- a/src/helpers/integrations/delete_integration.ts +++ b/src/helpers/integrations/delete_integration.ts @@ -1,8 +1,12 @@ -import {Bot} from "../../bot.ts"; +import { Bot } from "../../bot.ts"; /** Delete the attached integration object for the guild with this id. Requires MANAGE_GUILD permission. */ export async function deleteIntegration(bot: Bot, guildId: bigint, id: bigint) { await bot.utils.requireBotGuildPermissions(bot, guildId, ["MANAGE_GUILD"]); - return await bot.rest.runMethod(bot.rest,"delete", bot.constants.endpoints.GUILD_INTEGRATION(guildId, id)); + return await bot.rest.runMethod( + bot.rest, + "delete", + bot.constants.endpoints.GUILD_INTEGRATION(guildId, id) + ); } diff --git a/src/helpers/invites/create_invite.ts b/src/helpers/invites/create_invite.ts index fe3189b71..a18b66f45 100644 --- a/src/helpers/invites/create_invite.ts +++ b/src/helpers/invites/create_invite.ts @@ -2,7 +2,7 @@ import type { CreateChannelInvite } from "../../types/invites/create_channel_inv import type { InviteMetadata } from "../../types/invites/invite_metadata.ts"; import { Errors } from "../../types/discordeno/errors.ts"; import { Bot } from "../../bot.ts"; -import {SnakeCasedPropertiesDeep} from "../../types/util.ts"; +import { SnakeCasedPropertiesDeep } from "../../types/util.ts"; /** Creates a new invite for this channel. Requires CREATE_INSTANT_INVITE */ export async function createInvite(bot: Bot, channelId: bigint, options: CreateChannelInvite = {}) { @@ -15,13 +15,18 @@ export async function createInvite(bot: Bot, channelId: bigint, options: CreateC throw new Error(Errors.INVITE_MAX_USES_INVALID); } - return await bot.rest.runMethod>(bot.rest,"post", bot.constants.endpoints.CHANNEL_INVITES(channelId), { - max_age: options.maxAge, - max_uses: options.maxUses, - temporary: options.temporary, - unique: options.unique, - target_type: options.targetType, - target_user_id: options.targetUserId, - target_application_id: options.targetUserId, - }); + return await bot.rest.runMethod>( + bot.rest, + "post", + bot.constants.endpoints.CHANNEL_INVITES(channelId), + { + max_age: options.maxAge, + max_uses: options.maxUses, + temporary: options.temporary, + unique: options.unique, + target_type: options.targetType, + target_user_id: options.targetUserId, + target_application_id: options.targetUserId, + } + ); } diff --git a/src/helpers/invites/delete_invite.ts b/src/helpers/invites/delete_invite.ts index aecd9f62a..ced9fd715 100644 --- a/src/helpers/invites/delete_invite.ts +++ b/src/helpers/invites/delete_invite.ts @@ -1,6 +1,6 @@ import type { InviteMetadata } from "../../types/invites/invite_metadata.ts"; -import {Bot} from "../../bot.ts"; -import {SnakeCasedPropertiesDeep} from "../../types/util.ts"; +import { Bot } from "../../bot.ts"; +import { SnakeCasedPropertiesDeep } from "../../types/util.ts"; /** Deletes an invite for the given code. Requires `MANAGE_CHANNELS` or `MANAGE_GUILD` permission */ export async function deleteInvite(bot: Bot, channelId: bigint, inviteCode: string) { @@ -13,5 +13,9 @@ export async function deleteInvite(bot: Bot, channelId: bigint, inviteCode: stri } } - return await bot.rest.runMethod>(bot.rest,"delete", bot.constants.endpoints.INVITE(inviteCode)); + return await bot.rest.runMethod>( + bot.rest, + "delete", + bot.constants.endpoints.INVITE(inviteCode) + ); } diff --git a/src/helpers/invites/get_channel_invites.ts b/src/helpers/invites/get_channel_invites.ts index 8fdfadf0d..b889f78fb 100644 --- a/src/helpers/invites/get_channel_invites.ts +++ b/src/helpers/invites/get_channel_invites.ts @@ -1,13 +1,17 @@ import type { InviteMetadata } from "../../types/invites/invite_metadata.ts"; import { Collection } from "../../util/collection.ts"; -import {Bot} from "../../bot.ts"; -import {SnakeCasedPropertiesDeep} from "../../types/util.ts"; +import { Bot } from "../../bot.ts"; +import { SnakeCasedPropertiesDeep } from "../../types/util.ts"; /** Gets the invites for this channel. Requires MANAGE_CHANNEL */ export async function getChannelInvites(bot: Bot, channelId: bigint) { await bot.utils.requireBotChannelPermissions(channelId, ["MANAGE_CHANNELS"]); - const result = await bot.rest.runMethod[]>(bot.rest,"get", bot.constants.endpoints.CHANNEL_INVITES(channelId)); + const result = await bot.rest.runMethod[]>( + bot.rest, + "get", + bot.constants.endpoints.CHANNEL_INVITES(channelId) + ); return new Collection(result.map((invite) => [invite.code, invite])); } diff --git a/src/helpers/invites/get_invite.ts b/src/helpers/invites/get_invite.ts index 0a26a311e..51037c241 100644 --- a/src/helpers/invites/get_invite.ts +++ b/src/helpers/invites/get_invite.ts @@ -1,12 +1,16 @@ import { GetInvite } from "../../types/invites/get_invite.ts"; import type { InviteMetadata } from "../../types/invites/invite_metadata.ts"; -import {SnakeCasedPropertiesDeep} from "../../types/util.ts"; -import {Bot} from "../../bot.ts"; +import { SnakeCasedPropertiesDeep } from "../../types/util.ts"; +import { Bot } from "../../bot.ts"; /** Returns an invite for the given code or throws an error if the invite doesn't exists. */ export async function getInvite(bot: Bot, inviteCode: string, options?: GetInvite) { - return await bot.rest.runMethod>("get", bot.constants.endpoints.INVITE(inviteCode), { - with_counts: options.withCounts, - with_expiration: options.withExpiration, - }); + return await bot.rest.runMethod>( + "get", + bot.constants.endpoints.INVITE(inviteCode), + { + with_counts: options.withCounts, + with_expiration: options.withExpiration, + } + ); } diff --git a/src/helpers/invites/get_invites.ts b/src/helpers/invites/get_invites.ts index 43e5c6ae4..5a8e88760 100644 --- a/src/helpers/invites/get_invites.ts +++ b/src/helpers/invites/get_invites.ts @@ -1,13 +1,16 @@ import type { InviteMetadata } from "../../types/invites/invite_metadata.ts"; import { Collection } from "../../util/collection.ts"; -import {SnakeCasedPropertiesDeep} from "../../types/util.ts"; -import {Bot} from "../../bot.ts"; +import { SnakeCasedPropertiesDeep } from "../../types/util.ts"; +import { Bot } from "../../bot.ts"; /** Get all the invites for this guild. Requires MANAGE_GUILD permission */ export async function getInvites(bot: Bot, guildId: bigint) { await bot.utils.requireBotGuildPermissions(guildId, ["MANAGE_GUILD"]); - const result = await bot.rest.runMethod[]>("get", bot.constants.endpoints.GUILD_INVITES(guildId)); + const result = await bot.rest.runMethod[]>( + "get", + bot.constants.endpoints.GUILD_INVITES(guildId) + ); return new Collection(result.map((invite) => [invite.code, invite])); } diff --git a/src/helpers/misc/edit_bot_profile.ts b/src/helpers/misc/edit_bot_profile.ts index 769e8dc90..66dac6510 100644 --- a/src/helpers/misc/edit_bot_profile.ts +++ b/src/helpers/misc/edit_bot_profile.ts @@ -1,7 +1,7 @@ import { Errors } from "../../types/discordeno/errors.ts"; import type { User } from "../../types/users/user.ts"; -import {Bot} from "../../bot.ts"; -import {SnakeCasedPropertiesDeep} from "../../types/util.ts"; +import { Bot } from "../../bot.ts"; +import { SnakeCasedPropertiesDeep } from "../../types/util.ts"; /** Modifies the bot's username or avatar. * NOTE: username: if changed may cause the bot's discriminator to be randomized. @@ -27,7 +27,7 @@ export async function editBotProfile(bot: Bot, options: { username?: string; bot const avatar = options?.botAvatarURL ? await bot.utils.urlToBase64(options?.botAvatarURL) : options?.botAvatarURL; - return await bot.rest.runMethod>(bot,"patch", bot.constants.endpoints.USER_BOT, { + return await bot.rest.runMethod>(bot, "patch", bot.constants.endpoints.USER_BOT, { username: options.username?.trim(), avatar, }); diff --git a/src/helpers/misc/edit_bot_status.ts b/src/helpers/misc/edit_bot_status.ts index aadbeab10..7bba6658c 100644 --- a/src/helpers/misc/edit_bot_status.ts +++ b/src/helpers/misc/edit_bot_status.ts @@ -1,4 +1,4 @@ -import {Bot} from "../../bot.ts"; +import { Bot } from "../../bot.ts"; import { DiscordGatewayOpcodes } from "../../types/codes/gateway_opcodes.ts"; import type { StatusUpdate } from "../../types/gateway/status_update.ts"; @@ -12,7 +12,7 @@ export function editBotStatus(bot: Bot, data: Omit>(bot.rest,"get", bot.constants.endpoints.GATEWAY_BOT); + return await bot.rest.runMethod>( + bot.rest, + "get", + bot.constants.endpoints.GATEWAY_BOT + ); } diff --git a/src/helpers/misc/get_user.ts b/src/helpers/misc/get_user.ts index 5a96dfc7d..eb3de22f7 100644 --- a/src/helpers/misc/get_user.ts +++ b/src/helpers/misc/get_user.ts @@ -1,8 +1,12 @@ import type { User } from "../../types/users/user.ts"; -import {Bot} from "../../bot.ts"; -import {SnakeCasedPropertiesDeep} from "../../types/util.ts"; +import { Bot } from "../../bot.ts"; +import { SnakeCasedPropertiesDeep } from "../../types/util.ts"; /** This function will return the raw user payload in the rare cases you need to fetch a user directly from the API. */ export async function getUser(bot: Bot, userId: bigint) { - return await bot.rest.runMethod>(bot.rest,"get", bot.constants.endpoints.USER(userId)); + return await bot.rest.runMethod>( + bot.rest, + "get", + bot.constants.endpoints.USER(userId) + ); } diff --git a/src/helpers/oauth/get_application.ts b/src/helpers/oauth/get_application.ts index 4262eba04..38e48af6b 100644 --- a/src/helpers/oauth/get_application.ts +++ b/src/helpers/oauth/get_application.ts @@ -1,8 +1,12 @@ import { Application } from "../../types/applications/application.ts"; import { Bot } from "../../bot.ts"; -import {SnakeCasedPropertiesDeep} from "../../types/util.ts"; +import { SnakeCasedPropertiesDeep } from "../../types/util.ts"; /** Get the applications info */ export async function getApplicationInfo(bot: Bot) { - return await bot.rest.runMethod>>(bot.rest,"get", bot.constants.endpoints.OAUTH2_APPLICATION); + return await bot.rest.runMethod>>( + bot.rest, + "get", + bot.constants.endpoints.OAUTH2_APPLICATION + ); } diff --git a/src/helpers/voice/connect_to_voice_channel.ts b/src/helpers/voice/connect_to_voice_channel.ts index 510d45be9..5d986ed94 100644 --- a/src/helpers/voice/connect_to_voice_channel.ts +++ b/src/helpers/voice/connect_to_voice_channel.ts @@ -1,6 +1,6 @@ import type { UpdateVoiceState } from "../../types/voice/update_voice_state.ts"; import type { AtLeastOne } from "../../types/util.ts"; -import {Bot} from "../../bot.ts"; +import { Bot } from "../../bot.ts"; /** Connect or join a voice channel inside a guild. By default, the "selfDeaf" option is true. Requires `CONNECT` and `VIEW_CHANNEL` permissions. */ export async function connectToVoiceChannel(