mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 11:28:15 +00:00
NOT TESTED BECAUSE DISCORD NOT WORKING
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import { cacheHandlers } from "../../../cache.ts";
|
||||
import { rest } from "../../../rest/rest.ts";
|
||||
import { ChannelTypes, Errors } from "../../../types/mod.ts";
|
||||
import { endpoints } from "../../../util/constants.ts";
|
||||
//TODO(threads): this does not work rn
|
||||
/** Adds the current user to a thread. Returns a 204 empty response on success. Also requires the thread is not archived. Fires a Thread Members Update Gateway event.Adds another user to a thread. Requires the ability to send messages in the thread. Also requires the thread is not archived. Returns a 204 empty response on success. Fires a Thread Members Update Gateway event.
|
||||
* @param userId the user to add to the thread defaults to bot
|
||||
*/
|
||||
export async function addToThread(channelId: bigint, userId?: bigint) {
|
||||
// TODO(threads): perm check
|
||||
const channel = await cacheHandlers.get("channels", channelId);
|
||||
if (channel) {
|
||||
if (
|
||||
![
|
||||
ChannelTypes.GuildNewsThread,
|
||||
ChannelTypes.GuildPivateThread,
|
||||
ChannelTypes.GuildPublicThread,
|
||||
].includes(channel.type)
|
||||
) {
|
||||
throw new Error(Errors.NOT_A_THREAD_CHANNEL);
|
||||
}
|
||||
}
|
||||
console.log(
|
||||
"put",
|
||||
userId
|
||||
? endpoints.THREAD_USER(channelId, userId)
|
||||
: endpoints.THREAD_ME(channelId),
|
||||
);
|
||||
return await rest.runMethod(
|
||||
"put",
|
||||
userId
|
||||
? endpoints.THREAD_USER(channelId, userId)
|
||||
: endpoints.THREAD_ME(channelId),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { rest } from "../../../rest/rest.ts";
|
||||
import { endpoints } from "../../../util/constants.ts";
|
||||
|
||||
/** Returns all active threads in the channel, including public and private threads. Threads are ordered by their id, in descending order. Requires the READ_MESSAGE_HISTORY permission. */
|
||||
export async function getActiveThreads(channelId: bigint) {
|
||||
// TODO(threads): perm check
|
||||
// TODO(threads): test if it works
|
||||
return rest.runMethod(
|
||||
"get",
|
||||
endpoints.THREAD_ACTIVE(channelId),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user