mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 19:28:17 +00:00
change: prettier code
This commit is contained in:
committed by
GitHub Action
parent
4a12b7714b
commit
2266e9dd00
@@ -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"]);
|
||||
}
|
||||
|
||||
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,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { ModifyThread } from "../../../types/channels/threads/modify_thread.ts";
|
||||
import type { Bot } from "../../../bot.ts";
|
||||
import {channelToThread} from "../../../util/transformers/channel_to_thread.ts";
|
||||
import { channelToThread } from "../../../util/transformers/channel_to_thread.ts";
|
||||
|
||||
/** Update a thread's settings. Requires the `MANAGE_CHANNELS` permission for the guild. */
|
||||
export async function editThread(bot: Bot, threadId: bigint, options: ModifyThread, reason?: string) {
|
||||
@@ -8,19 +8,14 @@ export async function editThread(bot: Bot, threadId: bigint, options: ModifyThre
|
||||
|
||||
// TODO: permission checking
|
||||
|
||||
const result = await bot.rest.runMethod(
|
||||
bot.rest,
|
||||
"patch",
|
||||
bot.constants.endpoints.CHANNEL_BASE(threadId),
|
||||
{
|
||||
const result = await bot.rest.runMethod(bot.rest, "patch", bot.constants.endpoints.CHANNEL_BASE(threadId), {
|
||||
name: options.name,
|
||||
archived: options.archived,
|
||||
auto_archive_duration: options.autoArchiveDuration,
|
||||
locked: options.locked,
|
||||
rate_limit_per_user: options.rateLimitPerUser,
|
||||
reason,
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
return channelToThread(result);
|
||||
}
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
import type { Bot } from "../../../bot.ts";
|
||||
import type { ListActiveThreads } from "../../../types/channels/threads/list_active_threads.ts";
|
||||
import { Collection } from "../../../util/collection.ts";
|
||||
import {channelToThread} from "../../../util/transformers/channel_to_thread.ts";
|
||||
import { channelToThread } from "../../../util/transformers/channel_to_thread.ts";
|
||||
|
||||
/** Returns all active threads in the channel, including public and private threads. Threads are ordered by their id, in descending order. Requires the VIEW_CHANNEL permission. */
|
||||
export async function getActiveThreads(bot: Bot, channelId: bigint) {
|
||||
await bot.utils.requireBotChannelPermissions(bot, channelId, ["VIEW_CHANNEL"]);
|
||||
|
||||
// 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(
|
||||
result.threads.map((t) => {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { ListPublicArchivedThreads } from "../../../types/channels/threads/list_
|
||||
import { PermissionStrings } from "../../../types/permissions/permission_strings.ts";
|
||||
import { Collection } from "../../../util/collection.ts";
|
||||
import type { Bot } from "../../../bot.ts";
|
||||
import {channelToThread} from "../../../util/transformers/channel_to_thread.ts";
|
||||
import { channelToThread } from "../../../util/transformers/channel_to_thread.ts";
|
||||
|
||||
/** Get the archived threads for this channel, defaults to public */
|
||||
export async function getArchivedThreads(
|
||||
@@ -28,11 +28,13 @@ export async function getArchivedThreads(
|
||||
: options?.type === "private"
|
||||
? bot.constants.endpoints.THREAD_ARCHIVED_PRIVATE(channelId)
|
||||
: bot.constants.endpoints.THREAD_ARCHIVED_PUBLIC(channelId),
|
||||
options ? {
|
||||
options
|
||||
? {
|
||||
before: options.before,
|
||||
limit: options.limit,
|
||||
type: options.type
|
||||
} : {}
|
||||
type: options.type,
|
||||
}
|
||||
: {}
|
||||
)) as ListActiveThreads;
|
||||
|
||||
const threads = new Collection(
|
||||
|
||||
@@ -2,11 +2,14 @@ import type { Bot } from "../../../bot.ts";
|
||||
import { ThreadMember } from "../../../types/channels/threads/thread_member.ts";
|
||||
import { DiscordGatewayIntents } from "../../../types/gateway/gateway_intents.ts";
|
||||
import { Collection } from "../../../util/collection.ts";
|
||||
import {threadMemberModified} from "../../../util/transformers/thread_member_modified.ts";
|
||||
import { threadMemberModified } from "../../../util/transformers/thread_member_modified.ts";
|
||||
/** Returns thread members objects that are members of the thread. */
|
||||
export async function getThreadMembers(bot: Bot, threadId: bigint) {
|
||||
// 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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
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));
|
||||
|
||||
|
||||
@@ -7,5 +7,5 @@ export async function joinThread(bot: Bot, threadId: bigint) {
|
||||
throw new Error(bot.contants.Errors.CANNOT_ADD_USER_TO_ARCHIVED_THREADS);
|
||||
}
|
||||
|
||||
return await bot.rest.runMethod<undefined>(bot.rest,"put", bot.constants.endpoints.THREAD_ME(threadId));
|
||||
return await bot.rest.runMethod<undefined>(bot.rest, "put", bot.constants.endpoints.THREAD_ME(threadId));
|
||||
}
|
||||
|
||||
@@ -5,5 +5,5 @@ export async function leaveThread(bot: Bot, threadId: bigint) {
|
||||
const thread = await bot.cache.threads.get(threadId);
|
||||
if (thread?.archived) throw new Error(bot.constants.Errors.CANNOT_LEAVE_ARCHIVED_THREAD);
|
||||
|
||||
return await bot.rest.runMethod<undefined>(bot.rest,"delete", bot.constants.endpoints.THREAD_ME(threadId));
|
||||
return await bot.rest.runMethod<undefined>(bot.rest, "delete", bot.constants.endpoints.THREAD_ME(threadId));
|
||||
}
|
||||
|
||||
@@ -12,5 +12,5 @@ export async function removeThreadMember(bot: Bot, threadId: bigint, userId: big
|
||||
}
|
||||
}
|
||||
|
||||
return await bot.rest.runMethod<undefined>(bot.rest,"delete", bot.constants.endpoints.THREAD_USER(threadId, userId));
|
||||
return await bot.rest.runMethod<undefined>(bot.rest, "delete", bot.constants.endpoints.THREAD_USER(threadId, userId));
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { Channel } from "../../../types/channels/channel.ts";
|
||||
import type { StartThread } from "../../../types/channels/threads/start_thread.ts";
|
||||
import type { Bot } from "../../../bot.ts";
|
||||
import {channelToThread} from "../../../util/transformers/channel_to_thread.ts";
|
||||
import { channelToThread } from "../../../util/transformers/channel_to_thread.ts";
|
||||
|
||||
/** Creates a new private thread. Returns a thread channel. */
|
||||
export async function startPrivateThread(bot: Bot, channelId: bigint, options: StartThread) {
|
||||
@@ -15,9 +15,9 @@ export async function startPrivateThread(bot: Bot, channelId: bigint, options: S
|
||||
}
|
||||
|
||||
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,
|
||||
auto_archive_duration: options.autoArchiveDuration
|
||||
auto_archive_duration: options.autoArchiveDuration,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { Channel } from "../../../types/channels/channel.ts";
|
||||
import type { StartThread } from "../../../types/channels/threads/start_thread.ts";
|
||||
import type { Bot } from "../../../bot.ts";
|
||||
import {channelToThread} from "../../../util/transformers/channel_to_thread.ts";
|
||||
import { channelToThread } from "../../../util/transformers/channel_to_thread.ts";
|
||||
|
||||
/** Creates a new public thread from an existing message. Returns a thread channel. */
|
||||
export async function startThread(bot: Bot, channelId: bigint, messageId: bigint, options: StartThread) {
|
||||
@@ -15,9 +15,14 @@ export async function startThread(bot: Bot, channelId: bigint, messageId: bigint
|
||||
}
|
||||
|
||||
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,
|
||||
auto_archive_duration: options.autoArchiveDuration
|
||||
})
|
||||
auto_archive_duration: options.autoArchiveDuration,
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user