mirror of
https://github.com/discordeno/discordeno.git
synced 2026-09-17 08:47:22 +00:00
fix(bot): properly handle thread list sync event (#3116)
* fix: Added threadListSync event support * fix: Added threadListSync event support * Update packages/bot/src/bot.ts --------- Co-authored-by: ITOH <to@itoh.at>
This commit is contained in:
@@ -71,14 +71,11 @@ export function createBot(options: CreateBotOptions): Bot {
|
|||||||
bot.gateway.connection = await bot.rest.getSessionInfo()
|
bot.gateway.connection = await bot.rest.getSessionInfo()
|
||||||
|
|
||||||
// Check for overrides in the configuration
|
// Check for overrides in the configuration
|
||||||
if (!options.gateway?.url)
|
if (!options.gateway?.url) bot.gateway.url = bot.gateway.connection.url
|
||||||
bot.gateway.url = bot.gateway.connection.url;
|
|
||||||
|
|
||||||
if (!options.gateway?.totalShards)
|
if (!options.gateway?.totalShards) bot.gateway.totalShards = bot.gateway.connection.shards
|
||||||
bot.gateway.totalShards = bot.gateway.connection.shards;
|
|
||||||
|
|
||||||
if (!options.gateway?.lastShardId)
|
if (!options.gateway?.lastShardId) bot.gateway.lastShardId = bot.gateway.connection.shards - 1
|
||||||
bot.gateway.lastShardId = bot.gateway.connection.shards - 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await bot.gateway.spawnShards()
|
await bot.gateway.spawnShards()
|
||||||
@@ -90,7 +87,7 @@ export function createBot(options: CreateBotOptions): Bot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bot.helpers = createBotHelpers(bot)
|
bot.helpers = createBotHelpers(bot)
|
||||||
if (options.applicationId) bot.applicationId = bot.transformers.snowflake(options.applicationId);
|
if (options.applicationId) bot.applicationId = bot.transformers.snowflake(options.applicationId)
|
||||||
|
|
||||||
return bot
|
return bot
|
||||||
}
|
}
|
||||||
@@ -144,6 +141,7 @@ export interface EventHandlers {
|
|||||||
automodActionExecution: (payload: AutoModerationActionExecution) => unknown
|
automodActionExecution: (payload: AutoModerationActionExecution) => unknown
|
||||||
threadCreate: (thread: Channel) => unknown
|
threadCreate: (thread: Channel) => unknown
|
||||||
threadDelete: (thread: Channel) => unknown
|
threadDelete: (thread: Channel) => unknown
|
||||||
|
threadListSync: (payload: { guildId: bigint; channelIds?: bigint[]; threads: Channel[]; members: ThreadMember[] }) => unknown
|
||||||
threadMemberUpdate: (payload: { id: bigint; guildId: bigint; joinedAt: number; flags: number }) => unknown
|
threadMemberUpdate: (payload: { id: bigint; guildId: bigint; joinedAt: number; flags: number }) => unknown
|
||||||
threadMembersUpdate: (payload: { id: bigint; guildId: bigint; addedMembers?: ThreadMember[]; removedMemberIds?: bigint[] }) => unknown
|
threadMembersUpdate: (payload: { id: bigint; guildId: bigint; addedMembers?: ThreadMember[]; removedMemberIds?: bigint[] }) => unknown
|
||||||
threadUpdate: (thread: Channel) => unknown
|
threadUpdate: (thread: Channel) => unknown
|
||||||
@@ -187,7 +185,7 @@ export interface EventHandlers {
|
|||||||
guildId?: bigint
|
guildId?: bigint
|
||||||
member?: Member
|
member?: Member
|
||||||
user?: User
|
user?: User
|
||||||
emoji: Emoji,
|
emoji: Emoji
|
||||||
messageAuthorId?: bigint
|
messageAuthorId?: bigint
|
||||||
}) => unknown
|
}) => unknown
|
||||||
reactionRemove: (payload: { userId: bigint; channelId: bigint; messageId: bigint; guildId?: bigint; emoji: Emoji }) => unknown
|
reactionRemove: (payload: { userId: bigint; channelId: bigint; messageId: bigint; guildId?: bigint; emoji: Emoji }) => unknown
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ export async function handleThreadListSync(bot: Bot, data: DiscordGatewayPayload
|
|||||||
|
|
||||||
const guildId = bot.transformers.snowflake(payload.guild_id)
|
const guildId = bot.transformers.snowflake(payload.guild_id)
|
||||||
|
|
||||||
return {
|
bot.events.threadListSync?.({
|
||||||
guildId,
|
guildId,
|
||||||
channelIds: payload.channel_ids?.map((id) => bot.transformers.snowflake(id)),
|
channelIds: payload.channel_ids?.map((id) => bot.transformers.snowflake(id)),
|
||||||
threads: payload.threads.map((thread) => bot.transformers.channel(bot, { channel: thread, guildId })),
|
threads: payload.threads.map((thread) => bot.transformers.channel(bot, { channel: thread, guildId })),
|
||||||
@@ -14,6 +14,7 @@ export async function handleThreadListSync(bot: Bot, data: DiscordGatewayPayload
|
|||||||
id: member.id ? bot.transformers.snowflake(member.id) : undefined,
|
id: member.id ? bot.transformers.snowflake(member.id) : undefined,
|
||||||
userId: member.user_id ? bot.transformers.snowflake(member.user_id) : undefined,
|
userId: member.user_id ? bot.transformers.snowflake(member.user_id) : undefined,
|
||||||
joinTimestamp: Date.parse(member.join_timestamp),
|
joinTimestamp: Date.parse(member.join_timestamp),
|
||||||
|
flags: member.flags,
|
||||||
})),
|
})),
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user