diff --git a/packages/bot/src/helpers.ts b/packages/bot/src/helpers.ts index 3ba581cb7..4d02f4fad 100644 --- a/packages/bot/src/helpers.ts +++ b/packages/bot/src/helpers.ts @@ -1,12 +1,18 @@ import type { CreateWebhook } from '@discordeno/rest' import type { + AddDmRecipientOptions, + AddGuildMemberOptions, ApplicationCommandPermissions, AtLeastOne, BeginGuildPrune, BigString, + CamelizedDiscordAccessTokenResponse, + CamelizedDiscordApplicationRoleConnection, CamelizedDiscordArchivedThreads, CamelizedDiscordAuditLog, CamelizedDiscordBan, + CamelizedDiscordConnection, + CamelizedDiscordCurrentAuthorization, CamelizedDiscordFollowedChannel, CamelizedDiscordGetGatewayBot, CamelizedDiscordGuildPreview, @@ -14,14 +20,19 @@ import type { CamelizedDiscordInvite, CamelizedDiscordInviteMetadata, CamelizedDiscordModifyGuildWelcomeScreen, + CamelizedDiscordPartialGuild, CamelizedDiscordPrunedCount, + CamelizedDiscordTokenExchange, + CamelizedDiscordTokenRevocation, CamelizedDiscordVanityUrl, CamelizedDiscordVoiceRegion, CreateApplicationCommand, CreateAutoModerationRuleOptions, CreateChannelInvite, CreateForumPostWithMessage, + CreateGlobalApplicationCommandOptions, CreateGuild, + CreateGuildApplicationCommandOptions, CreateGuildBan, CreateGuildChannel, CreateGuildEmoji, @@ -44,7 +55,9 @@ import type { EditScheduledEvent, EditUserVoiceState, ExecuteWebhook, + GetApplicationCommandPermissionOptions, GetBans, + GetGroupDmOptions, GetGuildAuditLog, GetGuildPruneCountQuery, GetInvite, @@ -52,6 +65,7 @@ import type { GetReactions, GetScheduledEventUsers, GetScheduledEvents, + GetUserGuilds, GetWebhookMessageOptions, InteractionCallbackData, InteractionResponse, @@ -69,6 +83,8 @@ import type { SearchMembers, StartThreadWithMessage, StartThreadWithoutMessage, + UpsertGlobalApplicationCommandOptions, + UpsertGuildApplicationCommandOptions, } from '@discordeno/types' import { snakelize } from '@discordeno/utils' import type { Bot } from './bot.js' @@ -108,14 +124,14 @@ export function createBotHelpers(bot: Bot): BotHelpers { createForumThread: async (channelId, options, reason) => { return bot.transformers.channel(bot, { channel: snakelize(await bot.rest.createForumThread(channelId, options, reason)) }) }, - createGlobalApplicationCommand: async (command) => { - return bot.transformers.applicationCommand(bot, snakelize(await bot.rest.createGlobalApplicationCommand(command))) + createGlobalApplicationCommand: async (command, options) => { + return bot.transformers.applicationCommand(bot, snakelize(await bot.rest.createGlobalApplicationCommand(command, options))) }, createGuild: async (options) => { return bot.transformers.guild(bot, { guild: snakelize(await bot.rest.createGuild(options)), shardId: 0 }) }, - createGuildApplicationCommand: async (command, guildId) => { - return bot.transformers.applicationCommand(bot, snakelize(await bot.rest.createGuildApplicationCommand(command, guildId))) + createGuildApplicationCommand: async (command, guildId, options) => { + return bot.transformers.applicationCommand(bot, snakelize(await bot.rest.createGuildApplicationCommand(command, guildId, options))) }, createGuildFromTemplate: async (templateCode, options) => { return bot.transformers.guild(bot, { guild: snakelize(await bot.rest.createGuildFromTemplate(templateCode, options)), shardId: 0 }) @@ -235,11 +251,23 @@ export function createBotHelpers(bot: Bot): BotHelpers { getApplicationInfo: async () => { return bot.transformers.application(bot, snakelize(await bot.rest.getApplicationInfo())) }, - getApplicationCommandPermission: async (guildId, commandId) => { - return bot.transformers.applicationCommandPermission(bot, snakelize(await bot.rest.getApplicationCommandPermission(guildId, commandId))) + getCurrentAuthenticationInfo: async (bearerToken) => { + return await bot.rest.getCurrentAuthenticationInfo(bearerToken) }, - getApplicationCommandPermissions: async (guildId) => { - return (await bot.rest.getApplicationCommandPermissions(guildId)).map((res) => + exchangeToken: async (options) => { + return await bot.rest.exchangeToken(options) + }, + revokeToken: async (options) => { + return await bot.rest.revokeToken(options) + }, + getApplicationCommandPermission: async (guildId, commandId, options) => { + const res = await bot.rest.getApplicationCommandPermission(guildId, commandId, options) + const snakedRes = snakelize(res) + + return bot.transformers.applicationCommandPermission(bot, snakedRes) + }, + getApplicationCommandPermissions: async (guildId, options) => { + return (await bot.rest.getApplicationCommandPermissions(guildId, options)).map((res) => bot.transformers.applicationCommandPermission(bot, snakelize(res)), ) }, @@ -277,6 +305,9 @@ export function createBotHelpers(bot: Bot): BotHelpers { getDmChannel: async (userId) => { return bot.transformers.channel(bot, { channel: snakelize(await bot.rest.getDmChannel(userId)) }) }, + getGroupDmChannel: async (options) => { + return bot.transformers.channel(bot, { channel: snakelize(await bot.rest.getGroupDmChannel(options)) }) + }, getEmoji: async (guildId, emojiId) => { return bot.transformers.emoji(bot, snakelize(await bot.rest.getEmoji(guildId, emojiId))) }, @@ -298,6 +329,9 @@ export function createBotHelpers(bot: Bot): BotHelpers { getGuild: async (guildId, options) => { return bot.transformers.guild(bot, { guild: snakelize(await bot.rest.getGuild(guildId, options)), shardId: 0 }) }, + getGuilds: async (bearerToken, options) => { + return await bot.rest.getGuilds(bearerToken, options) + }, getGuildApplicationCommand: async (commandId, guildId) => { return bot.transformers.applicationCommand(bot, snakelize(await bot.rest.getGuildApplicationCommand(commandId, guildId))) }, @@ -405,6 +439,15 @@ export function createBotHelpers(bot: Bot): BotHelpers { getUser: async (id) => { return bot.transformers.user(bot, snakelize(await bot.rest.getUser(id))) }, + getCurrentUser: async (bearerToken) => { + return bot.transformers.user(bot, snakelize(await bot.rest.getCurrentUser(bearerToken))) + }, + getUserConnections: async (bearerToken) => { + return await bot.rest.getUserConnections(bearerToken) + }, + getUserApplicationRoleConnection: async (bearerToken, applicationId) => { + return await bot.rest.getUserApplicationRoleConnection(bearerToken, applicationId) + }, getVanityUrl: async (guildId) => { return await bot.rest.getVanityUrl(guildId) }, @@ -449,11 +492,15 @@ export function createBotHelpers(bot: Bot): BotHelpers { syncGuildTemplate: async (guildId) => { return bot.transformers.template(bot, snakelize(await bot.rest.syncGuildTemplate(guildId))) }, - upsertGlobalApplicationCommands: async (commands) => { - return (await bot.rest.upsertGlobalApplicationCommands(commands)).map((res) => bot.transformers.applicationCommand(bot, snakelize(res))) + upsertGlobalApplicationCommands: async (commands, options) => { + return (await bot.rest.upsertGlobalApplicationCommands(commands, options)).map((res) => + bot.transformers.applicationCommand(bot, snakelize(res)), + ) }, - upsertGuildApplicationCommands: async (guildId, commands) => { - return (await bot.rest.upsertGuildApplicationCommands(guildId, commands)).map((res) => bot.transformers.applicationCommand(bot, snakelize(res))) + upsertGuildApplicationCommands: async (guildId, commands, options) => { + return (await bot.rest.upsertGuildApplicationCommands(guildId, commands, options)).map((res) => + bot.transformers.applicationCommand(bot, snakelize(res)), + ) }, editBotMember: async (guildId, options, reason) => { return bot.transformers.member(bot, snakelize(await bot.rest.editBotMember(guildId, options, reason)), guildId, bot.id) @@ -464,6 +511,10 @@ export function createBotHelpers(bot: Bot): BotHelpers { getMember: async (guildId, userId) => { return bot.transformers.member(bot, snakelize(await bot.rest.getMember(guildId, userId)), guildId, userId) }, + getCurrentMember: async (guildId, bearerToken) => { + const res = await bot.rest.getCurrentMember(guildId, bearerToken) + return bot.transformers.member(bot, snakelize(res), guildId, bot.transformers.snowflake(res.user.id)) + }, getMembers: async (guildId, options) => { return (await bot.rest.getMembers(guildId, options)).map((res) => bot.transformers.member(bot, snakelize(res), guildId, bot.transformers.snowflake(res.user.id)), @@ -490,6 +541,12 @@ export function createBotHelpers(bot: Bot): BotHelpers { addThreadMember: async (channelId, userId) => { return await bot.rest.addThreadMember(channelId, userId) }, + addDmRecipient: async (channelId, userId, options) => { + return await bot.rest.addDmRecipient(channelId, userId, options) + }, + addGuildMember: async (guildId, userId, options) => { + return await bot.rest.addGuildMember(guildId, userId, options) + }, deleteAutomodRule: async (guildId, ruleId, reason) => { return await bot.rest.deleteAutomodRule(guildId, ruleId, reason) }, @@ -580,6 +637,9 @@ export function createBotHelpers(bot: Bot): BotHelpers { editUserVoiceState: async (guildId, options) => { return await bot.rest.editUserVoiceState(guildId, options) }, + editUserApplicationRoleConnection: async (bearerToken, applicationId, options) => { + return await bot.rest.editUserApplicationRoleConnection(bearerToken, applicationId, options) + }, joinThread: async (channelId) => { return await bot.rest.joinThread(channelId) }, @@ -595,6 +655,9 @@ export function createBotHelpers(bot: Bot): BotHelpers { removeThreadMember: async (channelId, userId) => { return await bot.rest.removeThreadMember(channelId, userId) }, + removeDmRecipient: async (channelId, userId) => { + return await bot.rest.removeDmRecipient(channelId, userId) + }, sendInteractionResponse: async (interactionId, token, options) => { return await bot.rest.sendInteractionResponse(interactionId, token, options) }, @@ -624,9 +687,13 @@ export interface BotHelpers { createChannel: (guildId: BigString, options: CreateGuildChannel, reason?: string) => Promise createEmoji: (guildId: BigString, options: CreateGuildEmoji, reason?: string) => Promise createForumThread: (channelId: BigString, options: CreateForumPostWithMessage, reason?: string) => Promise - createGlobalApplicationCommand: (command: CreateApplicationCommand) => Promise + createGlobalApplicationCommand: (command: CreateApplicationCommand, options?: CreateGlobalApplicationCommandOptions) => Promise createGuild: (options: CreateGuild) => Promise - createGuildApplicationCommand: (command: CreateApplicationCommand, guildId: BigString) => Promise + createGuildApplicationCommand: ( + command: CreateApplicationCommand, + guildId: BigString, + options?: CreateGuildApplicationCommandOptions, + ) => Promise createGuildFromTemplate: (templateCode: string, options: CreateGuildFromTemplate) => Promise createGuildSticker: (guildId: BigString, options: CreateGuildStickerOptions, reason?: string) => Promise createGuildTemplate: (guildId: BigString, options: CreateTemplate) => Promise