From 1c1c93ed7fdfab8c797cb7dac7fb9c5297e2be70 Mon Sep 17 00:00:00 2001 From: Skillz4Killz Date: Sat, 23 Oct 2021 15:50:59 +0000 Subject: [PATCH] change: prettier code --- src/bot.ts | 4 +- src/handlers/guilds/GUILD_BAN_ADD.ts | 6 +- src/handlers/guilds/GUILD_DELETE.ts | 3 +- src/handlers/guilds/GUILD_UPDATE.ts | 4 +- src/helpers/channels/category_children.ts | 2 +- src/helpers/channels/create_channel.ts | 62 ++++++++++--------- src/helpers/channels/create_stage_instance.ts | 15 ++--- src/helpers/channels/delete_channel.ts | 4 +- .../channels/delete_channel_overwrite.ts | 8 ++- src/helpers/channels/edit_channel.ts | 10 +-- .../channels/edit_channel_overwrite.ts | 17 +++-- src/helpers/channels/follow_channel.ts | 11 +++- src/helpers/channels/get_channel.ts | 12 ++-- src/helpers/channels/get_channel_webhooks.ts | 6 +- src/helpers/channels/get_channels.ts | 4 +- src/helpers/channels/get_pins.ts | 2 +- src/helpers/channels/get_stage_instance.ts | 2 +- src/helpers/channels/start_typing.ts | 2 +- src/helpers/channels/swap_channels.ts | 21 ++++--- src/helpers/channels/update_stage_instance.ts | 6 +- src/helpers/channels/update_voice_state.ts | 19 +++--- src/helpers/messages/get_reactions.ts | 10 ++- src/helpers/messages/pin_message.ts | 6 +- src/helpers/webhooks/create_webhook.ts | 15 +++-- src/helpers/webhooks/delete_webhook.ts | 4 +- .../webhooks/delete_webhook_message.ts | 8 ++- .../webhooks/delete_webhook_with_token.ts | 8 ++- src/helpers/webhooks/edit_webhook.ts | 17 +++-- .../webhooks/get_webhook_with_token.ts | 4 +- 29 files changed, 174 insertions(+), 118 deletions(-) diff --git a/src/bot.ts b/src/bot.ts index 8a0cae9af..581fce3a1 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -125,11 +125,11 @@ import { handleIntegrationCreate, handleIntegrationUpdate, handleIntegrationDelete, - handleGuildLoaded + handleGuildLoaded, } from "./handlers/mod.ts"; import { DiscordenoInteraction, transformInteraction } from "./transformers/interaction.ts"; import { DiscordenoIntegration, transformIntegration } from "./transformers/integration.ts"; -import {Emoji} from "./types/emojis/emoji.ts"; +import { Emoji } from "./types/emojis/emoji.ts"; import { transformApplication } from "./transformers/application.ts"; import { transformTeam } from "./transformers/team.ts"; import { DiscordenoInvite, transformInvite } from "./transformers/invite.ts"; diff --git a/src/handlers/guilds/GUILD_BAN_ADD.ts b/src/handlers/guilds/GUILD_BAN_ADD.ts index 5e0cda90c..8b1b4ffc4 100644 --- a/src/handlers/guilds/GUILD_BAN_ADD.ts +++ b/src/handlers/guilds/GUILD_BAN_ADD.ts @@ -6,7 +6,11 @@ import { SnakeCasedPropertiesDeep } from "../../types/util.ts"; export async function handleGuildBanAdd(bot: Bot, data: SnakeCasedPropertiesDeep) { const payload = data.d as SnakeCasedPropertiesDeep; // FIRST COMPLETE THE END USERS EVENT - await bot.events.guildBanAdd(bot, bot.transformers.user(bot, payload.user), bot.transformers.snowflake(payload.guild_id)); + await bot.events.guildBanAdd( + bot, + bot.transformers.user(bot, payload.user), + bot.transformers.snowflake(payload.guild_id) + ); // THEN DELETE THE MEMBER await bot.cache.members.delete(bot.transformers.snowflake(payload.user.id)); } diff --git a/src/handlers/guilds/GUILD_DELETE.ts b/src/handlers/guilds/GUILD_DELETE.ts index d7c276360..91f64641f 100644 --- a/src/handlers/guilds/GUILD_DELETE.ts +++ b/src/handlers/guilds/GUILD_DELETE.ts @@ -10,9 +10,8 @@ export async function handleGuildDelete(bot: Bot, data: DiscordGatewayPayload, s const guild = await bot.cache.guilds.get(id); await bot.events.guildDelete(bot, id, guild); if (!guild) return; - - await bot.cache.guilds.delete(id); + await bot.cache.guilds.delete(id); await Promise.all([ bot.cache.forEach("DELETE_MESSAGES_FROM_GUILD", { guildId: guild.id }), diff --git a/src/handlers/guilds/GUILD_UPDATE.ts b/src/handlers/guilds/GUILD_UPDATE.ts index 028867c50..62d2ecfad 100644 --- a/src/handlers/guilds/GUILD_UPDATE.ts +++ b/src/handlers/guilds/GUILD_UPDATE.ts @@ -5,10 +5,10 @@ import { SnakeCasedPropertiesDeep } from "../../types/util.ts"; export async function handleGuildUpdate(bot: Bot, data: DiscordGatewayPayload, shardId: number) { const payload = data.d as SnakeCasedPropertiesDeep; - + const guild = bot.transformers.guild(bot, { guild: payload, shardId }); const cached = await bot.cache.guilds.get(guild.id); await bot.cache.guilds.set(guild.id, guild); - + bot.events.guildUpdate(bot, guild, cached); } diff --git a/src/helpers/channels/category_children.ts b/src/helpers/channels/category_children.ts index 566d0c790..f027d16c8 100644 --- a/src/helpers/channels/category_children.ts +++ b/src/helpers/channels/category_children.ts @@ -1,4 +1,4 @@ -import {Bot} from "../../bot.ts"; +import { Bot } from "../../bot.ts"; /** Gets an array of all the channels ids that are the children of this category. * ⚠️ This does not work for custom cache users! diff --git a/src/helpers/channels/create_channel.ts b/src/helpers/channels/create_channel.ts index 7e8f84b8f..22259e6ba 100644 --- a/src/helpers/channels/create_channel.ts +++ b/src/helpers/channels/create_channel.ts @@ -5,38 +5,40 @@ import type { Bot } from "../../bot.ts"; /** Create a channel in your server. Bot needs MANAGE_CHANNEL permissions in the server. */ export async function createChannel(bot: Bot, guildId: bigint, options?: CreateGuildChannel, reason?: string) { - if (options?.permissionOverwrites) { - await bot.utils.requireOverwritePermissions(bot, guildId, options.permissionOverwrites); - } + if (options?.permissionOverwrites) { + await bot.utils.requireOverwritePermissions(bot, guildId, options.permissionOverwrites); + } - // BITRATES ARE IN THOUSANDS SO IF USER PROVIDES 32 WE CONVERT TO 32000 - if (options?.bitrate && options.bitrate < 1000) options.bitrate *= 1000; + // BITRATES ARE IN THOUSANDS SO IF USER PROVIDES 32 WE CONVERT TO 32000 + if (options?.bitrate && options.bitrate < 1000) options.bitrate *= 1000; - const result = await bot.rest.runMethod( - bot.rest, - "post", - bot.constants.endpoints.GUILD_CHANNELS(guildId), - options ? { - name: options.name, - topic: options.topic, - bitrate: options.bitrate, - userLimit: options.userLimit, - rateLimitPerUser: options.rateLimitPerUser, - position: options.position, - parentId: options.parentId, - nsfw: options.nsfw, - permission_overwrites: options?.permissionOverwrites?.map((perm) => ({ - ...perm, - allow: bot.utils.calculateBits(perm.allow), - deny: bot.utils.calculateBits(perm.deny), - })), - type: options?.type || DiscordChannelTypes.GuildText, - reason, - } : {} - ); + const result = await bot.rest.runMethod( + bot.rest, + "post", + bot.constants.endpoints.GUILD_CHANNELS(guildId), + options + ? { + name: options.name, + topic: options.topic, + bitrate: options.bitrate, + userLimit: options.userLimit, + rateLimitPerUser: options.rateLimitPerUser, + position: options.position, + parentId: options.parentId, + nsfw: options.nsfw, + permission_overwrites: options?.permissionOverwrites?.map((perm) => ({ + ...perm, + allow: bot.utils.calculateBits(perm.allow), + deny: bot.utils.calculateBits(perm.deny), + })), + type: options?.type || DiscordChannelTypes.GuildText, + reason, + } + : {} + ); - const discordenoChannel = bot.transformers.channel(result); - await bot.cache.channels.set(discordenoChannel.id, discordenoChannel); + const discordenoChannel = bot.transformers.channel(result); + await bot.cache.channels.set(discordenoChannel.id, discordenoChannel); - return discordenoChannel; + return discordenoChannel; } diff --git a/src/helpers/channels/create_stage_instance.ts b/src/helpers/channels/create_stage_instance.ts index bf0aaf56e..c1047284f 100644 --- a/src/helpers/channels/create_stage_instance.ts +++ b/src/helpers/channels/create_stage_instance.ts @@ -19,14 +19,9 @@ export async function createStageInstance(bot: Bot, channelId: bigint, topic: st throw new Error(bot.constants.Errors.INVALID_TOPIC_LENGTH); } - return await bot.rest.runMethod( - bot.rest, - "post", - bot.constants.endpoints.STAGE_INSTANCES, - { - channel_id: channelId, - topic, - privacy_level: privacyLevel, - } - ); + return await bot.rest.runMethod(bot.rest, "post", bot.constants.endpoints.STAGE_INSTANCES, { + channel_id: channelId, + topic, + privacy_level: privacyLevel, + }); } diff --git a/src/helpers/channels/delete_channel.ts b/src/helpers/channels/delete_channel.ts index 1a6379303..3eadecac6 100644 --- a/src/helpers/channels/delete_channel.ts +++ b/src/helpers/channels/delete_channel.ts @@ -19,5 +19,7 @@ export async function deleteChannel(bot: Bot, channelId: bigint, reason?: string await bot.utils.requireBotGuildPermissions(bot, guild, ["MANAGE_CHANNELS"]); } - return await bot.rest.runMethod(bot.rest, "delete", bot.constants.endpoints.CHANNEL_BASE(channelId), { reason }); + return await bot.rest.runMethod(bot.rest, "delete", bot.constants.endpoints.CHANNEL_BASE(channelId), { + reason, + }); } diff --git a/src/helpers/channels/delete_channel_overwrite.ts b/src/helpers/channels/delete_channel_overwrite.ts index 0f5d66ec8..064aec2c6 100644 --- a/src/helpers/channels/delete_channel_overwrite.ts +++ b/src/helpers/channels/delete_channel_overwrite.ts @@ -2,12 +2,16 @@ import type { Bot } from "../../bot.ts"; /** Delete the channel permission overwrites for a user or role in this channel. Requires `MANAGE_ROLES` permission. */ export async function deleteChannelOverwrite( - bot: Bot, + bot: Bot, guildId: bigint, channelId: bigint, overwriteId: bigint ): Promise { await bot.utils.requireBotGuildPermissions(bot, guildId, ["MANAGE_ROLES"]); - return await bot.rest.runMethod(bot.rest,"delete", bot.constants.endpoints.CHANNEL_OVERWRITE(channelId, overwriteId)); + return await bot.rest.runMethod( + bot.rest, + "delete", + bot.constants.endpoints.CHANNEL_OVERWRITE(channelId, overwriteId) + ); } diff --git a/src/helpers/channels/edit_channel.ts b/src/helpers/channels/edit_channel.ts index e7e4defe3..b2daa448f 100644 --- a/src/helpers/channels/edit_channel.ts +++ b/src/helpers/channels/edit_channel.ts @@ -2,7 +2,7 @@ import type { DiscordenoChannel } from "../../structures/channel.ts"; import type { Channel } from "../../types/channels/channel.ts"; import type { ModifyChannel } from "../../types/channels/modify_channel.ts"; import type { Bot } from "../../bot.ts"; -import {SnakeCasedPropertiesDeep} from "../../types/util.ts"; +import { SnakeCasedPropertiesDeep } from "../../types/util.ts"; /** Update a channel's settings. Requires the `MANAGE_CHANNELS` permission for the guild. */ export async function editChannel(bot: Bot, channelId: bigint, options: ModifyChannel, reason?: string) { @@ -41,7 +41,7 @@ export async function editChannel(bot: Bot, channelId: bigint, options: ModifyCh } const result = await bot.rest.runMethod>( - bot.rest, + bot.rest, "patch", bot.constants.endpoints.CHANNEL_BASE(channelId), { @@ -103,13 +103,15 @@ function processEditChannelQueue(bot: Bot) { if (!details) return; - await bot.helpers.editChannel(bot, details.channelId, details.options) + await bot.helpers + .editChannel(bot, details.channelId, details.options) .then((result) => details.resolve(result)) .catch(details.reject); const secondDetails = request.items.shift(); if (!secondDetails) return; - await bot.helpers.editChannel(bot, secondDetails.channelId, secondDetails.options) + await bot.helpers + .editChannel(bot, secondDetails.channelId, secondDetails.options) .then((result) => secondDetails.resolve(result)) .catch(secondDetails.reject); return; diff --git a/src/helpers/channels/edit_channel_overwrite.ts b/src/helpers/channels/edit_channel_overwrite.ts index bcfe5cf9d..da1d489b0 100644 --- a/src/helpers/channels/edit_channel_overwrite.ts +++ b/src/helpers/channels/edit_channel_overwrite.ts @@ -3,7 +3,7 @@ import type { Bot } from "../../bot.ts"; /** Edit the channel permission overwrites for a user or role in this channel. Requires `MANAGE_ROLES` permission. */ export async function editChannelOverwrite( - bot: Bot, + bot: Bot, guildId: bigint, channelId: bigint, overwriteId: bigint, @@ -11,9 +11,14 @@ export async function editChannelOverwrite( ): Promise { await bot.utils.requireBotGuildPermissions(bot, guildId, ["MANAGE_ROLES"]); - return await bot.rest.runMethod(bot.rest,"put", bot.constants.endpoints.CHANNEL_OVERWRITE(channelId, overwriteId), { - allow: bot.utils.calculateBits(options.allow), - deny: bot.utils.calculateBits(options.deny), - type: options.type, - }); + return await bot.rest.runMethod( + bot.rest, + "put", + bot.constants.endpoints.CHANNEL_OVERWRITE(channelId, overwriteId), + { + allow: bot.utils.calculateBits(options.allow), + deny: bot.utils.calculateBits(options.deny), + type: options.type, + } + ); } diff --git a/src/helpers/channels/follow_channel.ts b/src/helpers/channels/follow_channel.ts index 9512f4b29..5d8b7725f 100644 --- a/src/helpers/channels/follow_channel.ts +++ b/src/helpers/channels/follow_channel.ts @@ -5,9 +5,14 @@ import type { Bot } from "../../bot.ts"; export async function followChannel(bot: Bot, sourceChannelId: bigint, targetChannelId: bigint) { await bot.utils.requireBotChannelPermissions(bot, targetChannelId, ["MANAGE_WEBHOOKS"]); - const data = await bot.rest.runMethod(bot.rest,"post", bot.constants.endpoints.CHANNEL_FOLLOW(sourceChannelId), { - webhook_channel_id: targetChannelId, - }); + const data = await bot.rest.runMethod( + bot.rest, + "post", + bot.constants.endpoints.CHANNEL_FOLLOW(sourceChannelId), + { + webhook_channel_id: targetChannelId, + } + ); return data.webhookId; } diff --git a/src/helpers/channels/get_channel.ts b/src/helpers/channels/get_channel.ts index 6866a1cf8..613b00b34 100644 --- a/src/helpers/channels/get_channel.ts +++ b/src/helpers/channels/get_channel.ts @@ -6,14 +6,12 @@ import type { Channel } from "../../types/channels/channel.ts"; * ⚠️ **If you need this, you are probably doing something wrong. This is not intended for use. Your channels will be cached in your guild.** */ export async function getChannel(bot: Bot, channelId: bigint, addToCache = true) { - const result = await bot.rest.runMethod(bot.rest,"get", bot.constants.endpoints.CHANNEL_BASE(channelId)); + const result = await bot.rest.runMethod(bot.rest, "get", bot.constants.endpoints.CHANNEL_BASE(channelId)); - const discordenoChannel = bot.transformers.channel( - { - channel: result, - guildId: result.guildId ? bot.transformers.snowflake(result.guildId) : undefined - } - ); + const discordenoChannel = bot.transformers.channel({ + channel: result, + guildId: result.guildId ? bot.transformers.snowflake(result.guildId) : undefined, + }); if (addToCache) { await bot.cache.channels.set(discordenoChannel.id, discordenoChannel); } diff --git a/src/helpers/channels/get_channel_webhooks.ts b/src/helpers/channels/get_channel_webhooks.ts index 99da26ab1..fe6e0cb0f 100644 --- a/src/helpers/channels/get_channel_webhooks.ts +++ b/src/helpers/channels/get_channel_webhooks.ts @@ -6,7 +6,11 @@ import type { Bot } from "../../bot.ts"; export async function getChannelWebhooks(bot: Bot, channelId: bigint) { await bot.utils.requireBotChannelPermissions(bot, channelId, ["MANAGE_WEBHOOKS"]); - const result = await bot.rest.runMethod(bot.rest,"get", bot.constants.endpoints.CHANNEL_WEBHOOKS(channelId)); + const result = await bot.rest.runMethod( + bot.rest, + "get", + bot.constants.endpoints.CHANNEL_WEBHOOKS(channelId) + ); return new Collection(result.map((webhook) => [webhook.id, webhook])); } diff --git a/src/helpers/channels/get_channels.ts b/src/helpers/channels/get_channels.ts index 49e9970d3..94871d521 100644 --- a/src/helpers/channels/get_channels.ts +++ b/src/helpers/channels/get_channels.ts @@ -7,13 +7,13 @@ import type { Bot } from "../../bot.ts"; * ⚠️ **If you need this, you are probably doing something wrong. This is not intended for use. Your channels will be cached in your guild.** */ export async function getChannels(bot: Bot, guildId: bigint, addToCache = true) { - const result = await bot.rest.runMethod(bot.rest,"get", bot.constants.endpoints.GUILD_CHANNELS(guildId)); + const result = await bot.rest.runMethod(bot.rest, "get", bot.constants.endpoints.GUILD_CHANNELS(guildId)); return new Collection( ( await Promise.all( result.map(async (res) => { - const discordenoChannel = await bot.transformers.channel({channel: res, guildId}); + const discordenoChannel = await bot.transformers.channel({ channel: res, guildId }); if (addToCache) { await bot.cache.channels.set(discordenoChannel.id, discordenoChannel); } diff --git a/src/helpers/channels/get_pins.ts b/src/helpers/channels/get_pins.ts index 97c8ef1d5..d6a69574e 100644 --- a/src/helpers/channels/get_pins.ts +++ b/src/helpers/channels/get_pins.ts @@ -3,7 +3,7 @@ import type { Bot } from "../../bot.ts"; /** Get pinned messages in this channel. */ export async function getPins(bot: Bot, channelId: bigint) { - const result = await bot.rest.runMethod(bot.rest,"get", bot.constants.endpoints.CHANNEL_PINS(channelId)); + const result = await bot.rest.runMethod(bot.rest, "get", bot.constants.endpoints.CHANNEL_PINS(channelId)); return result.map(bot.transformers.message); } diff --git a/src/helpers/channels/get_stage_instance.ts b/src/helpers/channels/get_stage_instance.ts index bfb727e31..5f63f5e61 100644 --- a/src/helpers/channels/get_stage_instance.ts +++ b/src/helpers/channels/get_stage_instance.ts @@ -12,5 +12,5 @@ export async function getStageInstance(bot: Bot, channelId: bigint) { } } - return await bot.rest.runMethod(bot.rest,"get", bot.constants.endpoints.STAGE_INSTANCE(channelId)); + return await bot.rest.runMethod(bot.rest, "get", bot.constants.endpoints.STAGE_INSTANCE(channelId)); } diff --git a/src/helpers/channels/start_typing.ts b/src/helpers/channels/start_typing.ts index 6999e6cec..dad3caccf 100644 --- a/src/helpers/channels/start_typing.ts +++ b/src/helpers/channels/start_typing.ts @@ -29,5 +29,5 @@ export async function startTyping(bot: Bot, channelId: bigint) { } } - return await bot.rest.runMethod(bot.rest,"post", bot.constants.endpoints.CHANNEL_TYPING(channelId)); + return await bot.rest.runMethod(bot.rest, "post", bot.constants.endpoints.CHANNEL_TYPING(channelId)); } diff --git a/src/helpers/channels/swap_channels.ts b/src/helpers/channels/swap_channels.ts index 22618b7a0..a1df26369 100644 --- a/src/helpers/channels/swap_channels.ts +++ b/src/helpers/channels/swap_channels.ts @@ -7,12 +7,17 @@ export async function swapChannels(bot: Bot, guildId: bigint, channelPositions: throw "You must provide at least two channels to be swapped."; } - return await bot.rest.runMethod(bot.rest,"patch", bot.constants.endpoints.GUILD_CHANNELS(guildId), channelPositions.map((channelPosition) => { - return { - id: channelPosition.id, - position: channelPosition.position, - lock_positions: channelPosition.lockPositions, - parent_id: channelPosition.parentId - } - })); + return await bot.rest.runMethod( + bot.rest, + "patch", + bot.constants.endpoints.GUILD_CHANNELS(guildId), + channelPositions.map((channelPosition) => { + return { + id: channelPosition.id, + position: channelPosition.position, + lock_positions: channelPosition.lockPositions, + parent_id: channelPosition.parentId, + }; + }) + ); } diff --git a/src/helpers/channels/update_stage_instance.ts b/src/helpers/channels/update_stage_instance.ts index 4a98472ed..f8f34d4ff 100644 --- a/src/helpers/channels/update_stage_instance.ts +++ b/src/helpers/channels/update_stage_instance.ts @@ -4,7 +4,7 @@ import type { ChannelTypes } from "../../types/channels/channel_types.ts"; /** Updates fields of an existing Stage instance. Requires the user to be a moderator of the Stage channel. */ export async function updateStageInstance( - bot: Bot, + bot: Bot, channelId: bigint, data: Partial> = {} ) { @@ -28,8 +28,8 @@ export async function updateStageInstance( throw new Error(bot.constants.Errors.INVALID_TOPIC_LENGTH); } - return await bot.rest.runMethod(bot.rest,"patch", bot.constants.endpoints.STAGE_INSTANCE(channelId), { + return await bot.rest.runMethod(bot.rest, "patch", bot.constants.endpoints.STAGE_INSTANCE(channelId), { topic: data.topic, - privacy_level: data.privacyLevel + privacy_level: data.privacyLevel, }); } diff --git a/src/helpers/channels/update_voice_state.ts b/src/helpers/channels/update_voice_state.ts index 7960733ae..b01d9fbd3 100644 --- a/src/helpers/channels/update_voice_state.ts +++ b/src/helpers/channels/update_voice_state.ts @@ -18,14 +18,17 @@ export async function updateBotVoiceState( options: UpdateSelfVoiceState | ({ userId: bigint } & UpdateOthersVoiceState) ) { return await bot.rest.runMethod( - bot.rest, + bot.rest, "patch", - bot.constants.endpoints.UPDATE_VOICE_STATE(guildId, bot.utils.hasOwnProperty(options, "userId") ? options.userId : undefined), - { - channel_id: options.channelId, - suppress: options.suppress, - request_to_speak_timestamp: options.requestToSpeakTimestamp, - user_id: options.userId - } + bot.constants.endpoints.UPDATE_VOICE_STATE( + guildId, + bot.utils.hasOwnProperty(options, "userId") ? options.userId : undefined + ), + { + channel_id: options.channelId, + suppress: options.suppress, + request_to_speak_timestamp: options.requestToSpeakTimestamp, + user_id: options.userId, + } ); } diff --git a/src/helpers/messages/get_reactions.ts b/src/helpers/messages/get_reactions.ts index 600d682e9..6258df559 100644 --- a/src/helpers/messages/get_reactions.ts +++ b/src/helpers/messages/get_reactions.ts @@ -4,9 +4,15 @@ import { Collection } from "../../util/collection.ts"; import type { Bot } from "../../bot.ts"; /** Get a list of users that reacted with this emoji. */ -export async function getReactions(bot: Bot, channelId: bigint, messageId: bigint, reaction: string, options?: GetReactions) { +export async function getReactions( + bot: Bot, + channelId: bigint, + messageId: bigint, + reaction: string, + options?: GetReactions +) { const users = await bot.rest.runMethod( - bot.rest, + bot.rest, "get", bot.constants.endpoints.CHANNEL_MESSAGE_REACTION(channelId, messageId, reaction), options diff --git a/src/helpers/messages/pin_message.ts b/src/helpers/messages/pin_message.ts index 2ef455fc2..8642c3493 100644 --- a/src/helpers/messages/pin_message.ts +++ b/src/helpers/messages/pin_message.ts @@ -4,7 +4,11 @@ import type { Bot } from "../../bot.ts"; export async function pin(bot: Bot, channelId: bigint, messageId: bigint) { await bot.utils.requireBotChannelPermissions(bot, channelId, ["MANAGE_MESSAGES"]); - return await bot.rest.runMethod(bot.rest,"put", bot.constants.endpoints.CHANNEL_PIN(channelId, messageId)); + return await bot.rest.runMethod( + bot.rest, + "put", + bot.constants.endpoints.CHANNEL_PIN(channelId, messageId) + ); } // aliases diff --git a/src/helpers/webhooks/create_webhook.ts b/src/helpers/webhooks/create_webhook.ts index e0daa22f1..fa9728381 100644 --- a/src/helpers/webhooks/create_webhook.ts +++ b/src/helpers/webhooks/create_webhook.ts @@ -1,7 +1,7 @@ import type { Bot } from "../../bot.ts"; import type { CreateWebhook } from "../../types/webhooks/create_webhook.ts"; import type { Webhook } from "../../types/webhooks/webhook.ts"; -import type {SnakeCasedPropertiesDeep} from "../../types/util.ts"; +import type { SnakeCasedPropertiesDeep } from "../../types/util.ts"; /** * Create a new webhook. Requires the MANAGE_WEBHOOKS permission. Returns a webhook object on success. Webhook names follow our naming restrictions that can be found in our Usernames and Nicknames documentation, with the following additional stipulations: @@ -19,8 +19,13 @@ export async function createWebhook(bot: Bot, channelId: bigint, options: Create throw new Error(bot.constants.Errors.INVALID_WEBHOOK_NAME); } - return await bot.rest.runMethod>(bot.rest, "post", bot.constants.endpoints.CHANNEL_WEBHOOKS(channelId), { - ...options, - avatar: options.avatar ? await bot.utils.urlToBase64(options.avatar) : undefined, - }); + return await bot.rest.runMethod>( + bot.rest, + "post", + bot.constants.endpoints.CHANNEL_WEBHOOKS(channelId), + { + ...options, + avatar: options.avatar ? await bot.utils.urlToBase64(options.avatar) : undefined, + } + ); } diff --git a/src/helpers/webhooks/delete_webhook.ts b/src/helpers/webhooks/delete_webhook.ts index 274f66d63..dba5cc104 100644 --- a/src/helpers/webhooks/delete_webhook.ts +++ b/src/helpers/webhooks/delete_webhook.ts @@ -1,8 +1,8 @@ -import type {Bot} from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; /** Delete a webhook permanently. Requires the `MANAGE_WEBHOOKS` permission. Returns a undefined on success */ export async function deleteWebhook(bot: Bot, channelId: bigint, webhookId: bigint) { await bot.utils.requireBotChannelPermissions(bot, channelId, ["MANAGE_WEBHOOKS"]); - return await bot.rest.runMethod(bot.rset,"delete", bot.constants.endpoints.WEBHOOK_ID(webhookId)); + return await bot.rest.runMethod(bot.rset, "delete", bot.constants.endpoints.WEBHOOK_ID(webhookId)); } diff --git a/src/helpers/webhooks/delete_webhook_message.ts b/src/helpers/webhooks/delete_webhook_message.ts index 99d0762cc..608d780b8 100644 --- a/src/helpers/webhooks/delete_webhook_message.ts +++ b/src/helpers/webhooks/delete_webhook_message.ts @@ -1,5 +1,9 @@ -import type {Bot} from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; export async function deleteWebhookMessage(bot: Bot, webhookId: bigint, webhookToken: string, messageId: bigint) { - return await bot.rest.runMethod(bot.rest,"delete", bot.constants.endpoints.WEBHOOK_MESSAGE(webhookId, webhookToken, messageId)); + return await bot.rest.runMethod( + bot.rest, + "delete", + bot.constants.endpoints.WEBHOOK_MESSAGE(webhookId, webhookToken, messageId) + ); } diff --git a/src/helpers/webhooks/delete_webhook_with_token.ts b/src/helpers/webhooks/delete_webhook_with_token.ts index 9806e3846..2a98aecd6 100644 --- a/src/helpers/webhooks/delete_webhook_with_token.ts +++ b/src/helpers/webhooks/delete_webhook_with_token.ts @@ -1,6 +1,10 @@ -import type {Bot} from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; /** Delete a webhook permanently. Returns a undefined on success */ export async function deleteWebhookWithToken(bot: Bot, webhookId: bigint, webhookToken: string) { - return await bot.rest.runMethod(bot.rest,"delete", bot.constants.endpoints.WEBHOOK(webhookId, webhookToken)); + return await bot.rest.runMethod( + bot.rest, + "delete", + bot.constants.endpoints.WEBHOOK(webhookId, webhookToken) + ); } diff --git a/src/helpers/webhooks/edit_webhook.ts b/src/helpers/webhooks/edit_webhook.ts index 2e27c219a..6805c12e1 100644 --- a/src/helpers/webhooks/edit_webhook.ts +++ b/src/helpers/webhooks/edit_webhook.ts @@ -1,14 +1,19 @@ import type { ModifyWebhook } from "../../types/webhooks/modify_webhook.ts"; import type { Webhook } from "../../types/webhooks/webhook.ts"; -import type {Bot} from "../../bot.ts"; -import type {SnakeCasedPropertiesDeep} from "../../types/util.ts"; +import type { Bot } from "../../bot.ts"; +import type { SnakeCasedPropertiesDeep } from "../../types/util.ts"; /** Edit a webhook. Requires the `MANAGE_WEBHOOKS` permission. Returns the updated webhook object on success. */ export async function editWebhook(bot: Bot, channelId: bigint, webhookId: bigint, options: ModifyWebhook) { await bot.utils.requireBotChannelPermissions(channelId, ["MANAGE_WEBHOOKS"]); - return await bot.rest.runMethod>(bot.rest,"patch", bot.constants.endpoints.WEBHOOK_ID(webhookId), { - ...options, - channel_id: options.channelId, - }); + return await bot.rest.runMethod>( + bot.rest, + "patch", + bot.constants.endpoints.WEBHOOK_ID(webhookId), + { + ...options, + channel_id: options.channelId, + } + ); } diff --git a/src/helpers/webhooks/get_webhook_with_token.ts b/src/helpers/webhooks/get_webhook_with_token.ts index 5042ce2ae..786ac58ba 100644 --- a/src/helpers/webhooks/get_webhook_with_token.ts +++ b/src/helpers/webhooks/get_webhook_with_token.ts @@ -1,7 +1,7 @@ import type { Webhook } from "../../types/webhooks/webhook.ts"; -import type {Bot} from "../../bot.ts"; +import type { Bot } from "../../bot.ts"; /** Returns the new webhook object for the given id, this call does not require authentication and returns no user in the webhook object. */ export async function getWebhookWithToken(bot: Bot, webhookId: bigint, token: string) { - return await bot.rest.runMethod(bot.rest,"get", bot.constants.endpoints.WEBHOOK(webhookId, token)); + return await bot.rest.runMethod(bot.rest, "get", bot.constants.endpoints.WEBHOOK(webhookId, token)); }