diff --git a/plugins/cache/src/addCacheCollections.ts b/plugins/cache/src/addCacheCollections.ts index 7d3a7c325..fbd0c298b 100644 --- a/plugins/cache/src/addCacheCollections.ts +++ b/plugins/cache/src/addCacheCollections.ts @@ -2,7 +2,6 @@ import { Bot, Channel, Collection, - FinalHelpers, Guild, Member, Message, @@ -12,14 +11,16 @@ import { Webhook, } from "../deps.ts"; -export type BotWithCache = B & CacheProps & { helpers: BotHelpersWithCache }; +export type BotWithCache = Omit & CacheProps & { + helpers: BotHelpersWithCache; +}; -export interface BotHelpersWithCache extends FinalHelpers { +export type BotHelpersWithCache = Omit & { /** The added channelId argument at the end is used to validate permission checks */ - editWebhook: (webhookId: bigint, options: ModifyWebhook, channelId?: bigint) => Promise; -} + editWebhook: (webhookId: bigint, options: ModifyWebhook, fromChannelId?: bigint) => Promise; +}; -export interface CacheProps extends Bot { +export interface CacheProps { guilds: Collection; users: Collection; members: Collection; @@ -32,7 +33,7 @@ export interface CacheProps extends Bot { } export function addCacheCollections(bot: B): BotWithCache { - const cacheBot = bot as BotWithCache; + const cacheBot = bot as unknown as BotWithCache; cacheBot.guilds = new Collection(); cacheBot.users = new Collection(); cacheBot.members = new Collection(); @@ -43,5 +44,5 @@ export function addCacheCollections(bot: B): BotWithCache { cacheBot.dispatchedChannelIds = new Set(); cacheBot.activeGuildIds = new Set(); - return bot as BotWithCache; + return cacheBot; } diff --git a/plugins/permissions/src/webhooks/editWebhook.ts b/plugins/permissions/src/webhooks/editWebhook.ts index ad980c440..ec3118b0d 100644 --- a/plugins/permissions/src/webhooks/editWebhook.ts +++ b/plugins/permissions/src/webhooks/editWebhook.ts @@ -4,10 +4,9 @@ import { requireBotChannelPermissions } from "../permissions.ts"; export default function editWebhook(bot: BotWithCache) { const editWebhookOld = bot.helpers.editWebhook; - // @ts-ignore TODO: itoh need a better way for this - bot.helpers.editWebhook = async function (webhookId, options, channelId) { + bot.helpers.editWebhook = async function (webhookId, options, fromChannelId) { if (options.channelId) requireBotChannelPermissions(bot, options.channelId, ["MANAGE_WEBHOOKS"]); - if (channelId) requireBotChannelPermissions(bot, channelId, ["MANAGE_WEBHOOKS"]); + if (fromChannelId) requireBotChannelPermissions(bot, fromChannelId, ["MANAGE_WEBHOOKS"]); if (options.name) { if (