wynn/ts/src/discord/index.ts
a edb99b5c3b
All checks were successful
commit-tag / commit-tag-image (map[context:./migrations file:./migrations/Dockerfile name:migrations]) (push) Successful in 18s
commit-tag / commit-tag-image (map[context:./ts file:./ts/Dockerfile name:ts]) (push) Successful in 1m36s
noot
2025-07-15 23:34:47 -05:00

92 lines
2.4 KiB
TypeScript

import { Intents, type InteractionTypes } from '@discordeno/types'
import type {
Bot,
CompleteDesiredProperties,
DesiredPropertiesBehavior,
DiscordInteractionContextType,
InteractionData,
RecursivePartial,
TransformersDesiredProperties,
} from 'discordeno'
export const intents = [
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,
] as const
export const desiredProperties = {
interaction: {
id: true,
data: true,
type: true,
token: true,
message: true,
channelId: true,
channel: true,
guildId: true,
guild: true,
user: true,
member: true,
context: true,
},
message: {
id: true,
member: true,
guildId: true,
},
} as const satisfies RecursivePartial<TransformersDesiredProperties>
export type DesiredProperties = typeof desiredProperties
export const createBotParameters = {
intents: intents.reduce((acc, curr) => acc | curr, Intents.Guilds),
desiredProperties,
} as const
export type BotType = Bot<CompleteDesiredProperties<DesiredProperties>, DesiredPropertiesBehavior.RemoveKey>
// Type for the interaction reference passed to workflows/activities
export interface InteractionRef {
// id of the interaction
id: bigint
/** A continuation token for responding to the interaction */
token: string
type: InteractionTypes
acknowledged?: boolean
/** The guild it was sent from */
guildId?: bigint
channelId?: bigint
/** Guild member data for the invoking user, including permissions */
memberId?: bigint
/** User object for the invoking user, if invoked in a DM */
userId?: bigint
/** For the message the button was attached to */
messageId?: bigint
// locale of the interaction
locale?: string
/** The guild's preferred locale, if invoked in a guild */
guildLocale?: string
/** Context where the interaction was triggered from */
context?: DiscordInteractionContextType
}
// Type for the complete interaction handling payload
export interface InteractionCreatePayload {
ref: InteractionRef
data: Omit<InteractionData, 'resolved'>
}