mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 11:28:15 +00:00
Merge branch 'main' into fix-get-message-dm
This commit is contained in:
@@ -1,12 +1,10 @@
|
||||
import { cacheHandlers } from "../../cache.ts";
|
||||
import { rest } from "../../rest/rest.ts";
|
||||
import { structures } from "../../structures/mod.ts";
|
||||
import {
|
||||
CreateGuildChannel,
|
||||
DiscordChannel,
|
||||
DiscordChannelTypes,
|
||||
PermissionStrings,
|
||||
} from "../../types/mod.ts";
|
||||
import { DiscordChannel } from "../../types/channels/channel.ts";
|
||||
import { DiscordChannelTypes } from "../../types/channels/channel_types.ts";
|
||||
import { CreateGuildChannel } from "../../types/guilds/create_guild_channel.ts";
|
||||
import { PermissionStrings } from "../../types/permissions/permission_strings.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
import {
|
||||
calculateBits,
|
||||
@@ -17,7 +15,7 @@ import {
|
||||
export async function createChannel(
|
||||
guildId: string,
|
||||
name: string,
|
||||
options?: CreateGuildChannel,
|
||||
options?: CreateGuildChannel
|
||||
) {
|
||||
const requiredPerms: Set<PermissionStrings> = new Set(["MANAGE_CHANNELS"]);
|
||||
|
||||
@@ -28,8 +26,10 @@ export async function createChannel(
|
||||
|
||||
await requireBotGuildPermissions(guildId, [...requiredPerms]);
|
||||
|
||||
const result =
|
||||
(await rest.runMethod("post", endpoints.GUILD_CHANNELS(guildId), {
|
||||
const result = (await rest.runMethod(
|
||||
"post",
|
||||
endpoints.GUILD_CHANNELS(guildId),
|
||||
{
|
||||
...options,
|
||||
name,
|
||||
permission_overwrites: options?.permissionOverwrites?.map((perm) => ({
|
||||
@@ -39,7 +39,8 @@ export async function createChannel(
|
||||
deny: calculateBits(perm.deny),
|
||||
})),
|
||||
type: options?.type || DiscordChannelTypes.GUILD_TEXT,
|
||||
})) as DiscordChannel;
|
||||
}
|
||||
)) as DiscordChannel;
|
||||
|
||||
const channelStruct = await structures.createChannelStruct(result);
|
||||
await cacheHandlers.set("channels", channelStruct.id, channelStruct);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { cacheHandlers } from "../../cache.ts";
|
||||
import { rest } from "../../rest/rest.ts";
|
||||
import { Errors } from "../../types/mod.ts";
|
||||
import { Errors } from "../../types/misc/errors.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
import { requireBotGuildPermissions } from "../../util/permissions.ts";
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { rest } from "../../rest/rest.ts";
|
||||
import { Overwrite } from "../../types/mod.ts";
|
||||
import { Overwrite } from "../../types/channels/overwrite.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
import {
|
||||
calculateBits,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { rest } from "../../rest/rest.ts";
|
||||
import { DiscordFollowedChannel } from "../../types/mod.ts";
|
||||
import { DiscordFollowedChannel } from "../../types/channels/followed_channel.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
import { requireBotChannelPermissions } from "../../util/permissions.ts";
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { cacheHandlers } from "../../cache.ts";
|
||||
import { rest } from "../../rest/rest.ts";
|
||||
import { structures } from "../../structures/mod.ts";
|
||||
import { DiscordChannel } from "../../types/mod.ts";
|
||||
import { DiscordChannel } from "../../types/channels/channel.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
|
||||
/** Fetches a single channel object from the api.
|
||||
@@ -9,11 +9,10 @@ import { endpoints } from "../../util/constants.ts";
|
||||
* ⚠️ **If you need this, you are probably doing something wrong. This is not intended for use. Your channels will be cached in your guild.**
|
||||
*/
|
||||
export async function getChannel(channelId: string, addToCache = true) {
|
||||
const result =
|
||||
(await rest.runMethod(
|
||||
"get",
|
||||
endpoints.CHANNEL_BASE(channelId),
|
||||
)) as DiscordChannel;
|
||||
const result = (await rest.runMethod(
|
||||
"get",
|
||||
endpoints.CHANNEL_BASE(channelId),
|
||||
)) as DiscordChannel;
|
||||
|
||||
const channelStruct = await structures.createChannelStruct(
|
||||
result,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { rest } from "../../rest/rest.ts";
|
||||
import { DiscordWebhook } from "../../types/mod.ts";
|
||||
import { DiscordWebhook } from "../../types/webhooks/webhook.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
import { requireBotChannelPermissions } from "../../util/permissions.ts";
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { cacheHandlers } from "../../cache.ts";
|
||||
import { rest } from "../../rest/rest.ts";
|
||||
import { structures } from "../../structures/mod.ts";
|
||||
import { DiscordChannel } from "../../types/mod.ts";
|
||||
import { DiscordChannel } from "../../types/channels/channel.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
|
||||
/** Returns a list of guild channel objects.
|
||||
@@ -9,11 +9,10 @@ import { endpoints } from "../../util/constants.ts";
|
||||
* ⚠️ **If you need this, you are probably doing something wrong. This is not intended for use. Your channels will be cached in your guild.**
|
||||
*/
|
||||
export async function getChannels(guildId: string, addToCache = true) {
|
||||
const result =
|
||||
(await rest.runMethod(
|
||||
"get",
|
||||
endpoints.GUILD_CHANNELS(guildId),
|
||||
) as DiscordChannel[]);
|
||||
const result = (await rest.runMethod(
|
||||
"get",
|
||||
endpoints.GUILD_CHANNELS(guildId),
|
||||
) as DiscordChannel[]);
|
||||
|
||||
return Promise.all(result.map(async (res) => {
|
||||
const channelStruct = await structures.createChannelStruct(res, guildId);
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
import { rest } from "../../rest/rest.ts";
|
||||
import { structures } from "../../structures/mod.ts";
|
||||
import { DiscordMessage } from "../../types/mod.ts";
|
||||
import { DiscordMessage } from "../../types/messages/message.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
|
||||
/** Get pinned messages in this channel. */
|
||||
export async function getPins(channelId: string) {
|
||||
const result =
|
||||
(await rest.runMethod(
|
||||
"get",
|
||||
endpoints.CHANNEL_PINS(channelId),
|
||||
)) as DiscordMessage[];
|
||||
const result = (await rest.runMethod(
|
||||
"get",
|
||||
endpoints.CHANNEL_PINS(channelId),
|
||||
)) as DiscordMessage[];
|
||||
|
||||
return Promise.all(
|
||||
result.map((res) => structures.createMessageStruct(res)),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { cacheHandlers } from "../../cache.ts";
|
||||
import { rest } from "../../rest/rest.ts";
|
||||
import { DiscordChannelTypes, Errors } from "../../types/mod.ts";
|
||||
import { DiscordChannelTypes } from "../../types/channels/channel_types.ts";
|
||||
import { Errors } from "../../types/misc/errors.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
import { botHasChannelPermissions } from "../../util/permissions.ts";
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { rest } from "../../rest/rest.ts";
|
||||
import { ModifyGuildChannelPositions } from "../../types/mod.ts";
|
||||
import { ModifyGuildChannelPositions } from "../../types/guilds/modify_guild_channel_position.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
|
||||
/** Modify the positions of channels on the guild. Requires MANAGE_CHANNELS permisison. */
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { applicationId } from "../../bot.ts";
|
||||
import { rest } from "../../rest/rest.ts";
|
||||
import { structures } from "../../structures/mod.ts";
|
||||
import { Errors } from "../../types/misc/errors.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
|
||||
/** To edit your response to a slash command. If a messageId is not provided it will default to editing the original response. */
|
||||
|
||||
@@ -5,13 +5,12 @@ import { endpoints } from "../../util/constants.ts";
|
||||
|
||||
/** Fetch all of the global commands for your application. */
|
||||
export async function getSlashCommands(guildId?: string) {
|
||||
const result =
|
||||
(await rest.runMethod(
|
||||
"get",
|
||||
guildId
|
||||
? endpoints.COMMANDS_GUILD(applicationId, guildId)
|
||||
: endpoints.COMMANDS(applicationId),
|
||||
)) as SlashCommand[];
|
||||
const result = (await rest.runMethod(
|
||||
"get",
|
||||
guildId
|
||||
? endpoints.COMMANDS_GUILD(applicationId, guildId)
|
||||
: endpoints.COMMANDS(applicationId),
|
||||
)) as SlashCommand[];
|
||||
|
||||
return new Collection(result.map((command) => [command.name, command]));
|
||||
}
|
||||
|
||||
@@ -4,12 +4,11 @@ import { endpoints } from "../../util/constants.ts";
|
||||
|
||||
/** Create a new guild. Returns a guild object on success. Fires a Guild Create Gateway event. This endpoint can be used only by bots in less than 10 guilds. */
|
||||
export async function createGuild(options: CreateServerOptions) {
|
||||
const guild =
|
||||
(await rest.runMethod(
|
||||
"post",
|
||||
endpoints.GUILDS,
|
||||
options,
|
||||
)) as CreateGuildPayload;
|
||||
const guild = (await rest.runMethod(
|
||||
"post",
|
||||
endpoints.GUILDS,
|
||||
options,
|
||||
)) as CreateGuildPayload;
|
||||
|
||||
return structures.createGuildStruct(guild, 0);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,8 @@ export async function getAuditLogs(
|
||||
? AuditLogs[options.action_type]
|
||||
: undefined,
|
||||
limit: options.limit && options.limit >= 1 && options.limit <= 100
|
||||
? options.limit : 50,
|
||||
? options.limit
|
||||
: 50,
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -7,11 +7,10 @@ import { requireBotGuildPermissions } from "../../util/permissions.ts";
|
||||
export async function getBans(guildId: string) {
|
||||
await requireBotGuildPermissions(guildId, ["BAN_MEMBERS"]);
|
||||
|
||||
const results =
|
||||
(await rest.runMethod(
|
||||
"get",
|
||||
endpoints.GUILD_BANS(guildId),
|
||||
)) as BannedUser[];
|
||||
const results = (await rest.runMethod(
|
||||
"get",
|
||||
endpoints.GUILD_BANS(guildId),
|
||||
)) as BannedUser[];
|
||||
|
||||
return new Collection<string, BannedUser>(
|
||||
results.map((res) => [res.user.id, res]),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { rest } from "../../rest/rest.ts";
|
||||
import { Errors } from "../../types/misc/errors.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
import { requireBotGuildPermissions } from "../../util/permissions.ts";
|
||||
import { camelKeysToSnakeCase } from "../../util/utils.ts";
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { cacheHandlers } from "../../cache.ts";
|
||||
import { rest } from "../../rest/rest.ts";
|
||||
import { Errors } from "../../types/misc/errors.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
|
||||
/** Returns the widget for the guild. */
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { cacheHandlers } from "../../cache.ts";
|
||||
import { Errors } from "../../types/misc/errors.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
|
||||
/** Returns the widget image URL for the guild. */
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { cacheHandlers } from "../../cache.ts";
|
||||
import { rest } from "../../rest/rest.ts";
|
||||
import { Errors } from "../../types/misc/errors.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
import {
|
||||
botHasChannelPermissions,
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
import { Member } from "../../structures/mod.ts";
|
||||
import { rawAvatarURL } from "./raw_avatar_url.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
import { formatImageURL } from "../../util/utils.ts";
|
||||
|
||||
/** The users custom avatar or the default avatar */
|
||||
/** The users custom avatar or the default avatar if you don't have a member object. */
|
||||
export function avatarURL(
|
||||
member: Member,
|
||||
userId: string,
|
||||
discriminator: string,
|
||||
avatar?: string | null,
|
||||
size: ImageSize = 128,
|
||||
format?: ImageFormats,
|
||||
) {
|
||||
return rawAvatarURL(
|
||||
member.id,
|
||||
member.discriminator,
|
||||
member.avatar,
|
||||
size,
|
||||
format,
|
||||
);
|
||||
return avatar
|
||||
? formatImageURL(endpoints.USER_AVATAR(userId, avatar), size, format)
|
||||
: endpoints.USER_DEFAULT_AVATAR(Number(discriminator) % 5);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { rest } from "../../rest/rest.ts";
|
||||
import { Errors } from "../../types/misc/errors.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
import { urlToBase64 } from "../../util/utils.ts";
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { cacheHandlers } from "../../cache.ts";
|
||||
import { rest } from "../../rest/rest.ts";
|
||||
import { structures } from "../../structures/mod.ts";
|
||||
import { Errors } from "../../types/misc/errors.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
import {
|
||||
requireBotChannelPermissions,
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
import { identifyPayload } from "../../bot.ts";
|
||||
import { Member } from "../../structures/mod.ts";
|
||||
import { DiscordGatewayIntents } from "../../types/gateway/gateway_intents.ts";
|
||||
import { Errors } from "../../types/misc/errors.ts";
|
||||
import { Collection } from "../../util/collection.ts";
|
||||
import { requestAllMembers } from "../../ws/shard_manager.ts";
|
||||
import { DiscordGatewayIntents } from "../../types/gateway/gateway_intents.ts";
|
||||
import { Errors } from "../../types/misc/errors.ts";
|
||||
|
||||
/**
|
||||
* ⚠️ BEGINNER DEVS!! YOU SHOULD ALMOST NEVER NEED THIS AND YOU CAN GET FROM cache.members.get()
|
||||
@@ -19,7 +23,7 @@ export function fetchMembers(
|
||||
// You can request 1 member without the intent
|
||||
if (
|
||||
(!options?.limit || options.limit > 1) &&
|
||||
!(identifyPayload.intents && Intents.GUILD_MEMBERS)
|
||||
!(identifyPayload.intents && DiscordGatewayIntents.GUILD_MEMBERS)
|
||||
) {
|
||||
throw new Error(Errors.MISSING_INTENT_GUILD_MEMBERS);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { cacheHandlers } from "../../cache.ts";
|
||||
import { RequestManager } from "../../rest/request_manager.ts";
|
||||
import { rest } from "../../rest/rest.ts";
|
||||
import { structures } from "../../structures/mod.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
@@ -16,9 +15,11 @@ export async function getMember(
|
||||
const guild = await cacheHandlers.get("guilds", guildId);
|
||||
if (!guild && !options?.force) return;
|
||||
|
||||
const data = (await rest.runMethod("get",
|
||||
endpoints.GUILD_MEMBER(guildId, id),
|
||||
)) as MemberCreatePayload;
|
||||
const data =
|
||||
(await rest.runMethod(
|
||||
"get",
|
||||
endpoints.GUILD_MEMBER(guildId, id),
|
||||
)) as MemberCreatePayload;
|
||||
|
||||
const memberStruct = await structures.createMemberStruct(data, guildId);
|
||||
await cacheHandlers.set("members", memberStruct.id, memberStruct);
|
||||
|
||||
@@ -2,6 +2,9 @@ import { identifyPayload } from "../../bot.ts";
|
||||
import { cacheHandlers } from "../../cache.ts";
|
||||
import { rest } from "../../rest/rest.ts";
|
||||
import { Member, structures } from "../../structures/mod.ts";
|
||||
import { DiscordGatewayIntents } from "../../types/gateway/gateway_intents.ts";
|
||||
import { DiscordGuildMember } from "../../types/guilds/guild_member.ts";
|
||||
import { Errors } from "../../types/misc/errors.ts";
|
||||
import { Collection } from "../../util/collection.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
|
||||
@@ -14,7 +17,7 @@ import { endpoints } from "../../util/constants.ts";
|
||||
* GW(fetchMembers): 120/m(PER shard) rate limit. Meaning if you have 8 shards your limit is 960/m.
|
||||
*/
|
||||
export async function getMembers(guildId: string, options?: GetMemberOptions) {
|
||||
if (!(identifyPayload.intents && Intents.GUILD_MEMBERS)) {
|
||||
if (!(identifyPayload.intents && DiscordGatewayIntents.GUILD_MEMBERS)) {
|
||||
throw new Error(Errors.MISSING_INTENT_GUILD_MEMBERS);
|
||||
}
|
||||
|
||||
@@ -39,19 +42,12 @@ export async function getMembers(guildId: string, options?: GetMemberOptions) {
|
||||
);
|
||||
}
|
||||
|
||||
const result =
|
||||
(await rest.runMethod(
|
||||
"get",
|
||||
`${endpoints.GUILD_MEMBERS(guildId)}?limit=${
|
||||
membersLeft > 1000
|
||||
? 1000
|
||||
: membersLeft
|
||||
}${
|
||||
options?.after
|
||||
? `&after=${options.after}`
|
||||
: ""
|
||||
}`,
|
||||
)) as MemberCreatePayload[];
|
||||
const result = (await rest.runMethod(
|
||||
"get",
|
||||
`${endpoints.GUILD_MEMBERS(guildId)}?limit=${
|
||||
membersLeft > 1000 ? 1000 : membersLeft
|
||||
}${options?.after ? `&after=${options.after}` : ""}`,
|
||||
)) as DiscordGuildMember[];
|
||||
|
||||
const memberStructures = await Promise.all(
|
||||
result.map(async (member) => {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { botId } from "../../bot.ts";
|
||||
import { rest } from "../../rest/rest.ts";
|
||||
import { Errors } from "../../types/misc/errors.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
import {
|
||||
highestRole,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { rest } from "../../rest/rest.ts";
|
||||
import { Errors } from "../../types/misc/errors.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
import { requireBotGuildPermissions } from "../../util/permissions.ts";
|
||||
import { camelKeysToSnakeCase } from "../../util/utils.ts";
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
import { formatImageURL } from "../../util/utils.ts";
|
||||
|
||||
/** The users custom avatar or the default avatar if you don't have a member object. */
|
||||
export function rawAvatarURL(
|
||||
userId: string,
|
||||
discriminator: string,
|
||||
avatar?: string | null,
|
||||
size: ImageSize = 128,
|
||||
format?: ImageFormats,
|
||||
) {
|
||||
return avatar
|
||||
? formatImageURL(endpoints.USER_AVATAR(userId, avatar), size, format)
|
||||
: endpoints.USER_DEFAULT_AVATAR(Number(discriminator) % 5);
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import { rest } from "../../rest/rest.ts";
|
||||
import { Errors } from "../../types/misc/errors.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
import { requireBotChannelPermissions } from "../../util/permissions.ts";
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { botId } from "../../bot.ts";
|
||||
import { rest } from "../../rest/rest.ts";
|
||||
import { Message, structures } from "../../structures/mod.ts";
|
||||
import { Errors } from "../../types/misc/errors.ts";
|
||||
import { PermissionStrings } from "../../types/permissions/permission_strings.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
import { requireBotChannelPermissions } from "../../util/permissions.ts";
|
||||
|
||||
@@ -15,7 +17,7 @@ export async function editMessage(
|
||||
|
||||
if (typeof content === "string") content = { content };
|
||||
|
||||
const requiredPerms: Permission[] = ["SEND_MESSAGES"];
|
||||
const requiredPerms: PermissionStrings[] = ["SEND_MESSAGES"];
|
||||
|
||||
if (content.tts) requiredPerms.push("SEND_TTS_MESSAGES");
|
||||
|
||||
|
||||
@@ -13,11 +13,10 @@ export async function getMessage(channelId: string, id: string) {
|
||||
]);
|
||||
}
|
||||
|
||||
const result =
|
||||
(await rest.runMethod(
|
||||
"get",
|
||||
endpoints.CHANNEL_MESSAGE(channelId, id),
|
||||
)) as MessageCreateOptions;
|
||||
const result = (await rest.runMethod(
|
||||
"get",
|
||||
endpoints.CHANNEL_MESSAGE(channelId, id),
|
||||
)) as MessageCreateOptions;
|
||||
|
||||
return structures.createMessageStruct(result);
|
||||
}
|
||||
|
||||
@@ -19,12 +19,11 @@ export async function getMessages(
|
||||
|
||||
if (options?.limit && options.limit > 100) return;
|
||||
|
||||
const result =
|
||||
(await rest.runMethod(
|
||||
"get",
|
||||
endpoints.CHANNEL_MESSAGES(channelId),
|
||||
options,
|
||||
)) as MessageCreateOptions[];
|
||||
const result = (await rest.runMethod(
|
||||
"get",
|
||||
endpoints.CHANNEL_MESSAGES(channelId),
|
||||
options,
|
||||
)) as MessageCreateOptions[];
|
||||
|
||||
return Promise.all(
|
||||
result.map((res) => structures.createMessageStruct(res)),
|
||||
|
||||
@@ -9,12 +9,11 @@ export async function getReactions(
|
||||
reaction: string,
|
||||
options?: DiscordGetReactionsParams,
|
||||
) {
|
||||
const users =
|
||||
(await rest.runMethod(
|
||||
"get",
|
||||
endpoints.CHANNEL_MESSAGE_REACTION(channelId, messageId, reaction),
|
||||
options,
|
||||
)) as UserPayload[];
|
||||
const users = (await rest.runMethod(
|
||||
"get",
|
||||
endpoints.CHANNEL_MESSAGE_REACTION(channelId, messageId, reaction),
|
||||
options,
|
||||
)) as UserPayload[];
|
||||
|
||||
return new Collection(users.map((user) => [user.id, user]));
|
||||
}
|
||||
|
||||
@@ -4,11 +4,10 @@ import { endpoints } from "../../util/constants.ts";
|
||||
|
||||
/** Crosspost a message in a News Channel to following channels. */
|
||||
export async function publishMessage(channelId: string, messageId: string) {
|
||||
const data =
|
||||
(await rest.runMethod(
|
||||
"post",
|
||||
endpoints.CHANNEL_MESSAGE_CROSSPOST(channelId, messageId),
|
||||
)) as MessageCreateOptions;
|
||||
const data = (await rest.runMethod(
|
||||
"post",
|
||||
endpoints.CHANNEL_MESSAGE_CROSSPOST(channelId, messageId),
|
||||
)) as MessageCreateOptions;
|
||||
|
||||
return structures.createMessageStruct(data);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@ import { cacheHandlers } from "../../cache.ts";
|
||||
import { rest } from "../../rest/rest.ts";
|
||||
import { structures } from "../../structures/mod.ts";
|
||||
import { DiscordChannelTypes } from "../../types/channels/channel_types.ts";
|
||||
import { PermissionStrings } from "../../types/mod.ts";
|
||||
import { Errors } from "../../types/misc/errors.ts";
|
||||
import { PermissionStrings } from "../../types/permissions/permission_strings.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
import { requireBotChannelPermissions } from "../../util/permissions.ts";
|
||||
|
||||
|
||||
@@ -70,7 +70,6 @@ import { getMembersByQuery } from "./members/get_members_by_query.ts";
|
||||
import { kick, kickMember } from "./members/kick_member.ts";
|
||||
import { moveMember } from "./members/move_member.ts";
|
||||
import { pruneMembers } from "./members/prune_members.ts";
|
||||
import { rawAvatarURL } from "./members/raw_avatar_url.ts";
|
||||
import { sendDirectMessage } from "./members/send_direct_message.ts";
|
||||
import { unban, unbanMember } from "./members/unban_member.ts";
|
||||
import { addReaction } from "./messages/add_reaction.ts";
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { botId } from "../../bot.ts";
|
||||
import { rest } from "../../rest/rest.ts";
|
||||
import { Errors } from "../../types/misc/errors.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
import {
|
||||
isHigherPosition,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { botId } from "../../bot.ts";
|
||||
import { rest } from "../../rest/rest.ts";
|
||||
import { Errors } from "../../types/misc/errors.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
import {
|
||||
isHigherPosition,
|
||||
|
||||
@@ -23,12 +23,11 @@ export async function createGuildTemplate(
|
||||
throw new Error("The description can only be in between 0-120 characters.");
|
||||
}
|
||||
|
||||
const template =
|
||||
(await rest.runMethod(
|
||||
"post",
|
||||
endpoints.GUILD_TEMPLATES(guildId),
|
||||
data,
|
||||
)) as GuildTemplate;
|
||||
const template = (await rest.runMethod(
|
||||
"post",
|
||||
endpoints.GUILD_TEMPLATES(guildId),
|
||||
data,
|
||||
)) as GuildTemplate;
|
||||
|
||||
return structures.createTemplateStruct(template);
|
||||
}
|
||||
|
||||
@@ -13,11 +13,10 @@ export async function deleteGuildTemplate(
|
||||
) {
|
||||
await requireBotGuildPermissions(guildId, ["MANAGE_GUILD"]);
|
||||
|
||||
const deletedTemplate =
|
||||
(await rest.runMethod(
|
||||
"delete",
|
||||
`${endpoints.GUILD_TEMPLATES(guildId)}/${templateCode}`,
|
||||
)) as GuildTemplate;
|
||||
const deletedTemplate = (await rest.runMethod(
|
||||
"delete",
|
||||
`${endpoints.GUILD_TEMPLATES(guildId)}/${templateCode}`,
|
||||
)) as GuildTemplate;
|
||||
|
||||
return structures.createTemplateStruct(deletedTemplate);
|
||||
}
|
||||
|
||||
@@ -22,12 +22,11 @@ export async function editGuildTemplate(
|
||||
throw new Error("The description can only be in between 0-120 characters.");
|
||||
}
|
||||
|
||||
const template =
|
||||
(await rest.runMethod(
|
||||
"patch",
|
||||
`${endpoints.GUILD_TEMPLATES(guildId)}/${templateCode}`,
|
||||
data,
|
||||
)) as GuildTemplate;
|
||||
const template = (await rest.runMethod(
|
||||
"patch",
|
||||
`${endpoints.GUILD_TEMPLATES(guildId)}/${templateCode}`,
|
||||
data,
|
||||
)) as GuildTemplate;
|
||||
|
||||
return structures.createTemplateStruct(template);
|
||||
}
|
||||
|
||||
@@ -10,11 +10,10 @@ import { requireBotGuildPermissions } from "../../util/permissions.ts";
|
||||
export async function getGuildTemplates(guildId: string) {
|
||||
await requireBotGuildPermissions(guildId, ["MANAGE_GUILD"]);
|
||||
|
||||
const templates =
|
||||
(await rest.runMethod(
|
||||
"get",
|
||||
endpoints.GUILD_TEMPLATES(guildId),
|
||||
)) as GuildTemplate[];
|
||||
const templates = (await rest.runMethod(
|
||||
"get",
|
||||
endpoints.GUILD_TEMPLATES(guildId),
|
||||
)) as GuildTemplate[];
|
||||
|
||||
return templates.map((template) => structures.createTemplateStruct(template));
|
||||
}
|
||||
|
||||
@@ -4,11 +4,10 @@ import { endpoints } from "../../util/constants.ts";
|
||||
|
||||
/** Returns the guild template if it exists */
|
||||
export async function getTemplate(templateCode: string) {
|
||||
const result =
|
||||
(await rest.runMethod(
|
||||
"get",
|
||||
endpoints.GUILD_TEMPLATE(templateCode),
|
||||
) as GuildTemplate);
|
||||
const result = (await rest.runMethod(
|
||||
"get",
|
||||
endpoints.GUILD_TEMPLATE(templateCode),
|
||||
) as GuildTemplate);
|
||||
const template = await structures.createTemplateStruct(result);
|
||||
|
||||
return template;
|
||||
|
||||
@@ -10,11 +10,10 @@ import { requireBotGuildPermissions } from "../../util/permissions.ts";
|
||||
export async function syncGuildTemplate(guildId: string, templateCode: string) {
|
||||
await requireBotGuildPermissions(guildId, ["MANAGE_GUILD"]);
|
||||
|
||||
const template =
|
||||
(await rest.runMethod(
|
||||
"put",
|
||||
`${endpoints.GUILD_TEMPLATES(guildId)}/${templateCode}`,
|
||||
)) as GuildTemplate;
|
||||
const template = (await rest.runMethod(
|
||||
"put",
|
||||
`${endpoints.GUILD_TEMPLATES(guildId)}/${templateCode}`,
|
||||
)) as GuildTemplate;
|
||||
|
||||
return structures.createTemplateStruct(template);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { rest } from "../../rest/rest.ts";
|
||||
import { Errors } from "../../types/misc/errors.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
import { requireBotChannelPermissions } from "../../util/permissions.ts";
|
||||
import { urlToBase64 } from "../../util/utils.ts";
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { rest } from "../../rest/rest.ts";
|
||||
import { structures } from "../../structures/mod.ts";
|
||||
import { Errors } from "../../types/misc/errors.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
|
||||
export async function editWebhookMessage(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { rest } from "../../rest/rest.ts";
|
||||
import { structures } from "../../structures/mod.ts";
|
||||
import { Errors } from "../../types/misc/errors.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
|
||||
/** Execute a webhook with webhook Id and webhook token */
|
||||
|
||||
Reference in New Issue
Block a user