refactor(types,utils,rest,bot)!: Cleanup types & files (#3951)

* Cleanup some un-used & sort types, split files

* Remove commented code from reverse/component.ts

* Fix type error on the bot E2E test

* Add comment, remove DiscordInteractionResponse

* Remove camel.ts

* Error on unusedImport, refactor type imports

* Run biome check

* fix: typo

* Update comments for skuId and defaultValues

---------

Co-authored-by: Awesome Stickz <awesome@stickz.dev>
This commit is contained in:
Fleny
2024-11-09 17:27:55 +01:00
committed by GitHub
parent dbf4fda455
commit cfdf77027a
40 changed files with 1819 additions and 2417 deletions

View File

@@ -16,11 +16,13 @@
"rules": {
"recommended": false,
"correctness": {
"noUnusedVariables": "error"
"noUnusedVariables": "error",
"noUnusedImports": "error"
},
"style": {
"noNamespace": "error",
"noNonNullAssertion": "off",
"useImportType": "error",
"useConsistentArrayType": {
"level": "error",
"options": { "syntax": "shorthand" }

View File

@@ -1,4 +1,4 @@
import { type RequestMethods } from '@discordeno/bot'
import type { RequestMethods } from '@discordeno/bot'
import { REST_HOST, REST_PORT } from '../config.js'
import { buildFastifyApp, parseMultiformBody } from './fastify.js'
import restManager, { logger } from './restManager.js'

View File

@@ -2,43 +2,13 @@ import type { CreateGatewayManagerOptions, GatewayManager } from '@discordeno/ga
import { ShardSocketCloseCodes, createGatewayManager } from '@discordeno/gateway'
import type { CreateRestManagerOptions, RestManager } from '@discordeno/rest'
import { createRestManager } from '@discordeno/rest'
import type {
BigString,
DiscordGatewayPayload,
DiscordReady,
DiscordVoiceChannelEffectAnimationType,
GatewayIntents,
RecursivePartial,
} from '@discordeno/types'
import { type Collection, createLogger, getBotIdFromToken, type logger } from '@discordeno/utils'
import { createBotGatewayHandlers } from './handlers.js'
import type { BigString, GatewayDispatchEventNames, GatewayIntents, RecursivePartial } from '@discordeno/types'
import { createLogger, getBotIdFromToken, type logger } from '@discordeno/utils'
import type { TransformersDesiredProperties } from './desiredProperties.js'
import type { EventHandlers } from './events.js'
import { type GatewayHandlers, createBotGatewayHandlers } from './handlers.js'
import { type BotHelpers, createBotHelpers } from './helpers.js'
import { type Transformers, type TransformersDesiredProperties, createTransformers } from './transformers.js'
import type {
AuditLogEntry,
AutoModerationActionExecution,
AutoModerationRule,
Channel,
Emoji,
Entitlement,
Guild,
GuildApplicationCommandPermissions,
Integration,
Interaction,
Invite,
Member,
Message,
PresenceUpdate,
Role,
ScheduledEvent,
SoundboardSound,
Sticker,
Subscription,
ThreadMember,
User,
VoiceState,
} from './transformers/index.js'
import type { BotGatewayHandlerOptions } from './typings.js'
import { type Transformers, createTransformers } from './transformers.js'
/**
* Create a bot object that will maintain the rest and gateway connection.
@@ -65,7 +35,7 @@ export function createBot(options: CreateBotOptions): Bot {
// RUN DISPATCH CHECK
await bot.events.dispatchRequirements?.(data, shard.id)
bot.handlers[data.t as keyof ReturnType<typeof createBotGatewayHandlers>]?.(bot, data, shard.id)
bot.handlers[data.t as GatewayDispatchEventNames]?.(bot, data, shard.id)
}
}
@@ -133,7 +103,7 @@ export interface CreateBotOptions {
/** The functions that should transform discord objects to discordeno shaped objects. */
transformers?: RecursivePartial<Transformers>
/** The handler functions that should handle incoming discord payloads from gateway and call an event. */
handlers?: Partial<BotGatewayHandlerOptions>
handlers?: Partial<GatewayHandlers>
/**
* @deprecated Use with caution
*
@@ -176,122 +146,10 @@ export interface Bot {
/** The functions that should transform discord objects to discordeno shaped objects. */
transformers: Transformers
/** The handler functions that should handle incoming discord payloads from gateway and call an event. */
handlers: ReturnType<typeof createBotGatewayHandlers>
handlers: GatewayHandlers
helpers: BotHelpers
/** Start the bot connection to the gateway. */
start: () => Promise<void>
/** Shuts down all the bot connections to the gateway. */
shutdown: () => Promise<void>
}
export interface EventHandlers {
debug: (text: string, ...args: any[]) => unknown
applicationCommandPermissionsUpdate: (command: GuildApplicationCommandPermissions) => unknown
guildAuditLogEntryCreate: (log: AuditLogEntry, guildId: bigint) => unknown
automodRuleCreate: (rule: AutoModerationRule) => unknown
automodRuleUpdate: (rule: AutoModerationRule) => unknown
automodRuleDelete: (rule: AutoModerationRule) => unknown
automodActionExecution: (payload: AutoModerationActionExecution) => unknown
threadCreate: (thread: Channel) => unknown
threadDelete: (thread: Channel) => unknown
threadListSync: (payload: { guildId: bigint; channelIds?: bigint[]; threads: Channel[]; members: ThreadMember[] }) => unknown
threadMemberUpdate: (payload: { id: bigint; guildId: bigint; joinedAt: number; flags: number }) => unknown
threadMembersUpdate: (payload: { id: bigint; guildId: bigint; addedMembers?: ThreadMember[]; removedMemberIds?: bigint[] }) => unknown
threadUpdate: (thread: Channel) => unknown
scheduledEventCreate: (event: ScheduledEvent) => unknown
scheduledEventUpdate: (event: ScheduledEvent) => unknown
scheduledEventDelete: (event: ScheduledEvent) => unknown
/** Sent when a user has subscribed to a guild scheduled event. EXPERIMENTAL! */
scheduledEventUserAdd: (payload: { guildScheduledEventId: bigint; guildId: bigint; userId: bigint }) => unknown
/** Sent when a user has unsubscribed to a guild scheduled event. EXPERIMENTAL! */
scheduledEventUserRemove: (payload: { guildScheduledEventId: bigint; guildId: bigint; userId: bigint }) => unknown
ready: (
payload: {
shardId: number
v: number
user: User
guilds: bigint[]
sessionId: string
shard?: number[]
applicationId: bigint
},
rawPayload: DiscordReady,
) => unknown
interactionCreate: (interaction: Interaction) => unknown
integrationCreate: (integration: Integration) => unknown
integrationDelete: (payload: { id: bigint; guildId: bigint; applicationId?: bigint }) => unknown
integrationUpdate: (payload: { guildId: bigint }) => unknown
inviteCreate: (invite: Invite) => unknown
inviteDelete: (payload: { channelId: bigint; guildId?: bigint; code: string }) => unknown
guildMemberAdd: (member: Member, user: User) => unknown
guildMemberRemove: (user: User, guildId: bigint) => unknown
guildMemberUpdate: (member: Member, user: User) => unknown
guildStickersUpdate: (payload: { guildId: bigint; stickers: Sticker[] }) => unknown
messageCreate: (message: Message) => unknown
messageDelete: (payload: { id: bigint; channelId: bigint; guildId?: bigint }, message?: Message) => unknown
messageDeleteBulk: (payload: { ids: bigint[]; channelId: bigint; guildId?: bigint }) => unknown
messageUpdate: (message: Message) => unknown
reactionAdd: (payload: {
userId: bigint
channelId: bigint
messageId: bigint
guildId?: bigint
member?: Member
user?: User
emoji: Emoji
messageAuthorId?: bigint
burst: boolean
burstColors?: string[]
}) => unknown
reactionRemove: (payload: { userId: bigint; channelId: bigint; messageId: bigint; guildId?: bigint; emoji: Emoji; burst: boolean }) => unknown
reactionRemoveEmoji: (payload: { channelId: bigint; messageId: bigint; guildId?: bigint; emoji: Emoji }) => unknown
reactionRemoveAll: (payload: { channelId: bigint; messageId: bigint; guildId?: bigint }) => unknown
presenceUpdate: (presence: PresenceUpdate) => unknown
voiceChannelEffectSend: (payload: {
channelId: bigint
guildId: bigint
userId: bigint
emoji?: Emoji
animationType?: DiscordVoiceChannelEffectAnimationType
animationId?: number
soundId?: bigint | number
soundVolume?: number
}) => unknown
voiceServerUpdate: (payload: { token: string; endpoint?: string; guildId: bigint }) => unknown
voiceStateUpdate: (voiceState: VoiceState) => unknown
channelCreate: (channel: Channel) => unknown
dispatchRequirements: (data: DiscordGatewayPayload, shardId: number) => unknown
channelDelete: (channel: Channel) => unknown
channelPinsUpdate: (data: { guildId?: bigint; channelId: bigint; lastPinTimestamp?: number }) => unknown
channelUpdate: (channel: Channel) => unknown
stageInstanceCreate: (data: { id: bigint; guildId: bigint; channelId: bigint; topic: string }) => unknown
stageInstanceDelete: (data: { id: bigint; guildId: bigint; channelId: bigint; topic: string }) => unknown
stageInstanceUpdate: (data: { id: bigint; guildId: bigint; channelId: bigint; topic: string }) => unknown
guildEmojisUpdate: (payload: { guildId: bigint; emojis: Collection<bigint, Emoji> }) => unknown
guildBanAdd: (user: User, guildId: bigint) => unknown
guildBanRemove: (user: User, guildId: bigint) => unknown
guildCreate: (guild: Guild) => unknown
guildDelete: (id: bigint, shardId: number) => unknown
guildUnavailable: (id: bigint, shardId: number) => unknown
guildUpdate: (guild: Guild) => unknown
raw: (data: DiscordGatewayPayload, shardId: number) => unknown
roleCreate: (role: Role) => unknown
roleDelete: (payload: { guildId: bigint; roleId: bigint }) => unknown
roleUpdate: (role: Role) => unknown
webhooksUpdate: (payload: { channelId: bigint; guildId: bigint }) => unknown
botUpdate: (user: User) => unknown
typingStart: (payload: { guildId: bigint | undefined; channelId: bigint; userId: bigint; timestamp: number; member: Member | undefined }) => unknown
entitlementCreate: (entitlement: Entitlement) => unknown
entitlementUpdate: (entitlement: Entitlement) => unknown
entitlementDelete: (entitlement: Entitlement) => unknown
subscriptionCreate: (subscription: Subscription) => unknown
subscriptionUpdate: (subscription: Subscription) => unknown
subscriptionDelete: (subscription: Subscription) => unknown
messagePollVoteAdd: (payload: { userId: bigint; channelId: bigint; messageId: bigint; guildId?: bigint; answerId: number }) => unknown
messagePollVoteRemove: (payload: { userId: bigint; channelId: bigint; messageId: bigint; guildId?: bigint; answerId: number }) => unknown
soundboardSoundCreate: (payload: SoundboardSound) => unknown
soundboardSoundUpdate: (payload: SoundboardSound) => unknown
soundboardSoundDelete: (payload: { soundId: bigint; guildId: bigint }) => unknown
soundboardSoundsUpdate: (payload: { soundboardSounds: SoundboardSound[]; guildId: bigint }) => unknown
soundboardSounds: (payload: { soundboardSounds: SoundboardSound[]; guildId: bigint }) => unknown
}

File diff suppressed because it is too large Load Diff

138
packages/bot/src/events.ts Normal file
View File

@@ -0,0 +1,138 @@
import type { DiscordGatewayPayload, DiscordReady, DiscordVoiceChannelEffectAnimationType } from '@discordeno/types'
import type { Collection } from '@discordeno/utils'
import type {
AuditLogEntry,
AutoModerationActionExecution,
AutoModerationRule,
Channel,
Emoji,
Entitlement,
Guild,
GuildApplicationCommandPermissions,
Integration,
Interaction,
Invite,
Member,
Message,
PresenceUpdate,
Role,
ScheduledEvent,
SoundboardSound,
Sticker,
Subscription,
ThreadMember,
User,
VoiceState,
} from './transformers/types.js'
export interface EventHandlers {
debug: (text: string, ...args: any[]) => unknown
applicationCommandPermissionsUpdate: (command: GuildApplicationCommandPermissions) => unknown
guildAuditLogEntryCreate: (log: AuditLogEntry, guildId: bigint) => unknown
automodRuleCreate: (rule: AutoModerationRule) => unknown
automodRuleUpdate: (rule: AutoModerationRule) => unknown
automodRuleDelete: (rule: AutoModerationRule) => unknown
automodActionExecution: (payload: AutoModerationActionExecution) => unknown
threadCreate: (thread: Channel) => unknown
threadDelete: (thread: Channel) => unknown
threadListSync: (payload: { guildId: bigint; channelIds?: bigint[]; threads: Channel[]; members: ThreadMember[] }) => unknown
threadMemberUpdate: (payload: { id: bigint; guildId: bigint; joinedAt: number; flags: number }) => unknown
threadMembersUpdate: (payload: { id: bigint; guildId: bigint; addedMembers?: ThreadMember[]; removedMemberIds?: bigint[] }) => unknown
threadUpdate: (thread: Channel) => unknown
scheduledEventCreate: (event: ScheduledEvent) => unknown
scheduledEventUpdate: (event: ScheduledEvent) => unknown
scheduledEventDelete: (event: ScheduledEvent) => unknown
/** Sent when a user has subscribed to a guild scheduled event. EXPERIMENTAL! */
scheduledEventUserAdd: (payload: { guildScheduledEventId: bigint; guildId: bigint; userId: bigint }) => unknown
/** Sent when a user has unsubscribed to a guild scheduled event. EXPERIMENTAL! */
scheduledEventUserRemove: (payload: { guildScheduledEventId: bigint; guildId: bigint; userId: bigint }) => unknown
ready: (
payload: {
shardId: number
v: number
user: User
guilds: bigint[]
sessionId: string
shard?: number[]
applicationId: bigint
},
rawPayload: DiscordReady,
) => unknown
interactionCreate: (interaction: Interaction) => unknown
integrationCreate: (integration: Integration) => unknown
integrationDelete: (payload: { id: bigint; guildId: bigint; applicationId?: bigint }) => unknown
integrationUpdate: (payload: { guildId: bigint }) => unknown
inviteCreate: (invite: Invite) => unknown
inviteDelete: (payload: { channelId: bigint; guildId?: bigint; code: string }) => unknown
guildMemberAdd: (member: Member, user: User) => unknown
guildMemberRemove: (user: User, guildId: bigint) => unknown
guildMemberUpdate: (member: Member, user: User) => unknown
guildStickersUpdate: (payload: { guildId: bigint; stickers: Sticker[] }) => unknown
messageCreate: (message: Message) => unknown
messageDelete: (payload: { id: bigint; channelId: bigint; guildId?: bigint }, message?: Message) => unknown
messageDeleteBulk: (payload: { ids: bigint[]; channelId: bigint; guildId?: bigint }) => unknown
messageUpdate: (message: Message) => unknown
reactionAdd: (payload: {
userId: bigint
channelId: bigint
messageId: bigint
guildId?: bigint
member?: Member
user?: User
emoji: Emoji
messageAuthorId?: bigint
burst: boolean
burstColors?: string[]
}) => unknown
reactionRemove: (payload: { userId: bigint; channelId: bigint; messageId: bigint; guildId?: bigint; emoji: Emoji; burst: boolean }) => unknown
reactionRemoveEmoji: (payload: { channelId: bigint; messageId: bigint; guildId?: bigint; emoji: Emoji }) => unknown
reactionRemoveAll: (payload: { channelId: bigint; messageId: bigint; guildId?: bigint }) => unknown
presenceUpdate: (presence: PresenceUpdate) => unknown
voiceChannelEffectSend: (payload: {
channelId: bigint
guildId: bigint
userId: bigint
emoji?: Emoji
animationType?: DiscordVoiceChannelEffectAnimationType
animationId?: number
soundId?: bigint | number
soundVolume?: number
}) => unknown
voiceServerUpdate: (payload: { token: string; endpoint?: string; guildId: bigint }) => unknown
voiceStateUpdate: (voiceState: VoiceState) => unknown
channelCreate: (channel: Channel) => unknown
dispatchRequirements: (data: DiscordGatewayPayload, shardId: number) => unknown
channelDelete: (channel: Channel) => unknown
channelPinsUpdate: (data: { guildId?: bigint; channelId: bigint; lastPinTimestamp?: number }) => unknown
channelUpdate: (channel: Channel) => unknown
stageInstanceCreate: (data: { id: bigint; guildId: bigint; channelId: bigint; topic: string }) => unknown
stageInstanceDelete: (data: { id: bigint; guildId: bigint; channelId: bigint; topic: string }) => unknown
stageInstanceUpdate: (data: { id: bigint; guildId: bigint; channelId: bigint; topic: string }) => unknown
guildEmojisUpdate: (payload: { guildId: bigint; emojis: Collection<bigint, Emoji> }) => unknown
guildBanAdd: (user: User, guildId: bigint) => unknown
guildBanRemove: (user: User, guildId: bigint) => unknown
guildCreate: (guild: Guild) => unknown
guildDelete: (id: bigint, shardId: number) => unknown
guildUnavailable: (id: bigint, shardId: number) => unknown
guildUpdate: (guild: Guild) => unknown
raw: (data: DiscordGatewayPayload, shardId: number) => unknown
roleCreate: (role: Role) => unknown
roleDelete: (payload: { guildId: bigint; roleId: bigint }) => unknown
roleUpdate: (role: Role) => unknown
webhooksUpdate: (payload: { channelId: bigint; guildId: bigint }) => unknown
botUpdate: (user: User) => unknown
typingStart: (payload: { guildId: bigint | undefined; channelId: bigint; userId: bigint; timestamp: number; member: Member | undefined }) => unknown
entitlementCreate: (entitlement: Entitlement) => unknown
entitlementUpdate: (entitlement: Entitlement) => unknown
entitlementDelete: (entitlement: Entitlement) => unknown
subscriptionCreate: (subscription: Subscription) => unknown
subscriptionUpdate: (subscription: Subscription) => unknown
subscriptionDelete: (subscription: Subscription) => unknown
messagePollVoteAdd: (payload: { userId: bigint; channelId: bigint; messageId: bigint; guildId?: bigint; answerId: number }) => unknown
messagePollVoteRemove: (payload: { userId: bigint; channelId: bigint; messageId: bigint; guildId?: bigint; answerId: number }) => unknown
soundboardSoundCreate: (payload: SoundboardSound) => unknown
soundboardSoundUpdate: (payload: SoundboardSound) => unknown
soundboardSoundDelete: (payload: { soundId: bigint; guildId: bigint }) => unknown
soundboardSoundsUpdate: (payload: { soundboardSounds: SoundboardSound[]; guildId: bigint }) => unknown
soundboardSounds: (payload: { soundboardSounds: SoundboardSound[]; guildId: bigint }) => unknown
}

View File

@@ -1,10 +1,7 @@
import * as handlers from './handlers/index.js'
import type { Bot, DiscordGatewayPayload, GatewayDispatchEventNames } from './index.js'
import type { BotGatewayHandlerOptions } from './typings.js'
export function createBotGatewayHandlers(
options: Partial<BotGatewayHandlerOptions>,
): Record<GatewayDispatchEventNames, (bot: Bot, data: DiscordGatewayPayload, shardId: number) => any> {
export function createBotGatewayHandlers(options: Partial<GatewayHandlers>): GatewayHandlers {
return {
APPLICATION_COMMAND_PERMISSIONS_UPDATE: options.APPLICATION_COMMAND_PERMISSIONS_UPDATE ?? handlers.handleApplicationCommandPermissionsUpdate,
AUTO_MODERATION_ACTION_EXECUTION: options.AUTO_MODERATION_ACTION_EXECUTION ?? handlers.handleAutoModerationActionExecution,
@@ -83,4 +80,5 @@ export function createBotGatewayHandlers(
}
}
export interface GatewayHandlers extends ReturnType<typeof createBotGatewayHandlers> {}
export type GatewayHandlers = Record<GatewayDispatchEventNames, BotGatewayHandler>
export type BotGatewayHandler = (bot: Bot, data: DiscordGatewayPayload, shardId: number) => unknown

View File

@@ -1,4 +1,3 @@
import type { CreateWebhook } from '@discordeno/rest'
import type {
AddDmRecipientOptions,
AddGuildMemberOptions,
@@ -6,26 +5,6 @@ import type {
BeginGuildPrune,
BigString,
Camelize,
CamelizedDiscordAccessTokenResponse,
CamelizedDiscordApplicationCommandPermissions,
CamelizedDiscordApplicationRoleConnection,
CamelizedDiscordArchivedThreads,
CamelizedDiscordAuditLog,
CamelizedDiscordBan,
CamelizedDiscordConnection,
CamelizedDiscordCurrentAuthorization,
CamelizedDiscordFollowedChannel,
CamelizedDiscordGetGatewayBot,
CamelizedDiscordGuildPreview,
CamelizedDiscordGuildWidgetSettings,
CamelizedDiscordInvite,
CamelizedDiscordInviteMetadata,
CamelizedDiscordModifyGuildWelcomeScreen,
CamelizedDiscordPrunedCount,
CamelizedDiscordTokenExchange,
CamelizedDiscordTokenRevocation,
CamelizedDiscordVanityUrl,
CamelizedDiscordVoiceRegion,
CreateApplicationCommand,
CreateApplicationEmoji,
CreateAutoModerationRuleOptions,
@@ -47,11 +26,32 @@ import type {
CreateScheduledEvent,
CreateStageInstance,
CreateTemplate,
CreateWebhook,
DeleteWebhookMessageOptions,
DiscordAccessTokenResponse,
DiscordActivityInstance,
DiscordApplicationCommandPermissions,
DiscordApplicationRoleConnection,
DiscordArchivedThreads,
DiscordAuditLog,
DiscordBan,
DiscordConnection,
DiscordCurrentAuthorization,
DiscordEntitlement,
DiscordFollowedChannel,
DiscordGetGatewayBot,
DiscordGuildPreview,
DiscordGuildWidgetSettings,
DiscordInvite,
DiscordInviteMetadata,
DiscordMessage,
DiscordModifyGuildWelcomeScreen,
DiscordPrunedCount,
DiscordSubscription,
DiscordTokenExchange,
DiscordTokenRevocation,
DiscordVanityUrl,
DiscordVoiceRegion,
EditApplication,
EditAutoModerationRuleOptions,
EditBotMemberOptions,
@@ -818,7 +818,7 @@ export interface BotHelpers {
createGuildFromTemplate: (templateCode: string, options: CreateGuildFromTemplate) => Promise<Guild>
createGuildSticker: (guildId: BigString, options: CreateGuildStickerOptions, reason?: string) => Promise<Sticker>
createGuildTemplate: (guildId: BigString, options: CreateTemplate) => Promise<Template>
createInvite: (channelId: BigString, options?: CreateChannelInvite, reason?: string) => Promise<CamelizedDiscordInvite>
createInvite: (channelId: BigString, options?: CreateChannelInvite, reason?: string) => Promise<Camelize<DiscordInvite>>
createRole: (guildId: BigString, options: CreateGuildRole, reason?: string) => Promise<Role>
createScheduledEvent: (guildId: BigString, options: CreateScheduledEvent, reason?: string) => Promise<ScheduledEvent>
createStageInstance: (options: CreateStageInstance, reason?: string) => Promise<StageInstance>
@@ -827,7 +827,7 @@ export interface BotHelpers {
guildId: BigString,
commandId: BigString,
bearerToken: string,
options: CamelizedDiscordApplicationCommandPermissions[],
options: Camelize<DiscordApplicationCommandPermissions>[],
) => Promise<GuildApplicationCommandPermissions>
editAutomodRule: (
guildId: BigString,
@@ -860,21 +860,21 @@ export interface BotHelpers {
options: InteractionCallbackData & { threadId?: BigString },
) => Promise<Message>
editWebhookWithToken: (webhookId: BigString, token: string, options: Omit<ModifyWebhook, 'channelId'>) => Promise<Webhook>
editWelcomeScreen: (guildId: BigString, options: CamelizedDiscordModifyGuildWelcomeScreen, reason?: string) => Promise<WelcomeScreen>
editWidgetSettings: (guildId: BigString, options: CamelizedDiscordGuildWidgetSettings, reason?: string) => Promise<GuildWidgetSettings>
editWelcomeScreen: (guildId: BigString, options: Camelize<DiscordModifyGuildWelcomeScreen>, reason?: string) => Promise<WelcomeScreen>
editWidgetSettings: (guildId: BigString, options: Camelize<DiscordGuildWidgetSettings>, reason?: string) => Promise<GuildWidgetSettings>
editUserApplicationRoleConnection: (
bearerToken: string,
applicationId: BigString,
options: CamelizedDiscordApplicationRoleConnection,
) => Promise<CamelizedDiscordApplicationRoleConnection>
options: Camelize<DiscordApplicationRoleConnection>,
) => Promise<Camelize<DiscordApplicationRoleConnection>>
executeWebhook: (webhookId: BigString, token: string, options: ExecuteWebhook) => Promise<Message | undefined>
followAnnouncement: (sourceChannelId: BigString, targetChannelId: BigString) => Promise<CamelizedDiscordFollowedChannel>
followAnnouncement: (sourceChannelId: BigString, targetChannelId: BigString) => Promise<Camelize<DiscordFollowedChannel>>
getActiveThreads: (guildId: BigString) => Promise<{ threads: Channel[]; members: ThreadMember[] }>
getApplicationInfo: () => Promise<Application>
editApplicationInfo: (body: EditApplication) => Promise<Application>
getCurrentAuthenticationInfo: (bearerToken: string) => Promise<CamelizedDiscordCurrentAuthorization>
exchangeToken: (clientId: BigString, clientSecret: string, options: CamelizedDiscordTokenExchange) => Promise<CamelizedDiscordAccessTokenResponse>
revokeToken: (clientId: BigString, clientSecret: string, options: CamelizedDiscordTokenRevocation) => Promise<void>
getCurrentAuthenticationInfo: (bearerToken: string) => Promise<Camelize<DiscordCurrentAuthorization>>
exchangeToken: (clientId: BigString, clientSecret: string, options: Camelize<DiscordTokenExchange>) => Promise<Camelize<DiscordAccessTokenResponse>>
revokeToken: (clientId: BigString, clientSecret: string, options: Camelize<DiscordTokenRevocation>) => Promise<void>
getApplicationCommandPermission: (
guildId: BigString,
commandId: BigString,
@@ -884,14 +884,14 @@ export interface BotHelpers {
guildId: BigString,
options?: GetApplicationCommandPermissionOptions,
) => Promise<GuildApplicationCommandPermissions[]>
getAuditLog: (guildId: BigString, options?: GetGuildAuditLog) => Promise<CamelizedDiscordAuditLog>
getAuditLog: (guildId: BigString, options?: GetGuildAuditLog) => Promise<Camelize<DiscordAuditLog>>
getAutomodRule: (guildId: BigString, ruleId: BigString) => Promise<AutoModerationRule>
getAutomodRules: (guildId: BigString) => Promise<AutoModerationRule[]>
getAvailableVoiceRegions: () => Promise<CamelizedDiscordVoiceRegion[]>
getBan: (guildId: BigString, userId: BigString) => Promise<CamelizedDiscordBan>
getBans: (guildId: BigString, options?: GetBans) => Promise<CamelizedDiscordBan[]>
getAvailableVoiceRegions: () => Promise<Camelize<DiscordVoiceRegion>[]>
getBan: (guildId: BigString, userId: BigString) => Promise<Camelize<DiscordBan>>
getBans: (guildId: BigString, options?: GetBans) => Promise<Camelize<DiscordBan>[]>
getChannel: (channelId: BigString) => Promise<Channel>
getChannelInvites: (channelId: BigString) => Promise<CamelizedDiscordInviteMetadata[]>
getChannelInvites: (channelId: BigString) => Promise<Camelize<DiscordInviteMetadata>[]>
getChannels: (guildId: BigString) => Promise<Channel[]>
getChannelWebhooks: (channelId: BigString) => Promise<Webhook[]>
getDmChannel: (userId: BigString) => Promise<Channel>
@@ -901,14 +901,14 @@ export interface BotHelpers {
getEmojis: (guildId: BigString) => Promise<Emoji[]>
getApplicationEmojis: () => Promise<{ items: Emoji[] }>
getFollowupMessage: (token: string, messageId: BigString) => Promise<Message>
getGatewayBot: () => Promise<CamelizedDiscordGetGatewayBot>
getGatewayBot: () => Promise<Camelize<DiscordGetGatewayBot>>
getGlobalApplicationCommand: (commandId: BigString) => Promise<ApplicationCommand>
getGlobalApplicationCommands: () => Promise<ApplicationCommand[]>
getGuild: (guildId: BigString, options?: { counts?: boolean }) => Promise<Guild>
getGuilds: (bearerToken: string, options?: GetUserGuilds) => Promise<Partial<Guild>[]>
getGuildApplicationCommand: (commandId: BigString, guildId: BigString) => Promise<ApplicationCommand>
getGuildApplicationCommands: (guildId: BigString) => Promise<ApplicationCommand[]>
getGuildPreview: (guildId: BigString) => Promise<CamelizedDiscordGuildPreview>
getGuildPreview: (guildId: BigString) => Promise<Camelize<DiscordGuildPreview>>
getGuildSticker: (guildId: BigString, stickerId: BigString) => Promise<Sticker>
getGuildStickers: (guildId: BigString) => Promise<Sticker[]>
getGuildTemplate: (templateCode: string) => Promise<Template>
@@ -923,10 +923,10 @@ export interface BotHelpers {
getStickerPacks: () => Promise<StickerPack[]>
getOriginalInteractionResponse: (token: string) => Promise<Message>
getPinnedMessages: (channelId: BigString) => Promise<Message[]>
getPrivateArchivedThreads: (channelId: BigString, options?: ListArchivedThreads) => Promise<CamelizedDiscordArchivedThreads>
getPrivateJoinedArchivedThreads: (channelId: BigString, options?: ListArchivedThreads) => Promise<CamelizedDiscordArchivedThreads>
getPruneCount: (guildId: BigString, options?: GetGuildPruneCountQuery) => Promise<CamelizedDiscordPrunedCount>
getPublicArchivedThreads: (channelId: BigString, options?: ListArchivedThreads) => Promise<CamelizedDiscordArchivedThreads>
getPrivateArchivedThreads: (channelId: BigString, options?: ListArchivedThreads) => Promise<Camelize<DiscordArchivedThreads>>
getPrivateJoinedArchivedThreads: (channelId: BigString, options?: ListArchivedThreads) => Promise<Camelize<DiscordArchivedThreads>>
getPruneCount: (guildId: BigString, options?: GetGuildPruneCountQuery) => Promise<Camelize<DiscordPrunedCount>>
getPublicArchivedThreads: (channelId: BigString, options?: ListArchivedThreads) => Promise<Camelize<DiscordArchivedThreads>>
getRoles: (guildId: BigString) => Promise<Role[]>
getRole: (guildId: BigString, roleId: BigString) => Promise<Role>
getScheduledEvent: (guildId: BigString, eventId: BigString, options?: { withUserCount?: boolean }) => Promise<ScheduledEvent>
@@ -936,7 +936,7 @@ export interface BotHelpers {
eventId: BigString,
options?: GetScheduledEventUsers,
) => Promise<Array<{ user: User; member?: Member }>>
getSessionInfo: () => Promise<CamelizedDiscordGetGatewayBot>
getSessionInfo: () => Promise<Camelize<DiscordGetGatewayBot>>
getStageInstance: (channelId: BigString) => Promise<StageInstance>
getOwnVoiceState: (guildId: BigString) => Promise<VoiceState>
getUserVoiceState: (guildId: BigString, userId: BigString) => Promise<VoiceState>
@@ -946,10 +946,10 @@ export interface BotHelpers {
getReactions: (channelId: BigString, messageId: BigString, reaction: string, options?: GetReactions) => Promise<User[]>
getUser: (id: BigString) => Promise<User>
getCurrentUser: (bearerToken: string) => Promise<User>
getUserConnections: (bearerToken: string) => Promise<CamelizedDiscordConnection[]>
getUserApplicationRoleConnection: (bearerToken: string, applicationId: BigString) => Promise<CamelizedDiscordApplicationRoleConnection>
getVanityUrl: (guildId: BigString) => Promise<CamelizedDiscordVanityUrl>
getVoiceRegions: (guildId: BigString) => Promise<CamelizedDiscordVoiceRegion[]>
getUserConnections: (bearerToken: string) => Promise<Camelize<DiscordConnection>[]>
getUserApplicationRoleConnection: (bearerToken: string, applicationId: BigString) => Promise<Camelize<DiscordApplicationRoleConnection>>
getVanityUrl: (guildId: BigString) => Promise<Camelize<DiscordVanityUrl>>
getVoiceRegions: (guildId: BigString) => Promise<Camelize<DiscordVoiceRegion>[]>
getWebhook: (webhookId: BigString) => Promise<Webhook>
getWebhookMessage: (webhookId: BigString, token: string, messageId: BigString, options?: GetWebhookMessageOptions) => Promise<Message>
getWebhookWithToken: (webhookId: BigString, token: string) => Promise<Webhook>

View File

@@ -8,8 +8,8 @@ export * from './constants.js'
export * from './handlers/index.js'
export * from './handlers.js'
export * from './helpers.js'
export * from './optionalize.js'
export * from './transformers/index.js'
export * from './transformers.js'
export * from './typings.js'
export * from './events.js'
export * from './desiredProperties.js'
export * from './utils.js'

View File

@@ -1,73 +0,0 @@
export type OptionalizeAux<T extends object> = Id<
{
[K in KeysWithUndefined<T>]?: Optionalize<T[K]>
} & {
[K in Exclude<keyof T, KeysWithUndefined<T>>]: T[K] extends ObjectLiteral ? Optionalize<T[K]> : T[K]
}
>
/**
* Makes all of properties in T optional when they're null | undefined
* it is recursive
*/
export type Optionalize<T> = T extends object
? T extends unknown[]
? number extends T['length']
? T[number] extends object
? OptionalizeAux<T[number]>[]
: T
: Partial<T>
: OptionalizeAux<T>
: T
export type KeysWithUndefined<T> = {
[K in keyof T]-?: undefined extends T[K] ? K : null extends T[K] ? K : never
}[keyof T]
/**
* alternative to 'object' or '{}'
* @example:
* export const o: ObjectLiteral = [] as object; // error
* export const o: object = []; // no error
*/
export type ObjectLiteral<T = unknown> = {
[K in PropertyKey]: T
}
/**
* object identity type
*/
export type Id<T> = T extends infer U
? {
[K in keyof U]: U[K]
}
: never
/** Array with no utilty methods, aka Object.create(null) */
export interface ArrayWithNoPrototype<T> {
[index: number]: T | ArrayWithNoPrototype<T>
}
/**
* Allows any type but T
* it is recursive
* @example
* export type RequestData = Record<string, AnythingBut<bigint>>;
*/
export type AnythingBut<T> = Exclude<
| Primitive
| {
[K in PropertyKey]: AnythingBut<T>
}
| ArrayWithNoPrototype<
| Primitive
| {
[K in PropertyKey]: AnythingBut<T>
}
>,
T
>
/** Non object primitives */
export type Primitive = string | number | symbol | bigint | boolean | undefined | null
// | object <- don't make object a primitive

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
import type { DiscordAuditLogEntry } from '@discordeno/types'
import { type AuditLogEntry, type Bot } from '../index.js'
import type { AuditLogEntry, Bot } from '../index.js'
export function transformAuditLogEntry(bot: Bot, payload: DiscordAuditLogEntry): AuditLogEntry {
const auditLogEntry = {

View File

@@ -1,13 +1,48 @@
import {
type DiscordActionRow,
type DiscordButtonComponent,
type DiscordInputTextComponent,
type DiscordMessageComponent,
type DiscordSelectMenuComponent,
MessageComponentTypes,
} from '@discordeno/types'
import type { Bot, Component } from '../index.js'
import type { DiscordComponent } from '../typings.js'
export function transformComponent(bot: Bot, payload: DiscordComponent): Component {
const component = {
type: payload.type,
customId: payload.custom_id,
disabled: payload.disabled,
style: payload.style,
export function transformComponent(bot: Bot, payload: DiscordMessageComponent): Component {
let component: Component
// This switch is exhaustive, so we dont need the default case and TS does not error out for the un-initialized component variable
switch (payload.type) {
case MessageComponentTypes.ActionRow:
component = transformActionRow(bot, payload)
case MessageComponentTypes.Button:
component = transformButtonComponent(bot, payload as DiscordButtonComponent)
case MessageComponentTypes.InputText:
component = transformInputTextComponent(bot, payload as DiscordInputTextComponent)
case MessageComponentTypes.SelectMenu:
case MessageComponentTypes.SelectMenuChannels:
case MessageComponentTypes.SelectMenuRoles:
case MessageComponentTypes.SelectMenuUsers:
case MessageComponentTypes.SelectMenuUsersAndRoles:
component = transformSelectMenuComponent(bot, payload as DiscordSelectMenuComponent)
}
return bot.transformers.customizers.component(bot, payload, component)
}
function transformActionRow(bot: Bot, payload: DiscordActionRow): Component {
return {
type: MessageComponentTypes.ActionRow,
components: payload.components.map((component) => bot.transformers.component(bot, component)),
}
}
function transformButtonComponent(bot: Bot, payload: DiscordButtonComponent): Component {
return {
type: MessageComponentTypes.Button,
label: payload.label,
customId: payload.custom_id,
style: payload.style,
emoji: payload.emoji
? {
id: payload.emoji.id ? bot.transformers.snowflake(payload.emoji.id) : undefined,
@@ -16,6 +51,36 @@ export function transformComponent(bot: Bot, payload: DiscordComponent): Compone
}
: undefined,
url: payload.url,
disabled: payload.disabled,
skuId: payload.sku_id ? bot.transformers.snowflake(payload.sku_id) : undefined,
}
}
function transformInputTextComponent(_bot: Bot, payload: DiscordInputTextComponent): Component {
return {
type: MessageComponentTypes.InputText,
style: payload.style,
required: payload.required,
customId: payload.custom_id,
label: payload.label,
placeholder: payload.placeholder,
minLength: payload.min_length,
maxLength: payload.max_length,
value: payload.value,
}
}
function transformSelectMenuComponent(bot: Bot, payload: DiscordSelectMenuComponent): Component {
return {
type: payload.type,
customId: payload.custom_id,
placeholder: payload.placeholder,
minValues: payload.min_values,
maxValues: payload.max_values,
defaultValues: payload.default_values?.map((defaultValue) => ({
id: bot.transformers.snowflake(defaultValue.id),
type: defaultValue.type,
})),
channelTypes: payload.channel_types,
options: payload.options?.map((option) => ({
label: option.label,
@@ -30,14 +95,6 @@ export function transformComponent(bot: Bot, payload: DiscordComponent): Compone
: undefined,
default: option.default,
})),
placeholder: payload.placeholder,
minValues: payload.min_values,
maxValues: payload.max_values,
minLength: payload.min_length,
maxLength: payload.max_length,
value: payload.value,
components: payload.components?.map((component) => bot.transformers.component(bot, component)),
disabled: payload.disabled,
}
return bot.transformers.customizers.component(bot, payload, component)
}

View File

@@ -42,6 +42,7 @@ export * from './user.js'
export * from './voiceRegion.js'
export * from './voiceState.js'
export * from './webhook.js'
export * from './subscription.js'
export * from './welcomeScreen.js'
export * from './widget.js'
export * from './widgetSettings.js'

View File

@@ -1,30 +1,29 @@
import {
type ChannelTypes,
DiscordApplicationIntegrationType,
type DiscordInteraction,
type DiscordInteractionCallback,
type DiscordInteractionCallbackResponse,
type DiscordInteractionDataOption,
type DiscordInteractionDataResolved,
type DiscordInteractionResource,
InteractionResponseTypes,
InteractionTypes,
MessageFlags,
} from '@discordeno/types'
import { Collection } from '@discordeno/utils'
import {
type Bot,
type DiscordChannel,
type Interaction,
type InteractionCallback,
type InteractionCallbackResponse,
type InteractionDataOption,
type InteractionDataResolved,
type InteractionResolvedChannel,
type InteractionResource,
type Member,
type Message,
import type {
Bot,
DiscordChannel,
Interaction,
InteractionCallback,
InteractionCallbackResponse,
InteractionDataOption,
InteractionDataResolved,
InteractionResolvedChannel,
InteractionResource,
Member,
Message,
} from '../index.js'
import type { DiscordInteractionDataResolved } from '../typings.js'
const baseInteraction = {
async respond(response, options) {

View File

@@ -1,4 +1,4 @@
import { type BigString, type DiscordMember } from '@discordeno/types'
import type { BigString, DiscordMember } from '@discordeno/types'
import { iconHashToBigInt } from '@discordeno/utils'
import type { Bot } from '../bot.js'
import { Permissions } from './toggles/Permissions.js'

View File

@@ -1,5 +1,5 @@
import type { DiscordGuildOnboarding, DiscordGuildOnboardingPrompt, DiscordGuildOnboardingPromptOption } from '@discordeno/types'
import { type Bot, type GuildOnboarding, type GuildOnboardingPrompt, type GuildOnboardingPromptOption } from '../index.js'
import type { Bot, GuildOnboarding, GuildOnboardingPrompt, GuildOnboardingPromptOption } from '../index.js'
export function transformGuildOnboarding(bot: Bot, payload: DiscordGuildOnboarding): GuildOnboarding {
const props = bot.transformers.desiredProperties.guildOnboarding

View File

@@ -1,5 +1,5 @@
import type { DiscordAuditLogEntry } from '@discordeno/types'
import { type AuditLogEntry, type Bot } from '../../index.js'
import type { AuditLogEntry, Bot } from '../../index.js'
export function transformAuditLogEntryToDiscordAuditLogEntry(bot: Bot, payload: AuditLogEntry): DiscordAuditLogEntry {
return {

View File

@@ -1,30 +1,86 @@
import type { Bot, Component } from '../../index.js'
import type { DiscordComponent } from '../../typings.js'
import { type DiscordButtonComponent, type DiscordMessageComponent, MessageComponentTypes, type TextStyles } from '@discordeno/types'
import type { Bot, ButtonStyles, Component, DiscordActionRow, DiscordInputTextComponent, DiscordSelectMenuComponent } from '../../index.js'
export function transformComponentToDiscordComponent(bot: Bot, payload: Component): DiscordComponent {
export function transformComponentToDiscordComponent(bot: Bot, payload: Component): DiscordMessageComponent {
// This switch should include all cases
switch (payload.type) {
case MessageComponentTypes.ActionRow:
return transformActionRow(bot, payload)
case MessageComponentTypes.Button:
return transformButtonComponent(bot, payload)
case MessageComponentTypes.InputText:
return transformInputTextComponent(bot, payload)
case MessageComponentTypes.SelectMenu:
case MessageComponentTypes.SelectMenuChannels:
case MessageComponentTypes.SelectMenuRoles:
case MessageComponentTypes.SelectMenuUsers:
case MessageComponentTypes.SelectMenuUsersAndRoles:
return transformSelectMenuComponent(bot, payload)
}
}
function transformActionRow(bot: Bot, payload: Component): DiscordActionRow {
return {
type: payload.type,
type: MessageComponentTypes.ActionRow,
// The actionRow.components type is kinda annoying, so we need a cast for this
components: (payload.components?.map((component) => bot.transformers.reverse.component(bot, component)) ?? []) as DiscordActionRow['components'],
}
}
function transformButtonComponent(bot: Bot, payload: Component): DiscordButtonComponent {
// Since Component is a merge of all components, some casts are necessary
return {
type: MessageComponentTypes.Button,
style: payload.style as ButtonStyles,
custom_id: payload.customId,
disabled: payload.disabled,
required: payload.required,
style: payload.style,
label: payload.label,
emoji: payload.emoji
? {
id: payload.emoji.id?.toString(),
id: payload.emoji.id ? bot.transformers.reverse.snowflake(payload.emoji.id) : undefined,
name: payload.emoji.name,
animated: payload.emoji.animated,
}
: undefined,
label: payload.label,
url: payload.url,
sku_id: payload.skuId ? bot.transformers.reverse.snowflake(payload.skuId) : undefined,
}
}
function transformInputTextComponent(_bot: Bot, payload: Component): DiscordInputTextComponent {
// Since Component is a merge of all components, some casts are necessary
return {
type: MessageComponentTypes.InputText,
style: payload.style as TextStyles,
custom_id: payload.customId!,
label: payload.label!,
value: payload.value,
max_length: payload.maxLength,
min_length: payload.minLength,
placeholder: payload.placeholder,
required: payload.required,
}
}
function transformSelectMenuComponent(bot: Bot, payload: Component): DiscordSelectMenuComponent {
return {
type: payload.type as DiscordSelectMenuComponent['type'],
custom_id: payload.customId!,
channel_types: payload.channelTypes,
default_values: payload.defaultValues?.map((defaultValue) => ({
id: bot.transformers.reverse.snowflake(defaultValue.id),
type: defaultValue.type,
})),
disabled: payload.disabled,
max_values: payload.maxValues,
min_values: payload.minValues,
options: payload.options?.map((option) => ({
label: option.label,
value: option.value,
description: option.description,
emoji: option.emoji
? {
id: option.emoji.id?.toString(),
id: option.emoji.id ? bot.transformers.reverse.snowflake(option.emoji.id) : undefined,
name: option.emoji.name,
animated: option.emoji.animated,
}
@@ -32,11 +88,5 @@ export function transformComponentToDiscordComponent(bot: Bot, payload: Componen
default: option.default,
})),
placeholder: payload.placeholder,
min_values: payload.minValues,
max_values: payload.maxValues,
min_length: payload.minLength,
max_length: payload.maxLength,
value: payload.value,
components: payload.components?.map((component) => bot.transformers.reverse.component(bot, component)),
}
}

View File

@@ -1,6 +1,5 @@
import { calculateBits } from '@discordeno/utils'
import { calculateBits, isContextApplicationCommand } from '@discordeno/utils'
import type { ApplicationCommandOption, Bot, CreateApplicationCommand, DiscordCreateApplicationCommand } from '../../index.js'
import { isContextApplicationCommand } from '../../typings.js'
export function transformCreateApplicationCommandToDiscordCreateApplicationCommand(
bot: Bot,

View File

@@ -12,7 +12,6 @@ export * from './createApplicationCommand.js'
export * from './embed.js'
export * from './emoji.js'
export * from './gatewayBot.js'
export * from './interactionResponse.js'
export * from './member.js'
export * from './presence.js'
export * from './team.js'

View File

@@ -1,26 +0,0 @@
import type { Bot } from '../../index.js'
import type { BotInteractionResponse, DiscordInteractionResponse } from '../../typings.js'
export function transformInteractionResponseToDiscordInteractionResponse(bot: Bot, payload: BotInteractionResponse): DiscordInteractionResponse {
// If no mentions are provided, force disable mentions
if (payload.data && !payload.data?.allowedMentions) {
payload.data.allowedMentions = { parse: [] }
}
return {
type: payload.type,
data: payload.data
? {
tts: payload.data.tts,
title: payload.data.title,
flags: payload.data.flags,
content: payload.data.content,
choices: payload.data.choices?.map((choice) => bot.transformers.reverse.applicationCommandOptionChoice(bot, choice)),
custom_id: payload.data.customId,
embeds: payload.data.embeds?.map((embed) => bot.transformers.reverse.embed(bot, embed)),
allowed_mentions: bot.transformers.reverse.allowedMentions(bot, payload.data.allowedMentions!),
components: payload.data.components?.map((component) => bot.transformers.reverse.component(bot, component)),
}
: undefined,
}
}

View File

@@ -1,6 +1,5 @@
import type { DiscordThreadMember } from '@discordeno/types'
import type { DiscordThreadMember, DiscordThreadMemberGuildCreate } from '@discordeno/types'
import type { Bot, ThreadMember, ThreadMemberGuildCreate } from '../index.js'
import type { DiscordThreadMemberGuildCreate } from '../typings.js'
export function transformThreadMember(bot: Bot, payload: DiscordThreadMember): ThreadMember {
const threadMember = {

View File

@@ -24,7 +24,6 @@ import type {
DiscordGuildOnboardingPromptType,
DiscordInteractionContextType,
DiscordInviteType,
DiscordOverwrite,
DiscordPollLayoutType,
DiscordScheduledEventRecurrenceRuleFrequency,
DiscordScheduledEventRecurrenceRuleMonth,
@@ -544,6 +543,17 @@ export interface Component {
maxLength?: number
/** a list of child components */
components?: Component[]
/** List of default values for auto-populated select menu components; number of default values must be in the range defined by min_values and max_values */
defaultValues?: DiscordComponentDefaultValue[]
/** Identifier for a purchasable SKU, only available when using premium-style buttons */
skuId?: bigint
}
export interface DiscordComponentDefaultValue {
/** ID of a user, role, or channel */
id: bigint
/** Type of value that id represents. */
type: 'user' | 'role' | 'channel'
}
export interface Embed {

View File

@@ -1,220 +0,0 @@
import {
type AllowedMentions,
ApplicationCommandTypes,
type ButtonStyles,
type ChannelTypes,
type CreateApplicationCommand,
type CreateContextApplicationCommand,
type DiscordAllowedMentions,
type DiscordApplicationCommandOptionChoice,
type DiscordAttachment,
type DiscordChannel,
type DiscordEmbed,
type DiscordInteractionMember,
type DiscordMessage,
type DiscordRole,
type DiscordSelectOption,
type DiscordUser,
type FileContent,
type InteractionResponseTypes,
type MessageComponentTypes,
type MessageComponents,
type TextStyles,
} from '@discordeno/types'
import type * as handlers from './handlers/index.js'
import type { ApplicationCommandOptionChoice, Embed } from './transformers/index.js'
export function isContextApplicationCommand(command: CreateApplicationCommand): command is CreateContextApplicationCommand {
return command.type === ApplicationCommandTypes.Message || command.type === ApplicationCommandTypes.User
}
export interface DiscordInteractionResponse {
type: InteractionResponseTypes
data?: DiscordInteractionCallbackData
}
export interface DiscordInteractionCallbackData {
tts?: boolean
title?: string
flags?: number
content?: string
choices?: DiscordApplicationCommandOptionChoice[]
custom_id?: string
embeds?: DiscordEmbed[]
allowed_mentions?: DiscordAllowedMentions
components?: DiscordComponent[]
}
export interface DiscordComponent {
/** component type */
type: MessageComponentTypes
/** a developer-defined identifier for the component, max 100 characters */
custom_id?: string
/** whether the component is disabled, default false */
disabled?: boolean
/** For different styles/colors of the buttons */
style?: ButtonStyles | TextStyles
/** text that appears on the button (max 80 characters) */
label?: string
/** the dev-define value of the option, max 100 characters for select or 4000 for input. */
value?: string
/** Emoji object that includes fields of name, id, and animated supporting unicode and custom emojis. */
emoji?: {
/** Emoji id */
id?: string
/** Emoji name */
name?: string
/** Whether this emoji is animated */
animated?: boolean
}
/** optional url for link-style buttons that can navigate a user to the web. Only type 5 Link buttons can have a url */
url?: string
/** List of channel types to include in a channel select menu options list */
channel_types?: ChannelTypes[]
/** The choices! Maximum of 25 items. */
options?: DiscordSelectOption[]
/** A custom placeholder text if nothing is selected. Maximum 150 characters. */
placeholder?: string
/** The minimum number of items that must be selected. Default 1. Between 1-25. */
min_values?: number
/** The maximum number of items that can be selected. Default 1. Between 1-25. */
max_values?: number
/** The minimum input length for a text input. Between 0-4000. */
min_length?: number
/** The maximum input length for a text input. Between 1-4000. */
max_length?: number
/** a list of child components */
components?: DiscordComponent[]
/** whether this component is required to be filled, default true */
required?: boolean
}
/** https://discord.com/developers/docs/interactions/slash-commands#interaction-response */
export interface BotInteractionResponse {
/** The type of response */
type: InteractionResponseTypes
/** An optional response message */
data?: BotInteractionCallbackData
}
export interface BotInteractionCallbackData {
/** The message contents (up to 2000 characters) */
content?: string
/** True if this is a TTS message */
tts?: boolean
/** Embedded `rich` content (up to 6000 characters) */
embeds?: Embed[]
/** Allowed mentions for the message */
allowedMentions?: AllowedMentions
/** The contents of the files being sent */
files?: FileContent[]
/** The customId you want to use for this modal response. */
customId?: string
/** The title you want to use for this modal response. */
title?: string
/** The components you would like to have sent in this message */
components?: MessageComponents
/** Message flags combined as a bit field (only SUPPRESS_EMBEDS and EPHEMERAL can be set) */
flags?: number
/** Autocomplete choices (max of 25 choices) */
choices?: ApplicationCommandOptionChoice[]
}
export interface DiscordInteractionDataResolved {
/** The Ids and Message objects */
messages?: Record<string, DiscordMessage>
/** The Ids and User objects */
users?: Record<string, DiscordUser>
/** The Ids and partial Member objects */
members?: Record<string, Omit<DiscordInteractionMember, 'user' | 'deaf' | 'mute'>>
/** The Ids and Role objects */
roles?: Record<string, DiscordRole>
/** The Ids and partial Channel objects */
channels?: Record<string, Pick<DiscordChannel, 'id' | 'name' | 'type' | 'permissions' | 'thread_metadata' | 'parent_id'>>
/** The Ids and attachments objects */
attachments?: Record<string, DiscordAttachment>
}
export interface DiscordThreadMemberGuildCreate {
/** Any user-thread settings, currently only used for notifications */
flags: number
/** The time the current user last joined the thread */
join_timestamp: string
}
export interface BotGatewayHandlerOptions {
READY: typeof handlers.handleReady
APPLICATION_COMMAND_PERMISSIONS_UPDATE: typeof handlers.handleApplicationCommandPermissionsUpdate
AUTO_MODERATION_ACTION_EXECUTION: typeof handlers.handleAutoModerationActionExecution
AUTO_MODERATION_RULE_CREATE: typeof handlers.handleAutoModerationRuleCreate
AUTO_MODERATION_RULE_DELETE: typeof handlers.handleAutoModerationRuleDelete
AUTO_MODERATION_RULE_UPDATE: typeof handlers.handleAutoModerationRuleUpdate
CHANNEL_CREATE: typeof handlers.handleChannelCreate
CHANNEL_DELETE: typeof handlers.handleChannelDelete
CHANNEL_PINS_UPDATE: typeof handlers.handleChannelPinsUpdate
CHANNEL_UPDATE: typeof handlers.handleChannelUpdate
THREAD_CREATE: typeof handlers.handleThreadCreate
THREAD_UPDATE: typeof handlers.handleThreadUpdate
THREAD_DELETE: typeof handlers.handleThreadDelete
THREAD_LIST_SYNC: typeof handlers.handleThreadListSync
THREAD_MEMBERS_UPDATE: typeof handlers.handleThreadMembersUpdate
STAGE_INSTANCE_CREATE: typeof handlers.handleStageInstanceCreate
STAGE_INSTANCE_UPDATE: typeof handlers.handleStageInstanceUpdate
STAGE_INSTANCE_DELETE: typeof handlers.handleStageInstanceDelete
GUILD_AUDIT_LOG_ENTRY_CREATE: typeof handlers.handleGuildAuditLogEntryCreate
GUILD_BAN_ADD: typeof handlers.handleGuildBanAdd
GUILD_BAN_REMOVE: typeof handlers.handleGuildBanRemove
GUILD_CREATE: typeof handlers.handleGuildCreate
GUILD_DELETE: typeof handlers.handleGuildDelete
GUILD_EMOJIS_UPDATE: typeof handlers.handleGuildEmojisUpdate
GUILD_INTEGRATIONS_UPDATE: typeof handlers.handleGuildIntegrationsUpdate
GUILD_MEMBER_ADD: typeof handlers.handleGuildMemberAdd
GUILD_MEMBER_REMOVE: typeof handlers.handleGuildMemberRemove
GUILD_MEMBER_UPDATE: typeof handlers.handleGuildMemberUpdate
GUILD_MEMBERS_CHUNK: typeof handlers.handleGuildMembersChunk
GUILD_ROLE_CREATE: typeof handlers.handleGuildRoleCreate
GUILD_ROLE_DELETE: typeof handlers.handleGuildRoleDelete
GUILD_ROLE_UPDATE: typeof handlers.handleGuildRoleUpdate
GUILD_SCHEDULED_EVENT_CREATE: typeof handlers.handleGuildScheduledEventCreate
GUILD_SCHEDULED_EVENT_DELETE: typeof handlers.handleGuildScheduledEventDelete
GUILD_SCHEDULED_EVENT_UPDATE: typeof handlers.handleGuildScheduledEventUpdate
GUILD_SCHEDULED_EVENT_USER_ADD: typeof handlers.handleGuildScheduledEventUserAdd
GUILD_SCHEDULED_EVENT_USER_REMOVE: typeof handlers.handleGuildScheduledEventUserRemove
GUILD_STICKERS_UPDATE: typeof handlers.handleGuildStickersUpdate
GUILD_UPDATE: typeof handlers.handleGuildUpdate
INTERACTION_CREATE: typeof handlers.handleInteractionCreate
INVITE_CREATE: typeof handlers.handleInviteCreate
INVITE_DELETE: typeof handlers.handleInviteCreate
MESSAGE_CREATE: typeof handlers.handleMessageCreate
MESSAGE_DELETE_BULK: typeof handlers.handleMessageDeleteBulk
MESSAGE_DELETE: typeof handlers.handleMessageDelete
MESSAGE_REACTION_ADD: typeof handlers.handleMessageReactionAdd
MESSAGE_REACTION_REMOVE_ALL: typeof handlers.handleMessageReactionRemoveAll
MESSAGE_REACTION_REMOVE_EMOJI: typeof handlers.handleMessageReactionRemoveEmoji
MESSAGE_REACTION_REMOVE: typeof handlers.handleMessageReactionRemove
MESSAGE_UPDATE: typeof handlers.handleMessageUpdate
PRESENCE_UPDATE: typeof handlers.handlePresenceUpdate
TYPING_START: typeof handlers.handleTypingStart
USER_UPDATE: typeof handlers.handleUserUpdate
VOICE_CHANNEL_EFFECT_SEND: typeof handlers.handleVoiceChannelEffectSend
VOICE_SERVER_UPDATE: typeof handlers.handleVoiceServerUpdate
VOICE_STATE_UPDATE: typeof handlers.handleVoiceStateUpdate
WEBHOOKS_UPDATE: typeof handlers.handleWebhooksUpdate
INTEGRATION_CREATE: typeof handlers.handleIntegrationCreate
INTEGRATION_UPDATE: typeof handlers.handleIntegrationUpdate
INTEGRATION_DELETE: typeof handlers.handleIntegrationDelete
ENTITLEMENT_CREATE: typeof handlers.handleEntitlementCreate
ENTITLEMENT_UPDATE: typeof handlers.handleEntitlementUpdate
ENTITLEMENT_DELETE: typeof handlers.handleEntitlementDelete
SUBSCRIPTION_CREATE: typeof handlers.handleSubscriptionCreate
SUBSCRIPTION_UPDATE: typeof handlers.handleSubscriptionUpdate
SUBSCRIPTION_DELETE: typeof handlers.handleSubscriptionDelete
MESSAGE_POLL_VOTE_ADD: typeof handlers.handleMessagePollVoteAdd
MESSAGE_POLL_VOTE_REMOVE: typeof handlers.handleMessagePollVoteRemove
GUILD_SOUNDBOARD_SOUND_CREATE: typeof handlers.handleGuildSoundboardSoundCreate
GUILD_SOUNDBOARD_SOUND_DELETE: typeof handlers.handleGuildSoundboardSoundDelete
GUILD_SOUNDBOARD_SOUND_UPDATE: typeof handlers.handleGuildSoundboardSoundUpdate
GUILD_SOUNDBOARD_SOUNDS_UPDATE: typeof handlers.handleGuildSoundboardSoundsUpdate
SOUNDBOARD_SOUNDS: typeof handlers.handleSoundboardSounds
}

View File

@@ -3,8 +3,8 @@ import { delay, logger, snakeToCamelCase } from '@discordeno/utils'
import { use as chaiUse } from 'chai'
import chaiAsPromised from 'chai-as-promised'
import { describe, it } from 'mocha'
import type { EventHandlers } from '../../src/bot.js'
import { createBot } from '../../src/bot.js'
import type { EventHandlers } from '../../src/events.js'
import { token } from './constants.js'
chaiUse(chaiAsPromised)

View File

@@ -65,7 +65,7 @@ function processInterfaceDeclarationNode(node: ts.InterfaceDeclaration, config:
const isOptional = !!(member.getFlags() & ts.SymbolFlags.Optional)
const isInternal = !!jsDoc.find((x) => x.name === 'internal')
// If the propriety is internal then we don't want to apply the desired propriety logic to it
// If the property is internal then we don't want to apply the desired property logic to it
if (isInternal || isPropertyDesired(config, interfaceName, memberName)) {
writeJSDoc(writeStream, docs, jsDoc, ' ')
writeInterfaceMember(writeStream, memberName, typeText, isOptional)

View File

@@ -38,7 +38,7 @@ describe('discordeno generate', () => {
expect(allDiagnostics).to.be.an('array').that.is.empty
})
it('can get propriety dependencies', () => {
it('can get property dependencies', () => {
const deps = getPropertyDependencies('member', 'mute')
expect(deps).to.have.members(['toggles'])

View File

@@ -1,5 +1,5 @@
import { Buffer } from 'node:buffer'
import { Inflate, createInflate, inflateSync, constants as zlibConstants } from 'node:zlib'
import { type Inflate, createInflate, inflateSync, constants as zlibConstants } from 'node:zlib'
import type { DiscordGatewayPayload, DiscordHello, DiscordReady } from '@discordeno/types'
import { GatewayCloseEventCodes, GatewayOpcodes } from '@discordeno/types'
import { LeakyBucket, camelize, delay, logger } from '@discordeno/utils'

File diff suppressed because it is too large Load Diff

View File

@@ -1,350 +0,0 @@
import type {
DiscordAccessTokenResponse,
DiscordActionRow,
DiscordActiveThreads,
DiscordActivity,
DiscordActivityAssets,
DiscordActivityButton,
DiscordActivityEmoji,
DiscordActivityInstanceResource,
DiscordActivityParty,
DiscordActivitySecrets,
DiscordActivityTimestamps,
DiscordAllowedMentions,
DiscordApplication,
DiscordApplicationCommand,
DiscordApplicationCommandOption,
DiscordApplicationCommandOptionChoice,
DiscordApplicationCommandPermissions,
DiscordApplicationIntegrationTypeConfiguration,
DiscordApplicationRoleConnection,
DiscordApplicationWebhook,
DiscordArchivedThreads,
DiscordAttachment,
DiscordAuditLog,
DiscordAuditLogChange,
DiscordAuditLogEntry,
DiscordAutoModerationAction,
DiscordAutoModerationActionExecution,
DiscordAutoModerationActionMetadata,
DiscordAutoModerationRule,
DiscordAutoModerationRuleTriggerMetadata,
DiscordBan,
DiscordBulkBan,
DiscordButtonComponent,
DiscordChannel,
DiscordChannelMention,
DiscordChannelPinsUpdate,
DiscordClientStatus,
DiscordConnection,
DiscordCreateApplicationCommand,
DiscordCreateForumPostWithMessage,
DiscordCreateGuildChannel,
DiscordCreateGuildEmoji,
DiscordCreateMessage,
DiscordCreateWebhook,
DiscordCurrentAuthorization,
DiscordDefaultReactionEmoji,
DiscordEditChannelPermissionOverridesOptions,
DiscordEmbed,
DiscordEmbedAuthor,
DiscordEmbedField,
DiscordEmbedFooter,
DiscordEmbedImage,
DiscordEmbedProvider,
DiscordEmbedThumbnail,
DiscordEmbedVideo,
DiscordEmoji,
DiscordEntitlement,
DiscordFollowAnnouncementChannel,
DiscordFollowedChannel,
DiscordForumTag,
DiscordGatewayPayload,
DiscordGetAnswerVotesResponse,
DiscordGetGatewayBot,
DiscordGuild,
DiscordGuildApplicationCommandPermissions,
DiscordGuildBanAddRemove,
DiscordGuildEmojisUpdate,
DiscordGuildIntegrationsUpdate,
DiscordGuildMemberAdd,
DiscordGuildMemberRemove,
DiscordGuildMemberUpdate,
DiscordGuildMembersChunk,
DiscordGuildOnboarding,
DiscordGuildOnboardingPrompt,
DiscordGuildOnboardingPromptOption,
DiscordGuildPreview,
DiscordGuildRoleCreate,
DiscordGuildRoleDelete,
DiscordGuildRoleUpdate,
DiscordGuildStickersUpdate,
DiscordGuildWidget,
DiscordGuildWidgetSettings,
DiscordHello,
DiscordIncomingWebhook,
DiscordInputTextComponent,
DiscordInstallParams,
DiscordIntegration,
DiscordIntegrationAccount,
DiscordIntegrationApplication,
DiscordIntegrationCreateUpdate,
DiscordIntegrationDelete,
DiscordInteraction,
DiscordInteractionCallback,
DiscordInteractionCallbackResponse,
DiscordInteractionData,
DiscordInteractionDataOption,
DiscordInteractionMember,
DiscordInteractionResource,
DiscordInvite,
DiscordInviteCreate,
DiscordInviteDelete,
DiscordInviteMetadata,
DiscordInviteStageInstance,
DiscordListActiveThreads,
DiscordListArchivedThreads,
DiscordMember,
DiscordMemberWithUser,
DiscordMessage,
DiscordMessageActivity,
DiscordMessageComponents,
DiscordMessageDelete,
DiscordMessageDeleteBulk,
DiscordMessageInteraction,
DiscordMessageReactionAdd,
DiscordMessageReactionRemove,
DiscordMessageReactionRemoveAll,
DiscordMessageReactionRemoveEmoji,
DiscordMessageReference,
DiscordModifyChannel,
DiscordModifyGuildChannelPositions,
DiscordModifyGuildEmoji,
DiscordModifyGuildWelcomeScreen,
DiscordOptionalAuditEntryInfo,
DiscordOverwrite,
DiscordPoll,
DiscordPollAnswer,
DiscordPollAnswerCount,
DiscordPollMedia,
DiscordPollResult,
DiscordPresenceUpdate,
DiscordPrunedCount,
DiscordReaction,
DiscordReady,
DiscordRole,
DiscordRoleTags,
DiscordScheduledEvent,
DiscordScheduledEventEntityMetadata,
DiscordScheduledEventUserAdd,
DiscordScheduledEventUserRemove,
DiscordSelectMenuComponent,
DiscordSelectMenuDefaultValue,
DiscordSelectOption,
DiscordSessionStartLimit,
DiscordSku,
DiscordSoundboardSound,
DiscordStageInstance,
DiscordSticker,
DiscordStickerItem,
DiscordStickerPack,
DiscordTeam,
DiscordTeamMember,
DiscordTemplate,
DiscordThreadListSync,
DiscordThreadMember,
DiscordThreadMemberUpdate,
DiscordThreadMembersUpdate,
DiscordThreadMetadata,
DiscordTokenExchange,
DiscordTokenExchangeAuthorizationCode,
DiscordTokenExchangeClientCredentials,
DiscordTokenExchangeRefreshToken,
DiscordTokenRevocation,
DiscordTypingStart,
DiscordUnavailableGuild,
DiscordUser,
DiscordVanityUrl,
DiscordVoiceRegion,
DiscordVoiceServerUpdate,
DiscordVoiceState,
DiscordWebhook,
DiscordWebhookUpdate,
DiscordWelcomeScreen,
DiscordWelcomeScreenChannel,
} from './discord.js'
import type { Camelize } from './shared.js'
export interface CamelizedDiscordUser extends Camelize<DiscordUser> {}
export interface CamelizedDiscordIntegration extends Camelize<DiscordIntegration> {}
export interface CamelizedDiscordIntegrationAccount extends Camelize<DiscordIntegrationAccount> {}
export interface CamelizedDiscordIntegrationApplication extends Camelize<DiscordIntegrationApplication> {}
export interface CamelizedDiscordIntegrationCreateUpdate extends Camelize<DiscordIntegrationCreateUpdate> {}
export interface CamelizedDiscordIntegrationDelete extends Camelize<DiscordIntegrationDelete> {}
export interface CamelizedDiscordGuildIntegrationsUpdate extends Camelize<DiscordGuildIntegrationsUpdate> {}
export interface CamelizedDiscordTypingStart extends Camelize<DiscordTypingStart> {}
export interface CamelizedDiscordMember extends Camelize<DiscordMember> {}
export interface CamelizedDiscordApplication extends Camelize<DiscordApplication> {}
export interface CamelizedDiscordApplicationIntegrationTypeConfiguration extends Camelize<DiscordApplicationIntegrationTypeConfiguration> {}
export interface CamelizedDiscordApplicationRoleConnection extends Camelize<DiscordApplicationRoleConnection> {}
export type CamelizedDiscordTokenExchange = Camelize<DiscordTokenExchange>
export interface CamelizedDiscordTokenExchangeAuthorizationCode extends Camelize<DiscordTokenExchangeAuthorizationCode> {}
export interface CamelizedDiscordTokenExchangeRefreshToken extends Camelize<DiscordTokenExchangeRefreshToken> {}
export interface CamelizedDiscordTokenExchangeClientCredentials extends Camelize<DiscordTokenExchangeClientCredentials> {}
export interface CamelizedDiscordAccessTokenResponse extends Camelize<DiscordAccessTokenResponse> {}
export interface CamelizedDiscordTokenRevocation extends Camelize<DiscordTokenRevocation> {}
export interface CamelizedDiscordCurrentAuthorization extends Camelize<DiscordCurrentAuthorization> {}
export interface CamelizedDiscordConnection extends Camelize<DiscordConnection> {}
export interface CamelizedDiscordTeam extends Camelize<DiscordTeam> {}
export interface CamelizedDiscordTeamMember extends Camelize<DiscordTeamMember> {}
export interface CamelizedDiscordWebhookUpdate extends Camelize<DiscordWebhookUpdate> {}
export interface CamelizedDiscordAllowedMentions extends Camelize<DiscordAllowedMentions> {}
export interface CamelizedDiscordEmbed extends Camelize<DiscordEmbed> {}
export interface CamelizedDiscordEmbedAuthor extends Camelize<DiscordEmbedAuthor> {}
export interface CamelizedDiscordEmbedField extends Camelize<DiscordEmbedField> {}
export interface CamelizedDiscordEmbedFooter extends Camelize<DiscordEmbedFooter> {}
export interface CamelizedDiscordEmbedImage extends Camelize<DiscordEmbedImage> {}
export interface CamelizedDiscordEmbedProvider extends Camelize<DiscordEmbedProvider> {}
export interface CamelizedDiscordEmbedThumbnail extends Camelize<DiscordEmbedThumbnail> {}
export interface CamelizedDiscordEmbedVideo extends Camelize<DiscordEmbedVideo> {}
export interface CamelizedDiscordAttachment extends Camelize<DiscordAttachment> {}
export type CamelizedDiscordWebhook = Camelize<DiscordWebhook>
export interface CamelizedDiscordIncomingWebhook extends Camelize<DiscordIncomingWebhook> {}
export interface CamelizedDiscordApplicationWebhook extends Camelize<DiscordApplicationWebhook> {}
export interface CamelizedDiscordGuild extends Camelize<DiscordGuild> {}
export interface CamelizedDiscordRole extends Camelize<DiscordRole> {}
export interface CamelizedDiscordRoleTags extends Camelize<DiscordRoleTags> {}
export interface CamelizedDiscordEmoji extends Camelize<DiscordEmoji> {}
export interface CamelizedDiscordVoiceState extends Camelize<DiscordVoiceState> {}
export interface CamelizedDiscordChannel extends Camelize<DiscordChannel> {}
export interface CamelizedDiscordPresenceUpdate extends Camelize<DiscordPresenceUpdate> {}
export interface CamelizedDiscordWelcomeScreen extends Camelize<DiscordWelcomeScreen> {}
export interface CamelizedDiscordWelcomeScreenChannel extends Camelize<DiscordWelcomeScreenChannel> {}
export interface CamelizedDiscordStageInstance extends Camelize<DiscordStageInstance> {}
export interface CamelizedDiscordThreadMetadata extends Camelize<DiscordThreadMetadata> {}
export interface CamelizedDiscordThreadMember extends Camelize<DiscordThreadMember> {}
export interface CamelizedDiscordActivity extends Camelize<DiscordActivity> {}
export interface CamelizedDiscordClientStatus extends Camelize<DiscordClientStatus> {}
export interface CamelizedDiscordActivityTimestamps extends Camelize<DiscordActivityTimestamps> {}
export interface CamelizedDiscordActivityEmoji extends Camelize<DiscordActivityEmoji> {}
export interface CamelizedDiscordActivityParty extends Camelize<DiscordActivityParty> {}
export interface CamelizedDiscordActivityAssets extends Camelize<DiscordActivityAssets> {}
export interface CamelizedDiscordActivitySecrets extends Camelize<DiscordActivitySecrets> {}
export interface CamelizedDiscordActivityButton extends Camelize<DiscordActivityButton> {}
export interface CamelizedDiscordOverwrite extends Camelize<DiscordOverwrite> {}
export interface CamelizedDiscordMemberWithUser extends Camelize<DiscordMemberWithUser> {}
export interface CamelizedDiscordMessage extends Camelize<DiscordMessage> {}
export interface CamelizedDiscordChannelMention extends Camelize<DiscordChannelMention> {}
export interface CamelizedDiscordReaction extends Camelize<DiscordReaction> {}
export interface CamelizedDiscordMessageActivity extends Camelize<DiscordMessageActivity> {}
export interface CamelizedDiscordMessageReference extends Camelize<DiscordMessageReference> {}
export interface CamelizedDiscordPoll extends Camelize<DiscordPoll> {}
export interface CamelizedDiscordPollMedia extends Camelize<DiscordPollMedia> {}
export interface CamelizedDiscordPollAnswer extends Camelize<DiscordPollAnswer> {}
export interface CamelizedDiscordPollAnswerCount extends Camelize<DiscordPollAnswerCount> {}
export interface CamelizedDiscordPollResult extends Camelize<DiscordPollResult> {}
export interface CamelizedDiscordGetAnswerVotesResponse extends Camelize<DiscordGetAnswerVotesResponse> {}
export interface CamelizedDiscordSticker extends Camelize<DiscordSticker> {}
export interface CamelizedDiscordMessageInteraction extends Camelize<DiscordMessageInteraction> {}
export type CamelizedDiscordMessageComponents = Camelize<DiscordMessageComponents>
export interface CamelizedDiscordActionRow extends Camelize<DiscordActionRow> {}
export interface CamelizedDiscordSelectMenuComponent extends Camelize<DiscordSelectMenuComponent> {}
export interface CamelizedDiscordSelectOption extends Camelize<DiscordSelectOption> {}
export interface CamelizedDiscordSelectMenuDefaultValue extends Camelize<DiscordSelectMenuDefaultValue> {}
export interface CamelizedDiscordButtonComponent extends Camelize<DiscordButtonComponent> {}
export interface CamelizedDiscordInputTextComponent extends Camelize<DiscordInputTextComponent> {}
export interface CamelizedDiscordStickerItem extends Camelize<DiscordStickerItem> {}
export interface CamelizedDiscordStickerPack extends Camelize<DiscordStickerPack> {}
export interface CamelizedDiscordInteraction extends Camelize<DiscordInteraction> {}
export interface CamelizedDiscordInteractionCallbackResponse extends Camelize<DiscordInteractionCallbackResponse> {}
export interface CamelizedDiscordInteractionCallback extends Camelize<DiscordInteractionCallback> {}
export interface CamelizedDiscordInteractionResource extends Camelize<DiscordInteractionResource> {}
export interface CamelizedDiscordActivityInstanceResource extends Camelize<DiscordActivityInstanceResource> {}
export interface CamelizedDiscordInteractionMember extends Camelize<DiscordInteractionMember> {}
export interface CamelizedDiscordInteractionData extends Camelize<DiscordInteractionData> {}
export interface CamelizedDiscordInteractionDataOption extends Camelize<DiscordInteractionDataOption> {}
export interface CamelizedDiscordListActiveThreads extends Camelize<DiscordListActiveThreads> {}
export interface CamelizedDiscordListArchivedThreads extends Camelize<DiscordListArchivedThreads> {}
export interface CamelizedDiscordThreadListSync extends Camelize<DiscordThreadListSync> {}
export interface CamelizedDiscordAuditLog extends Camelize<DiscordAuditLog> {}
export interface CamelizedDiscordAutoModerationRule extends Camelize<DiscordAutoModerationRule> {}
export interface CamelizedDiscordAutoModerationRuleTriggerMetadata extends Camelize<DiscordAutoModerationRuleTriggerMetadata> {}
export interface CamelizedDiscordAutoModerationAction extends Camelize<DiscordAutoModerationAction> {}
export interface CamelizedDiscordAutoModerationActionMetadata extends Camelize<DiscordAutoModerationActionMetadata> {}
export interface CamelizedDiscordAutoModerationActionExecution extends Camelize<DiscordAutoModerationActionExecution> {}
export interface CamelizedDiscordAuditLogEntry extends Camelize<DiscordAuditLogEntry> {}
export type CamelizedDiscordAuditLogChange = Camelize<DiscordAuditLogChange>
export interface CamelizedDiscordOptionalAuditEntryInfo extends Camelize<DiscordOptionalAuditEntryInfo> {}
export interface CamelizedDiscordScheduledEvent extends Camelize<DiscordScheduledEvent> {}
export interface CamelizedDiscordScheduledEventEntityMetadata extends Camelize<DiscordScheduledEventEntityMetadata> {}
export interface CamelizedDiscordGetGatewayBot extends Camelize<DiscordGetGatewayBot> {}
export interface CamelizedDiscordSessionStartLimit extends Camelize<DiscordSessionStartLimit> {}
export interface CamelizedDiscordInviteMetadata extends Camelize<DiscordInviteMetadata> {}
export interface CamelizedDiscordInvite extends Camelize<DiscordInvite> {}
export interface CamelizedDiscordInviteStageInstance extends Camelize<DiscordInviteStageInstance> {}
export interface CamelizedDiscordApplicationCommand extends Camelize<DiscordApplicationCommand> {}
export interface CamelizedDiscordCreateApplicationCommand extends Camelize<DiscordCreateApplicationCommand> {}
export interface CamelizedDiscordApplicationCommandOption extends Camelize<DiscordApplicationCommandOption> {}
export interface CamelizedDiscordApplicationCommandOptionChoice extends Camelize<DiscordApplicationCommandOptionChoice> {}
export interface CamelizedDiscordGuildApplicationCommandPermissions extends Camelize<DiscordGuildApplicationCommandPermissions> {}
export interface CamelizedDiscordApplicationCommandPermissions extends Camelize<DiscordApplicationCommandPermissions> {}
export interface CamelizedDiscordGuildWidget extends Camelize<DiscordGuildWidget> {}
export interface CamelizedDiscordGuildPreview extends Camelize<DiscordGuildPreview> {}
export interface CamelizedDiscordFollowedChannel extends Camelize<DiscordFollowedChannel> {}
export interface CamelizedDiscordGatewayPayload extends Camelize<DiscordGatewayPayload> {}
export interface CamelizedDiscordGuildMembersChunk extends Camelize<DiscordGuildMembersChunk> {}
export interface CamelizedDiscordChannelPinsUpdate extends Camelize<DiscordChannelPinsUpdate> {}
export interface CamelizedDiscordGuildRoleDelete extends Camelize<DiscordGuildRoleDelete> {}
export interface CamelizedDiscordGuildBanAddRemove extends Camelize<DiscordGuildBanAddRemove> {}
export interface CamelizedDiscordMessageReactionRemove extends Camelize<DiscordMessageReactionRemove> {}
export interface CamelizedDiscordMessageReactionAdd extends Camelize<DiscordMessageReactionAdd> {}
export interface CamelizedDiscordVoiceServerUpdate extends Camelize<DiscordVoiceServerUpdate> {}
export interface CamelizedDiscordInviteCreate extends Camelize<DiscordInviteCreate> {}
export interface CamelizedDiscordHello extends Camelize<DiscordHello> {}
export interface CamelizedDiscordReady extends Camelize<DiscordReady> {}
export interface CamelizedDiscordUnavailableGuild extends Camelize<DiscordUnavailableGuild> {}
export interface CamelizedDiscordMessageDeleteBulk extends Camelize<DiscordMessageDeleteBulk> {}
export interface CamelizedDiscordTemplate extends Camelize<DiscordTemplate> {}
export interface CamelizedDiscordGuildMemberAdd extends Camelize<DiscordGuildMemberAdd> {}
export interface CamelizedDiscordMessageDelete extends Camelize<DiscordMessageDelete> {}
export interface CamelizedDiscordThreadMembersUpdate extends Camelize<DiscordThreadMembersUpdate> {}
export interface CamelizedDiscordThreadMemberUpdate extends Camelize<DiscordThreadMemberUpdate> {}
export interface CamelizedDiscordGuildRoleCreate extends Camelize<DiscordGuildRoleCreate> {}
export interface CamelizedDiscordGuildEmojisUpdate extends Camelize<DiscordGuildEmojisUpdate> {}
export interface CamelizedDiscordGuildStickersUpdate extends Camelize<DiscordGuildStickersUpdate> {}
export interface CamelizedDiscordGuildMemberUpdate extends Camelize<DiscordGuildMemberUpdate> {}
export interface CamelizedDiscordMessageReactionRemoveAll extends Camelize<DiscordMessageReactionRemoveAll> {}
export interface CamelizedDiscordGuildRoleUpdate extends Camelize<DiscordGuildRoleUpdate> {}
export interface CamelizedDiscordScheduledEventUserAdd extends Camelize<DiscordScheduledEventUserAdd> {}
export type CamelizedDiscordMessageReactionRemoveEmoji = Camelize<DiscordMessageReactionRemoveEmoji>
export interface CamelizedDiscordGuildMemberRemove extends Camelize<DiscordGuildMemberRemove> {}
export interface CamelizedDiscordBan extends Camelize<DiscordBan> {}
export interface CamelizedDiscordScheduledEventUserRemove extends Camelize<DiscordScheduledEventUserRemove> {}
export interface CamelizedDiscordInviteDelete extends Camelize<DiscordInviteDelete> {}
export interface CamelizedDiscordVoiceRegion extends Camelize<DiscordVoiceRegion> {}
export interface CamelizedDiscordGuildWidgetSettings extends Camelize<DiscordGuildWidgetSettings> {}
export interface CamelizedDiscordInstallParams extends Camelize<DiscordInstallParams> {}
export interface CamelizedDiscordForumTag extends Camelize<DiscordForumTag> {}
export interface CamelizedDiscordDefaultReactionEmoji extends Camelize<DiscordDefaultReactionEmoji> {}
export interface CamelizedDiscordModifyChannel extends Camelize<DiscordModifyChannel> {}
export interface CamelizedDiscordCreateGuildEmoji extends Camelize<DiscordCreateGuildEmoji> {}
export interface CamelizedDiscordModifyGuildEmoji extends Camelize<DiscordModifyGuildEmoji> {}
export interface CamelizedDiscordCreateGuildChannel extends Camelize<DiscordCreateGuildChannel> {}
export interface CamelizedDiscordCreateMessage extends Camelize<DiscordCreateMessage> {}
export interface CamelizedDiscordModifyGuildWelcomeScreen extends Camelize<DiscordModifyGuildWelcomeScreen> {}
export interface CamelizedDiscordFollowAnnouncementChannel extends Camelize<DiscordFollowAnnouncementChannel> {}
export interface CamelizedDiscordEditChannelPermissionOverridesOptions extends Camelize<DiscordEditChannelPermissionOverridesOptions> {}
export interface CamelizedDiscordModifyGuildChannelPositions extends Camelize<DiscordModifyGuildChannelPositions> {}
export interface CamelizedDiscordCreateWebhook extends Camelize<DiscordCreateWebhook> {}
export interface CamelizedDiscordCreateForumPostWithMessage extends Camelize<DiscordCreateForumPostWithMessage> {}
export type CamelizedDiscordArchivedThreads = Camelize<DiscordArchivedThreads>
export interface CamelizedDiscordActiveThreads extends Camelize<DiscordActiveThreads> {}
export interface CamelizedDiscordVanityUrl extends Camelize<DiscordVanityUrl> {}
export interface CamelizedDiscordPrunedCount extends Camelize<DiscordPrunedCount> {}
export interface CamelizedDiscordGuildOnboarding extends Camelize<DiscordGuildOnboarding> {}
export interface CamelizedDiscordGuildOnboardingPrompt extends Camelize<DiscordGuildOnboardingPrompt> {}
export interface CamelizedDiscordGuildOnboardingOption extends Camelize<DiscordGuildOnboardingPromptOption> {}
export interface CamelizedDiscordEntitlement extends Camelize<DiscordEntitlement> {}
export interface CamelizedDiscordSku extends Camelize<DiscordSku> {}
export interface CamelizedDiscordBulkBan extends Camelize<DiscordBulkBan> {}
export interface CamelizedDiscordSoundboardSound extends Camelize<DiscordSoundboardSound> {}

View File

@@ -1,50 +1,50 @@
import {
type ActivityTypes,
type AllowedMentionsTypes,
type ApplicationCommandOptionTypes,
type ApplicationCommandPermissionTypes,
type ApplicationCommandTypes,
type ApplicationFlags,
type AttachmentFlags,
type AuditLogEvents,
type ButtonStyles,
type ChannelFlags,
type ChannelTypes,
type DefaultMessageNotificationLevels,
type EmbedTypes,
type ExplicitContentFilterLevels,
type ForumLayout,
type GatewayEventNames,
type GuildFeatures,
type GuildNsfwLevel,
type IntegrationExpireBehaviors,
type InteractionResponseTypes,
type InteractionTypes,
type Localization,
type MessageActivityTypes,
type MessageComponentTypes,
type MessageFlags,
type MessageTypes,
type MfaLevels,
type OverwriteTypes,
type PickPartial,
type PremiumTiers,
type PremiumTypes,
type RoleFlags,
type ScheduledEventEntityType,
type ScheduledEventPrivacyLevel,
type ScheduledEventStatus,
type SkuFlags,
type SortOrderTypes,
type StickerFormatTypes,
type StickerTypes,
type SystemChannelFlags,
type TargetTypes,
type TeamMembershipStates,
type TextStyles,
type VerificationLevels,
type VideoQualityModes,
type WebhookTypes,
import type {
ActivityTypes,
AllowedMentionsTypes,
ApplicationCommandOptionTypes,
ApplicationCommandPermissionTypes,
ApplicationCommandTypes,
ApplicationFlags,
AttachmentFlags,
AuditLogEvents,
ButtonStyles,
ChannelFlags,
ChannelTypes,
DefaultMessageNotificationLevels,
EmbedTypes,
ExplicitContentFilterLevels,
ForumLayout,
GatewayEventNames,
GuildFeatures,
GuildNsfwLevel,
IntegrationExpireBehaviors,
InteractionResponseTypes,
InteractionTypes,
Localization,
MessageActivityTypes,
MessageComponentTypes,
MessageFlags,
MessageTypes,
MfaLevels,
OverwriteTypes,
PickPartial,
PremiumTiers,
PremiumTypes,
RoleFlags,
ScheduledEventEntityType,
ScheduledEventPrivacyLevel,
ScheduledEventStatus,
SkuFlags,
SortOrderTypes,
StickerFormatTypes,
StickerTypes,
SystemChannelFlags,
TargetTypes,
TeamMembershipStates,
TextStyles,
VerificationLevels,
VideoQualityModes,
WebhookTypes,
} from './shared.js'
/** https://discord.com/developers/docs/resources/user#user-object */
@@ -1822,7 +1822,7 @@ export interface DiscordSelectOption {
/** https://discord.com/developers/docs/interactions/message-components#select-menu-object-select-default-value-structure */
export interface DiscordSelectMenuDefaultValue {
/** ID of a user, role, or channel */
id: bigint
id: string
/** Type of value that id represents. */
type: 'user' | 'role' | 'channel'
}
@@ -1872,7 +1872,7 @@ export interface DiscordButtonComponent {
/** Whether or not this button is disabled */
disabled?: boolean
/**
* SKU for {@link ButtonStyles.Premium | premium} buttons that can navigate a user to the application shop.
* Identifier for a purchasable SKU
*
* @remarks
* Buttons of style {@link ButtonStyles.Premium | Premium} must have a sku_id, any other button with a different style can not have a a sku_id
@@ -2047,20 +2047,7 @@ export interface DiscordInteractionData {
/** the type of the invoked command */
type: ApplicationCommandTypes
/** Converted users + roles + channels + attachments */
resolved?: {
/** The Ids and Message objects */
messages?: Record<string, DiscordMessage>
/** The Ids and User objects */
users?: Record<string, DiscordUser>
/** The Ids and partial Member objects */
members?: Record<string, Omit<DiscordInteractionMember, 'user' | 'deaf' | 'mute'>>
/** The Ids and Role objects */
roles?: Record<string, DiscordRole>
/** The Ids and partial Channel objects */
channels?: Record<string, Pick<DiscordChannel, 'id' | 'name' | 'type' | 'permissions'>>
/** The ids and attachment objects */
attachments: Record<string, DiscordAttachment>
}
resolved?: DiscordInteractionDataResolved
/** The params + values from the user */
options?: DiscordInteractionDataOption[]
/** The target id if this is a context menu command. */
@@ -2069,6 +2056,21 @@ export interface DiscordInteractionData {
guild_id?: string
}
export interface DiscordInteractionDataResolved {
/** The Ids and Message objects */
messages?: Record<string, DiscordMessage>
/** The Ids and User objects */
users?: Record<string, DiscordUser>
/** The Ids and partial Member objects */
members?: Record<string, Omit<DiscordInteractionMember, 'user' | 'deaf' | 'mute'>>
/** The Ids and Role objects */
roles?: Record<string, DiscordRole>
/** The Ids and partial Channel objects */
channels?: Record<string, Pick<DiscordChannel, 'id' | 'name' | 'type' | 'permissions'>>
/** The ids and attachment objects */
attachments: Record<string, DiscordAttachment>
}
export interface DiscordInteractionDataOption {
/** Name of the parameter */
name: string
@@ -3930,3 +3932,10 @@ export interface DiscordEventWebhookApplicationAuthorizedBody {
/** Server which app was authorized for (when integration type is 0) */
guild?: DiscordGuild
}
export interface DiscordThreadMemberGuildCreate {
/** Any user-thread settings, currently only used for notifications */
flags: number
/** The time the current user last joined the thread */
join_timestamp: string
}

View File

@@ -45,7 +45,6 @@ import type {
MessageFlags,
OverwriteTypes,
PermissionStrings,
PickPartial,
ScheduledEventEntityType,
ScheduledEventPrivacyLevel,
ScheduledEventStatus,
@@ -1632,3 +1631,10 @@ export interface ModifyGuildSoundboardSound {
/** The unicode character of a standard emoji for the soundboard sound */
emojiName: string | null
}
export interface CreateWebhook {
/** Name of the webhook (1-80 characters) */
name: string
/** Image url for the default webhook avatar */
avatar?: string | null
}

View File

@@ -1,4 +1,3 @@
export * from './camel.js'
export * from './discord.js'
export * from './discordeno.js'
export * from './shared.js'

View File

@@ -964,7 +964,7 @@ export type GatewayDispatchEventNames =
| 'MESSAGE_POLL_VOTE_ADD'
| 'MESSAGE_POLL_VOTE_REMOVE'
export type GatewayEventNames = GatewayDispatchEventNames | 'READY' | 'RESUMED'
export type GatewayEventNames = GatewayDispatchEventNames | 'RESUMED'
/** https://discord.com/developers/docs/topics/gateway#list-of-intents */
export enum GatewayIntents {

View File

@@ -1,11 +1,14 @@
import type {
DiscordInviteCreate,
DiscordInviteMetadata,
GetMessagesAfter,
GetMessagesAround,
GetMessagesBefore,
GetMessagesLimit,
GetMessagesOptions,
import {
ApplicationCommandTypes,
type CreateApplicationCommand,
type CreateContextApplicationCommand,
type DiscordInviteCreate,
type DiscordInviteMetadata,
type GetMessagesAfter,
type GetMessagesAround,
type GetMessagesBefore,
type GetMessagesLimit,
type GetMessagesOptions,
} from '@discordeno/types'
import { hasProperty } from './utils.js'
@@ -28,3 +31,7 @@ export function isGetMessagesLimit(options: GetMessagesOptions): options is GetM
export function isInviteWithMetadata(options: DiscordInviteCreate | DiscordInviteMetadata): options is DiscordInviteMetadata {
return !hasProperty(options, 'channel_id')
}
export function isContextApplicationCommand(command: CreateApplicationCommand): command is CreateContextApplicationCommand {
return command.type === ApplicationCommandTypes.Message || command.type === ApplicationCommandTypes.User
}

View File

@@ -9,7 +9,7 @@
Create as many sidebars as you want.
*/
import { type SidebarsConfig } from '@docusaurus/plugin-content-docs'
import type { SidebarsConfig } from '@docusaurus/plugin-content-docs'
const sidebars: SidebarsConfig = {
// By default, Docusaurus generates a sidebar from the docs folder structure

View File

@@ -1,4 +1,4 @@
import { type Edge, type Node } from 'reactflow'
import type { Edge, Node } from 'reactflow'
import 'reactflow/dist/style.css'
import BaseFlowChart, { defaultNodeOptions, multiplier } from './BaseFlowChart'

View File

@@ -1,4 +1,4 @@
import { type FeatureList } from '@site/src/types'
import type { FeatureList } from '@site/src/types'
import clsx from 'clsx'
export default function Feature({ data }: FeatureList): JSX.Element {

View File

@@ -1,5 +1,5 @@
import styles from '@site/src/styling/styles.module.css'
import { type FeatureItem } from '@site/src/types'
import type { FeatureItem } from '@site/src/types'
import Feature from './feature'
const FeatureList: FeatureItem[] = [

View File

@@ -22,7 +22,7 @@
}
/* For readability concerns, you should choose a lighter palette in dark mode. */
[data-theme='dark'] {
[data-theme="dark"] {
--ifm-color-primary: #25c2a0;
--ifm-color-primary-dark: #21af90;
--ifm-color-primary-darker: #1fa588;
@@ -51,7 +51,7 @@
position: absolute;
left: 4px;
content: '+';
content: "+";
color: #00da86ce;
font-weight: bold;
@@ -71,7 +71,7 @@
position: absolute;
left: 4px;
content: '-';
content: "-";
color: #da001dce;
font-weight: bold;