mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 03:18:17 +00:00
refactor!: move dirs outside of src/ (#2032)
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
import type { Channel } from "../../types/channels/channel.ts";
|
||||
import type { DiscordGatewayPayload } from "../../types/gateway/gatewayPayload.ts";
|
||||
import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
|
||||
|
||||
import type { Bot } from "../../bot.ts";
|
||||
|
||||
export async function handleChannelCreate(bot: Bot, payload: DiscordGatewayPayload) {
|
||||
const channel = bot.transformers.channel(bot, { channel: payload.d as SnakeCasedPropertiesDeep<Channel> });
|
||||
|
||||
bot.events.channelCreate(bot, channel);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import type { Channel } from "../../types/channels/channel.ts";
|
||||
import type { DiscordGatewayPayload } from "../../types/gateway/gatewayPayload.ts";
|
||||
import type { Bot } from "../../bot.ts";
|
||||
import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
|
||||
|
||||
export async function handleChannelDelete(bot: Bot, data: DiscordGatewayPayload) {
|
||||
const payload = data.d as SnakeCasedPropertiesDeep<Channel>;
|
||||
if (!payload.guild_id) return;
|
||||
|
||||
bot.events.channelDelete(
|
||||
bot,
|
||||
bot.transformers.channel(bot, {
|
||||
channel: payload,
|
||||
guildId: payload.guild_id ? bot.transformers.snowflake(payload.guild_id) : undefined,
|
||||
}),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import type { Bot } from "../../bot.ts";
|
||||
import type { ChannelPinsUpdate } from "../../types/channels/channelPinsUpdate.ts";
|
||||
import type { DiscordGatewayPayload } from "../../types/gateway/gatewayPayload.ts";
|
||||
import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
|
||||
|
||||
export async function handleChannelPinsUpdate(bot: Bot, data: DiscordGatewayPayload) {
|
||||
const payload = data.d as SnakeCasedPropertiesDeep<ChannelPinsUpdate>;
|
||||
|
||||
bot.events.channelPinsUpdate(bot, {
|
||||
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,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import type { Bot } from "../../bot.ts";
|
||||
import type { Channel } from "../../types/channels/channel.ts";
|
||||
import type { DiscordGatewayPayload } from "../../types/gateway/gatewayPayload.ts";
|
||||
import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
|
||||
|
||||
export async function handleChannelUpdate(bot: Bot, data: DiscordGatewayPayload) {
|
||||
const payload = data.d as SnakeCasedPropertiesDeep<Channel>;
|
||||
const channel = bot.transformers.channel(bot, { channel: payload });
|
||||
|
||||
bot.events.channelUpdate(bot, channel);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import type { Bot } from "../../bot.ts";
|
||||
import type { StageInstance } from "../../types/channels/stageInstance.ts";
|
||||
import type { DiscordGatewayPayload } from "../../types/gateway/gatewayPayload.ts";
|
||||
import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
|
||||
|
||||
export function handleStageInstanceCreate(bot: Bot, data: DiscordGatewayPayload) {
|
||||
const payload = data.d as SnakeCasedPropertiesDeep<StageInstance>;
|
||||
|
||||
bot.events.stageInstanceCreate(bot, {
|
||||
id: bot.transformers.snowflake(payload.id),
|
||||
guildId: bot.transformers.snowflake(payload.guild_id),
|
||||
channelId: bot.transformers.snowflake(payload.channel_id),
|
||||
topic: payload.topic,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import type { Bot } from "../../bot.ts";
|
||||
import type { StageInstance } from "../../types/channels/stageInstance.ts";
|
||||
import type { DiscordGatewayPayload } from "../../types/gateway/gatewayPayload.ts";
|
||||
import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
|
||||
|
||||
export function handleStageInstanceDelete(bot: Bot, data: DiscordGatewayPayload) {
|
||||
const payload = data.d as SnakeCasedPropertiesDeep<StageInstance>;
|
||||
|
||||
bot.events.stageInstanceDelete(bot, {
|
||||
id: bot.transformers.snowflake(payload.id),
|
||||
guildId: bot.transformers.snowflake(payload.guild_id),
|
||||
channelId: bot.transformers.snowflake(payload.channel_id),
|
||||
topic: payload.topic,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import type { Bot } from "../../bot.ts";
|
||||
import type { StageInstance } from "../../types/channels/stageInstance.ts";
|
||||
import type { DiscordGatewayPayload } from "../../types/gateway/gatewayPayload.ts";
|
||||
import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
|
||||
|
||||
export function handleStageInstanceUpdate(bot: Bot, data: DiscordGatewayPayload) {
|
||||
const payload = data.d as SnakeCasedPropertiesDeep<StageInstance>;
|
||||
|
||||
bot.events.stageInstanceUpdate(bot, {
|
||||
id: bot.transformers.snowflake(payload.id),
|
||||
guildId: bot.transformers.snowflake(payload.guild_id),
|
||||
channelId: bot.transformers.snowflake(payload.channel_id),
|
||||
topic: payload.topic,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { Bot } from "../../bot.ts";
|
||||
import { Channel } from "../../types/channels/channel.ts";
|
||||
import { DiscordGatewayPayload } from "../../types/gateway/gatewayPayload.ts";
|
||||
import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
|
||||
|
||||
export async function handleThreadCreate(bot: Bot, data: DiscordGatewayPayload) {
|
||||
const payload = data.d as SnakeCasedPropertiesDeep<Channel>;
|
||||
|
||||
bot.events.threadCreate(bot, bot.transformers.channel(bot, { channel: payload }));
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { Bot } from "../../bot.ts";
|
||||
import { Channel } from "../../types/channels/channel.ts";
|
||||
import { DiscordGatewayPayload } from "../../types/gateway/gatewayPayload.ts";
|
||||
import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
|
||||
|
||||
export async function handleThreadDelete(bot: Bot, data: DiscordGatewayPayload) {
|
||||
const payload = data.d as SnakeCasedPropertiesDeep<Channel>;
|
||||
bot.events.threadDelete(bot, bot.transformers.channel(bot, { channel: payload }));
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import { Bot } from "../../bot.ts";
|
||||
import { ThreadListSync } from "../../types/channels/threads/threadListSync.ts";
|
||||
import { DiscordGatewayPayload } from "../../types/gateway/gatewayPayload.ts";
|
||||
import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
|
||||
|
||||
export async function handleThreadListSync(bot: Bot, data: DiscordGatewayPayload) {
|
||||
const payload = data.d as SnakeCasedPropertiesDeep<ThreadListSync>;
|
||||
|
||||
const guildId = bot.transformers.snowflake(payload.guild_id);
|
||||
return {
|
||||
guildId,
|
||||
channelIds: payload.channel_ids?.map((id) => bot.transformers.snowflake(id)),
|
||||
threads: payload.threads.map((thread) => bot.transformers.channel(bot, { channel: thread, guildId })),
|
||||
members: payload.members.map((member) => ({
|
||||
id: member.id ? bot.transformers.snowflake(member.id) : undefined,
|
||||
userId: member.user_id ? bot.transformers.snowflake(member.user_id) : undefined,
|
||||
joinTimestamp: Date.parse(member.join_timestamp),
|
||||
})),
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { Bot } from "../../bot.ts";
|
||||
import { ThreadMembersUpdate } from "../../types/channels/threads/threadMembersUpdate.ts";
|
||||
import { DiscordGatewayPayload } from "../../types/gateway/gatewayPayload.ts";
|
||||
import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
|
||||
|
||||
export async function handleThreadMembersUpdate(bot: Bot, data: DiscordGatewayPayload) {
|
||||
const payload = data.d as SnakeCasedPropertiesDeep<ThreadMembersUpdate>;
|
||||
bot.events.threadMembersUpdate(bot, {
|
||||
id: bot.transformers.snowflake(payload.id),
|
||||
guildId: bot.transformers.snowflake(payload.guild_id),
|
||||
addedMembers: payload.added_members?.map((member) => bot.transformers.threadMember(bot, member)),
|
||||
removedMemberIds: payload.removed_member_ids?.map((id) => bot.transformers.snowflake(id)),
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { Bot } from "../../bot.ts";
|
||||
import { DiscordGatewayPayload } from "../../types/gateway/gatewayPayload.ts";
|
||||
|
||||
export async function handleThreadMemberUpdate(bot: Bot, data: DiscordGatewayPayload) {
|
||||
// This event is documented for completeness, but unlikely to be used by most bots
|
||||
return;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { Bot } from "../../bot.ts";
|
||||
import { Channel } from "../../types/channels/channel.ts";
|
||||
import { DiscordGatewayPayload } from "../../types/gateway/gatewayPayload.ts";
|
||||
import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
|
||||
|
||||
export async function handleThreadUpdate(bot: Bot, data: DiscordGatewayPayload) {
|
||||
const payload = data.d as SnakeCasedPropertiesDeep<Channel>;
|
||||
|
||||
bot.events.threadUpdate(bot, bot.transformers.channel(bot, { channel: payload }));
|
||||
}
|
||||
Reference in New Issue
Block a user