import { ApplicationCommandOptionChoice, Bot, Collection, CreateMessage, DiscordenoChannel, DiscordenoMember, DiscordenoMessage, FinalHelpers, ListGuildMembers, ModifyThread, } from "./deps.ts"; import { cloneChannel } from "./src/channels.ts"; import { sendAutocompleteChoices } from "./src/sendAutoCompleteChoices.ts"; import { sendDirectMessage } from "./src/sendDirectMessage.ts"; import { suppressEmbeds } from "./src/suppressEmbeds.ts"; import { archiveThread, editThread, lockThread, unarchiveThread, unlockThread } from "./src/threads.ts"; import { disconnectMember } from "./src/disconnectMember.ts"; import { getMembersPaginated } from "./src/getMembersPaginated.ts"; import { moveMember } from "./src/moveMember.ts"; export interface BotWithHelpersPlugin extends Bot { helpers: FinalHelpers & { sendDirectMessage: ( userId: bigint, content: string | CreateMessage, ) => Promise; suppressEmbeds: ( channelId: bigint, messageId: bigint, ) => Promise; archiveThread: (threadId: bigint) => Promise; unarchiveThread: (threadId: bigint) => Promise; lockThread: (threadId: bigint) => Promise; unlockThread: (threadId: bigint) => Promise; editThread: ( threadId: bigint, options: ModifyThread, reason?: string, ) => Promise; cloneChannel: ( channel: DiscordenoChannel, reason?: string, ) => Promise; sendAutocompleteChoices: ( interactionId: bigint, interactionToken: string, choices: ApplicationCommandOptionChoice[], ) => Promise; disconnectMember: ( guildId: bigint, memberId: bigint, ) => Promise; getMembersPaginated: ( guildId: bigint, options: ListGuildMembers & { memberCount: number }, ) => Promise>; moveMember: ( guildId: bigint, memberId: bigint, channelId: bigint, ) => Promise; }; } export function enableHelpersPlugin(rawBot: Bot): BotWithHelpersPlugin { const bot = rawBot as BotWithHelpersPlugin; bot.helpers.sendDirectMessage = ( userId: bigint, content: string | CreateMessage, ) => sendDirectMessage(bot, userId, content); bot.helpers.suppressEmbeds = (channelId: bigint, messageId: bigint) => suppressEmbeds(bot, channelId, messageId); bot.helpers.archiveThread = (threadId: bigint) => archiveThread(bot, threadId); bot.helpers.unarchiveThread = (threadId: bigint) => unarchiveThread(bot, threadId); bot.helpers.lockThread = (threadId: bigint) => lockThread(bot, threadId); bot.helpers.unlockThread = (threadId: bigint) => unlockThread(bot, threadId); bot.helpers.editThread = ( threadId: bigint, options: ModifyThread, reason?: string, ) => editThread(bot, threadId, options, reason); bot.helpers.cloneChannel = (channel: DiscordenoChannel, reason?: string) => cloneChannel(bot, channel, reason); bot.helpers.sendAutocompleteChoices = ( interactionId: bigint, interactionToken: string, choices: ApplicationCommandOptionChoice[], ) => sendAutocompleteChoices(bot, interactionId, interactionToken, choices); bot.helpers.disconnectMember = (guildId: bigint, memberId: bigint) => disconnectMember(bot, guildId, memberId); bot.helpers.getMembersPaginated = ( guildId: bigint, options: ListGuildMembers & { memberCount: number }, ) => getMembersPaginated(bot, guildId, options); bot.helpers.moveMember = ( guildId: bigint, memberId: bigint, channelId: bigint, ) => moveMember(bot, guildId, memberId, channelId); return bot as BotWithHelpersPlugin; } // EXPORT EVERYTHING HERE SO USERS CAN OPT TO USE FUNCTIONS DIRECTLY export * from "./src/channels.ts"; export * from "./src/disconnectMember.ts"; export * from "./src/getMembersPaginated.ts"; export * from "./src/moveMember.ts"; export * from "./src/sendAutoCompleteChoices.ts"; export * from "./src/sendDirectMessage.ts"; export * from "./src/suppressEmbeds.ts"; export * from "./src/threads.ts"; export default enableHelpersPlugin;