mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 19:28:17 +00:00
Prettified Code!
This commit is contained in:
@@ -12,11 +12,9 @@ export async function addToThread(channelId: bigint, userId?: bigint) {
|
||||
const channel = await cacheHandlers.get("channels", channelId);
|
||||
if (channel) {
|
||||
if (
|
||||
![
|
||||
ChannelTypes.GuildNewsThread,
|
||||
ChannelTypes.GuildPivateThread,
|
||||
ChannelTypes.GuildPublicThread,
|
||||
].includes(channel.type)
|
||||
![ChannelTypes.GuildNewsThread, ChannelTypes.GuildPivateThread, ChannelTypes.GuildPublicThread].includes(
|
||||
channel.type
|
||||
)
|
||||
) {
|
||||
throw new Error(Errors.NOT_A_THREAD_CHANNEL);
|
||||
}
|
||||
@@ -24,8 +22,6 @@ export async function addToThread(channelId: bigint, userId?: bigint) {
|
||||
|
||||
return await rest.runMethod(
|
||||
"put",
|
||||
userId
|
||||
? endpoints.THREAD_USER(channelId, userId)
|
||||
: endpoints.THREAD_ME(channelId)
|
||||
userId ? endpoints.THREAD_USER(channelId, userId) : endpoints.THREAD_ME(channelId)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -12,11 +12,9 @@ export async function getThreadMembers(channelId: bigint) {
|
||||
const channel = await cacheHandlers.get("channels", channelId);
|
||||
if (channel) {
|
||||
if (
|
||||
![
|
||||
ChannelTypes.GuildNewsThread,
|
||||
ChannelTypes.GuildPivateThread,
|
||||
ChannelTypes.GuildPublicThread,
|
||||
].includes(channel.type)
|
||||
![ChannelTypes.GuildNewsThread, ChannelTypes.GuildPivateThread, ChannelTypes.GuildPublicThread].includes(
|
||||
channel.type
|
||||
)
|
||||
) {
|
||||
throw new Error(Errors.NOT_A_THREAD_CHANNEL);
|
||||
}
|
||||
|
||||
@@ -10,11 +10,9 @@ export async function removeFromThread(channelId: bigint, userId?: bigint) {
|
||||
const channel = await cacheHandlers.get("channels", channelId);
|
||||
if (channel) {
|
||||
if (
|
||||
![
|
||||
ChannelTypes.GuildNewsThread,
|
||||
ChannelTypes.GuildPivateThread,
|
||||
ChannelTypes.GuildPublicThread,
|
||||
].includes(channel.type)
|
||||
![ChannelTypes.GuildNewsThread, ChannelTypes.GuildPivateThread, ChannelTypes.GuildPublicThread].includes(
|
||||
channel.type
|
||||
)
|
||||
) {
|
||||
throw new Error(Errors.NOT_A_THREAD_CHANNEL);
|
||||
}
|
||||
@@ -22,8 +20,6 @@ export async function removeFromThread(channelId: bigint, userId?: bigint) {
|
||||
|
||||
return await rest.runMethod(
|
||||
"delete",
|
||||
userId
|
||||
? endpoints.THREAD_USER(channelId, userId)
|
||||
: endpoints.THREAD_ME(channelId)
|
||||
userId ? endpoints.THREAD_USER(channelId, userId) : endpoints.THREAD_ME(channelId)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -10,16 +10,11 @@ import { snakelize } from "../../../util/utils.ts";
|
||||
* Creates a new public thread from an existing message. Returns a channel on success, and a 400 BAD REQUEST on invalid parameters. Fires a Thread Create Gateway event.
|
||||
* @param messageId when provided the thread will be public
|
||||
*/
|
||||
export async function startThread(
|
||||
channelId: bigint,
|
||||
options: StartThread & { messageId?: bigint }
|
||||
) {
|
||||
export async function startThread(channelId: bigint, options: StartThread & { messageId?: bigint }) {
|
||||
const channel = await cacheHandlers.get("channels", channelId);
|
||||
if (channel) {
|
||||
// TODO(threads): perm check
|
||||
if (
|
||||
![ChannelTypes.GuildText, ChannelTypes.GuildNews].includes(channel.type)
|
||||
) {
|
||||
if (![ChannelTypes.GuildText, ChannelTypes.GuildNews].includes(channel.type)) {
|
||||
throw new Error(Errors.INVALID_THREAD_PARENT_CHANNEL_TYPE);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user