mirror of
https://github.com/discordeno/discordeno.git
synced 2026-09-17 08:47:22 +00:00
formatter: Use semicolons (#4686)
I prefer semicolors, they also help avoiding certain pitfalls in JavaScript/TypeScript, such as the following code sample: ```js const xyz = "test" (something.else as string) = "another" ``` This results in a TypeError: "test" is not a function, this is because js thinks we are trying to call the string "test" as a function. To fix this it requires a `;` somewhere before the `(`, such as `;(something ... ` which in my opinion is ugly and less clean overall.
This commit is contained in:
+67
-67
@@ -1,20 +1,20 @@
|
||||
import type { CreateGatewayManagerOptions, GatewayManager } from '@discordeno/gateway'
|
||||
import { createGatewayManager, ShardSocketCloseCodes } from '@discordeno/gateway'
|
||||
import type { CreateRestManagerOptions, RestManager } from '@discordeno/rest'
|
||||
import { createRestManager } from '@discordeno/rest'
|
||||
import type { BigString, GatewayDispatchEventNames, GatewayIntents, RecursivePartial } from '@discordeno/types'
|
||||
import { createLogger, getBotIdFromToken, type logger } from '@discordeno/utils'
|
||||
import type { CreateGatewayManagerOptions, GatewayManager } from '@discordeno/gateway';
|
||||
import { createGatewayManager, ShardSocketCloseCodes } from '@discordeno/gateway';
|
||||
import type { CreateRestManagerOptions, RestManager } from '@discordeno/rest';
|
||||
import { createRestManager } from '@discordeno/rest';
|
||||
import type { BigString, GatewayDispatchEventNames, GatewayIntents, RecursivePartial } from '@discordeno/types';
|
||||
import { createLogger, getBotIdFromToken, type logger } from '@discordeno/utils';
|
||||
import type {
|
||||
CompleteDesiredProperties,
|
||||
DesiredPropertiesBehavior,
|
||||
SetupDesiredProps,
|
||||
TransformersDesiredProperties,
|
||||
TransformersObjects,
|
||||
} from './desiredProperties.js'
|
||||
import type { EventHandlers } from './events.js'
|
||||
import { type BotGatewayHandler, createBotGatewayHandlers, type GatewayHandlers } from './handlers.js'
|
||||
import { type BotHelpers, createBotHelpers } from './helpers.js'
|
||||
import { createTransformers, type Transformers } from './transformers.js'
|
||||
} from './desiredProperties.js';
|
||||
import type { EventHandlers } from './events.js';
|
||||
import { type BotGatewayHandler, createBotGatewayHandlers, type GatewayHandlers } from './handlers.js';
|
||||
import { type BotHelpers, createBotHelpers } from './helpers.js';
|
||||
import { createTransformers, type Transformers } from './transformers.js';
|
||||
|
||||
/**
|
||||
* Create a bot object that will maintain the rest and gateway connection.
|
||||
@@ -27,44 +27,44 @@ import { createTransformers, type Transformers } from './transformers.js'
|
||||
export function createBot<
|
||||
TProps extends TransformersDesiredProperties,
|
||||
TBehavior extends DesiredPropertiesBehavior = DesiredPropertiesBehavior.RemoveKey,
|
||||
>(options: CreateBotOptions<TProps, TBehavior>): Bot<TProps, TBehavior>
|
||||
>(options: CreateBotOptions<TProps, TBehavior>): Bot<TProps, TBehavior>;
|
||||
export function createBot<
|
||||
TProps extends RecursivePartial<TransformersDesiredProperties>,
|
||||
TBehavior extends DesiredPropertiesBehavior = DesiredPropertiesBehavior.RemoveKey,
|
||||
>(options: CreateBotOptions<TProps, TBehavior>): Bot<CompleteDesiredProperties<TProps>, TBehavior>
|
||||
>(options: CreateBotOptions<TProps, TBehavior>): Bot<CompleteDesiredProperties<TProps>, TBehavior>;
|
||||
|
||||
export function createBot<
|
||||
TProps extends RecursivePartial<TransformersDesiredProperties>,
|
||||
TBehavior extends DesiredPropertiesBehavior = DesiredPropertiesBehavior.RemoveKey,
|
||||
>(options: CreateBotOptions<TProps, TBehavior>): Bot<CompleteDesiredProperties<TProps>, TBehavior> {
|
||||
type CompleteProps = CompleteDesiredProperties<TProps>
|
||||
type TypedBot = Bot<CompleteProps, TBehavior>
|
||||
type CompleteProps = CompleteDesiredProperties<TProps>;
|
||||
type TypedBot = Bot<CompleteProps, TBehavior>;
|
||||
|
||||
if (!options.transformers) options.transformers = {}
|
||||
if (!options.rest) options.rest = { token: options.token, applicationId: options.applicationId }
|
||||
if (!options.rest.token) options.rest.token = options.token
|
||||
if (!options.rest.logger && options.loggerFactory) options.rest.logger = options.loggerFactory('REST')
|
||||
if (!options.gateway) options.gateway = { token: options.token }
|
||||
if (!options.gateway.token) options.gateway.token = options.token
|
||||
if (!options.gateway.events) options.gateway.events = {}
|
||||
if (!options.gateway.logger && options.loggerFactory) options.gateway.logger = options.loggerFactory('GATEWAY')
|
||||
if (!options.transformers) options.transformers = {};
|
||||
if (!options.rest) options.rest = { token: options.token, applicationId: options.applicationId };
|
||||
if (!options.rest.token) options.rest.token = options.token;
|
||||
if (!options.rest.logger && options.loggerFactory) options.rest.logger = options.loggerFactory('REST');
|
||||
if (!options.gateway) options.gateway = { token: options.token };
|
||||
if (!options.gateway.token) options.gateway.token = options.token;
|
||||
if (!options.gateway.events) options.gateway.events = {};
|
||||
if (!options.gateway.logger && options.loggerFactory) options.gateway.logger = options.loggerFactory('GATEWAY');
|
||||
if (!options.gateway.events.message) {
|
||||
options.gateway.events.message = async (shard, data) => {
|
||||
// TRIGGER RAW EVENT
|
||||
bot.events.raw?.(data, shard.id)
|
||||
bot.events.raw?.(data, shard.id);
|
||||
|
||||
if (!data.t) return
|
||||
if (!data.t) return;
|
||||
|
||||
// RUN DISPATCH CHECK
|
||||
await bot.events.dispatchRequirements?.(data, shard.id)
|
||||
bot.handlers[data.t as GatewayDispatchEventNames]?.(bot, data, shard.id)
|
||||
}
|
||||
await bot.events.dispatchRequirements?.(data, shard.id);
|
||||
bot.handlers[data.t as GatewayDispatchEventNames]?.(bot, data, shard.id);
|
||||
};
|
||||
}
|
||||
|
||||
options.gateway.intents = options.intents
|
||||
;(options.transformers as Transformers<CompleteProps, TBehavior>).desiredProperties = options.desiredProperties as CompleteProps
|
||||
options.gateway.intents = options.intents;
|
||||
(options.transformers as Transformers<CompleteProps, TBehavior>).desiredProperties = options.desiredProperties as CompleteProps;
|
||||
|
||||
const id = getBotIdFromToken(options.token)
|
||||
const id = getBotIdFromToken(options.token);
|
||||
|
||||
const bot: TypedBot = {
|
||||
id,
|
||||
@@ -79,63 +79,63 @@ export function createBot<
|
||||
helpers: {} as BotHelpers<CompleteProps, TBehavior>,
|
||||
async start() {
|
||||
if (!options.gateway?.connection) {
|
||||
bot.gateway.connection = await bot.rest.getSessionInfo()
|
||||
bot.gateway.connection = await bot.rest.getSessionInfo();
|
||||
|
||||
// Check for overrides in the configuration
|
||||
if (!options.gateway?.url) bot.gateway.url = bot.gateway.connection.url
|
||||
if (!options.gateway?.url) bot.gateway.url = bot.gateway.connection.url;
|
||||
|
||||
if (!options.gateway?.totalShards) bot.gateway.totalShards = bot.gateway.connection.shards
|
||||
if (!options.gateway?.totalShards) bot.gateway.totalShards = bot.gateway.connection.shards;
|
||||
|
||||
if (!options.gateway?.lastShardId && !options.gateway?.totalShards) bot.gateway.lastShardId = bot.gateway.connection.shards - 1
|
||||
if (!options.gateway?.lastShardId && !options.gateway?.totalShards) bot.gateway.lastShardId = bot.gateway.connection.shards - 1;
|
||||
}
|
||||
|
||||
if (!bot.gateway.resharding.getSessionInfo) {
|
||||
bot.gateway.resharding.getSessionInfo = async () => {
|
||||
return await bot.rest.getGatewayBot()
|
||||
}
|
||||
return await bot.rest.getGatewayBot();
|
||||
};
|
||||
}
|
||||
|
||||
await bot.gateway.spawnShards()
|
||||
await bot.gateway.spawnShards();
|
||||
},
|
||||
|
||||
async shutdown() {
|
||||
return await bot.gateway.shutdown(ShardSocketCloseCodes.Shutdown, 'User requested bot stop')
|
||||
return await bot.gateway.shutdown(ShardSocketCloseCodes.Shutdown, 'User requested bot stop');
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
bot.helpers = createBotHelpers(bot)
|
||||
if (options.applicationId) bot.applicationId = bot.transformers.snowflake(options.applicationId)
|
||||
bot.helpers = createBotHelpers(bot);
|
||||
if (options.applicationId) bot.applicationId = bot.transformers.snowflake(options.applicationId);
|
||||
|
||||
return bot
|
||||
return bot;
|
||||
}
|
||||
|
||||
export interface CreateBotOptions<TProps extends RecursivePartial<TransformersDesiredProperties>, TBehavior extends DesiredPropertiesBehavior> {
|
||||
/** The bot's token. */
|
||||
token: string
|
||||
token: string;
|
||||
/** Application Id of the bot incase it is an old bot token. */
|
||||
applicationId?: BigString
|
||||
applicationId?: BigString;
|
||||
/** The bot's intents that will be used to make a connection with discords gateway. */
|
||||
intents?: GatewayIntents
|
||||
intents?: GatewayIntents;
|
||||
/** Any options you wish to provide to the rest manager. */
|
||||
rest?: Omit<CreateRestManagerOptions, 'token'> & Partial<Pick<CreateRestManagerOptions, 'token'>>
|
||||
rest?: Omit<CreateRestManagerOptions, 'token'> & Partial<Pick<CreateRestManagerOptions, 'token'>>;
|
||||
/** Any options you wish to provide to the gateway manager. */
|
||||
gateway?: Omit<CreateGatewayManagerOptions, 'token'> & Partial<Pick<CreateGatewayManagerOptions, 'token'>>
|
||||
gateway?: Omit<CreateGatewayManagerOptions, 'token'> & Partial<Pick<CreateGatewayManagerOptions, 'token'>>;
|
||||
/** The event handlers. */
|
||||
events?: Partial<EventHandlers<CompleteDesiredProperties<NoInfer<TProps>>, TBehavior>>
|
||||
events?: Partial<EventHandlers<CompleteDesiredProperties<NoInfer<TProps>>, TBehavior>>;
|
||||
/** The functions that should transform discord objects to discordeno shaped objects. */
|
||||
transformers?: RecursivePartial<Omit<Transformers<CompleteDesiredProperties<NoInfer<TProps>>, TBehavior>, 'desiredProperties'>>
|
||||
transformers?: RecursivePartial<Omit<Transformers<CompleteDesiredProperties<NoInfer<TProps>>, TBehavior>, 'desiredProperties'>>;
|
||||
/** The handler functions that should handle incoming discord payloads from gateway and call an event. */
|
||||
handlers?: Partial<Record<GatewayDispatchEventNames, BotGatewayHandler<CompleteDesiredProperties<NoInfer<TProps>>, TBehavior>>>
|
||||
handlers?: Partial<Record<GatewayDispatchEventNames, BotGatewayHandler<CompleteDesiredProperties<NoInfer<TProps>>, TBehavior>>>;
|
||||
/**
|
||||
* Set the desired properties for the bot
|
||||
*/
|
||||
desiredProperties: TProps
|
||||
desiredProperties: TProps;
|
||||
/**
|
||||
* Set the desired properties behavior for undesired properties
|
||||
*
|
||||
* @default DesiredPropertiesBehavior.RemoveKey
|
||||
*/
|
||||
desiredPropertiesBehavior?: TBehavior
|
||||
desiredPropertiesBehavior?: TBehavior;
|
||||
/**
|
||||
* This factory will be invoked to create the logger for gateway, rest and bot
|
||||
*
|
||||
@@ -144,7 +144,7 @@ export interface CreateBotOptions<TProps extends RecursivePartial<TransformersDe
|
||||
*
|
||||
* This function will be invoked 3 times, one with the name of `REST`, one with `GATEWAY` and the third one with name `BOT`
|
||||
*/
|
||||
loggerFactory?: (name: 'REST' | 'GATEWAY' | 'BOT') => Pick<typeof logger, 'debug' | 'info' | 'warn' | 'error' | 'fatal'>
|
||||
loggerFactory?: (name: 'REST' | 'GATEWAY' | 'BOT') => Pick<typeof logger, 'debug' | 'info' | 'warn' | 'error' | 'fatal'>;
|
||||
}
|
||||
|
||||
export interface Bot<
|
||||
@@ -152,28 +152,28 @@ export interface Bot<
|
||||
TBehavior extends DesiredPropertiesBehavior = DesiredPropertiesBehavior.RemoveKey,
|
||||
> {
|
||||
/** The id of the bot. */
|
||||
id: bigint
|
||||
id: bigint;
|
||||
/** The application id of the bot. This is usually the same as id but in the case of old bots can be different. */
|
||||
applicationId: bigint
|
||||
applicationId: bigint;
|
||||
/** The rest manager. */
|
||||
rest: RestManager
|
||||
rest: RestManager;
|
||||
/** The gateway manager. */
|
||||
gateway: GatewayManager
|
||||
gateway: GatewayManager;
|
||||
/** The event handlers. */
|
||||
events: Partial<EventHandlers<TProps, TBehavior>>
|
||||
events: Partial<EventHandlers<TProps, TBehavior>>;
|
||||
/** A logger utility to make it easy to log nice and useful things in the bot code. */
|
||||
logger: Pick<typeof logger, 'debug' | 'info' | 'warn' | 'error' | 'fatal'>
|
||||
logger: Pick<typeof logger, 'debug' | 'info' | 'warn' | 'error' | 'fatal'>;
|
||||
/** The functions that should transform discord objects to discordeno shaped objects. */
|
||||
transformers: Transformers<TProps, TBehavior> & {
|
||||
$inferredTypes: {
|
||||
[K in keyof TransformersObjects]: SetupDesiredProps<TransformersObjects[K], TProps, TBehavior>
|
||||
}
|
||||
}
|
||||
[K in keyof TransformersObjects]: SetupDesiredProps<TransformersObjects[K], TProps, TBehavior>;
|
||||
};
|
||||
};
|
||||
/** The handler functions that should handle incoming discord payloads from gateway and call an event. */
|
||||
handlers: GatewayHandlers<TProps, TBehavior>
|
||||
helpers: BotHelpers<TProps, TBehavior>
|
||||
handlers: GatewayHandlers<TProps, TBehavior>;
|
||||
helpers: BotHelpers<TProps, TBehavior>;
|
||||
/** Start the bot connection to the gateway. */
|
||||
start: () => Promise<void>
|
||||
start: () => Promise<void>;
|
||||
/** Shuts down all the bot connections to the gateway. */
|
||||
shutdown: () => Promise<void>
|
||||
shutdown: () => Promise<void>;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ApplicationCommandOptionTypes } from '@discordeno/types'
|
||||
import type { CompleteDesiredProperties, DesiredPropertiesBehavior, SetupDesiredProps, TransformersDesiredProperties } from './desiredProperties.js'
|
||||
import type { Attachment, Channel, Interaction, InteractionDataOption, Member, Role, User } from './transformers/types.js'
|
||||
import { ApplicationCommandOptionTypes } from '@discordeno/types';
|
||||
import type { CompleteDesiredProperties, DesiredPropertiesBehavior, SetupDesiredProps, TransformersDesiredProperties } from './desiredProperties.js';
|
||||
import type { Attachment, Channel, Interaction, InteractionDataOption, Member, Role, User } from './transformers/types.js';
|
||||
|
||||
export function commandOptionsParser<
|
||||
TProps extends TransformersDesiredProperties & { interaction: { data: true } },
|
||||
@@ -11,51 +11,51 @@ export function commandOptionsParser<
|
||||
Interaction,
|
||||
CompleteDesiredProperties<{ interaction: { data: true } }>,
|
||||
DesiredPropertiesBehavior.RemoveKey
|
||||
>
|
||||
>;
|
||||
|
||||
if (!interaction.data) return {}
|
||||
if (!options) options = interaction.data.options ?? []
|
||||
if (!interaction.data) return {};
|
||||
if (!options) options = interaction.data.options ?? [];
|
||||
|
||||
const args: ParsedInteractionOption<TProps, TBehavior> = {}
|
||||
const args: ParsedInteractionOption<TProps, TBehavior> = {};
|
||||
|
||||
for (const option of options) {
|
||||
switch (option.type) {
|
||||
case ApplicationCommandOptionTypes.SubCommandGroup:
|
||||
case ApplicationCommandOptionTypes.SubCommand:
|
||||
args[option.name] = commandOptionsParser(interaction, option.options) as InteractionResolvedData<TProps, TBehavior>
|
||||
break
|
||||
args[option.name] = commandOptionsParser(interaction, option.options) as InteractionResolvedData<TProps, TBehavior>;
|
||||
break;
|
||||
case ApplicationCommandOptionTypes.Channel:
|
||||
args[option.name] = interaction.data.resolved?.channels?.get(BigInt(option.value!)) as InteractionResolvedData<TProps, TBehavior>
|
||||
break
|
||||
args[option.name] = interaction.data.resolved?.channels?.get(BigInt(option.value!)) as InteractionResolvedData<TProps, TBehavior>;
|
||||
break;
|
||||
case ApplicationCommandOptionTypes.Role:
|
||||
args[option.name] = interaction.data.resolved?.roles?.get(BigInt(option.value!)) as InteractionResolvedData<TProps, TBehavior>
|
||||
break
|
||||
args[option.name] = interaction.data.resolved?.roles?.get(BigInt(option.value!)) as InteractionResolvedData<TProps, TBehavior>;
|
||||
break;
|
||||
case ApplicationCommandOptionTypes.User:
|
||||
args[option.name] = {
|
||||
user: interaction.data.resolved?.users?.get(BigInt(option.value!)) as InteractionResolvedData<TProps, TBehavior>,
|
||||
member: interaction.data.resolved?.members?.get(BigInt(option.value!)) as InteractionResolvedData<TProps, TBehavior>,
|
||||
}
|
||||
break
|
||||
};
|
||||
break;
|
||||
case ApplicationCommandOptionTypes.Attachment:
|
||||
args[option.name] = interaction.data.resolved?.attachments?.get(BigInt(option.value!)) as InteractionResolvedData<TProps, TBehavior>
|
||||
break
|
||||
args[option.name] = interaction.data.resolved?.attachments?.get(BigInt(option.value!)) as InteractionResolvedData<TProps, TBehavior>;
|
||||
break;
|
||||
case ApplicationCommandOptionTypes.Mentionable:
|
||||
// Mentionable are roles or users
|
||||
args[option.name] = (interaction.data.resolved?.roles?.get(BigInt(option.value!)) as ParsedInteractionOption<TProps, TBehavior>[string]) ?? {
|
||||
user: interaction.data.resolved?.users?.get(BigInt(option.value!)) as InteractionResolvedData<TProps, TBehavior>,
|
||||
member: interaction.data.resolved?.members?.get(BigInt(option.value!)) as InteractionResolvedData<TProps, TBehavior>,
|
||||
}
|
||||
break
|
||||
};
|
||||
break;
|
||||
default:
|
||||
args[option.name] = option.value as InteractionResolvedData<TProps, TBehavior>
|
||||
args[option.name] = option.value as InteractionResolvedData<TProps, TBehavior>;
|
||||
}
|
||||
}
|
||||
|
||||
return args
|
||||
return args;
|
||||
}
|
||||
|
||||
export interface ParsedInteractionOption<TProps extends TransformersDesiredProperties, TBehavior extends DesiredPropertiesBehavior> {
|
||||
[key: string]: InteractionResolvedData<TProps, TBehavior>
|
||||
[key: string]: InteractionResolvedData<TProps, TBehavior>;
|
||||
}
|
||||
|
||||
export type InteractionResolvedData<TProps extends TransformersDesiredProperties, TBehavior extends DesiredPropertiesBehavior> =
|
||||
@@ -66,11 +66,11 @@ export type InteractionResolvedData<TProps extends TransformersDesiredProperties
|
||||
| InteractionResolvedDataChannel<TProps, TBehavior>
|
||||
| SetupDesiredProps<Role, TProps, TBehavior>
|
||||
| SetupDesiredProps<Attachment, TProps, TBehavior>
|
||||
| ParsedInteractionOption<TProps, TBehavior>
|
||||
| ParsedInteractionOption<TProps, TBehavior>;
|
||||
|
||||
export interface InteractionResolvedDataUser<TProps extends TransformersDesiredProperties, TBehavior extends DesiredPropertiesBehavior> {
|
||||
user: SetupDesiredProps<User, TProps, TBehavior>
|
||||
member: InteractionResolvedDataMember<TProps, TBehavior>
|
||||
user: SetupDesiredProps<User, TProps, TBehavior>;
|
||||
member: InteractionResolvedDataMember<TProps, TBehavior>;
|
||||
}
|
||||
|
||||
export type InteractionResolvedDataChannel<TProps extends TransformersDesiredProperties, TBehavior extends DesiredPropertiesBehavior> = Pick<
|
||||
@@ -92,17 +92,17 @@ export type InteractionResolvedDataChannel<TProps extends TransformersDesiredPro
|
||||
| 'position'
|
||||
| 'threadMetadata'
|
||||
>
|
||||
>
|
||||
>;
|
||||
|
||||
export type InteractionResolvedDataMember<TProps extends TransformersDesiredProperties, TBehavior extends DesiredPropertiesBehavior> = Omit<
|
||||
SetupDesiredProps<Member, TProps, TBehavior>,
|
||||
'user' | 'deaf' | 'mute'
|
||||
>
|
||||
>;
|
||||
|
||||
/** @deprecated Use {@link InteractionResolvedDataUser} */
|
||||
export interface InteractionResolvedUser {
|
||||
user: User
|
||||
member: InteractionResolvedMember
|
||||
user: User;
|
||||
member: InteractionResolvedMember;
|
||||
}
|
||||
|
||||
/** @deprecated Use {@link InteractionResolvedDataChannel} */
|
||||
@@ -122,7 +122,7 @@ export type InteractionResolvedChannel = Pick<
|
||||
| 'topic'
|
||||
| 'position'
|
||||
| 'threadMetadata'
|
||||
>
|
||||
>;
|
||||
|
||||
/** @deprecated Use {@link InteractionResolvedDataMember} */
|
||||
export type InteractionResolvedMember = Omit<Member, 'user' | 'deaf' | 'mute'>
|
||||
export type InteractionResolvedMember = Omit<Member, 'user' | 'deaf' | 'mute'>;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export const SLASH_COMMANDS_NAME_REGEX = /^[-_ʼ\p{L}\p{N}\p{sc=Deva}\p{sc=Thai}]{1,32}$/u
|
||||
export const CONTEXT_MENU_COMMANDS_NAME_REGEX = /^[\w-\s]{1,32}$/
|
||||
export const CHANNEL_MENTION_REGEX = /<#[0-9]+>/g
|
||||
export const DISCORD_SNOWFLAKE_REGEX = /^(?<id>\d{17,19})$/
|
||||
export const SLASH_COMMANDS_NAME_REGEX = /^[-_ʼ\p{L}\p{N}\p{sc=Deva}\p{sc=Thai}]{1,32}$/u;
|
||||
export const CONTEXT_MENU_COMMANDS_NAME_REGEX = /^[\w-\s]{1,32}$/;
|
||||
export const CHANNEL_MENTION_REGEX = /<#[0-9]+>/g;
|
||||
export const DISCORD_SNOWFLAKE_REGEX = /^(?<id>\d{17,19})$/;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { RecursivePartial } from '@discordeno/types'
|
||||
import type { Collection } from '@discordeno/utils'
|
||||
import type { Bot } from './bot.js'
|
||||
import type { InteractionResolvedDataChannel, InteractionResolvedDataMember } from './commandOptionsParser.js'
|
||||
import type { RecursivePartial } from '@discordeno/types';
|
||||
import type { Collection } from '@discordeno/utils';
|
||||
import type { Bot } from './bot.js';
|
||||
import type { InteractionResolvedDataChannel, InteractionResolvedDataMember } from './commandOptionsParser.js';
|
||||
import type {
|
||||
ActivityInstance,
|
||||
ActivityLocation,
|
||||
@@ -56,7 +56,7 @@ import type {
|
||||
UserPrimaryGuild,
|
||||
VoiceState,
|
||||
Webhook,
|
||||
} from './transformers/types.js'
|
||||
} from './transformers/types.js';
|
||||
|
||||
/**
|
||||
* All the objects that support desired properties
|
||||
@@ -64,59 +64,59 @@ import type {
|
||||
* @private This is subject to breaking changes at any time
|
||||
*/
|
||||
export interface TransformersObjects {
|
||||
activityInstance: ActivityInstance
|
||||
activityLocation: ActivityLocation
|
||||
attachment: Attachment
|
||||
avatarDecorationData: AvatarDecorationData
|
||||
channel: Channel
|
||||
collectibles: Collectibles
|
||||
component: Component
|
||||
defaultReactionEmoji: DefaultReactionEmoji
|
||||
emoji: Emoji
|
||||
entitlement: Entitlement
|
||||
forumTag: ForumTag
|
||||
guild: Guild
|
||||
guildOnboarding: GuildOnboarding
|
||||
guildOnboardingPrompt: GuildOnboardingPrompt
|
||||
guildOnboardingPromptOption: GuildOnboardingPromptOption
|
||||
incidentsData: IncidentsData
|
||||
interaction: Interaction
|
||||
interactionCallback: InteractionCallback
|
||||
interactionCallbackResponse: InteractionCallbackResponse
|
||||
interactionResource: InteractionResource
|
||||
invite: Invite
|
||||
inviteStageInstance: InviteStageInstance
|
||||
lobby: Lobby
|
||||
lobbyMember: LobbyMember
|
||||
mediaGalleryItem: MediaGalleryItem
|
||||
member: Member
|
||||
message: Message
|
||||
messageCall: MessageCall
|
||||
messageInteraction: MessageInteraction
|
||||
messageInteractionMetadata: MessageInteractionMetadata
|
||||
messagePin: MessagePin
|
||||
messageReference: MessageReference
|
||||
messageSnapshot: MessageSnapshot
|
||||
nameplate: Nameplate
|
||||
poll: Poll
|
||||
pollAnswer: PollAnswer
|
||||
pollAnswerCount: PollAnswerCount
|
||||
pollMedia: PollMedia
|
||||
pollResult: PollResult
|
||||
role: Role
|
||||
roleColors: RoleColors
|
||||
scheduledEvent: ScheduledEvent
|
||||
scheduledEventRecurrenceRule: ScheduledEventRecurrenceRule
|
||||
sku: Sku
|
||||
soundboardSound: SoundboardSound
|
||||
stageInstance: StageInstance
|
||||
sticker: Sticker
|
||||
subscription: Subscription
|
||||
unfurledMediaItem: UnfurledMediaItem
|
||||
user: User
|
||||
userPrimaryGuild: UserPrimaryGuild
|
||||
voiceState: VoiceState
|
||||
webhook: Webhook
|
||||
activityInstance: ActivityInstance;
|
||||
activityLocation: ActivityLocation;
|
||||
attachment: Attachment;
|
||||
avatarDecorationData: AvatarDecorationData;
|
||||
channel: Channel;
|
||||
collectibles: Collectibles;
|
||||
component: Component;
|
||||
defaultReactionEmoji: DefaultReactionEmoji;
|
||||
emoji: Emoji;
|
||||
entitlement: Entitlement;
|
||||
forumTag: ForumTag;
|
||||
guild: Guild;
|
||||
guildOnboarding: GuildOnboarding;
|
||||
guildOnboardingPrompt: GuildOnboardingPrompt;
|
||||
guildOnboardingPromptOption: GuildOnboardingPromptOption;
|
||||
incidentsData: IncidentsData;
|
||||
interaction: Interaction;
|
||||
interactionCallback: InteractionCallback;
|
||||
interactionCallbackResponse: InteractionCallbackResponse;
|
||||
interactionResource: InteractionResource;
|
||||
invite: Invite;
|
||||
inviteStageInstance: InviteStageInstance;
|
||||
lobby: Lobby;
|
||||
lobbyMember: LobbyMember;
|
||||
mediaGalleryItem: MediaGalleryItem;
|
||||
member: Member;
|
||||
message: Message;
|
||||
messageCall: MessageCall;
|
||||
messageInteraction: MessageInteraction;
|
||||
messageInteractionMetadata: MessageInteractionMetadata;
|
||||
messagePin: MessagePin;
|
||||
messageReference: MessageReference;
|
||||
messageSnapshot: MessageSnapshot;
|
||||
nameplate: Nameplate;
|
||||
poll: Poll;
|
||||
pollAnswer: PollAnswer;
|
||||
pollAnswerCount: PollAnswerCount;
|
||||
pollMedia: PollMedia;
|
||||
pollResult: PollResult;
|
||||
role: Role;
|
||||
roleColors: RoleColors;
|
||||
scheduledEvent: ScheduledEvent;
|
||||
scheduledEventRecurrenceRule: ScheduledEventRecurrenceRule;
|
||||
sku: Sku;
|
||||
soundboardSound: SoundboardSound;
|
||||
stageInstance: StageInstance;
|
||||
sticker: Sticker;
|
||||
subscription: Subscription;
|
||||
unfurledMediaItem: UnfurledMediaItem;
|
||||
user: User;
|
||||
userPrimaryGuild: UserPrimaryGuild;
|
||||
voiceState: VoiceState;
|
||||
webhook: Webhook;
|
||||
}
|
||||
|
||||
// NOTE: the top-level objects need both the dependencies and alwaysPresents even if empty when the key is specified, this is due the extends & nullability on DesiredPropertiesMetadata
|
||||
@@ -130,107 +130,107 @@ export interface TransformersObjects {
|
||||
export interface TransformersDesiredPropertiesMetadata extends DesiredPropertiesMetadata {
|
||||
channel: {
|
||||
dependencies: {
|
||||
archived: ['toggles']
|
||||
invitable: ['toggles']
|
||||
locked: ['toggles']
|
||||
nsfw: ['toggles']
|
||||
newlyCreated: ['toggles']
|
||||
managed: ['toggles']
|
||||
}
|
||||
alwaysPresents: ['toggles', 'internalOverwrites', 'internalThreadMetadata']
|
||||
}
|
||||
archived: ['toggles'];
|
||||
invitable: ['toggles'];
|
||||
locked: ['toggles'];
|
||||
nsfw: ['toggles'];
|
||||
newlyCreated: ['toggles'];
|
||||
managed: ['toggles'];
|
||||
};
|
||||
alwaysPresents: ['toggles', 'internalOverwrites', 'internalThreadMetadata'];
|
||||
};
|
||||
|
||||
guild: {
|
||||
dependencies: {
|
||||
threads: ['channels']
|
||||
features: ['toggles']
|
||||
}
|
||||
alwaysPresents: []
|
||||
}
|
||||
threads: ['channels'];
|
||||
features: ['toggles'];
|
||||
};
|
||||
alwaysPresents: [];
|
||||
};
|
||||
|
||||
interaction: {
|
||||
dependencies: {
|
||||
respond: ['type', 'token', 'id']
|
||||
edit: ['type', 'token', 'id']
|
||||
deferEdit: ['type', 'token', 'id']
|
||||
defer: ['type', 'token', 'id']
|
||||
delete: ['type', 'token']
|
||||
}
|
||||
alwaysPresents: ['bot', 'acknowledged']
|
||||
}
|
||||
respond: ['type', 'token', 'id'];
|
||||
edit: ['type', 'token', 'id'];
|
||||
deferEdit: ['type', 'token', 'id'];
|
||||
defer: ['type', 'token', 'id'];
|
||||
delete: ['type', 'token'];
|
||||
};
|
||||
alwaysPresents: ['bot', 'acknowledged'];
|
||||
};
|
||||
|
||||
member: {
|
||||
dependencies: {
|
||||
deaf: ['toggles']
|
||||
mute: ['toggles']
|
||||
pending: ['toggles']
|
||||
flags: ['toggles']
|
||||
didRejoin: ['toggles']
|
||||
startedOnboarding: ['toggles']
|
||||
bypassesVerification: ['toggles']
|
||||
completedOnboarding: ['toggles']
|
||||
}
|
||||
alwaysPresents: []
|
||||
}
|
||||
deaf: ['toggles'];
|
||||
mute: ['toggles'];
|
||||
pending: ['toggles'];
|
||||
flags: ['toggles'];
|
||||
didRejoin: ['toggles'];
|
||||
startedOnboarding: ['toggles'];
|
||||
bypassesVerification: ['toggles'];
|
||||
completedOnboarding: ['toggles'];
|
||||
};
|
||||
alwaysPresents: [];
|
||||
};
|
||||
|
||||
message: {
|
||||
dependencies: {
|
||||
crossposted: ['flags']
|
||||
ephemeral: ['flags']
|
||||
failedToMentionSomeRolesInThread: ['flags']
|
||||
hasThread: ['flags']
|
||||
isCrosspost: ['flags']
|
||||
loading: ['flags']
|
||||
mentionedUserIds: ['mentions']
|
||||
mentionEveryone: ['bitfield']
|
||||
pinned: ['bitfield']
|
||||
sourceMessageDeleted: ['flags']
|
||||
suppressEmbeds: ['flags']
|
||||
suppressNotifications: ['flags']
|
||||
timestamp: ['id']
|
||||
tts: ['bitfield']
|
||||
urgent: ['flags']
|
||||
}
|
||||
alwaysPresents: ['bitfield', 'flags']
|
||||
}
|
||||
crossposted: ['flags'];
|
||||
ephemeral: ['flags'];
|
||||
failedToMentionSomeRolesInThread: ['flags'];
|
||||
hasThread: ['flags'];
|
||||
isCrosspost: ['flags'];
|
||||
loading: ['flags'];
|
||||
mentionedUserIds: ['mentions'];
|
||||
mentionEveryone: ['bitfield'];
|
||||
pinned: ['bitfield'];
|
||||
sourceMessageDeleted: ['flags'];
|
||||
suppressEmbeds: ['flags'];
|
||||
suppressNotifications: ['flags'];
|
||||
timestamp: ['id'];
|
||||
tts: ['bitfield'];
|
||||
urgent: ['flags'];
|
||||
};
|
||||
alwaysPresents: ['bitfield', 'flags'];
|
||||
};
|
||||
|
||||
role: {
|
||||
dependencies: {
|
||||
hoist: ['toggles']
|
||||
managed: ['toggles']
|
||||
mentionable: ['toggles']
|
||||
premiumSubscriber: ['toggles']
|
||||
availableForPurchase: ['toggles']
|
||||
guildConnections: ['toggles']
|
||||
}
|
||||
alwaysPresents: ['internalTags']
|
||||
}
|
||||
hoist: ['toggles'];
|
||||
managed: ['toggles'];
|
||||
mentionable: ['toggles'];
|
||||
premiumSubscriber: ['toggles'];
|
||||
availableForPurchase: ['toggles'];
|
||||
guildConnections: ['toggles'];
|
||||
};
|
||||
alwaysPresents: ['internalTags'];
|
||||
};
|
||||
|
||||
user: {
|
||||
dependencies: {
|
||||
tag: ['username', 'discriminator']
|
||||
bot: ['toggles']
|
||||
system: ['toggles']
|
||||
mfaEnabled: ['toggles']
|
||||
verified: ['toggles']
|
||||
avatarUrl: ['avatar', 'id']
|
||||
displayName: ['username', 'globalName']
|
||||
defaultAvatarUrl: ['id', 'discriminator']
|
||||
displayAvatarUrl: ['avatar', 'id', 'discriminator']
|
||||
createdTimestamp: ['id']
|
||||
}
|
||||
alwaysPresents: []
|
||||
}
|
||||
tag: ['username', 'discriminator'];
|
||||
bot: ['toggles'];
|
||||
system: ['toggles'];
|
||||
mfaEnabled: ['toggles'];
|
||||
verified: ['toggles'];
|
||||
avatarUrl: ['avatar', 'id'];
|
||||
displayName: ['username', 'globalName'];
|
||||
defaultAvatarUrl: ['id', 'discriminator'];
|
||||
displayAvatarUrl: ['avatar', 'id', 'discriminator'];
|
||||
createdTimestamp: ['id'];
|
||||
};
|
||||
alwaysPresents: [];
|
||||
};
|
||||
|
||||
emoji: {
|
||||
dependencies: {
|
||||
animated: ['toggles']
|
||||
available: ['toggles']
|
||||
managed: ['toggles']
|
||||
requireColons: ['toggles']
|
||||
}
|
||||
alwaysPresents: ['toggles']
|
||||
}
|
||||
animated: ['toggles'];
|
||||
available: ['toggles'];
|
||||
managed: ['toggles'];
|
||||
requireColons: ['toggles'];
|
||||
};
|
||||
alwaysPresents: ['toggles'];
|
||||
};
|
||||
}
|
||||
|
||||
export function createDesiredPropertiesObject<T extends RecursivePartial<TransformersDesiredProperties>, TDefault extends boolean = false>(
|
||||
@@ -859,35 +859,35 @@ export function createDesiredPropertiesObject<T extends RecursivePartial<Transfo
|
||||
flags: defaultValue,
|
||||
...desiredProperties.lobbyMember,
|
||||
},
|
||||
} satisfies TransformersDesiredProperties as CompleteDesiredProperties<T, TDefault>
|
||||
} satisfies TransformersDesiredProperties as CompleteDesiredProperties<T, TDefault>;
|
||||
}
|
||||
|
||||
/** @private This is subject to breaking changes without notices */
|
||||
export type KeyByValue<TObj, TValue> = {
|
||||
[Key in keyof TObj]: TObj[Key] extends TValue ? Key : never
|
||||
}[keyof TObj]
|
||||
[Key in keyof TObj]: TObj[Key] extends TValue ? Key : never;
|
||||
}[keyof TObj];
|
||||
|
||||
/** @private This is subject to breaking changes without notices */
|
||||
export type Complete<TObj, TDefault> = {
|
||||
[K in keyof TObj]-?: undefined extends TObj[K] ? TDefault : Exclude<TObj[K], undefined>
|
||||
}
|
||||
[K in keyof TObj]-?: undefined extends TObj[K] ? TDefault : Exclude<TObj[K], undefined>;
|
||||
};
|
||||
|
||||
/** @private This is subject to breaking changes without notices */
|
||||
export type JoinTuple<T extends string[], TDelimiter extends string> = T extends readonly [infer F extends string, ...infer R extends string[]]
|
||||
? R['length'] extends 0
|
||||
? F
|
||||
: `${F}${TDelimiter}${JoinTuple<R, TDelimiter>}`
|
||||
: ''
|
||||
: '';
|
||||
|
||||
/** @private This is subject to breaking changes without notices */
|
||||
export type DesiredPropertiesMetadata = {
|
||||
[K in keyof TransformersObjects]: {
|
||||
dependencies?: {
|
||||
[Key in keyof TransformersObjects[K]]?: (keyof TransformersObjects[K])[]
|
||||
}
|
||||
alwaysPresents?: (keyof TransformersObjects[K])[]
|
||||
}
|
||||
}
|
||||
[Key in keyof TransformersObjects[K]]?: (keyof TransformersObjects[K])[];
|
||||
};
|
||||
alwaysPresents?: (keyof TransformersObjects[K])[];
|
||||
};
|
||||
};
|
||||
|
||||
/** @private This is subject to breaking changes without notices */
|
||||
export type DesirableProperties<
|
||||
@@ -901,24 +901,24 @@ export type DesirableProperties<
|
||||
| (keyof T extends NonNullable<TransformersDesiredPropertiesMetadata[TKey]['alwaysPresents']>[number]
|
||||
? never
|
||||
: NonNullable<TransformersDesiredPropertiesMetadata[TKey]['alwaysPresents']>[number])
|
||||
>
|
||||
>;
|
||||
|
||||
/** @private This is subject to breaking changes without notices */
|
||||
export type DesiredPropertiesMapper<T extends TransformersObjects[keyof TransformersObjects]> = {
|
||||
[Key in DesirableProperties<T>]: boolean
|
||||
}
|
||||
[Key in DesirableProperties<T>]: boolean;
|
||||
};
|
||||
|
||||
declare const TypeErrorSymbol: unique symbol
|
||||
declare const TypeErrorSymbol: unique symbol;
|
||||
|
||||
/** @private This is subject to breaking changes without notices */
|
||||
export interface DesiredPropertiesError<T extends string> {
|
||||
[TypeErrorSymbol]: T
|
||||
[TypeErrorSymbol]: T;
|
||||
}
|
||||
|
||||
/** @private This is subject to breaking changes without notices */
|
||||
export type AreDependenciesSatisfied<T, TDependencies extends Record<string, string[]> | undefined, TProps> = {
|
||||
[K in keyof T]: IsKeyDesired<T[K], TDependencies, TProps> extends true ? true : false
|
||||
}
|
||||
[K in keyof T]: IsKeyDesired<T[K], TDependencies, TProps> extends true ? true : false;
|
||||
};
|
||||
|
||||
/** @private This is subject to breaking changes without notices */
|
||||
export type IsKeyDesired<TKey, TDependencies extends Record<string, string[]> | undefined, TProps> = TKey extends keyof TProps // The key has a desired props?
|
||||
@@ -937,7 +937,7 @@ export type IsKeyDesired<TKey, TDependencies extends Record<string, string[]> |
|
||||
: // No, this is a key to not include
|
||||
DesiredPropertiesError<`This property depends on the following properties: ${JoinTuple<NonNullable<TDependencies>[TKey], ', '>}. Not all of these props are set as desired in desiredProperties option in createBot(), so you can't use it. More info here: https://discordeno.js.org/desired-props`>
|
||||
: // No, we include it but it does not have neither props nor dependencies
|
||||
true
|
||||
true;
|
||||
|
||||
/** The behavior it should be used when resolving an undesired property */
|
||||
export enum DesiredPropertiesBehavior {
|
||||
@@ -954,7 +954,7 @@ export type RemoveKeyIfUndesired<Key, T, TProps extends TransformersDesiredPrope
|
||||
TProps[KeyByValue<TransformersObjects, T>]
|
||||
> extends true
|
||||
? Key
|
||||
: never
|
||||
: never;
|
||||
|
||||
/** @private This is subject to breaking changes without notices */
|
||||
export type GetErrorWhenUndesired<
|
||||
@@ -968,10 +968,10 @@ export type GetErrorWhenUndesired<
|
||||
TransformersDesiredPropertiesMetadata[KeyByValue<TransformersObjects, T>]['dependencies'],
|
||||
TProps[KeyByValue<TransformersObjects, T>]
|
||||
>,
|
||||
> = TIsDesired extends true ? TransformProperty<T[Key], TProps, TBehavior> : TIsDesired
|
||||
> = TIsDesired extends true ? TransformProperty<T[Key], TProps, TBehavior> : TIsDesired;
|
||||
|
||||
/** @private This is subject to breaking changes without notices */
|
||||
export type IsObject<T> = T extends object ? (T extends Function ? false : true) : false
|
||||
export type IsObject<T> = T extends object ? (T extends Function ? false : true) : false;
|
||||
|
||||
// If the object is a transformed object, a collection of transformed object or an array of transformed objects we need to apply the desired props to them as well
|
||||
// NOTE: changing the order of these ternaries can cause bugs, for this reason we check in this order:
|
||||
@@ -1015,7 +1015,7 @@ export type TransformProperty<T, TProps extends TransformersDesiredProperties, T
|
||||
? // Yes, we need to ensure nested inside there aren't transformed objects
|
||||
{ [K in keyof T]: TransformProperty<T[K], TProps, TBehavior> }
|
||||
: // No, this is a normal value such as string / bigint / number
|
||||
T
|
||||
T;
|
||||
|
||||
/**
|
||||
* Apply desired properties to a transformer object.
|
||||
@@ -1031,17 +1031,17 @@ export type SetupDesiredProps<
|
||||
: Key]: // When the behavior is to change the type we use the GetErrorWhenUndesired type helper else apply the desired props to the key and return
|
||||
TBehavior extends DesiredPropertiesBehavior.ChangeType
|
||||
? GetErrorWhenUndesired<Key, T, TProps, TBehavior>
|
||||
: TransformProperty<T[Key], TProps, TBehavior>
|
||||
}
|
||||
: TransformProperty<T[Key], TProps, TBehavior>;
|
||||
};
|
||||
|
||||
/**
|
||||
* The desired properties for each transformer object.
|
||||
*/
|
||||
export type TransformersDesiredProperties = {
|
||||
[Key in keyof TransformersObjects]: DesiredPropertiesMapper<TransformersObjects[Key]>
|
||||
}
|
||||
[Key in keyof TransformersObjects]: DesiredPropertiesMapper<TransformersObjects[Key]>;
|
||||
};
|
||||
|
||||
/** @private This is subject to breaking changes without notices */
|
||||
export type CompleteDesiredProperties<T extends RecursivePartial<TransformersDesiredProperties>, TTDefault extends boolean = false> = {
|
||||
[K in keyof TransformersDesiredProperties]: Complete<Partial<TransformersDesiredProperties[K]> & T[K], TTDefault>
|
||||
}
|
||||
[K in keyof TransformersDesiredProperties]: Complete<Partial<TransformersDesiredProperties[K]> & T[K], TTDefault>;
|
||||
};
|
||||
|
||||
+125
-125
@@ -1,6 +1,6 @@
|
||||
import type { DiscordGatewayPayload, DiscordRateLimited, DiscordReady, DiscordVoiceChannelEffectAnimationType } from '@discordeno/types'
|
||||
import type { Collection } from '@discordeno/utils'
|
||||
import type { DesiredPropertiesBehavior, SetupDesiredProps, TransformersDesiredProperties } from './desiredProperties.js'
|
||||
import type { DiscordGatewayPayload, DiscordRateLimited, DiscordReady, DiscordVoiceChannelEffectAnimationType } from '@discordeno/types';
|
||||
import type { Collection } from '@discordeno/utils';
|
||||
import type { DesiredPropertiesBehavior, SetupDesiredProps, TransformersDesiredProperties } from './desiredProperties.js';
|
||||
import type {
|
||||
AuditLogEntry,
|
||||
AutoModerationActionExecution,
|
||||
@@ -24,137 +24,137 @@ import type {
|
||||
ThreadMember,
|
||||
User,
|
||||
VoiceState,
|
||||
} from './transformers/types.js'
|
||||
} from './transformers/types.js';
|
||||
|
||||
export type EventHandlers<TProps extends TransformersDesiredProperties, TBehavior extends DesiredPropertiesBehavior> = {
|
||||
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: SetupDesiredProps<Channel, TProps, TBehavior>) => unknown
|
||||
threadDelete: (thread: SetupDesiredProps<Channel, TProps, TBehavior>) => 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: SetupDesiredProps<Channel, TProps, TBehavior>) => unknown;
|
||||
threadDelete: (thread: SetupDesiredProps<Channel, TProps, TBehavior>) => unknown;
|
||||
threadListSync: (payload: {
|
||||
guildId: bigint
|
||||
channelIds?: bigint[]
|
||||
threads: SetupDesiredProps<Channel, TProps, TBehavior>[]
|
||||
members: ThreadMember[]
|
||||
}) => unknown
|
||||
threadMemberUpdate: (payload: { id: bigint; guildId: bigint; joinedTimestamp: number; flags: number }) => unknown
|
||||
threadMembersUpdate: (payload: { id: bigint; guildId: bigint; addedMembers?: ThreadMember[]; removedMemberIds?: bigint[] }) => unknown
|
||||
threadUpdate: (thread: SetupDesiredProps<Channel, TProps, TBehavior>) => unknown
|
||||
scheduledEventCreate: (event: SetupDesiredProps<ScheduledEvent, TProps, TBehavior>) => unknown
|
||||
scheduledEventUpdate: (event: SetupDesiredProps<ScheduledEvent, TProps, TBehavior>) => unknown
|
||||
scheduledEventDelete: (event: SetupDesiredProps<ScheduledEvent, TProps, TBehavior>) => unknown
|
||||
scheduledEventUserAdd: (payload: { guildScheduledEventId: bigint; guildId: bigint; userId: bigint }) => unknown
|
||||
scheduledEventUserRemove: (payload: { guildScheduledEventId: bigint; guildId: bigint; userId: bigint }) => unknown
|
||||
guildId: bigint;
|
||||
channelIds?: bigint[];
|
||||
threads: SetupDesiredProps<Channel, TProps, TBehavior>[];
|
||||
members: ThreadMember[];
|
||||
}) => unknown;
|
||||
threadMemberUpdate: (payload: { id: bigint; guildId: bigint; joinedTimestamp: number; flags: number }) => unknown;
|
||||
threadMembersUpdate: (payload: { id: bigint; guildId: bigint; addedMembers?: ThreadMember[]; removedMemberIds?: bigint[] }) => unknown;
|
||||
threadUpdate: (thread: SetupDesiredProps<Channel, TProps, TBehavior>) => unknown;
|
||||
scheduledEventCreate: (event: SetupDesiredProps<ScheduledEvent, TProps, TBehavior>) => unknown;
|
||||
scheduledEventUpdate: (event: SetupDesiredProps<ScheduledEvent, TProps, TBehavior>) => unknown;
|
||||
scheduledEventDelete: (event: SetupDesiredProps<ScheduledEvent, TProps, TBehavior>) => unknown;
|
||||
scheduledEventUserAdd: (payload: { guildScheduledEventId: bigint; guildId: bigint; userId: bigint }) => unknown;
|
||||
scheduledEventUserRemove: (payload: { guildScheduledEventId: bigint; guildId: bigint; userId: bigint }) => unknown;
|
||||
ready: (
|
||||
payload: {
|
||||
shardId: number
|
||||
v: number
|
||||
user: SetupDesiredProps<User, TProps, TBehavior>
|
||||
guilds: bigint[]
|
||||
sessionId: string
|
||||
shard?: number[]
|
||||
applicationId: bigint
|
||||
shardId: number;
|
||||
v: number;
|
||||
user: SetupDesiredProps<User, TProps, TBehavior>;
|
||||
guilds: bigint[];
|
||||
sessionId: string;
|
||||
shard?: number[];
|
||||
applicationId: bigint;
|
||||
},
|
||||
rawPayload: DiscordReady,
|
||||
) => unknown
|
||||
resumed: (shardId: number) => unknown
|
||||
rateLimited: (data: DiscordRateLimited, shardId: number) => unknown
|
||||
interactionCreate: (interaction: SetupDesiredProps<Interaction, TProps, TBehavior>) => unknown
|
||||
integrationCreate: (integration: Integration) => unknown
|
||||
integrationDelete: (payload: { id: bigint; guildId: bigint; applicationId?: bigint }) => unknown
|
||||
integrationUpdate: (payload: { guildId: bigint }) => unknown
|
||||
inviteCreate: (invite: SetupDesiredProps<Invite, TProps, TBehavior>) => unknown
|
||||
inviteDelete: (payload: { channelId: bigint; guildId?: bigint; code: string }) => unknown
|
||||
guildMemberAdd: (member: SetupDesiredProps<Member, TProps, TBehavior>, user: SetupDesiredProps<User, TProps, TBehavior>) => unknown
|
||||
guildMemberRemove: (user: SetupDesiredProps<User, TProps, TBehavior>, guildId: bigint) => unknown
|
||||
guildMemberUpdate: (member: SetupDesiredProps<Member, TProps, TBehavior>, user: SetupDesiredProps<User, TProps, TBehavior>) => unknown
|
||||
guildStickersUpdate: (payload: { guildId: bigint; stickers: SetupDesiredProps<Sticker, TProps, TBehavior>[] }) => unknown
|
||||
messageCreate: (message: SetupDesiredProps<Message, TProps, TBehavior>) => unknown
|
||||
messageDelete: (payload: { id: bigint; channelId: bigint; guildId?: bigint }, message?: SetupDesiredProps<Message, TProps, TBehavior>) => unknown
|
||||
messageDeleteBulk: (payload: { ids: bigint[]; channelId: bigint; guildId?: bigint }) => unknown
|
||||
messageUpdate: (message: SetupDesiredProps<Message, TProps, TBehavior>) => unknown
|
||||
) => unknown;
|
||||
resumed: (shardId: number) => unknown;
|
||||
rateLimited: (data: DiscordRateLimited, shardId: number) => unknown;
|
||||
interactionCreate: (interaction: SetupDesiredProps<Interaction, TProps, TBehavior>) => unknown;
|
||||
integrationCreate: (integration: Integration) => unknown;
|
||||
integrationDelete: (payload: { id: bigint; guildId: bigint; applicationId?: bigint }) => unknown;
|
||||
integrationUpdate: (payload: { guildId: bigint }) => unknown;
|
||||
inviteCreate: (invite: SetupDesiredProps<Invite, TProps, TBehavior>) => unknown;
|
||||
inviteDelete: (payload: { channelId: bigint; guildId?: bigint; code: string }) => unknown;
|
||||
guildMemberAdd: (member: SetupDesiredProps<Member, TProps, TBehavior>, user: SetupDesiredProps<User, TProps, TBehavior>) => unknown;
|
||||
guildMemberRemove: (user: SetupDesiredProps<User, TProps, TBehavior>, guildId: bigint) => unknown;
|
||||
guildMemberUpdate: (member: SetupDesiredProps<Member, TProps, TBehavior>, user: SetupDesiredProps<User, TProps, TBehavior>) => unknown;
|
||||
guildStickersUpdate: (payload: { guildId: bigint; stickers: SetupDesiredProps<Sticker, TProps, TBehavior>[] }) => unknown;
|
||||
messageCreate: (message: SetupDesiredProps<Message, TProps, TBehavior>) => unknown;
|
||||
messageDelete: (payload: { id: bigint; channelId: bigint; guildId?: bigint }, message?: SetupDesiredProps<Message, TProps, TBehavior>) => unknown;
|
||||
messageDeleteBulk: (payload: { ids: bigint[]; channelId: bigint; guildId?: bigint }) => unknown;
|
||||
messageUpdate: (message: SetupDesiredProps<Message, TProps, TBehavior>) => unknown;
|
||||
reactionAdd: (payload: {
|
||||
userId: bigint
|
||||
channelId: bigint
|
||||
messageId: bigint
|
||||
guildId?: bigint
|
||||
member?: SetupDesiredProps<Member, TProps, TBehavior>
|
||||
user?: SetupDesiredProps<User, TProps, TBehavior>
|
||||
emoji: SetupDesiredProps<Emoji, TProps, TBehavior>
|
||||
messageAuthorId?: bigint
|
||||
burst: boolean
|
||||
burstColors?: string[]
|
||||
}) => unknown
|
||||
userId: bigint;
|
||||
channelId: bigint;
|
||||
messageId: bigint;
|
||||
guildId?: bigint;
|
||||
member?: SetupDesiredProps<Member, TProps, TBehavior>;
|
||||
user?: SetupDesiredProps<User, TProps, TBehavior>;
|
||||
emoji: SetupDesiredProps<Emoji, TProps, TBehavior>;
|
||||
messageAuthorId?: bigint;
|
||||
burst: boolean;
|
||||
burstColors?: string[];
|
||||
}) => unknown;
|
||||
reactionRemove: (payload: {
|
||||
userId: bigint
|
||||
channelId: bigint
|
||||
messageId: bigint
|
||||
guildId?: bigint
|
||||
emoji: SetupDesiredProps<Emoji, TProps, TBehavior>
|
||||
burst: boolean
|
||||
}) => unknown
|
||||
userId: bigint;
|
||||
channelId: bigint;
|
||||
messageId: bigint;
|
||||
guildId?: bigint;
|
||||
emoji: SetupDesiredProps<Emoji, TProps, TBehavior>;
|
||||
burst: boolean;
|
||||
}) => unknown;
|
||||
reactionRemoveEmoji: (payload: {
|
||||
channelId: bigint
|
||||
messageId: bigint
|
||||
guildId?: bigint
|
||||
emoji: SetupDesiredProps<Emoji, TProps, TBehavior>
|
||||
}) => unknown
|
||||
reactionRemoveAll: (payload: { channelId: bigint; messageId: bigint; guildId?: bigint }) => unknown
|
||||
presenceUpdate: (presence: PresenceUpdate) => unknown
|
||||
channelId: bigint;
|
||||
messageId: bigint;
|
||||
guildId?: bigint;
|
||||
emoji: SetupDesiredProps<Emoji, TProps, TBehavior>;
|
||||
}) => unknown;
|
||||
reactionRemoveAll: (payload: { channelId: bigint; messageId: bigint; guildId?: bigint }) => unknown;
|
||||
presenceUpdate: (presence: PresenceUpdate) => unknown;
|
||||
voiceChannelEffectSend: (payload: {
|
||||
channelId: bigint
|
||||
guildId: bigint
|
||||
userId: bigint
|
||||
emoji?: SetupDesiredProps<Emoji, TProps, TBehavior>
|
||||
animationType?: DiscordVoiceChannelEffectAnimationType
|
||||
animationId?: number
|
||||
soundId?: bigint | number
|
||||
soundVolume?: number
|
||||
}) => unknown
|
||||
voiceServerUpdate: (payload: { token: string; endpoint?: string; guildId: bigint }) => unknown
|
||||
voiceStateUpdate: (voiceState: SetupDesiredProps<VoiceState, TProps, TBehavior>) => unknown
|
||||
channelCreate: (channel: SetupDesiredProps<Channel, TProps, TBehavior>) => unknown
|
||||
dispatchRequirements: (data: DiscordGatewayPayload, shardId: number) => unknown
|
||||
channelDelete: (channel: SetupDesiredProps<Channel, TProps, TBehavior>) => unknown
|
||||
channelPinsUpdate: (data: { guildId?: bigint; channelId: bigint; lastPinTimestamp?: number }) => unknown
|
||||
channelUpdate: (channel: SetupDesiredProps<Channel, TProps, TBehavior>) => 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, SetupDesiredProps<Emoji, TProps, TBehavior>> }) => unknown
|
||||
guildBanAdd: (user: SetupDesiredProps<User, TProps, TBehavior>, guildId: bigint) => unknown
|
||||
guildBanRemove: (user: SetupDesiredProps<User, TProps, TBehavior>, guildId: bigint) => unknown
|
||||
guildCreate: (guild: SetupDesiredProps<Guild, TProps, TBehavior>) => unknown
|
||||
guildDelete: (data: { id: bigint; unavailable: boolean }, shardId: number) => unknown
|
||||
guildUpdate: (guild: SetupDesiredProps<Guild, TProps, TBehavior>) => unknown
|
||||
raw: (data: DiscordGatewayPayload, shardId: number) => unknown
|
||||
roleCreate: (role: SetupDesiredProps<Role, TProps, TBehavior>) => unknown
|
||||
roleDelete: (payload: { guildId: bigint; roleId: bigint }) => unknown
|
||||
roleUpdate: (role: SetupDesiredProps<Role, TProps, TBehavior>) => unknown
|
||||
webhooksUpdate: (payload: { channelId: bigint; guildId: bigint }) => unknown
|
||||
botUpdate: (user: SetupDesiredProps<User, TProps, TBehavior>) => unknown
|
||||
channelId: bigint;
|
||||
guildId: bigint;
|
||||
userId: bigint;
|
||||
emoji?: SetupDesiredProps<Emoji, TProps, TBehavior>;
|
||||
animationType?: DiscordVoiceChannelEffectAnimationType;
|
||||
animationId?: number;
|
||||
soundId?: bigint | number;
|
||||
soundVolume?: number;
|
||||
}) => unknown;
|
||||
voiceServerUpdate: (payload: { token: string; endpoint?: string; guildId: bigint }) => unknown;
|
||||
voiceStateUpdate: (voiceState: SetupDesiredProps<VoiceState, TProps, TBehavior>) => unknown;
|
||||
channelCreate: (channel: SetupDesiredProps<Channel, TProps, TBehavior>) => unknown;
|
||||
dispatchRequirements: (data: DiscordGatewayPayload, shardId: number) => unknown;
|
||||
channelDelete: (channel: SetupDesiredProps<Channel, TProps, TBehavior>) => unknown;
|
||||
channelPinsUpdate: (data: { guildId?: bigint; channelId: bigint; lastPinTimestamp?: number }) => unknown;
|
||||
channelUpdate: (channel: SetupDesiredProps<Channel, TProps, TBehavior>) => 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, SetupDesiredProps<Emoji, TProps, TBehavior>> }) => unknown;
|
||||
guildBanAdd: (user: SetupDesiredProps<User, TProps, TBehavior>, guildId: bigint) => unknown;
|
||||
guildBanRemove: (user: SetupDesiredProps<User, TProps, TBehavior>, guildId: bigint) => unknown;
|
||||
guildCreate: (guild: SetupDesiredProps<Guild, TProps, TBehavior>) => unknown;
|
||||
guildDelete: (data: { id: bigint; unavailable: boolean }, shardId: number) => unknown;
|
||||
guildUpdate: (guild: SetupDesiredProps<Guild, TProps, TBehavior>) => unknown;
|
||||
raw: (data: DiscordGatewayPayload, shardId: number) => unknown;
|
||||
roleCreate: (role: SetupDesiredProps<Role, TProps, TBehavior>) => unknown;
|
||||
roleDelete: (payload: { guildId: bigint; roleId: bigint }) => unknown;
|
||||
roleUpdate: (role: SetupDesiredProps<Role, TProps, TBehavior>) => unknown;
|
||||
webhooksUpdate: (payload: { channelId: bigint; guildId: bigint }) => unknown;
|
||||
botUpdate: (user: SetupDesiredProps<User, TProps, TBehavior>) => unknown;
|
||||
typingStart: (payload: {
|
||||
guildId: bigint | undefined
|
||||
channelId: bigint
|
||||
userId: bigint
|
||||
timestamp: number
|
||||
member: SetupDesiredProps<Member, TProps, TBehavior> | undefined
|
||||
}) => unknown
|
||||
entitlementCreate: (entitlement: SetupDesiredProps<Entitlement, TProps, TBehavior>) => unknown
|
||||
entitlementUpdate: (entitlement: SetupDesiredProps<Entitlement, TProps, TBehavior>) => unknown
|
||||
entitlementDelete: (entitlement: SetupDesiredProps<Entitlement, TProps, TBehavior>) => unknown
|
||||
subscriptionCreate: (subscription: SetupDesiredProps<Subscription, TProps, TBehavior>) => unknown
|
||||
subscriptionUpdate: (subscription: SetupDesiredProps<Subscription, TProps, TBehavior>) => unknown
|
||||
subscriptionDelete: (subscription: SetupDesiredProps<Subscription, TProps, TBehavior>) => 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: SetupDesiredProps<SoundboardSound, TProps, TBehavior>) => unknown
|
||||
soundboardSoundUpdate: (payload: SetupDesiredProps<SoundboardSound, TProps, TBehavior>) => unknown
|
||||
soundboardSoundDelete: (payload: { soundId: bigint; guildId: bigint }) => unknown
|
||||
soundboardSoundsUpdate: (payload: { soundboardSounds: SetupDesiredProps<SoundboardSound, TProps, TBehavior>[]; guildId: bigint }) => unknown
|
||||
soundboardSounds: (payload: { soundboardSounds: SetupDesiredProps<SoundboardSound, TProps, TBehavior>[]; guildId: bigint }) => unknown
|
||||
}
|
||||
guildId: bigint | undefined;
|
||||
channelId: bigint;
|
||||
userId: bigint;
|
||||
timestamp: number;
|
||||
member: SetupDesiredProps<Member, TProps, TBehavior> | undefined;
|
||||
}) => unknown;
|
||||
entitlementCreate: (entitlement: SetupDesiredProps<Entitlement, TProps, TBehavior>) => unknown;
|
||||
entitlementUpdate: (entitlement: SetupDesiredProps<Entitlement, TProps, TBehavior>) => unknown;
|
||||
entitlementDelete: (entitlement: SetupDesiredProps<Entitlement, TProps, TBehavior>) => unknown;
|
||||
subscriptionCreate: (subscription: SetupDesiredProps<Subscription, TProps, TBehavior>) => unknown;
|
||||
subscriptionUpdate: (subscription: SetupDesiredProps<Subscription, TProps, TBehavior>) => unknown;
|
||||
subscriptionDelete: (subscription: SetupDesiredProps<Subscription, TProps, TBehavior>) => 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: SetupDesiredProps<SoundboardSound, TProps, TBehavior>) => unknown;
|
||||
soundboardSoundUpdate: (payload: SetupDesiredProps<SoundboardSound, TProps, TBehavior>) => unknown;
|
||||
soundboardSoundDelete: (payload: { soundId: bigint; guildId: bigint }) => unknown;
|
||||
soundboardSoundsUpdate: (payload: { soundboardSounds: SetupDesiredProps<SoundboardSound, TProps, TBehavior>[]; guildId: bigint }) => unknown;
|
||||
soundboardSounds: (payload: { soundboardSounds: SetupDesiredProps<SoundboardSound, TProps, TBehavior>[]; guildId: bigint }) => unknown;
|
||||
};
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import type { DiscordGatewayPayload, GatewayDispatchEventNames } from '@discordeno/types'
|
||||
import type { Bot } from './bot.js'
|
||||
import type { DesiredPropertiesBehavior, TransformersDesiredProperties } from './desiredProperties.js'
|
||||
import * as handlers from './handlers/index.js'
|
||||
import type { DiscordGatewayPayload, GatewayDispatchEventNames } from '@discordeno/types';
|
||||
import type { Bot } from './bot.js';
|
||||
import type { DesiredPropertiesBehavior, TransformersDesiredProperties } from './desiredProperties.js';
|
||||
import * as handlers from './handlers/index.js';
|
||||
|
||||
export function createBotGatewayHandlers<TProps extends TransformersDesiredProperties, TBehavior extends DesiredPropertiesBehavior>(
|
||||
options: Partial<GatewayHandlers<TProps, TBehavior>>,
|
||||
): GatewayHandlers<TProps, TBehavior> {
|
||||
const _options = options as Partial<GatewayHandlers<TransformersDesiredProperties, DesiredPropertiesBehavior.RemoveKey>>
|
||||
const _options = options as Partial<GatewayHandlers<TransformersDesiredProperties, DesiredPropertiesBehavior.RemoveKey>>;
|
||||
|
||||
return {
|
||||
APPLICATION_COMMAND_PERMISSIONS_UPDATE: _options.APPLICATION_COMMAND_PERMISSIONS_UPDATE ?? handlers.handleApplicationCommandPermissionsUpdate,
|
||||
@@ -85,16 +85,16 @@ export function createBotGatewayHandlers<TProps extends TransformersDesiredPrope
|
||||
GUILD_SOUNDBOARD_SOUND_UPDATE: _options.GUILD_SOUNDBOARD_SOUND_UPDATE ?? handlers.handleGuildSoundboardSoundUpdate,
|
||||
GUILD_SOUNDBOARD_SOUNDS_UPDATE: _options.GUILD_SOUNDBOARD_SOUNDS_UPDATE ?? handlers.handleGuildSoundboardSoundsUpdate,
|
||||
SOUNDBOARD_SOUNDS: _options.SOUNDBOARD_SOUNDS ?? handlers.handleSoundboardSounds,
|
||||
} satisfies GatewayHandlers<TransformersDesiredProperties, DesiredPropertiesBehavior.RemoveKey> as unknown as GatewayHandlers<TProps, TBehavior>
|
||||
} satisfies GatewayHandlers<TransformersDesiredProperties, DesiredPropertiesBehavior.RemoveKey> as unknown as GatewayHandlers<TProps, TBehavior>;
|
||||
}
|
||||
|
||||
export type GatewayHandlers<TProps extends TransformersDesiredProperties, TBehavior extends DesiredPropertiesBehavior> = Record<
|
||||
GatewayDispatchEventNames,
|
||||
BotGatewayHandler<TProps, TBehavior>
|
||||
>
|
||||
>;
|
||||
|
||||
export type BotGatewayHandler<TProps extends TransformersDesiredProperties, TBehavior extends DesiredPropertiesBehavior> = (
|
||||
bot: Bot<TProps, TBehavior>,
|
||||
data: DiscordGatewayPayload,
|
||||
shardId: number,
|
||||
) => unknown
|
||||
) => unknown;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import type { DiscordChannel, DiscordGatewayPayload } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordChannel, DiscordGatewayPayload } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleChannelCreate(bot: Bot, payload: DiscordGatewayPayload, _shardId: number): Promise<void> {
|
||||
if (!bot.events.channelCreate) return
|
||||
if (!bot.events.channelCreate) return;
|
||||
|
||||
const data = payload.d as DiscordChannel
|
||||
const channel = bot.transformers.channel(bot, data, { guildId: data.guild_id })
|
||||
const data = payload.d as DiscordChannel;
|
||||
const channel = bot.transformers.channel(bot, data, { guildId: data.guild_id });
|
||||
|
||||
bot.events.channelCreate(channel)
|
||||
bot.events.channelCreate(channel);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { DiscordChannel, DiscordGatewayPayload } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordChannel, DiscordGatewayPayload } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleChannelDelete(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.channelDelete) return
|
||||
if (!bot.events.channelDelete) return;
|
||||
|
||||
const payload = data.d as DiscordChannel
|
||||
const payload = data.d as DiscordChannel;
|
||||
|
||||
bot.events.channelDelete(bot.transformers.channel(bot, payload, { guildId: payload.guild_id }))
|
||||
bot.events.channelDelete(bot.transformers.channel(bot, payload, { guildId: payload.guild_id }));
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import type { DiscordChannelPinsUpdate, DiscordGatewayPayload } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordChannelPinsUpdate, DiscordGatewayPayload } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleChannelPinsUpdate(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.channelPinsUpdate) return
|
||||
if (!bot.events.channelPinsUpdate) return;
|
||||
|
||||
const payload = data.d as DiscordChannelPinsUpdate
|
||||
const payload = data.d as DiscordChannelPinsUpdate;
|
||||
|
||||
bot.events.channelPinsUpdate({
|
||||
guildId: payload.guild_id ? bot.transformers.snowflake(payload.guild_id) : undefined,
|
||||
channelId: bot.transformers.snowflake(payload.channel_id),
|
||||
lastPinTimestamp: payload.last_pin_timestamp ? Date.parse(payload.last_pin_timestamp) : undefined,
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import type { DiscordChannel, DiscordGatewayPayload } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordChannel, DiscordGatewayPayload } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleChannelUpdate(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.channelUpdate) return
|
||||
if (!bot.events.channelUpdate) return;
|
||||
|
||||
const payload = data.d as DiscordChannel
|
||||
const channel = bot.transformers.channel(bot, payload)
|
||||
const payload = data.d as DiscordChannel;
|
||||
const channel = bot.transformers.channel(bot, payload);
|
||||
|
||||
bot.events.channelUpdate(channel)
|
||||
bot.events.channelUpdate(channel);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import type { DiscordGatewayPayload, DiscordStageInstance } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordStageInstance } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleStageInstanceCreate(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.stageInstanceCreate) return
|
||||
if (!bot.events.stageInstanceCreate) return;
|
||||
|
||||
const payload = data.d as DiscordStageInstance
|
||||
const payload = data.d as DiscordStageInstance;
|
||||
|
||||
bot.events.stageInstanceCreate({
|
||||
id: bot.transformers.snowflake(payload.id),
|
||||
guildId: bot.transformers.snowflake(payload.guild_id),
|
||||
channelId: bot.transformers.snowflake(payload.channel_id),
|
||||
topic: payload.topic,
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import type { DiscordGatewayPayload, DiscordStageInstance } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordStageInstance } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleStageInstanceDelete(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.stageInstanceDelete) return
|
||||
if (!bot.events.stageInstanceDelete) return;
|
||||
|
||||
const payload = data.d as DiscordStageInstance
|
||||
const payload = data.d as DiscordStageInstance;
|
||||
|
||||
bot.events.stageInstanceDelete({
|
||||
id: bot.transformers.snowflake(payload.id),
|
||||
guildId: bot.transformers.snowflake(payload.guild_id),
|
||||
channelId: bot.transformers.snowflake(payload.channel_id),
|
||||
topic: payload.topic,
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import type { DiscordGatewayPayload, DiscordStageInstance } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordStageInstance } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleStageInstanceUpdate(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.stageInstanceUpdate) return
|
||||
if (!bot.events.stageInstanceUpdate) return;
|
||||
|
||||
const payload = data.d as DiscordStageInstance
|
||||
const payload = data.d as DiscordStageInstance;
|
||||
|
||||
bot.events.stageInstanceUpdate({
|
||||
id: bot.transformers.snowflake(payload.id),
|
||||
guildId: bot.transformers.snowflake(payload.guild_id),
|
||||
channelId: bot.transformers.snowflake(payload.channel_id),
|
||||
topic: payload.topic,
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { DiscordChannel, DiscordGatewayPayload } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordChannel, DiscordGatewayPayload } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleThreadCreate(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.threadCreate) return
|
||||
if (!bot.events.threadCreate) return;
|
||||
|
||||
const payload = data.d as DiscordChannel
|
||||
const payload = data.d as DiscordChannel;
|
||||
|
||||
bot.events.threadCreate(bot.transformers.channel(bot, payload))
|
||||
bot.events.threadCreate(bot.transformers.channel(bot, payload));
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { DiscordChannel, DiscordGatewayPayload } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordChannel, DiscordGatewayPayload } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleThreadDelete(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.threadDelete) return
|
||||
if (!bot.events.threadDelete) return;
|
||||
|
||||
const payload = data.d as DiscordChannel
|
||||
const payload = data.d as DiscordChannel;
|
||||
|
||||
bot.events.threadDelete(bot.transformers.channel(bot, payload))
|
||||
bot.events.threadDelete(bot.transformers.channel(bot, payload));
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import type { DiscordGatewayPayload, DiscordThreadListSync } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordThreadListSync } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleThreadListSync(bot: Bot, data: DiscordGatewayPayload): Promise<any> {
|
||||
if (!bot.events.threadListSync) return
|
||||
if (!bot.events.threadListSync) return;
|
||||
|
||||
const payload = data.d as DiscordThreadListSync
|
||||
const payload = data.d as DiscordThreadListSync;
|
||||
|
||||
const guildId = bot.transformers.snowflake(payload.guild_id)
|
||||
const guildId = bot.transformers.snowflake(payload.guild_id);
|
||||
|
||||
bot.events.threadListSync({
|
||||
guildId,
|
||||
@@ -18,5 +18,5 @@ export async function handleThreadListSync(bot: Bot, data: DiscordGatewayPayload
|
||||
joinTimestamp: Date.parse(member.join_timestamp),
|
||||
flags: member.flags,
|
||||
})),
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import type { DiscordGatewayPayload, DiscordThreadMembersUpdate } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordThreadMembersUpdate } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleThreadMembersUpdate(bot: Bot, data: DiscordGatewayPayload, _shardId: number): Promise<void> {
|
||||
if (!bot.events.threadMembersUpdate) return
|
||||
if (!bot.events.threadMembersUpdate) return;
|
||||
|
||||
const payload = data.d as DiscordThreadMembersUpdate
|
||||
const payload = data.d as DiscordThreadMembersUpdate;
|
||||
|
||||
bot.events.threadMembersUpdate({
|
||||
id: bot.transformers.snowflake(payload.id),
|
||||
guildId: bot.transformers.snowflake(payload.guild_id),
|
||||
addedMembers: payload.added_members?.map((member) => bot.transformers.threadMember?.(bot, member, { guildId: payload.guild_id })),
|
||||
removedMemberIds: payload.removed_member_ids?.map((id) => bot.transformers.snowflake(id)),
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import type { DiscordGatewayPayload, DiscordThreadMemberUpdate } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordThreadMemberUpdate } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleThreadMemberUpdate(bot: Bot, data: DiscordGatewayPayload, _shardId: number): Promise<void> {
|
||||
if (!bot.events.threadMemberUpdate) return
|
||||
if (!bot.events.threadMemberUpdate) return;
|
||||
|
||||
const payload = data.d as DiscordThreadMemberUpdate
|
||||
const payload = data.d as DiscordThreadMemberUpdate;
|
||||
|
||||
bot.events.threadMemberUpdate({
|
||||
id: bot.transformers.snowflake(payload.id),
|
||||
guildId: bot.transformers.snowflake(payload.guild_id),
|
||||
joinedTimestamp: Date.parse(payload.join_timestamp),
|
||||
flags: payload.flags,
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { DiscordChannel, DiscordGatewayPayload } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordChannel, DiscordGatewayPayload } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleThreadUpdate(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.threadUpdate) return
|
||||
if (!bot.events.threadUpdate) return;
|
||||
|
||||
const payload = data.d as DiscordChannel
|
||||
const payload = data.d as DiscordChannel;
|
||||
|
||||
bot.events.threadUpdate(bot.transformers.channel(bot, payload))
|
||||
bot.events.threadUpdate(bot.transformers.channel(bot, payload));
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
export * from './CHANNEL_CREATE.js'
|
||||
export * from './CHANNEL_DELETE.js'
|
||||
export * from './CHANNEL_PINS_UPDATE.js'
|
||||
export * from './CHANNEL_UPDATE.js'
|
||||
export * from './STAGE_INSTANCE_CREATE.js'
|
||||
export * from './STAGE_INSTANCE_DELETE.js'
|
||||
export * from './STAGE_INSTANCE_UPDATE.js'
|
||||
export * from './THREAD_CREATE.js'
|
||||
export * from './THREAD_DELETE.js'
|
||||
export * from './THREAD_LIST_SYNC.js'
|
||||
export * from './THREAD_MEMBER_UPDATE.js'
|
||||
export * from './THREAD_MEMBERS_UPDATE.js'
|
||||
export * from './THREAD_UPDATE.js'
|
||||
export * from './CHANNEL_CREATE.js';
|
||||
export * from './CHANNEL_DELETE.js';
|
||||
export * from './CHANNEL_PINS_UPDATE.js';
|
||||
export * from './CHANNEL_UPDATE.js';
|
||||
export * from './STAGE_INSTANCE_CREATE.js';
|
||||
export * from './STAGE_INSTANCE_DELETE.js';
|
||||
export * from './STAGE_INSTANCE_UPDATE.js';
|
||||
export * from './THREAD_CREATE.js';
|
||||
export * from './THREAD_DELETE.js';
|
||||
export * from './THREAD_LIST_SYNC.js';
|
||||
export * from './THREAD_MEMBER_UPDATE.js';
|
||||
export * from './THREAD_MEMBERS_UPDATE.js';
|
||||
export * from './THREAD_UPDATE.js';
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import type { DiscordGatewayPayload, DiscordGuildEmojisUpdate } from '@discordeno/types'
|
||||
import { Collection } from '@discordeno/utils'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordGuildEmojisUpdate } from '@discordeno/types';
|
||||
import { Collection } from '@discordeno/utils';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleGuildEmojisUpdate(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.guildEmojisUpdate) return
|
||||
if (!bot.events.guildEmojisUpdate) return;
|
||||
|
||||
const payload = data.d as DiscordGuildEmojisUpdate
|
||||
const payload = data.d as DiscordGuildEmojisUpdate;
|
||||
|
||||
bot.events.guildEmojisUpdate({
|
||||
guildId: bot.transformers.snowflake(payload.guild_id),
|
||||
emojis: new Collection(payload.emojis.map((emoji) => [bot.transformers.snowflake(emoji.id!), bot.transformers.emoji(bot, emoji)])),
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
export * from './GUILD_EMOJIS_UPDATE.js'
|
||||
export * from './GUILD_EMOJIS_UPDATE.js';
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import type { DiscordEntitlement, DiscordGatewayPayload } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordEntitlement, DiscordGatewayPayload } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleEntitlementCreate(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.entitlementCreate) return
|
||||
if (!bot.events.entitlementCreate) return;
|
||||
|
||||
const payload = data.d as DiscordEntitlement
|
||||
bot.events.entitlementCreate(bot.transformers.entitlement(bot, payload))
|
||||
const payload = data.d as DiscordEntitlement;
|
||||
bot.events.entitlementCreate(bot.transformers.entitlement(bot, payload));
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import type { DiscordEntitlement, DiscordGatewayPayload } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordEntitlement, DiscordGatewayPayload } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleEntitlementDelete(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.entitlementDelete) return
|
||||
if (!bot.events.entitlementDelete) return;
|
||||
|
||||
const payload = data.d as DiscordEntitlement
|
||||
bot.events.entitlementDelete(bot.transformers.entitlement(bot, payload))
|
||||
const payload = data.d as DiscordEntitlement;
|
||||
bot.events.entitlementDelete(bot.transformers.entitlement(bot, payload));
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import type { DiscordEntitlement, DiscordGatewayPayload } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordEntitlement, DiscordGatewayPayload } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleEntitlementUpdate(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.entitlementUpdate) return
|
||||
if (!bot.events.entitlementUpdate) return;
|
||||
|
||||
const payload = data.d as DiscordEntitlement
|
||||
bot.events.entitlementUpdate(bot.transformers.entitlement(bot, payload))
|
||||
const payload = data.d as DiscordEntitlement;
|
||||
bot.events.entitlementUpdate(bot.transformers.entitlement(bot, payload));
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export * from './ENTITLEMENT_CREATE.js'
|
||||
export * from './ENTITLEMENT_DELETE.js'
|
||||
export * from './ENTITLEMENT_UPDATE.js'
|
||||
export * from './ENTITLEMENT_CREATE.js';
|
||||
export * from './ENTITLEMENT_DELETE.js';
|
||||
export * from './ENTITLEMENT_UPDATE.js';
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { DiscordAuditLogEntry, DiscordGatewayPayload } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordAuditLogEntry, DiscordGatewayPayload } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleGuildAuditLogEntryCreate(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.guildAuditLogEntryCreate) return
|
||||
if (!bot.events.guildAuditLogEntryCreate) return;
|
||||
|
||||
// TODO: better type here
|
||||
const payload = data.d as DiscordAuditLogEntry & { guild_id: string }
|
||||
bot.events.guildAuditLogEntryCreate(bot.transformers.auditLogEntry(bot, payload), bot.transformers.snowflake(payload.guild_id))
|
||||
const payload = data.d as DiscordAuditLogEntry & { guild_id: string };
|
||||
bot.events.guildAuditLogEntryCreate(bot.transformers.auditLogEntry(bot, payload), bot.transformers.snowflake(payload.guild_id));
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import type { DiscordGatewayPayload, DiscordGuildBanAddRemove } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordGuildBanAddRemove } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleGuildBanAdd(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.guildBanAdd) return
|
||||
if (!bot.events.guildBanAdd) return;
|
||||
|
||||
const payload = data.d as DiscordGuildBanAddRemove
|
||||
bot.events.guildBanAdd(bot.transformers.user(bot, payload.user), bot.transformers.snowflake(payload.guild_id))
|
||||
const payload = data.d as DiscordGuildBanAddRemove;
|
||||
bot.events.guildBanAdd(bot.transformers.user(bot, payload.user), bot.transformers.snowflake(payload.guild_id));
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { DiscordGatewayPayload, DiscordGuildBanAddRemove } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordGuildBanAddRemove } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleGuildBanRemove(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.guildBanRemove) return
|
||||
if (!bot.events.guildBanRemove) return;
|
||||
|
||||
const payload = data.d as DiscordGuildBanAddRemove
|
||||
const payload = data.d as DiscordGuildBanAddRemove;
|
||||
|
||||
await bot.events.guildBanRemove(bot.transformers.user(bot, payload.user), bot.transformers.snowflake(payload.guild_id))
|
||||
await bot.events.guildBanRemove(bot.transformers.user(bot, payload.user), bot.transformers.snowflake(payload.guild_id));
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import type { DiscordGatewayPayload, DiscordGuild } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordGuild } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleGuildCreate(bot: Bot, data: DiscordGatewayPayload, shardId: number): Promise<void> {
|
||||
if (!bot.events.guildCreate) return
|
||||
if (!bot.events.guildCreate) return;
|
||||
|
||||
const payload = data.d as DiscordGuild
|
||||
bot.events.guildCreate(bot.transformers.guild(bot, payload, { shardId }))
|
||||
const payload = data.d as DiscordGuild;
|
||||
bot.events.guildCreate(bot.transformers.guild(bot, payload, { shardId }));
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { DiscordGatewayPayload, DiscordUnavailableGuild } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordUnavailableGuild } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleGuildDelete(bot: Bot, data: DiscordGatewayPayload, shardId: number): Promise<void> {
|
||||
if (!bot.events.guildDelete) return
|
||||
if (!bot.events.guildDelete) return;
|
||||
|
||||
const payload = data.d as DiscordUnavailableGuild
|
||||
const payload = data.d as DiscordUnavailableGuild;
|
||||
|
||||
bot.events.guildDelete(
|
||||
{
|
||||
@@ -12,5 +12,5 @@ export async function handleGuildDelete(bot: Bot, data: DiscordGatewayPayload, s
|
||||
unavailable: payload.unavailable ?? false,
|
||||
},
|
||||
shardId,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import type { DiscordGatewayPayload, DiscordGuildIntegrationsUpdate } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordGuildIntegrationsUpdate } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleGuildIntegrationsUpdate(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.integrationUpdate) return
|
||||
if (!bot.events.integrationUpdate) return;
|
||||
|
||||
const payload = data.d as DiscordGuildIntegrationsUpdate
|
||||
const payload = data.d as DiscordGuildIntegrationsUpdate;
|
||||
|
||||
bot.events.integrationUpdate({
|
||||
guildId: bot.transformers.snowflake(payload.guild_id),
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import type { DiscordGatewayPayload, DiscordGuildStickersUpdate } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordGuildStickersUpdate } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleGuildStickersUpdate(bot: Bot, data: DiscordGatewayPayload, _shardId: number): Promise<void> {
|
||||
if (!bot.events.guildStickersUpdate) return
|
||||
if (!bot.events.guildStickersUpdate) return;
|
||||
|
||||
const payload = data.d as DiscordGuildStickersUpdate
|
||||
const payload = data.d as DiscordGuildStickersUpdate;
|
||||
|
||||
bot.events.guildStickersUpdate({
|
||||
guildId: bot.transformers.snowflake(payload.guild_id),
|
||||
stickers: payload.stickers.map((sticker) => {
|
||||
sticker.guild_id = payload.guild_id
|
||||
return bot.transformers.sticker(bot, sticker)
|
||||
sticker.guild_id = payload.guild_id;
|
||||
return bot.transformers.sticker(bot, sticker);
|
||||
}),
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { DiscordGatewayPayload, DiscordGuild } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordGuild } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleGuildUpdate(bot: Bot, data: DiscordGatewayPayload, shardId: number): Promise<void> {
|
||||
if (!bot.events.guildUpdate) return
|
||||
if (!bot.events.guildUpdate) return;
|
||||
|
||||
const payload = data.d as DiscordGuild
|
||||
const payload = data.d as DiscordGuild;
|
||||
|
||||
bot.events.guildUpdate(bot.transformers.guild(bot, payload, { shardId }))
|
||||
bot.events.guildUpdate(bot.transformers.guild(bot, payload, { shardId }));
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { DiscordAutoModerationActionExecution, DiscordGatewayPayload } from '@discordeno/types'
|
||||
import type { Bot } from '../../../bot.js'
|
||||
import type { DiscordAutoModerationActionExecution, DiscordGatewayPayload } from '@discordeno/types';
|
||||
import type { Bot } from '../../../bot.js';
|
||||
|
||||
/** Requires the MANAGE_GUILD permission. */
|
||||
export async function handleAutoModerationActionExecution(bot: Bot, data: DiscordGatewayPayload, _shardId: number): Promise<void> {
|
||||
if (!bot.events.automodActionExecution) return
|
||||
if (!bot.events.automodActionExecution) return;
|
||||
|
||||
const payload = data.d as DiscordAutoModerationActionExecution
|
||||
bot.events.automodActionExecution(bot.transformers.automodActionExecution(bot, payload))
|
||||
const payload = data.d as DiscordAutoModerationActionExecution;
|
||||
bot.events.automodActionExecution(bot.transformers.automodActionExecution(bot, payload));
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { DiscordAutoModerationRule, DiscordGatewayPayload } from '@discordeno/types'
|
||||
import type { Bot } from '../../../bot.js'
|
||||
import type { DiscordAutoModerationRule, DiscordGatewayPayload } from '@discordeno/types';
|
||||
import type { Bot } from '../../../bot.js';
|
||||
|
||||
/** Requires the MANAGE_GUILD permission. */
|
||||
export async function handleAutoModerationRuleCreate(bot: Bot, data: DiscordGatewayPayload, _shardId: number): Promise<void> {
|
||||
if (!bot.events.automodRuleCreate) return
|
||||
if (!bot.events.automodRuleCreate) return;
|
||||
|
||||
const payload = data.d as DiscordAutoModerationRule
|
||||
bot.events.automodRuleCreate(bot.transformers.automodRule(bot, payload))
|
||||
const payload = data.d as DiscordAutoModerationRule;
|
||||
bot.events.automodRuleCreate(bot.transformers.automodRule(bot, payload));
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { DiscordAutoModerationRule, DiscordGatewayPayload } from '@discordeno/types'
|
||||
import type { Bot } from '../../../bot.js'
|
||||
import type { DiscordAutoModerationRule, DiscordGatewayPayload } from '@discordeno/types';
|
||||
import type { Bot } from '../../../bot.js';
|
||||
|
||||
/** Requires the MANAGE_GUILD permission. */
|
||||
export async function handleAutoModerationRuleDelete(bot: Bot, data: DiscordGatewayPayload, _shardId: number): Promise<void> {
|
||||
if (!bot.events.automodRuleDelete) return
|
||||
if (!bot.events.automodRuleDelete) return;
|
||||
|
||||
const payload = data.d as DiscordAutoModerationRule
|
||||
bot.events.automodRuleDelete(bot.transformers.automodRule(bot, payload))
|
||||
const payload = data.d as DiscordAutoModerationRule;
|
||||
bot.events.automodRuleDelete(bot.transformers.automodRule(bot, payload));
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { DiscordAutoModerationRule, DiscordGatewayPayload } from '@discordeno/types'
|
||||
import type { Bot } from '../../../bot.js'
|
||||
import type { DiscordAutoModerationRule, DiscordGatewayPayload } from '@discordeno/types';
|
||||
import type { Bot } from '../../../bot.js';
|
||||
|
||||
/** Requires the MANAGE_GUILD permission. */
|
||||
export async function handleAutoModerationRuleUpdate(bot: Bot, data: DiscordGatewayPayload, _shardId: number): Promise<void> {
|
||||
if (!bot.events.automodRuleUpdate) return
|
||||
if (!bot.events.automodRuleUpdate) return;
|
||||
|
||||
const payload = data.d as DiscordAutoModerationRule
|
||||
bot.events.automodRuleUpdate(bot.transformers.automodRule(bot, payload))
|
||||
const payload = data.d as DiscordAutoModerationRule;
|
||||
bot.events.automodRuleUpdate(bot.transformers.automodRule(bot, payload));
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export * from './AUTO_MODERATION_ACTION_EXECUTION.js'
|
||||
export * from './AUTO_MODERATION_RULE_CREATE.js'
|
||||
export * from './AUTO_MODERATION_RULE_DELETE.js'
|
||||
export * from './AUTO_MODERATION_RULE_UPDATE.js'
|
||||
export * from './AUTO_MODERATION_ACTION_EXECUTION.js';
|
||||
export * from './AUTO_MODERATION_RULE_CREATE.js';
|
||||
export * from './AUTO_MODERATION_RULE_DELETE.js';
|
||||
export * from './AUTO_MODERATION_RULE_UPDATE.js';
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
export * from './automod/index.js'
|
||||
export * from './GUILD_AUDIT_LOG_ENTRY_CREATE.js'
|
||||
export * from './GUILD_BAN_ADD.js'
|
||||
export * from './GUILD_BAN_REMOVE.js'
|
||||
export * from './GUILD_CREATE.js'
|
||||
export * from './GUILD_DELETE.js'
|
||||
export * from './GUILD_INTEGRATIONS_UPDATE.js'
|
||||
export * from './GUILD_STICKERS_UPDATE.js'
|
||||
export * from './GUILD_UPDATE.js'
|
||||
export * from './scheduledEvents/index.js'
|
||||
export * from './automod/index.js';
|
||||
export * from './GUILD_AUDIT_LOG_ENTRY_CREATE.js';
|
||||
export * from './GUILD_BAN_ADD.js';
|
||||
export * from './GUILD_BAN_REMOVE.js';
|
||||
export * from './GUILD_CREATE.js';
|
||||
export * from './GUILD_DELETE.js';
|
||||
export * from './GUILD_INTEGRATIONS_UPDATE.js';
|
||||
export * from './GUILD_STICKERS_UPDATE.js';
|
||||
export * from './GUILD_UPDATE.js';
|
||||
export * from './scheduledEvents/index.js';
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import type { DiscordGatewayPayload, DiscordScheduledEvent } from '@discordeno/types'
|
||||
import type { Bot } from '../../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordScheduledEvent } from '@discordeno/types';
|
||||
import type { Bot } from '../../../bot.js';
|
||||
|
||||
export async function handleGuildScheduledEventCreate(bot: Bot, data: DiscordGatewayPayload, _shardId: number): Promise<void> {
|
||||
if (!bot.events.scheduledEventCreate) return
|
||||
if (!bot.events.scheduledEventCreate) return;
|
||||
|
||||
const payload = data.d as DiscordScheduledEvent
|
||||
bot.events.scheduledEventCreate(bot.transformers.scheduledEvent(bot, payload))
|
||||
const payload = data.d as DiscordScheduledEvent;
|
||||
bot.events.scheduledEventCreate(bot.transformers.scheduledEvent(bot, payload));
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import type { DiscordGatewayPayload, DiscordScheduledEvent } from '@discordeno/types'
|
||||
import type { Bot } from '../../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordScheduledEvent } from '@discordeno/types';
|
||||
import type { Bot } from '../../../bot.js';
|
||||
|
||||
export async function handleGuildScheduledEventDelete(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.scheduledEventDelete) return
|
||||
if (!bot.events.scheduledEventDelete) return;
|
||||
|
||||
const payload = data.d as DiscordScheduledEvent
|
||||
bot.events.scheduledEventDelete(bot.transformers.scheduledEvent(bot, payload))
|
||||
const payload = data.d as DiscordScheduledEvent;
|
||||
bot.events.scheduledEventDelete(bot.transformers.scheduledEvent(bot, payload));
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import type { DiscordGatewayPayload, DiscordScheduledEvent } from '@discordeno/types'
|
||||
import type { Bot } from '../../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordScheduledEvent } from '@discordeno/types';
|
||||
import type { Bot } from '../../../bot.js';
|
||||
|
||||
export async function handleGuildScheduledEventUpdate(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.scheduledEventUpdate) return
|
||||
if (!bot.events.scheduledEventUpdate) return;
|
||||
|
||||
const payload = data.d as DiscordScheduledEvent
|
||||
bot.events.scheduledEventUpdate(bot.transformers.scheduledEvent(bot, payload))
|
||||
const payload = data.d as DiscordScheduledEvent;
|
||||
bot.events.scheduledEventUpdate(bot.transformers.scheduledEvent(bot, payload));
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import type { DiscordGatewayPayload, DiscordScheduledEventUserAdd } from '@discordeno/types'
|
||||
import type { Bot } from '../../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordScheduledEventUserAdd } from '@discordeno/types';
|
||||
import type { Bot } from '../../../bot.js';
|
||||
|
||||
export async function handleGuildScheduledEventUserAdd(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.scheduledEventUserAdd) return
|
||||
if (!bot.events.scheduledEventUserAdd) return;
|
||||
|
||||
const payload = data.d as DiscordScheduledEventUserAdd
|
||||
const payload = data.d as DiscordScheduledEventUserAdd;
|
||||
|
||||
bot.events.scheduledEventUserAdd({
|
||||
guildScheduledEventId: bot.transformers.snowflake(payload.guild_scheduled_event_id),
|
||||
userId: bot.transformers.snowflake(payload.user_id),
|
||||
guildId: bot.transformers.snowflake(payload.guild_id),
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
+5
-5
@@ -1,14 +1,14 @@
|
||||
import type { DiscordGatewayPayload, DiscordScheduledEventUserRemove } from '@discordeno/types'
|
||||
import type { Bot } from '../../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordScheduledEventUserRemove } from '@discordeno/types';
|
||||
import type { Bot } from '../../../bot.js';
|
||||
|
||||
export async function handleGuildScheduledEventUserRemove(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.scheduledEventUserRemove) return
|
||||
if (!bot.events.scheduledEventUserRemove) return;
|
||||
|
||||
const payload = data.d as DiscordScheduledEventUserRemove
|
||||
const payload = data.d as DiscordScheduledEventUserRemove;
|
||||
|
||||
bot.events.scheduledEventUserRemove({
|
||||
guildScheduledEventId: bot.transformers.snowflake(payload.guild_scheduled_event_id),
|
||||
userId: bot.transformers.snowflake(payload.user_id),
|
||||
guildId: bot.transformers.snowflake(payload.guild_id),
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export * from './GUILD_SCHEDULED_EVENT_CREATE.js'
|
||||
export * from './GUILD_SCHEDULED_EVENT_DELETE.js'
|
||||
export * from './GUILD_SCHEDULED_EVENT_UPDATE.js'
|
||||
export * from './GUILD_SCHEDULED_EVENT_USER_ADD.js'
|
||||
export * from './GUILD_SCHEDULED_EVENT_USER_REMOVE.js'
|
||||
export * from './GUILD_SCHEDULED_EVENT_CREATE.js';
|
||||
export * from './GUILD_SCHEDULED_EVENT_DELETE.js';
|
||||
export * from './GUILD_SCHEDULED_EVENT_UPDATE.js';
|
||||
export * from './GUILD_SCHEDULED_EVENT_USER_ADD.js';
|
||||
export * from './GUILD_SCHEDULED_EVENT_USER_REMOVE.js';
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
export * from './channels/index.js'
|
||||
export * from './emojis/index.js'
|
||||
export * from './entitlements/index.js'
|
||||
export * from './guilds/index.js'
|
||||
export * from './integrations/index.js'
|
||||
export * from './interactions/index.js'
|
||||
export * from './invites/index.js'
|
||||
export * from './members/index.js'
|
||||
export * from './messages/index.js'
|
||||
export * from './misc/index.js'
|
||||
export * from './poll/index.js'
|
||||
export * from './roles/index.js'
|
||||
export * from './soundboard/index.js'
|
||||
export * from './subscriptions/index.js'
|
||||
export * from './voice/index.js'
|
||||
export * from './webhooks/index.js'
|
||||
export * from './channels/index.js';
|
||||
export * from './emojis/index.js';
|
||||
export * from './entitlements/index.js';
|
||||
export * from './guilds/index.js';
|
||||
export * from './integrations/index.js';
|
||||
export * from './interactions/index.js';
|
||||
export * from './invites/index.js';
|
||||
export * from './members/index.js';
|
||||
export * from './messages/index.js';
|
||||
export * from './misc/index.js';
|
||||
export * from './poll/index.js';
|
||||
export * from './roles/index.js';
|
||||
export * from './soundboard/index.js';
|
||||
export * from './subscriptions/index.js';
|
||||
export * from './voice/index.js';
|
||||
export * from './webhooks/index.js';
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import type { DiscordGatewayPayload, DiscordIntegrationCreateUpdate } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordIntegrationCreateUpdate } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleIntegrationCreate(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.integrationCreate) return
|
||||
if (!bot.events.integrationCreate) return;
|
||||
|
||||
bot.events.integrationCreate(bot.transformers.integration(bot, data.d as DiscordIntegrationCreateUpdate))
|
||||
bot.events.integrationCreate(bot.transformers.integration(bot, data.d as DiscordIntegrationCreateUpdate));
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import type { DiscordGatewayPayload, DiscordIntegrationDelete } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordIntegrationDelete } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleIntegrationDelete(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.integrationDelete) return
|
||||
if (!bot.events.integrationDelete) return;
|
||||
|
||||
const payload = data.d as DiscordIntegrationDelete
|
||||
const payload = data.d as DiscordIntegrationDelete;
|
||||
|
||||
bot.events.integrationDelete({
|
||||
id: bot.transformers.snowflake(payload.id),
|
||||
guildId: bot.transformers.snowflake(payload.guild_id),
|
||||
applicationId: payload.application_id ? bot.transformers.snowflake(payload.application_id) : undefined,
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import type { DiscordGatewayPayload, DiscordIntegrationCreateUpdate } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordIntegrationCreateUpdate } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleIntegrationUpdate(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.integrationUpdate) return
|
||||
if (!bot.events.integrationUpdate) return;
|
||||
|
||||
bot.events.integrationUpdate(bot.transformers.integration(bot, data.d as DiscordIntegrationCreateUpdate))
|
||||
bot.events.integrationUpdate(bot.transformers.integration(bot, data.d as DiscordIntegrationCreateUpdate));
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export * from './INTEGRATION_CREATE.js'
|
||||
export * from './INTEGRATION_DELETE.js'
|
||||
export * from './INTEGRATION_UPDATE.js'
|
||||
export * from './INTEGRATION_CREATE.js';
|
||||
export * from './INTEGRATION_DELETE.js';
|
||||
export * from './INTEGRATION_UPDATE.js';
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import type { DiscordGatewayPayload, DiscordGuildApplicationCommandPermissions } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordGuildApplicationCommandPermissions } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleApplicationCommandPermissionsUpdate(bot: Bot, data: DiscordGatewayPayload, _shardId: number): Promise<void> {
|
||||
if (!bot.events.applicationCommandPermissionsUpdate) return
|
||||
if (!bot.events.applicationCommandPermissionsUpdate) return;
|
||||
|
||||
const payload = data.d as DiscordGuildApplicationCommandPermissions
|
||||
bot.events.applicationCommandPermissionsUpdate(bot.transformers.applicationCommandPermission(bot, payload))
|
||||
const payload = data.d as DiscordGuildApplicationCommandPermissions;
|
||||
bot.events.applicationCommandPermissionsUpdate(bot.transformers.applicationCommandPermission(bot, payload));
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { DiscordGatewayPayload, DiscordInteraction } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordInteraction } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleInteractionCreate(bot: Bot, data: DiscordGatewayPayload, shardId: number): Promise<void> {
|
||||
if (!bot.events.interactionCreate) return
|
||||
if (!bot.events.interactionCreate) return;
|
||||
|
||||
const payload = data.d as DiscordInteraction
|
||||
const payload = data.d as DiscordInteraction;
|
||||
|
||||
bot.events.interactionCreate(bot.transformers.interaction(bot, payload, { shardId }))
|
||||
bot.events.interactionCreate(bot.transformers.interaction(bot, payload, { shardId }));
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
export * from './APPLICATION_COMMAND_PERMISSIONS_UPDATE.js'
|
||||
export * from './INTERACTION_CREATE.js'
|
||||
export * from './APPLICATION_COMMAND_PERMISSIONS_UPDATE.js';
|
||||
export * from './INTERACTION_CREATE.js';
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { DiscordGatewayPayload, DiscordInviteCreate } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordInviteCreate } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleInviteCreate(bot: Bot, data: DiscordGatewayPayload, shardId: number): Promise<void> {
|
||||
if (!bot.events.inviteCreate) return
|
||||
if (!bot.events.inviteCreate) return;
|
||||
|
||||
const payload = data.d as DiscordInviteCreate
|
||||
const payload = data.d as DiscordInviteCreate;
|
||||
|
||||
bot.events.inviteCreate(bot.transformers.invite(bot, payload, { shardId }))
|
||||
bot.events.inviteCreate(bot.transformers.invite(bot, payload, { shardId }));
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { DiscordGatewayPayload, DiscordInviteDelete } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordInviteDelete } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleInviteDelete(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.inviteDelete) return
|
||||
if (!bot.events.inviteDelete) return;
|
||||
|
||||
const payload = data.d as DiscordInviteDelete
|
||||
const payload = data.d as DiscordInviteDelete;
|
||||
|
||||
bot.events.inviteDelete({
|
||||
/** The channel of the invite */
|
||||
@@ -13,5 +13,5 @@ export async function handleInviteDelete(bot: Bot, data: DiscordGatewayPayload):
|
||||
guildId: payload.guild_id ? bot.transformers.snowflake(payload.guild_id) : undefined,
|
||||
/** The unique invite code */
|
||||
code: payload.code,
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
export * from './INVITE_CREATE.js'
|
||||
export * from './INVITE_DELETE.js'
|
||||
export * from './INVITE_CREATE.js';
|
||||
export * from './INVITE_DELETE.js';
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
import type { DiscordGatewayPayload, DiscordGuildMembersChunk } from '@discordeno/types'
|
||||
import { camelize } from '@discordeno/utils'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordGuildMembersChunk } from '@discordeno/types';
|
||||
import { camelize } from '@discordeno/utils';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleGuildMembersChunk(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
const payload = data.d as DiscordGuildMembersChunk
|
||||
const payload = data.d as DiscordGuildMembersChunk;
|
||||
|
||||
// If it's not enabled skip checks.
|
||||
if (!bot.gateway.cache.requestMembers.enabled) return
|
||||
if (!bot.gateway.cache.requestMembers.enabled) return;
|
||||
|
||||
// If this request has no nonce, skip checks.
|
||||
if (!payload.nonce) return
|
||||
if (!payload.nonce) return;
|
||||
|
||||
const pending = bot.gateway.cache.requestMembers.pending.get(payload.nonce)
|
||||
const pending = bot.gateway.cache.requestMembers.pending.get(payload.nonce);
|
||||
|
||||
if (!pending) return
|
||||
if (!pending) return;
|
||||
|
||||
if (payload.chunk_count === 1) pending.members = payload.members
|
||||
else pending.members.push(...payload.members)
|
||||
if (payload.chunk_count === 1) pending.members = payload.members;
|
||||
else pending.members.push(...payload.members);
|
||||
|
||||
// If this is not the final chunk, just save to cache.
|
||||
if (payload.chunk_index + 1 < payload.chunk_count) return
|
||||
if (payload.chunk_index + 1 < payload.chunk_count) return;
|
||||
|
||||
// Resolve the promise that all requests are done.
|
||||
pending.resolve(camelize(pending.members))
|
||||
pending.resolve(camelize(pending.members));
|
||||
|
||||
// Delete the cache to clean up once its done.
|
||||
bot.gateway.cache.requestMembers.pending.delete(payload.nonce)
|
||||
bot.gateway.cache.requestMembers.pending.delete(payload.nonce);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import type { DiscordGatewayPayload, DiscordGuildMemberAdd } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordGuildMemberAdd } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleGuildMemberAdd(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.guildMemberAdd) return
|
||||
if (!bot.events.guildMemberAdd) return;
|
||||
|
||||
const payload = data.d as DiscordGuildMemberAdd
|
||||
const guildId = bot.transformers.snowflake(payload.guild_id)
|
||||
const user = bot.transformers.user(bot, payload.user)
|
||||
const member = bot.transformers.member(bot, payload, { guildId, userId: payload.user.id })
|
||||
bot.events.guildMemberAdd(member, user)
|
||||
const payload = data.d as DiscordGuildMemberAdd;
|
||||
const guildId = bot.transformers.snowflake(payload.guild_id);
|
||||
const user = bot.transformers.user(bot, payload.user);
|
||||
const member = bot.transformers.member(bot, payload, { guildId, userId: payload.user.id });
|
||||
bot.events.guildMemberAdd(member, user);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import type { DiscordGatewayPayload, DiscordGuildMemberRemove } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordGuildMemberRemove } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleGuildMemberRemove(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.guildMemberRemove) return
|
||||
if (!bot.events.guildMemberRemove) return;
|
||||
|
||||
const payload = data.d as DiscordGuildMemberRemove
|
||||
const guildId = bot.transformers.snowflake(payload.guild_id)
|
||||
const user = bot.transformers.user(bot, payload.user)
|
||||
const payload = data.d as DiscordGuildMemberRemove;
|
||||
const guildId = bot.transformers.snowflake(payload.guild_id);
|
||||
const user = bot.transformers.user(bot, payload.user);
|
||||
|
||||
bot.events.guildMemberRemove(user, guildId)
|
||||
bot.events.guildMemberRemove(user, guildId);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import type { DiscordGatewayPayload, DiscordGuildMemberUpdate } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordGuildMemberUpdate } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleGuildMemberUpdate(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.guildMemberUpdate) return
|
||||
if (!bot.events.guildMemberUpdate) return;
|
||||
|
||||
const payload = data.d as DiscordGuildMemberUpdate
|
||||
const payload = data.d as DiscordGuildMemberUpdate;
|
||||
|
||||
const user = bot.transformers.user(bot, payload.user)
|
||||
const user = bot.transformers.user(bot, payload.user);
|
||||
bot.events.guildMemberUpdate(
|
||||
// @ts-expect-error Flags in the update are nullable, while on the member they are be always present
|
||||
bot.transformers.member(bot, payload, { guildId: payload.guild_id, userId: payload.user.id }),
|
||||
user,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export * from './GUILD_MEMBER_ADD.js'
|
||||
export * from './GUILD_MEMBER_REMOVE.js'
|
||||
export * from './GUILD_MEMBER_UPDATE.js'
|
||||
export * from './GUILD_MEMBERS_CHUNK.js'
|
||||
export * from './GUILD_MEMBER_ADD.js';
|
||||
export * from './GUILD_MEMBER_REMOVE.js';
|
||||
export * from './GUILD_MEMBER_UPDATE.js';
|
||||
export * from './GUILD_MEMBERS_CHUNK.js';
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { DiscordGatewayPayload, DiscordMessage } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordMessage } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleMessageCreate(bot: Bot, data: DiscordGatewayPayload, shardId: number): Promise<void> {
|
||||
if (!bot.events.messageCreate) return
|
||||
if (!bot.events.messageCreate) return;
|
||||
|
||||
const payload = data.d as DiscordMessage
|
||||
const payload = data.d as DiscordMessage;
|
||||
|
||||
bot.events.messageCreate(bot.transformers.message(bot, payload, { shardId }))
|
||||
bot.events.messageCreate(bot.transformers.message(bot, payload, { shardId }));
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import type { DiscordGatewayPayload, DiscordMessageDelete } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordMessageDelete } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleMessageDelete(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.messageDelete) return
|
||||
if (!bot.events.messageDelete) return;
|
||||
|
||||
const payload = data.d as DiscordMessageDelete
|
||||
const payload = data.d as DiscordMessageDelete;
|
||||
|
||||
bot.events.messageDelete({
|
||||
id: bot.transformers.snowflake(payload.id),
|
||||
channelId: bot.transformers.snowflake(payload.channel_id),
|
||||
guildId: payload.guild_id ? bot.transformers.snowflake(payload.guild_id) : undefined,
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import type { DiscordGatewayPayload, DiscordMessageDeleteBulk } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordMessageDeleteBulk } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleMessageDeleteBulk(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.messageDeleteBulk) return
|
||||
if (!bot.events.messageDeleteBulk) return;
|
||||
|
||||
const payload = data.d as DiscordMessageDeleteBulk
|
||||
const payload = data.d as DiscordMessageDeleteBulk;
|
||||
|
||||
const channelId = bot.transformers.snowflake(payload.channel_id)
|
||||
const guildId = payload.guild_id ? bot.transformers.snowflake(payload.guild_id) : undefined
|
||||
const channelId = bot.transformers.snowflake(payload.channel_id);
|
||||
const guildId = payload.guild_id ? bot.transformers.snowflake(payload.guild_id) : undefined;
|
||||
|
||||
bot.events.messageDeleteBulk({
|
||||
ids: payload.ids.map((id) => bot.transformers.snowflake(id)),
|
||||
channelId,
|
||||
guildId,
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import type { DiscordGatewayPayload, DiscordMessageReactionAdd } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordMessageReactionAdd } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleMessageReactionAdd(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.reactionAdd) return
|
||||
if (!bot.events.reactionAdd) return;
|
||||
|
||||
const payload = data.d as DiscordMessageReactionAdd
|
||||
const payload = data.d as DiscordMessageReactionAdd;
|
||||
|
||||
const guildId = payload.guild_id ? bot.transformers.snowflake(payload.guild_id) : undefined
|
||||
const userId = bot.transformers.snowflake(payload.user_id)
|
||||
const guildId = payload.guild_id ? bot.transformers.snowflake(payload.guild_id) : undefined;
|
||||
const userId = bot.transformers.snowflake(payload.user_id);
|
||||
bot.events.reactionAdd({
|
||||
userId,
|
||||
channelId: bot.transformers.snowflake(payload.channel_id),
|
||||
@@ -20,5 +20,5 @@ export async function handleMessageReactionAdd(bot: Bot, data: DiscordGatewayPay
|
||||
messageAuthorId: payload.message_author_id ? bot.transformers.snowflake(payload.message_author_id) : undefined,
|
||||
burst: payload.burst,
|
||||
burstColors: payload.burst_colors,
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { DiscordGatewayPayload, DiscordMessageReactionRemove } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordMessageReactionRemove } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleMessageReactionRemove(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.reactionRemove) return
|
||||
if (!bot.events.reactionRemove) return;
|
||||
|
||||
const payload = data.d as DiscordMessageReactionRemove
|
||||
const payload = data.d as DiscordMessageReactionRemove;
|
||||
|
||||
bot.events.reactionRemove({
|
||||
userId: bot.transformers.snowflake(payload.user_id),
|
||||
@@ -14,5 +14,5 @@ export async function handleMessageReactionRemove(bot: Bot, data: DiscordGateway
|
||||
// @ts-expect-error TODO: Deal with partials
|
||||
emoji: bot.transformers.emoji(bot, payload.emoji),
|
||||
burst: payload.burst,
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import type { DiscordGatewayPayload, DiscordMessageReactionRemoveAll } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordMessageReactionRemoveAll } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleMessageReactionRemoveAll(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.reactionRemoveAll) return
|
||||
if (!bot.events.reactionRemoveAll) return;
|
||||
|
||||
const payload = data.d as DiscordMessageReactionRemoveAll
|
||||
const payload = data.d as DiscordMessageReactionRemoveAll;
|
||||
|
||||
bot.events.reactionRemoveAll({
|
||||
channelId: bot.transformers.snowflake(payload.channel_id),
|
||||
messageId: bot.transformers.snowflake(payload.message_id),
|
||||
guildId: payload.guild_id ? bot.transformers.snowflake(payload.guild_id) : undefined,
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { DiscordGatewayPayload, DiscordMessageReactionRemoveEmoji } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordMessageReactionRemoveEmoji } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleMessageReactionRemoveEmoji(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.reactionRemoveEmoji) return
|
||||
if (!bot.events.reactionRemoveEmoji) return;
|
||||
|
||||
const payload = data.d as DiscordMessageReactionRemoveEmoji
|
||||
const payload = data.d as DiscordMessageReactionRemoveEmoji;
|
||||
|
||||
bot.events.reactionRemoveEmoji({
|
||||
channelId: bot.transformers.snowflake(payload.channel_id),
|
||||
@@ -12,5 +12,5 @@ export async function handleMessageReactionRemoveEmoji(bot: Bot, data: DiscordGa
|
||||
guildId: payload.guild_id ? bot.transformers.snowflake(payload.guild_id) : undefined,
|
||||
// @ts-expect-error TODO: Deal with partials
|
||||
emoji: bot.transformers.emoji(bot, payload.emoji),
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import type { DiscordGatewayPayload, DiscordMessage } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordMessage } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleMessageUpdate(bot: Bot, data: DiscordGatewayPayload, shardId: number): Promise<void> {
|
||||
if (!bot.events.messageUpdate) return
|
||||
if (!bot.events.messageUpdate) return;
|
||||
|
||||
const payload = data.d as DiscordMessage
|
||||
if (!payload.edited_timestamp) return
|
||||
const payload = data.d as DiscordMessage;
|
||||
if (!payload.edited_timestamp) return;
|
||||
|
||||
bot.events.messageUpdate(bot.transformers.message(bot, payload, { shardId }))
|
||||
bot.events.messageUpdate(bot.transformers.message(bot, payload, { shardId }));
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
export * from './MESSAGE_CREATE.js'
|
||||
export * from './MESSAGE_DELETE.js'
|
||||
export * from './MESSAGE_DELETE_BULK.js'
|
||||
export * from './MESSAGE_REACTION_ADD.js'
|
||||
export * from './MESSAGE_REACTION_REMOVE.js'
|
||||
export * from './MESSAGE_REACTION_REMOVE_ALL.js'
|
||||
export * from './MESSAGE_REACTION_REMOVE_EMOJI.js'
|
||||
export * from './MESSAGE_UPDATE.js'
|
||||
export * from './MESSAGE_CREATE.js';
|
||||
export * from './MESSAGE_DELETE.js';
|
||||
export * from './MESSAGE_DELETE_BULK.js';
|
||||
export * from './MESSAGE_REACTION_ADD.js';
|
||||
export * from './MESSAGE_REACTION_REMOVE.js';
|
||||
export * from './MESSAGE_REACTION_REMOVE_ALL.js';
|
||||
export * from './MESSAGE_REACTION_REMOVE_EMOJI.js';
|
||||
export * from './MESSAGE_UPDATE.js';
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import type { DiscordGatewayPayload, DiscordPresenceUpdate } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordPresenceUpdate } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handlePresenceUpdate(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.presenceUpdate) return
|
||||
if (!bot.events.presenceUpdate) return;
|
||||
|
||||
bot.events.presenceUpdate(bot.transformers.presence(bot, data.d as DiscordPresenceUpdate))
|
||||
bot.events.presenceUpdate(bot.transformers.presence(bot, data.d as DiscordPresenceUpdate));
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import type { DiscordGatewayPayload, DiscordRateLimited } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordRateLimited } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleRateLimited(bot: Bot, data: DiscordGatewayPayload, shardId: number): Promise<void> {
|
||||
if (!bot.events.rateLimited) return
|
||||
if (!bot.events.rateLimited) return;
|
||||
|
||||
const payload = data.d as DiscordRateLimited
|
||||
bot.events.rateLimited(payload, shardId)
|
||||
const payload = data.d as DiscordRateLimited;
|
||||
bot.events.rateLimited(payload, shardId);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { DiscordGatewayPayload, DiscordReady } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordReady } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleReady(bot: Bot, data: DiscordGatewayPayload, shardId: number): Promise<void> {
|
||||
if (!bot.events.ready) return
|
||||
if (!bot.events.ready) return;
|
||||
|
||||
const payload = data.d as DiscordReady
|
||||
const payload = data.d as DiscordReady;
|
||||
// Triggered on each shard
|
||||
bot.events.ready(
|
||||
{
|
||||
@@ -17,8 +17,8 @@ export async function handleReady(bot: Bot, data: DiscordGatewayPayload, shardId
|
||||
applicationId: bot.transformers.snowflake(payload.application.id),
|
||||
},
|
||||
payload,
|
||||
)
|
||||
);
|
||||
|
||||
bot.id = bot.transformers.snowflake(payload.user.id)
|
||||
bot.applicationId = bot.transformers.snowflake(payload.application.id)
|
||||
bot.id = bot.transformers.snowflake(payload.user.id);
|
||||
bot.applicationId = bot.transformers.snowflake(payload.application.id);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import type { DiscordGatewayPayload } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleResumed(bot: Bot, _data: DiscordGatewayPayload, shardId: number): Promise<void> {
|
||||
if (!bot.events.resumed) return
|
||||
if (!bot.events.resumed) return;
|
||||
|
||||
bot.events.resumed(shardId)
|
||||
bot.events.resumed(shardId);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import type { DiscordGatewayPayload, DiscordTypingStart } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordTypingStart } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleTypingStart(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.typingStart) return
|
||||
if (!bot.events.typingStart) return;
|
||||
|
||||
const payload = data.d as DiscordTypingStart
|
||||
const payload = data.d as DiscordTypingStart;
|
||||
|
||||
const guildId = payload.guild_id ? bot.transformers.snowflake(payload.guild_id) : undefined
|
||||
const userId = bot.transformers.snowflake(payload.user_id)
|
||||
const guildId = payload.guild_id ? bot.transformers.snowflake(payload.guild_id) : undefined;
|
||||
const userId = bot.transformers.snowflake(payload.user_id);
|
||||
|
||||
bot.events.typingStart({
|
||||
guildId,
|
||||
@@ -15,5 +15,5 @@ export async function handleTypingStart(bot: Bot, data: DiscordGatewayPayload):
|
||||
userId,
|
||||
timestamp: payload.timestamp,
|
||||
member: payload.member && guildId ? bot.transformers.member(bot, payload.member, { guildId, userId }) : undefined,
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import type { DiscordGatewayPayload, DiscordUser } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordUser } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleUserUpdate(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.botUpdate) return
|
||||
if (!bot.events.botUpdate) return;
|
||||
|
||||
const payload = data.d as DiscordUser
|
||||
bot.events.botUpdate(bot.transformers.user(bot, payload))
|
||||
const payload = data.d as DiscordUser;
|
||||
bot.events.botUpdate(bot.transformers.user(bot, payload));
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
export * from './PRESENCE_UPDATE.js'
|
||||
export * from './RATE_LIMITED.js'
|
||||
export * from './READY.js'
|
||||
export * from './RESUMED.js'
|
||||
export * from './TYPING_START.js'
|
||||
export * from './USER_UPDATE.js'
|
||||
export * from './PRESENCE_UPDATE.js';
|
||||
export * from './RATE_LIMITED.js';
|
||||
export * from './READY.js';
|
||||
export * from './RESUMED.js';
|
||||
export * from './TYPING_START.js';
|
||||
export * from './USER_UPDATE.js';
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { DiscordGatewayPayload, DiscordPollVoteAdd } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordPollVoteAdd } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleMessagePollVoteAdd(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.messagePollVoteAdd) return
|
||||
if (!bot.events.messagePollVoteAdd) return;
|
||||
|
||||
const payload = data.d as DiscordPollVoteAdd
|
||||
const payload = data.d as DiscordPollVoteAdd;
|
||||
|
||||
bot.events.messagePollVoteAdd({
|
||||
userId: bot.transformers.snowflake(payload.user_id),
|
||||
@@ -12,5 +12,5 @@ export async function handleMessagePollVoteAdd(bot: Bot, data: DiscordGatewayPay
|
||||
messageId: bot.transformers.snowflake(payload.message_id),
|
||||
guildId: payload.guild_id ? bot.transformers.snowflake(payload.guild_id) : undefined,
|
||||
answerId: payload.answer_id,
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { DiscordGatewayPayload, DiscordPollVoteRemove } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordPollVoteRemove } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleMessagePollVoteRemove(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.messagePollVoteRemove) return
|
||||
if (!bot.events.messagePollVoteRemove) return;
|
||||
|
||||
const payload = data.d as DiscordPollVoteRemove
|
||||
const payload = data.d as DiscordPollVoteRemove;
|
||||
|
||||
bot.events.messagePollVoteRemove({
|
||||
userId: bot.transformers.snowflake(payload.user_id),
|
||||
@@ -12,5 +12,5 @@ export async function handleMessagePollVoteRemove(bot: Bot, data: DiscordGateway
|
||||
messageId: bot.transformers.snowflake(payload.message_id),
|
||||
guildId: payload.guild_id ? bot.transformers.snowflake(payload.guild_id) : undefined,
|
||||
answerId: payload.answer_id,
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
export * from './MESSAGE_POLL_VOTE_ADD.js'
|
||||
export * from './MESSAGE_POLL_VOTE_REMOVE.js'
|
||||
export * from './MESSAGE_POLL_VOTE_ADD.js';
|
||||
export * from './MESSAGE_POLL_VOTE_REMOVE.js';
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import type { DiscordGatewayPayload, DiscordGuildRoleCreate } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordGuildRoleCreate } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleGuildRoleCreate(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.roleCreate) return
|
||||
if (!bot.events.roleCreate) return;
|
||||
|
||||
const payload = data.d as DiscordGuildRoleCreate
|
||||
const payload = data.d as DiscordGuildRoleCreate;
|
||||
bot.events.roleCreate(
|
||||
bot.transformers.role(bot, payload.role, {
|
||||
guildId: bot.transformers.snowflake(payload.guild_id),
|
||||
}),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import type { DiscordGatewayPayload, DiscordGuildRoleDelete } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordGuildRoleDelete } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleGuildRoleDelete(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.roleDelete) return
|
||||
if (!bot.events.roleDelete) return;
|
||||
|
||||
const payload = data.d as DiscordGuildRoleDelete
|
||||
const payload = data.d as DiscordGuildRoleDelete;
|
||||
bot.events.roleDelete({
|
||||
roleId: bot.transformers.snowflake(payload.role_id),
|
||||
guildId: bot.transformers.snowflake(payload.guild_id),
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import type { DiscordGatewayPayload, DiscordGuildRoleUpdate } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordGuildRoleUpdate } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleGuildRoleUpdate(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.roleUpdate) return
|
||||
if (!bot.events.roleUpdate) return;
|
||||
|
||||
const payload = data.d as DiscordGuildRoleUpdate
|
||||
const payload = data.d as DiscordGuildRoleUpdate;
|
||||
|
||||
bot.events.roleUpdate(
|
||||
bot.transformers.role(bot, payload.role, {
|
||||
guildId: bot.transformers.snowflake(payload.guild_id),
|
||||
}),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export * from './GUILD_ROLE_CREATE.js'
|
||||
export * from './GUILD_ROLE_DELETE.js'
|
||||
export * from './GUILD_ROLE_UPDATE.js'
|
||||
export * from './GUILD_ROLE_CREATE.js';
|
||||
export * from './GUILD_ROLE_DELETE.js';
|
||||
export * from './GUILD_ROLE_UPDATE.js';
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import type { DiscordGatewayPayload, DiscordSoundboardSoundsUpdate } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordSoundboardSoundsUpdate } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleGuildSoundboardSoundsUpdate(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.soundboardSoundsUpdate) return
|
||||
if (!bot.events.soundboardSoundsUpdate) return;
|
||||
|
||||
const payload = data.d as DiscordSoundboardSoundsUpdate
|
||||
const payload = data.d as DiscordSoundboardSoundsUpdate;
|
||||
|
||||
bot.events.soundboardSoundsUpdate({
|
||||
guildId: bot.transformers.snowflake(payload.guild_id),
|
||||
soundboardSounds: payload.soundboard_sounds.map((sound) => bot.transformers.soundboardSound(bot, sound)),
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { DiscordGatewayPayload, DiscordSoundboardSound } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordSoundboardSound } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleGuildSoundboardSoundCreate(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.soundboardSoundCreate) return
|
||||
if (!bot.events.soundboardSoundCreate) return;
|
||||
|
||||
const payload = data.d as DiscordSoundboardSound
|
||||
const payload = data.d as DiscordSoundboardSound;
|
||||
|
||||
bot.events.soundboardSoundCreate(bot.transformers.soundboardSound(bot, payload))
|
||||
bot.events.soundboardSoundCreate(bot.transformers.soundboardSound(bot, payload));
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import type { DiscordGatewayPayload, DiscordSoundboardSoundDelete } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordSoundboardSoundDelete } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleGuildSoundboardSoundDelete(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.soundboardSoundDelete) return
|
||||
if (!bot.events.soundboardSoundDelete) return;
|
||||
|
||||
const payload = data.d as DiscordSoundboardSoundDelete
|
||||
const payload = data.d as DiscordSoundboardSoundDelete;
|
||||
|
||||
bot.events.soundboardSoundDelete({
|
||||
guildId: bot.transformers.snowflake(payload.guild_id),
|
||||
soundId: bot.transformers.snowflake(payload.sound_id),
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { DiscordGatewayPayload, DiscordSoundboardSound } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordSoundboardSound } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleGuildSoundboardSoundUpdate(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.soundboardSoundUpdate) return
|
||||
if (!bot.events.soundboardSoundUpdate) return;
|
||||
|
||||
const payload = data.d as DiscordSoundboardSound
|
||||
const payload = data.d as DiscordSoundboardSound;
|
||||
|
||||
bot.events.soundboardSoundUpdate(bot.transformers.soundboardSound(bot, payload))
|
||||
bot.events.soundboardSoundUpdate(bot.transformers.soundboardSound(bot, payload));
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import type { DiscordGatewayPayload, DiscordSoundboardSounds } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordSoundboardSounds } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleSoundboardSounds(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.soundboardSounds) return
|
||||
if (!bot.events.soundboardSounds) return;
|
||||
|
||||
const payload = data.d as DiscordSoundboardSounds
|
||||
const payload = data.d as DiscordSoundboardSounds;
|
||||
|
||||
bot.events.soundboardSounds({
|
||||
guildId: bot.transformers.snowflake(payload.guild_id),
|
||||
soundboardSounds: payload.soundboard_sounds.map((sound) => bot.transformers.soundboardSound(bot, sound)),
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export * from './GUILD_SOUNDBOARD_SOUND_CREATE.js'
|
||||
export * from './GUILD_SOUNDBOARD_SOUND_DELETE.js'
|
||||
export * from './GUILD_SOUNDBOARD_SOUND_UPDATE.js'
|
||||
export * from './GUILD_SOUNDBOARD_SOUNDS_UPDATE.js'
|
||||
export * from './SOUNDBOARD_SOUNDS.js'
|
||||
export * from './GUILD_SOUNDBOARD_SOUND_CREATE.js';
|
||||
export * from './GUILD_SOUNDBOARD_SOUND_DELETE.js';
|
||||
export * from './GUILD_SOUNDBOARD_SOUND_UPDATE.js';
|
||||
export * from './GUILD_SOUNDBOARD_SOUNDS_UPDATE.js';
|
||||
export * from './SOUNDBOARD_SOUNDS.js';
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import type { DiscordGatewayPayload, DiscordSubscription } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordSubscription } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleSubscriptionCreate(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.subscriptionCreate) return
|
||||
if (!bot.events.subscriptionCreate) return;
|
||||
|
||||
const payload = data.d as DiscordSubscription
|
||||
bot.events.subscriptionCreate(bot.transformers.subscription(bot, payload))
|
||||
const payload = data.d as DiscordSubscription;
|
||||
bot.events.subscriptionCreate(bot.transformers.subscription(bot, payload));
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import type { DiscordGatewayPayload, DiscordSubscription } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordSubscription } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleSubscriptionDelete(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.subscriptionDelete) return
|
||||
if (!bot.events.subscriptionDelete) return;
|
||||
|
||||
const payload = data.d as DiscordSubscription
|
||||
bot.events.subscriptionDelete(bot.transformers.subscription(bot, payload))
|
||||
const payload = data.d as DiscordSubscription;
|
||||
bot.events.subscriptionDelete(bot.transformers.subscription(bot, payload));
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import type { DiscordGatewayPayload, DiscordSubscription } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordSubscription } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleSubscriptionUpdate(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.subscriptionUpdate) return
|
||||
if (!bot.events.subscriptionUpdate) return;
|
||||
|
||||
const payload = data.d as DiscordSubscription
|
||||
bot.events.subscriptionUpdate(bot.transformers.subscription(bot, payload))
|
||||
const payload = data.d as DiscordSubscription;
|
||||
bot.events.subscriptionUpdate(bot.transformers.subscription(bot, payload));
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export * from './SUBSCRIPTION_CREATE.js'
|
||||
export * from './SUBSCRIPTION_DELETE.js'
|
||||
export * from './SUBSCRIPTION_UPDATE.js'
|
||||
export * from './SUBSCRIPTION_CREATE.js';
|
||||
export * from './SUBSCRIPTION_DELETE.js';
|
||||
export * from './SUBSCRIPTION_UPDATE.js';
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { DiscordGatewayPayload, DiscordVoiceChannelEffectSend } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordVoiceChannelEffectSend } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleVoiceChannelEffectSend(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.voiceChannelEffectSend) return
|
||||
if (!bot.events.voiceChannelEffectSend) return;
|
||||
|
||||
const payload = data.d as DiscordVoiceChannelEffectSend
|
||||
const payload = data.d as DiscordVoiceChannelEffectSend;
|
||||
|
||||
bot.events.voiceChannelEffectSend({
|
||||
guildId: bot.transformers.snowflake(payload.guild_id),
|
||||
@@ -15,5 +15,5 @@ export async function handleVoiceChannelEffectSend(bot: Bot, data: DiscordGatewa
|
||||
emoji: payload.emoji ? bot.transformers.emoji(bot, payload.emoji) : undefined,
|
||||
soundId: typeof payload.sound_id === 'string' ? bot.transformers.snowflake(payload.sound_id) : payload.sound_id,
|
||||
soundVolume: payload.sound_volume,
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import type { DiscordGatewayPayload, DiscordVoiceServerUpdate } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordVoiceServerUpdate } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleVoiceServerUpdate(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.voiceServerUpdate) return
|
||||
if (!bot.events.voiceServerUpdate) return;
|
||||
|
||||
const payload = data.d as DiscordVoiceServerUpdate
|
||||
const payload = data.d as DiscordVoiceServerUpdate;
|
||||
|
||||
bot.events.voiceServerUpdate({
|
||||
token: payload.token,
|
||||
guildId: bot.transformers.snowflake(payload.guild_id),
|
||||
endpoint: payload.endpoint ?? undefined,
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { DiscordGatewayPayload, DiscordVoiceState } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordVoiceState } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleVoiceStateUpdate(bot: Bot, data: DiscordGatewayPayload): Promise<void> {
|
||||
if (!bot.events.voiceStateUpdate) return
|
||||
if (!bot.events.voiceStateUpdate) return;
|
||||
|
||||
const payload = data.d as DiscordVoiceState
|
||||
const payload = data.d as DiscordVoiceState;
|
||||
|
||||
bot.events.voiceStateUpdate(bot.transformers.voiceState(bot, payload, { guildId: payload.guild_id }))
|
||||
bot.events.voiceStateUpdate(bot.transformers.voiceState(bot, payload, { guildId: payload.guild_id }));
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export * from './VOICE_CHANNEL_EFFECT_SEND.js'
|
||||
export * from './VOICE_SERVER_UPDATE.js'
|
||||
export * from './VOICE_STATE_UPDATE.js'
|
||||
export * from './VOICE_CHANNEL_EFFECT_SEND.js';
|
||||
export * from './VOICE_SERVER_UPDATE.js';
|
||||
export * from './VOICE_STATE_UPDATE.js';
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import type { DiscordGatewayPayload, DiscordWebhookUpdate } from '@discordeno/types'
|
||||
import type { Bot } from '../../bot.js'
|
||||
import type { DiscordGatewayPayload, DiscordWebhookUpdate } from '@discordeno/types';
|
||||
import type { Bot } from '../../bot.js';
|
||||
|
||||
export async function handleWebhooksUpdate(bot: Bot, data: DiscordGatewayPayload, _shardId: number): Promise<void> {
|
||||
if (!bot.events.webhooksUpdate) return
|
||||
if (!bot.events.webhooksUpdate) return;
|
||||
|
||||
const payload = data.d as DiscordWebhookUpdate
|
||||
const payload = data.d as DiscordWebhookUpdate;
|
||||
bot.events.webhooksUpdate({
|
||||
channelId: bot.transformers.snowflake(payload.channel_id),
|
||||
guildId: bot.transformers.snowflake(payload.guild_id),
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user