Merge branch 'main' into collection-sweeper

This commit is contained in:
ITOH
2021-05-18 19:55:48 +02:00
15 changed files with 75 additions and 23 deletions

View File

@@ -1,6 +1,6 @@
import { getGatewayBot } from "./helpers/misc/get_gateway_bot.ts";
import { rest } from "./rest/rest.ts";
import type { EventHandlers } from "./types/discordeno/eventHandlers.ts";
import type { EventHandlers } from "./types/discordeno/event_handlers.ts";
import { DiscordGatewayIntents } from "./types/gateway/gateway_intents.ts";
import { snowflakeToBigint } from "./util/bigint.ts";
import { GATEWAY_VERSION } from "./util/constants.ts";

View File

@@ -0,0 +1,7 @@
import { eventHandlers } from "../../bot.ts";
import type { StageInstance } from "../../types/channels/stage_instance.ts";
import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts";
export function handleStageInstanceCreate(data: DiscordGatewayPayload) {
eventHandlers.stageInstanceCreate?.(data.d as StageInstance);
}

View File

@@ -0,0 +1,7 @@
import { eventHandlers } from "../../bot.ts";
import type { StageInstance } from "../../types/channels/stage_instance.ts";
import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts";
export function handleStageInstanceDelete(data: DiscordGatewayPayload) {
eventHandlers.stageInstanceDelete?.(data.d as StageInstance);
}

View File

@@ -0,0 +1,7 @@
import { eventHandlers } from "../../bot.ts";
import type { StageInstance } from "../../types/channels/stage_instance.ts";
import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts";
export function handleStageInstanceUpdate(data: DiscordGatewayPayload) {
eventHandlers.stageInstanceUpdate?.(data.d as StageInstance);
}

View File

@@ -2,6 +2,9 @@ import { handleChannelCreate } from "./channels/CHANNEL_CREATE.ts";
import { handleChannelDelete } from "./channels/CHANNEL_DELETE.ts";
import { handleChannelPinsUpdate } from "./channels/CHANNEL_PINS_UPDATE.ts";
import { handleChannelUpdate } from "./channels/CHANNEL_UPDATE.ts";
import { handleStageInstanceCreate } from "./channels/STAGE_INSTANCE_CREATE.ts";
import { handleStageInstanceUpdate } from "./channels/STAGE_INSTANCE_UPDATE.ts";
import { handleStageInstanceDelete } from "./channels/STAGE_INSTANCE_DELETE.ts";
import { handleThreadCreate } from "./channels/THREAD_CREATE.ts";
import { handleThreadDelete } from "./channels/THREAD_DELETE.ts";
import { handleThreadListSync } from "./channels/THREAD_LIST_SYNC.ts";
@@ -83,6 +86,9 @@ export {
handleMessageUpdate,
handlePresenceUpdate,
handleReady,
handleStageInstanceCreate,
handleStageInstanceDelete,
handleStageInstanceUpdate,
handleThreadCreate,
handleThreadDelete,
handleThreadListSync,
@@ -110,6 +116,10 @@ export let handlers = {
THREAD_LIST_SYNC: handleThreadListSync,
THREAD_MEMBER_UPDATE: handleThreadMemberUpdate,
THREAD_MEMBERS_UPDATE: handleThreadMembersUpdate,
STAGE_INSTANCE_CREATE: handleStageInstanceCreate,
STAGE_INSTANCE_UPDATE: handleStageInstanceUpdate,
STAGE_INSTANCE_DELETE: handleStageInstanceDelete,
// commands
APPLICATION_COMMAND_CREATE: handleApplicationCommandCreate,
APPLICATION_COMMAND_DELETE: handleApplicationCommandDelete,

View File

@@ -2,7 +2,7 @@ import { eventHandlers } from "../../bot.ts";
import { cacheHandlers } from "../../cache.ts";
import { structures } from "../../structures/mod.ts";
import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts";
import type { GuildRoleCreate } from "../../types/mod.ts";
import type { GuildRoleCreate } from "../../types/guilds/guild_role_create.ts";
import { snowflakeToBigint } from "../../util/bigint.ts";
export async function handleGuildRoleCreate(data: DiscordGatewayPayload) {

View File

@@ -2,7 +2,7 @@ import { eventHandlers } from "../../bot.ts";
import { cacheHandlers } from "../../cache.ts";
import { structures } from "../../structures/mod.ts";
import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts";
import type { GuildRoleUpdate } from "../../types/mod.ts";
import type { GuildRoleUpdate } from "../../types/guilds/guild_role_update.ts";
import { snowflakeToBigint } from "../../util/bigint.ts";
export async function handleGuildRoleUpdate(data: DiscordGatewayPayload) {

View File

@@ -1,7 +1,7 @@
import { cacheHandlers } from "../../cache.ts";
import { rest } from "../../rest/rest.ts";
import { Errors } from "../../types/discordeno/errors.ts";
import { ChannelTypes } from "../../types/mod.ts";
import { ChannelTypes } from "../../types/channels/channel_types.ts";
import { endpoints } from "../../util/constants.ts";
import { requireBotGuildPermissions } from "../../util/permissions.ts";

View File

@@ -1,6 +1,7 @@
import { cacheHandlers } from "../../../cache.ts";
import { rest } from "../../../rest/rest.ts";
import { ChannelTypes, Errors } from "../../../types/mod.ts";
import { ChannelTypes } from "../../../types/channels/channel_types.ts";
import { Errors } from "../../../types/discordeno/errors.ts";
import { endpoints } from "../../../util/constants.ts";
//TODO(threads): this does not work rn
/** Adds the current user to a thread. Returns a 204 empty response on success. Also requires the thread is not archived. Fires a Thread Members Update Gateway event.Adds another user to a thread. Requires the ability to send messages in the thread. Also requires the thread is not archived. Returns a 204 empty response on success. Fires a Thread Members Update Gateway event.

View File

@@ -1,5 +1,5 @@
import { rest } from "../../rest/rest.ts";
import type { WelcomeScreen } from "../../types/mod.ts";
import type { WelcomeScreen } from "../../types/guilds/welcome_screen.ts";
import { endpoints } from "../../util/constants.ts";
export async function getWelcomeScreen(guildId: bigint) {

View File

@@ -4,27 +4,26 @@ import { DiscordenoMember } from "../../structures/member.ts";
import { DiscordenoMessage } from "../../structures/message.ts";
import { DiscordenoRole } from "../../structures/role.ts";
import { Collection } from "../../util/collection.ts";
import { PresenceUpdate } from "../activity/presence_update.ts";
import { StageInstance } from "../channels/stage_instance.ts";
import { ThreadMember } from "../channels/threads/thread_member.ts";
import { ThreadMembersUpdate } from "../channels/threads/thread_members_update.ts";
import { Emoji } from "../emojis/emoji.ts";
import { GatewayPayload } from "../gateway/gateway_payload.ts";
import { DiscordGatewayPayload } from "../gateway/gateway_payload.ts";
import { IntegrationCreateUpdate } from "../integrations/integration_create_update.ts";
import { IntegrationDelete } from "../integrations/integration_delete.ts";
import { ApplicationCommandCreateUpdateDelete } from "../interactions/commands/application_command_create_update_delete.ts";
import {
DiscordGatewayPayload,
Emoji,
GatewayPayload,
IntegrationDelete,
Interaction,
InviteCreate,
InviteDelete,
MessageReactionAdd,
MessageReactionRemove,
MessageReactionRemoveAll,
PresenceUpdate,
TypingStart,
User,
VoiceState,
} from "../mod.ts";
import { Interaction } from "../interactions/interaction.ts";
import { InviteCreate } from "../invites/invite_create.ts";
import { InviteDelete } from "../invites/invite_delete.ts";
import { MessageReactionAdd } from "../messages/message_reaction_add.ts";
import { MessageReactionRemove } from "../messages/message_reaction_remove.ts";
import { MessageReactionRemoveAll } from "../messages/message_reaction_remove_all.ts";
import { TypingStart } from "../misc/typing_start.ts";
import { User } from "../users/user.ts";
import { VoiceServerUpdate } from "../voice/voice_server_update.ts";
import { VoiceState } from "../voice/voice_state.ts";
import { DebugArg } from "./debug_arg.ts";
import { GuildUpdateChange } from "./guild_update_change.ts";
@@ -170,6 +169,12 @@ export type EventHandlersDefinitions = {
shardReady: [shardId: number];
/** Sent when a shard failed to load. */
shardFailedToLoad: [shardId: number, unavailableGuildIds: Set<bigint>];
/** Sent when a Stage instance is created (i.e. the Stage is now "live"). */
stageInstanceCreate: [instance: StageInstance];
/** Sent when a Stage instance has been deleted (i.e. the Stage has been closed). */
stageInstanceDelete: [instance: StageInstance];
/** Sent when a Stage instance has been updated. */
stageInstanceUpdate: [instance: StageInstance];
/** Sent when a thread is created */
threadCreate: [channel: DiscordenoChannel];
/** Sent when a thread is updated */

View File

@@ -2,7 +2,7 @@ export * from "./create_slash_command.ts";
export * from "./debug_arg.ts";
export * from "./edit_webhook_message.ts";
export * from "./errors.ts";
export * from "./eventHandlers.ts";
export * from "./event_handlers.ts";
export * from "./file_content.ts";
export * from "./guild_member.ts";
export * from "./guild_update_change.ts";

View File

@@ -10,6 +10,15 @@ export enum DiscordGatewayIntents {
* - CHANNEL_UPDATE
* - CHANNEL_DELETE
* - CHANNEL_PINS_UPDATE
* - THREAD_CREATE
* - THREAD_UPDATE
* - THREAD_DELETE
* - THREAD_LIST_SYNC
* - THREAD_MEMBER_UPDATE
* - THREAD_MEMBERS_UPDATE
* - STAGE_INSTANCE_CREATE
* - STAGE_INSTANCE_UPDATE
* - STAGE_INSTANCE_DELETE
*/
Guilds = 1 << 0,
/**

View File

@@ -50,6 +50,9 @@ export interface GatewayPayload {
| "INTEGRATION_CREATE"
| "INTEGRATION_UPDATE"
| "INTEGRATION_DELETE"
| "STAGE_INSTANCE_CREATE"
| "STAGE_INSTANCE_UPDATE"
| "STAGE_INSTANCE_DELETE"
| null;
}

View File

@@ -12,6 +12,7 @@ import { DiscordPremiumTiers } from "./premium_tiers.ts";
import { DiscordSystemChannelFlags } from "./system_channel_flags.ts";
import { DiscordVerificationLevels } from "./verification_levels.ts";
import { WelcomeScreen } from "./welcome_screen.ts";
import type { StageInstance } from "../channels/stage_instance.ts";
/** https://discord.com/developers/docs/resources/guild#guild-object */
export interface Guild {
@@ -112,4 +113,6 @@ export interface Guild {
welcomeScreen?: WelcomeScreen;
/** `true` if this guild is designated as NSFW */
nsfw: boolean;
/** Stage instances in the guild */
stageInstances?: StageInstance[];
}