Files
discordeno/plugins/permissions/src/channels/threads/getArchivedThreads.ts
2022-01-26 19:02:34 +01:00

23 lines
674 B
TypeScript

import { BotWithCache } from "../../../deps.ts";
import { requireBotChannelPermissions } from "../../permissions.ts";
export default function getArchivedThreads(bot: BotWithCache) {
const getArchivedThreadsOld = bot.helpers.getArchivedThreads;
bot.helpers.getArchivedThreads = async function (channelId, options) {
const channel = await bot.channels.get(channelId);
if (channel) {
await requireBotChannelPermissions(
bot,
channel,
options?.type === "private"
? ["READ_MESSAGE_HISTORY", "MANAGE_THREADS"]
: ["READ_MESSAGE_HISTORY"],
);
}
return getArchivedThreadsOld(channelId, options);
};
}