mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 19:28:17 +00:00
Merge remote-tracking branch 'origin/fp-attempt-9001' into fp-attempt-9001
This commit is contained in:
@@ -8,5 +8,7 @@ export async function deleteThread(bot: Bot, threadId: bigint, reason?: string)
|
|||||||
if (channel?.guildId) await bot.utils.requireBotGuildPermissions(bot, channel.guildId, ["MANAGE_THREADS"]);
|
if (channel?.guildId) await bot.utils.requireBotGuildPermissions(bot, channel.guildId, ["MANAGE_THREADS"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return await bot.rest.runMethod<undefined>(bot.rest,"delete", bot.constants.endpoints.CHANNEL_BASE(threadId), { reason });
|
return await bot.rest.runMethod<undefined>(bot.rest, "delete", bot.constants.endpoints.CHANNEL_BASE(threadId), {
|
||||||
|
reason,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,19 +8,14 @@ export async function editThread(bot: Bot, threadId: bigint, options: ModifyThre
|
|||||||
|
|
||||||
// TODO: permission checking
|
// TODO: permission checking
|
||||||
|
|
||||||
const result = await bot.rest.runMethod(
|
const result = await bot.rest.runMethod(bot.rest, "patch", bot.constants.endpoints.CHANNEL_BASE(threadId), {
|
||||||
bot.rest,
|
|
||||||
"patch",
|
|
||||||
bot.constants.endpoints.CHANNEL_BASE(threadId),
|
|
||||||
{
|
|
||||||
name: options.name,
|
name: options.name,
|
||||||
archived: options.archived,
|
archived: options.archived,
|
||||||
auto_archive_duration: options.autoArchiveDuration,
|
auto_archive_duration: options.autoArchiveDuration,
|
||||||
locked: options.locked,
|
locked: options.locked,
|
||||||
rate_limit_per_user: options.rateLimitPerUser,
|
rate_limit_per_user: options.rateLimitPerUser,
|
||||||
reason,
|
reason,
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
return channelToThread(result);
|
return channelToThread(result);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,11 @@ export async function getActiveThreads(bot: Bot, channelId: bigint) {
|
|||||||
await bot.utils.requireBotChannelPermissions(bot, channelId, ["VIEW_CHANNEL"]);
|
await bot.utils.requireBotChannelPermissions(bot, channelId, ["VIEW_CHANNEL"]);
|
||||||
|
|
||||||
// TODO: pagination
|
// TODO: pagination
|
||||||
const result = (await bot.rest.runMethod(bot.rest,"get", bot.constants.endpoints.THREAD_ACTIVE(channelId))) as ListActiveThreads;
|
const result = (await bot.rest.runMethod(
|
||||||
|
bot.rest,
|
||||||
|
"get",
|
||||||
|
bot.constants.endpoints.THREAD_ACTIVE(channelId)
|
||||||
|
)) as ListActiveThreads;
|
||||||
|
|
||||||
const threads = new Collection(
|
const threads = new Collection(
|
||||||
result.threads.map((t) => {
|
result.threads.map((t) => {
|
||||||
|
|||||||
@@ -28,11 +28,13 @@ export async function getArchivedThreads(
|
|||||||
: options?.type === "private"
|
: options?.type === "private"
|
||||||
? bot.constants.endpoints.THREAD_ARCHIVED_PRIVATE(channelId)
|
? bot.constants.endpoints.THREAD_ARCHIVED_PRIVATE(channelId)
|
||||||
: bot.constants.endpoints.THREAD_ARCHIVED_PUBLIC(channelId),
|
: bot.constants.endpoints.THREAD_ARCHIVED_PUBLIC(channelId),
|
||||||
options ? {
|
options
|
||||||
|
? {
|
||||||
before: options.before,
|
before: options.before,
|
||||||
limit: options.limit,
|
limit: options.limit,
|
||||||
type: options.type
|
type: options.type,
|
||||||
} : {}
|
}
|
||||||
|
: {}
|
||||||
)) as ListActiveThreads;
|
)) as ListActiveThreads;
|
||||||
|
|
||||||
const threads = new Collection(
|
const threads = new Collection(
|
||||||
|
|||||||
@@ -6,7 +6,10 @@ import {threadMemberModified} from "../../../util/transformers/thread_member_mod
|
|||||||
/** Returns thread members objects that are members of the thread. */
|
/** Returns thread members objects that are members of the thread. */
|
||||||
export async function getThreadMembers(bot: Bot, threadId: bigint) {
|
export async function getThreadMembers(bot: Bot, threadId: bigint) {
|
||||||
// Check if intents is not 0 as proxy ws won't set intents in other instances
|
// Check if intents is not 0 as proxy ws won't set intents in other instances
|
||||||
if (bot.gateway.identifyPayload.intents && !(bot.gateway.identifyPayload.intents & DiscordGatewayIntents.GuildMembers)) {
|
if (
|
||||||
|
bot.gateway.identifyPayload.intents &&
|
||||||
|
!(bot.gateway.identifyPayload.intents & DiscordGatewayIntents.GuildMembers)
|
||||||
|
) {
|
||||||
throw new Error(bot.constants.Errors.MISSING_INTENT_GUILD_MEMBERS);
|
throw new Error(bot.constants.Errors.MISSING_INTENT_GUILD_MEMBERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -17,7 +20,11 @@ export async function getThreadMembers(bot: Bot, threadId: bigint) {
|
|||||||
throw new Error(bot.constants.Errors.CANNOT_GET_MEMBERS_OF_AN_UNJOINED_PRIVATE_THREAD);
|
throw new Error(bot.constants.Errors.CANNOT_GET_MEMBERS_OF_AN_UNJOINED_PRIVATE_THREAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await bot.rest.runMethod<ThreadMember[]>(bot.rest,"get", bot.constants.endpoints.THREAD_MEMBERS(threadId));
|
const result = await bot.rest.runMethod<ThreadMember[]>(
|
||||||
|
bot.rest,
|
||||||
|
"get",
|
||||||
|
bot.constants.endpoints.THREAD_MEMBERS(threadId)
|
||||||
|
);
|
||||||
|
|
||||||
const members = result.map((member) => threadMemberModified(member));
|
const members = result.map((member) => threadMemberModified(member));
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export async function startPrivateThread(bot: Bot, channelId: bigint, options: S
|
|||||||
return channelToThread(
|
return channelToThread(
|
||||||
await bot.rest.runMethod<Channel>(bot.rest, "post", bot.constants.endpoints.THREAD_START_PRIVATE(channelId), {
|
await bot.rest.runMethod<Channel>(bot.rest, "post", bot.constants.endpoints.THREAD_START_PRIVATE(channelId), {
|
||||||
name: options.name,
|
name: options.name,
|
||||||
auto_archive_duration: options.autoArchiveDuration
|
auto_archive_duration: options.autoArchiveDuration,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,9 +15,14 @@ export async function startThread(bot: Bot, channelId: bigint, messageId: bigint
|
|||||||
}
|
}
|
||||||
|
|
||||||
return channelToThread(
|
return channelToThread(
|
||||||
await bot.rest.runMethod<Channel>(bot.rest,"post", bot.constants.endpoints.THREAD_START_PUBLIC(channelId, messageId), {
|
await bot.rest.runMethod<Channel>(
|
||||||
|
bot.rest,
|
||||||
|
"post",
|
||||||
|
bot.constants.endpoints.THREAD_START_PUBLIC(channelId, messageId),
|
||||||
|
{
|
||||||
name: options.name,
|
name: options.name,
|
||||||
auto_archive_duration: options.autoArchiveDuration
|
auto_archive_duration: options.autoArchiveDuration,
|
||||||
})
|
}
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user