2025-06-14 23:04:46 +00:00
|
|
|
import { Intents, type InteractionTypes } from '@discordeno/types'
|
|
|
|
|
import type { Bot, CompleteDesiredProperties, DesiredPropertiesBehavior } from 'discordeno'
|
2025-06-14 05:36:37 +00:00
|
|
|
export const intents = [
|
2025-06-14 23:04:46 +00:00
|
|
|
Intents.GuildModeration,
|
|
|
|
|
Intents.GuildWebhooks,
|
|
|
|
|
Intents.GuildExpressions,
|
|
|
|
|
Intents.GuildScheduledEvents,
|
|
|
|
|
Intents.GuildMessagePolls,
|
|
|
|
|
Intents.GuildIntegrations,
|
|
|
|
|
Intents.GuildInvites,
|
|
|
|
|
Intents.GuildMessageReactions,
|
|
|
|
|
Intents.GuildPresences,
|
|
|
|
|
Intents.DirectMessages,
|
|
|
|
|
Intents.DirectMessageReactions,
|
|
|
|
|
Intents.GuildMembers,
|
|
|
|
|
Intents.Guilds,
|
|
|
|
|
Intents.GuildInvites,
|
|
|
|
|
Intents.GuildMessages,
|
2025-03-01 21:10:31 +00:00
|
|
|
] as const
|
|
|
|
|
|
2025-06-14 05:36:37 +00:00
|
|
|
export const createBotParameters = {
|
2025-06-14 23:04:46 +00:00
|
|
|
intents: intents.reduce((acc, curr) => acc | curr, Intents.Guilds),
|
|
|
|
|
desiredProperties: {
|
|
|
|
|
interaction: {
|
|
|
|
|
id: true,
|
|
|
|
|
data: true,
|
|
|
|
|
type: true,
|
|
|
|
|
token: true,
|
|
|
|
|
message: true,
|
|
|
|
|
channelId: true,
|
|
|
|
|
channel: true,
|
|
|
|
|
guildId: true,
|
|
|
|
|
guild: true,
|
|
|
|
|
user: true,
|
|
|
|
|
member: true,
|
|
|
|
|
},
|
|
|
|
|
message: {
|
|
|
|
|
id: true,
|
|
|
|
|
member: true,
|
|
|
|
|
guildId: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
2025-06-14 05:36:37 +00:00
|
|
|
} as const
|
|
|
|
|
|
|
|
|
|
// Extract the type of desired properties from our parameters
|
2025-06-14 23:04:46 +00:00
|
|
|
type ExtractedDesiredProperties = typeof createBotParameters.desiredProperties
|
2025-06-14 05:36:37 +00:00
|
|
|
|
|
|
|
|
// The BotType uses the CompleteDesiredProperties helper to fill in the missing properties
|
2025-06-14 23:04:46 +00:00
|
|
|
export type BotType = Bot<CompleteDesiredProperties<ExtractedDesiredProperties>, DesiredPropertiesBehavior.RemoveKey>
|
2025-06-14 05:36:37 +00:00
|
|
|
|
|
|
|
|
// Type for the interaction reference passed to workflows/activities
|
|
|
|
|
export interface InteractionRef {
|
2025-06-14 23:04:46 +00:00
|
|
|
id: bigint
|
|
|
|
|
token: string
|
|
|
|
|
type: InteractionTypes
|
|
|
|
|
acknowledged?: boolean
|
2025-06-14 05:36:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Type for the interaction data payload
|
2025-06-14 23:04:46 +00:00
|
|
|
export type InteractionData = Parameters<NonNullable<BotType['events']['interactionCreate']>>[0]['data']
|
2025-02-27 03:56:30 +00:00
|
|
|
|
2025-06-14 05:36:37 +00:00
|
|
|
// Type for the complete interaction handling payload
|
|
|
|
|
export interface InteractionCreatePayload {
|
2025-06-14 23:04:46 +00:00
|
|
|
ref: InteractionRef
|
|
|
|
|
data: InteractionData
|
2025-06-14 05:36:37 +00:00
|
|
|
}
|