From 9426f4e2defc227f195f87336f501ea319f30376 Mon Sep 17 00:00:00 2001 From: LTS20050703 Date: Thu, 15 Sep 2022 21:45:54 +0700 Subject: [PATCH] fix(plugins): type errors (#2472) * fix plugins * deno fmt --- plugins/helpers/src/channels.ts | 13 +++---------- plugins/permissions/src/channels/createChannel.ts | 4 ++-- plugins/permissions/src/channels/editChannel.ts | 4 ++-- plugins/validations/src/messages/sendMessage.ts | 5 ++++- 4 files changed, 11 insertions(+), 15 deletions(-) diff --git a/plugins/helpers/src/channels.ts b/plugins/helpers/src/channels.ts index f699a8ecb..3ce3a7d94 100644 --- a/plugins/helpers/src/channels.ts +++ b/plugins/helpers/src/channels.ts @@ -1,11 +1,7 @@ import { Bot, Channel, CreateGuildChannel, separateOverwrites } from "../deps.ts"; /** Create a copy of a channel */ -export async function cloneChannel( - bot: Bot, - channel: Channel, - reason?: string, -) { +export async function cloneChannel(bot: Bot, channel: Channel, reason?: string) { if (!channel.guildId) { throw new Error(`Cannot clone a channel outside a guild`); } @@ -30,12 +26,9 @@ export async function cloneChannel( deny: bot.utils.calculatePermissions(BigInt(deny)), }; }), + reason, }; //Create the channel (also handles permissions) - return await bot.helpers.createChannel( - channel.guildId!, - createChannelOptions, - reason, - ); + return await bot.helpers.createChannel(channel.guildId!, createChannelOptions); } diff --git a/plugins/permissions/src/channels/createChannel.ts b/plugins/permissions/src/channels/createChannel.ts index 36ee08efa..b71335b08 100644 --- a/plugins/permissions/src/channels/createChannel.ts +++ b/plugins/permissions/src/channels/createChannel.ts @@ -4,7 +4,7 @@ import { requireBotGuildPermissions } from "../permissions.ts"; export function createChannel(bot: BotWithCache) { const createChannel = bot.helpers.createChannel; - bot.helpers.createChannel = async function (guildId, options, reason) { + bot.helpers.createChannel = async function (guildId, options) { const guild = bot.guilds.get(guildId); if (guild) { @@ -47,6 +47,6 @@ export function createChannel(bot: BotWithCache) { requireBotGuildPermissions(bot, guild, requiredPerms); } - return await createChannel(guildId, options, reason); + return await createChannel(guildId, options); }; } diff --git a/plugins/permissions/src/channels/editChannel.ts b/plugins/permissions/src/channels/editChannel.ts index e3923f353..ad5ab5dec 100644 --- a/plugins/permissions/src/channels/editChannel.ts +++ b/plugins/permissions/src/channels/editChannel.ts @@ -4,7 +4,7 @@ import { requireBotChannelPermissions } from "../permissions.ts"; export function editChannel(bot: BotWithCache) { const editChannel = bot.helpers.editChannel; - bot.helpers.editChannel = async function (channelId, options, reason) { + bot.helpers.editChannel = async function (channelId, options) { const channel = bot.channels.get(channelId); if (channel?.guildId) { @@ -71,6 +71,6 @@ export function editChannel(bot: BotWithCache) { requireBotChannelPermissions(bot, channel, requiredPerms); } - return await editChannel(channelId, options, reason); + return await editChannel(channelId, options); }; } diff --git a/plugins/validations/src/messages/sendMessage.ts b/plugins/validations/src/messages/sendMessage.ts index 901622a07..844ad2c9f 100644 --- a/plugins/validations/src/messages/sendMessage.ts +++ b/plugins/validations/src/messages/sendMessage.ts @@ -55,7 +55,10 @@ export function sendMessage(bot: Bot) { if (content.components) validateComponents(bot, content.components); - if (!content.content?.length && !content.embeds?.length && !content.components?.length && !content.file && !content.stickerIds?.length) { + if ( + !content.content?.length && !content.embeds?.length && !content.components?.length && !content.file && + !content.stickerIds?.length + ) { throw new Error( "When sending a message, you must provide a value for at least one of content, embeds, stickerIds, components, or file.", );