From fa2a0307fa4f52c39e017441ffae9b02b696e346 Mon Sep 17 00:00:00 2001 From: ayntee Date: Sat, 27 Mar 2021 17:04:25 +0400 Subject: [PATCH] types: remove EventHandlers and RateLimitData --- src/bot.ts | 186 ----------------------------------------------------- 1 file changed, 186 deletions(-) diff --git a/src/bot.ts b/src/bot.ts index 832a1d748..c911ceebe 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -4,7 +4,6 @@ import { DiscordGetGatewayBot, DiscordIdentify, } from "./types/gateway.ts"; -import { CamelCaseProps } from "./types/util.ts"; import { baseEndpoints, GATEWAY_VERSION } from "./util/constants.ts"; import { spawnShards } from "./ws/shard_manager.ts"; @@ -122,191 +121,6 @@ export async function startBigBrainBot(data: BigBrainBotConfig) { ); } -export interface EventHandlers { - rateLimit?: (data: RateLimitData) => unknown; - /** Sent when a new Slash Command is created, relevant to the current user. */ - applicationCommandCreate?: ( - data: CamelCaseProps, - ) => unknown; - /** Sent when a Slash Command relevant to the current user is updated. */ - applicationCommandUpdate?: ( - data: CamelCaseProps, - ) => unknown; - /** Sent when a Slash Command relevant to the current user is deleted. */ - applicationCommandDelete?: ( - data: CamelCaseProps, - ) => unknown; - /** Sent when properties about the user change. */ - botUpdate?: (user: UserPayload) => unknown; - /** Sent when a new guild channel is created, relevant to the current user. */ - channelCreate?: (channel: Channel) => unknown; - /** Sent when a channel is updated. This is not sent when the field `last_message_id` is altered. To keep track of the `last_message_id` changes, you must listen for `MESSAGE_CREATE` events. */ - channelUpdate?: (channel: Channel, cachedChannel: Channel) => unknown; - /** Sent when a channel relevant to the current user is deleted. */ - channelDelete?: (channel: Channel) => unknown; - /** Sent when a message is pinned or unpinned in a text channel. This is not sent when a pinned message is deleted. */ - channelPinsUpdate?: ( - channel: Channel, - guild?: Guild, - lastPinTimestamp?: string | null, - ) => unknown; - debug?: (args: DebugArg) => unknown; - dispatchRequirements?: (data: DiscordPayload, shardID: number) => unknown; - /** Sent when a user is banned from a guild. */ - guildBanAdd?: (guild: Guild, user: UserPayload, member?: Member) => unknown; - /** Sent when a user is unbanned from a guild. */ - guildBanRemove?: ( - guild: Guild, - user: UserPayload, - member?: Member, - ) => unknown; - /** - * This event can be sent in three different scenarios: - * 1. When a user is initially connecting, to lazily load and backfill information for all unavailable guilds sent in the `READY` event. Guilds that are unavailable due to an outage will send a `GUILD_DELETE` event. - * 2. When a Guild becomes available again to the client. - * 3. When the current user joins a new Guild. - */ - guildCreate?: (guild: Guild) => unknown; - guildLoaded?: (guild: Guild) => unknown; - /** Sent when a guild is updated. */ - guildUpdate?: (guild: Guild, changes: GuildUpdateChange[]) => unknown; - /** Sent when a guild becomes or was already unavailable due to an outage, or when the user leaves or is removed from a guild. If the `unavailable` field is not set, the user was removed from the guild. */ - guildDelete?: (guild: Guild) => unknown; - /** Sent when a guild's emojis have been updated. */ - guildEmojisUpdate?: ( - guild: Guild, - emojis: Collection, - cachedEmojis: Collection, - ) => unknown; - /** Sent when a guild integration is updated. */ - guildIntegrationsUpdate?: (guild: Guild) => unknown; - /** Sent when a new user joins a guild. */ - guildMemberAdd?: (guild: Guild, member: Member) => unknown; - /** Sent when a user is removed from a guild (leave/kick/ban). */ - guildMemberRemove?: ( - guild: Guild, - user: UserPayload, - member?: Member, - ) => unknown; - /** Sent when a guild member is updated. This will also fire when the user object of a guild member changes. */ - guildMemberUpdate?: ( - guild: Guild, - member: Member, - cachedMember?: Member, - ) => unknown; - heartbeat?: () => unknown; - /** Sent when a user in a guild uses a Slash Command. */ - interactionCreate?: ( - data: Omit & { member: Member }, - ) => unknown; - /** Sent when a message is created. */ - messageCreate?: (message: Message) => unknown; - /** Sent when a message is deleted. */ - messageDelete?: (partial: PartialMessage, message?: Message) => unknown; - /** Sent when a message is updated. */ - messageUpdate?: (message: Message, cachedMessage: OldMessage) => unknown; - nicknameUpdate?: ( - guild: Guild, - member: Member, - nickname: string, - oldNickname?: string, - ) => unknown; - /** A user's presence is their current state on a guild. This event is sent when a user's presence or info, such as name or avatar, is updated. */ - presenceUpdate?: ( - presence: PresenceUpdatePayload, - oldPresence?: PresenceUpdatePayload, - ) => unknown; - raw?: (data: DiscordPayload) => unknown; - rawGateway?: (data: unknown) => unknown; - ready?: () => unknown; - /** Sent when a user adds a reaction to a message. */ - reactionAdd?: ( - payload: MessageReactionUncachedPayload, - emoji: ReactionPayload, - userID: string, - message?: Message, - ) => unknown; - /** Sent when a user removes a reaction from a message. */ - reactionRemove?: ( - payload: MessageReactionUncachedPayload, - emoji: ReactionPayload, - userID: string, - message?: Message, - ) => unknown; - /** Sent when a user explicitly removes all reactions from a message. */ - reactionRemoveAll?: (data: BaseMessageReactionPayload) => unknown; - /** Sent when a bot removes all instances of a given emoji from the reactions of a message. */ - reactionRemoveEmoji?: (data: MessageReactionRemoveEmojiPayload) => unknown; - /** Sent when a guild role is created. */ - roleCreate?: (guild: Guild, role: Role) => unknown; - /** Sent when a guild role is deleted. */ - roleDelete?: (guild: Guild, role: Role) => unknown; - /** Sent when a guild role is updated. */ - roleUpdate?: (guild: Guild, role: Role, cachedRole: Role) => unknown; - roleGained?: (guild: Guild, member: Member, roleID: string) => unknown; - roleLost?: (guild: Guild, member: Member, roleID: string) => unknown; - shardReady?: (shardID: number) => unknown; - shardFailedToLoad?: ( - shardID: number, - guildIDs: Set, - ) => unknown; - /** Sent when a user starts typing in a channel. */ - typingStart?: (data: TypingStartPayload) => unknown; - voiceChannelJoin?: (member: Member, channelID: string) => unknown; - voiceChannelLeave?: (member: Member, channelID: string) => unknown; - voiceChannelSwitch?: ( - member: Member, - channelID: string, - oldChannelID: string, - ) => unknown; - /** Sent when someone joins/leaves/moves voice channels. */ - voiceStateUpdate?: ( - member: Member, - voiceState: VoiceStateUpdatePayload, - ) => unknown; - /** Sent when a guild's voice server is updated. This is sent when initially connecting to voice, and when the current voice instance fails over to a new server. */ - voiceServerUpdate?: ( - token: string, - guild: Guild, - endpoint: string, - ) => unknown; - /** Sent when a guild channel's webhook is created, updated, or deleted. */ - webhooksUpdate?: (channelID: string, guildID: string) => unknown; - /** Sent when a member has passed the guild's Membership Screening requirements */ - membershipScreeningPassed?: (guild: Guild, member: Member) => unknown; - /** Sent when an integration is created on a server such as twitch, youtube etc.. */ - integrationCreate?: ( - data: CamelCaseProps, - ) => unknown; - /** Sent when an integration is updated. */ - integrationUpdate?: ( - data: CamelCaseProps, - ) => unknown; - /** Sent when an integration is deleted. */ - integrationDelete?: ( - data: CamelCaseProps, - ) => undefined; - /** Sent when a new invite to a channel is created. */ - inviteCreate?: (data: CamelCaseProps) => unknown; - /** Sent when an invite is deleted. */ - inviteDelete?: (data: CamelCaseProps) => unknown; -} - -export interface RateLimitData { - /** The number of remaining requests that can be made */ - remaining: string | null; - /** Epoch time (seconds since 00:00:00 UTC on January 1, 1970) at which the rate limit resets */ - resetTimestamp: string | null; - /** Total time (in seconds) of when the current rate limit bucket will reset. Can have decimals to match previous millisecond ratelimit precision */ - retryAfter: string | null; - /** Returned only on a HTTP 429 response if the rate limit headers returned are of the global rate limit (not per-route) */ - global: string | null; - /** A unique string denoting the rate limit being encountered (non-inclusive of major parameters in the route path) */ - bucketID: string | null; - /** The URL the HTTP request is made to */ - url: string; -} - export interface BotConfig { token: string; compress?: boolean;