mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 19:28:17 +00:00
Merge branch 'main' into change-enums
This commit is contained in:
@@ -0,0 +1,15 @@
|
|||||||
|
import { applicationId } from "../../bot.ts";
|
||||||
|
import { rest } from "../../rest/rest.ts";
|
||||||
|
import { structures } from "../../structures/mod.ts";
|
||||||
|
import type { Message } from "../../types/messages/message.ts";
|
||||||
|
import { endpoints } from "../../util/constants.ts";
|
||||||
|
|
||||||
|
/** Returns the initial Interactio response. Functions the same as Get Webhook Message */
|
||||||
|
export async function getOriginalInteractionResponse(token: string) {
|
||||||
|
const result = await rest.runMethod<Message>(
|
||||||
|
"get",
|
||||||
|
endpoints.INTERACTION_ORIGINAL_ID_TOKEN(applicationId, token),
|
||||||
|
);
|
||||||
|
|
||||||
|
return await structures.createDiscordenoMessage(result);
|
||||||
|
}
|
||||||
@@ -1,11 +1,14 @@
|
|||||||
import { rest } from "../../rest/rest.ts";
|
import { rest } from "../../rest/rest.ts";
|
||||||
|
import { GetInvite } from "../../types/invites/get_invite.ts";
|
||||||
import type { Invite } from "../../types/invites/invite.ts";
|
import type { Invite } from "../../types/invites/invite.ts";
|
||||||
import { endpoints } from "../../util/constants.ts";
|
import { endpoints } from "../../util/constants.ts";
|
||||||
|
import { camelKeysToSnakeCase } from "../../util/utils.ts";
|
||||||
|
|
||||||
/** Returns an invite for the given code or throws an error if the invite doesn't exists. */
|
/** Returns an invite for the given code or throws an error if the invite doesn't exists. */
|
||||||
export async function getInvite(inviteCode: string) {
|
export async function getInvite(inviteCode: string, options?: GetInvite) {
|
||||||
return await rest.runMethod<Invite>(
|
return await rest.runMethod<Invite>(
|
||||||
"get",
|
"get",
|
||||||
endpoints.INVITE(inviteCode),
|
endpoints.INVITE(inviteCode),
|
||||||
|
camelKeysToSnakeCase(options ?? {}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -145,13 +145,6 @@ export async function sendMessage(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
|
||||||
content.nonce &&
|
|
||||||
!validateLength(content.nonce.toString(), { max: 25 })
|
|
||||||
) {
|
|
||||||
throw new Error(Errors.NONCE_TOO_LONG);
|
|
||||||
}
|
|
||||||
|
|
||||||
const result = await rest.runMethod<Message>(
|
const result = await rest.runMethod<Message>(
|
||||||
"post",
|
"post",
|
||||||
endpoints.CHANNEL_MESSAGES(channelId),
|
endpoints.CHANNEL_MESSAGES(channelId),
|
||||||
|
|||||||
+10
-4
@@ -19,6 +19,7 @@ import { deleteSlashCommand } from "./commands/delete_slash_command.ts";
|
|||||||
import { deleteSlashResponse } from "./commands/delete_slash_response.ts";
|
import { deleteSlashResponse } from "./commands/delete_slash_response.ts";
|
||||||
import { editSlashCommandPermissions } from "./commands/edit_slash_command_permissions.ts";
|
import { editSlashCommandPermissions } from "./commands/edit_slash_command_permissions.ts";
|
||||||
import { editSlashResponse } from "./commands/edit_slash_response.ts";
|
import { editSlashResponse } from "./commands/edit_slash_response.ts";
|
||||||
|
import { getOriginalInteractionResponse } from "./commands/get_original_interaction_response.ts";
|
||||||
import { getSlashCommand } from "./commands/get_slash_command.ts";
|
import { getSlashCommand } from "./commands/get_slash_command.ts";
|
||||||
import { getSlashCommands } from "./commands/get_slash_commands.ts";
|
import { getSlashCommands } from "./commands/get_slash_commands.ts";
|
||||||
import { getSlashCommandPermission } from "./commands/get_slash_command_permission.ts";
|
import { getSlashCommandPermission } from "./commands/get_slash_command_permission.ts";
|
||||||
@@ -111,6 +112,9 @@ import { editGuildTemplate } from "./templates/edit_guild_template.ts";
|
|||||||
import { getGuildTemplates } from "./templates/get_guild_templates.ts";
|
import { getGuildTemplates } from "./templates/get_guild_templates.ts";
|
||||||
import { getTemplate } from "./templates/get_template.ts";
|
import { getTemplate } from "./templates/get_template.ts";
|
||||||
import { syncGuildTemplate } from "./templates/sync_guild_template.ts";
|
import { syncGuildTemplate } from "./templates/sync_guild_template.ts";
|
||||||
|
// Type Guards
|
||||||
|
import { isActionRow } from "./type_guards/is_action_row.ts";
|
||||||
|
import { isButton } from "./type_guards/is_button.ts";
|
||||||
import { createWebhook } from "./webhooks/create_webhook.ts";
|
import { createWebhook } from "./webhooks/create_webhook.ts";
|
||||||
import { deleteWebhook } from "./webhooks/delete_webhook.ts";
|
import { deleteWebhook } from "./webhooks/delete_webhook.ts";
|
||||||
import { deleteWebhookMessage } from "./webhooks/delete_webhook_message.ts";
|
import { deleteWebhookMessage } from "./webhooks/delete_webhook_message.ts";
|
||||||
@@ -118,13 +122,11 @@ import { deleteWebhookWithToken } from "./webhooks/delete_webhook_with_token.ts"
|
|||||||
import { editWebhook } from "./webhooks/edit_webhook.ts";
|
import { editWebhook } from "./webhooks/edit_webhook.ts";
|
||||||
import { editWebhookMessage } from "./webhooks/edit_webhook_message.ts";
|
import { editWebhookMessage } from "./webhooks/edit_webhook_message.ts";
|
||||||
import { editWebhookWithToken } from "./webhooks/edit_webhook_with_token.ts";
|
import { editWebhookWithToken } from "./webhooks/edit_webhook_with_token.ts";
|
||||||
import { sendWebhook } from "./webhooks/send_webhook.ts";
|
|
||||||
import { getWebhook } from "./webhooks/get_webhook.ts";
|
import { getWebhook } from "./webhooks/get_webhook.ts";
|
||||||
import { getWebhooks } from "./webhooks/get_webhooks.ts";
|
import { getWebhooks } from "./webhooks/get_webhooks.ts";
|
||||||
|
import { getWebhookMessage } from "./webhooks/get_webhook_message.ts";
|
||||||
import { getWebhookWithToken } from "./webhooks/get_webhook_with_token.ts";
|
import { getWebhookWithToken } from "./webhooks/get_webhook_with_token.ts";
|
||||||
// Type Guards
|
import { sendWebhook } from "./webhooks/send_webhook.ts";
|
||||||
import { isActionRow } from "./type_guards/is_action_row.ts";
|
|
||||||
import { isButton } from "./type_guards/is_button.ts";
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
addDiscoverySubcategory,
|
addDiscoverySubcategory,
|
||||||
@@ -205,6 +207,7 @@ export {
|
|||||||
getMembers,
|
getMembers,
|
||||||
getMessage,
|
getMessage,
|
||||||
getMessages,
|
getMessages,
|
||||||
|
getOriginalInteractionResponse,
|
||||||
getPins,
|
getPins,
|
||||||
getPruneCount,
|
getPruneCount,
|
||||||
getReactions,
|
getReactions,
|
||||||
@@ -218,6 +221,7 @@ export {
|
|||||||
getVanityURL,
|
getVanityURL,
|
||||||
getVoiceRegions,
|
getVoiceRegions,
|
||||||
getWebhook,
|
getWebhook,
|
||||||
|
getWebhookMessage,
|
||||||
getWebhooks,
|
getWebhooks,
|
||||||
getWebhookWithToken,
|
getWebhookWithToken,
|
||||||
getWelcomeScreen,
|
getWelcomeScreen,
|
||||||
@@ -289,6 +293,7 @@ export let helpers = {
|
|||||||
getSlashCommands,
|
getSlashCommands,
|
||||||
upsertSlashCommand,
|
upsertSlashCommand,
|
||||||
upsertSlashCommands,
|
upsertSlashCommands,
|
||||||
|
getOriginalInteractionResponse,
|
||||||
// emojis
|
// emojis
|
||||||
createEmoji,
|
createEmoji,
|
||||||
deleteEmoji,
|
deleteEmoji,
|
||||||
@@ -396,6 +401,7 @@ export let helpers = {
|
|||||||
getWebhookWithToken,
|
getWebhookWithToken,
|
||||||
getWebhook,
|
getWebhook,
|
||||||
getWebhooks,
|
getWebhooks,
|
||||||
|
getWebhookMessage,
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Helpers = typeof helpers;
|
export type Helpers = typeof helpers;
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import { rest } from "../../rest/rest.ts";
|
||||||
|
import { structures } from "../../structures/mod.ts";
|
||||||
|
import type { Message } from "../../types/messages/message.ts";
|
||||||
|
import { endpoints } from "../../util/constants.ts";
|
||||||
|
|
||||||
|
/** Returns a previousy-sent webhook message from the same token. Returns a message object on success. */
|
||||||
|
export async function getWebhookMessage(
|
||||||
|
webhookId: bigint,
|
||||||
|
webhookToken: string,
|
||||||
|
messageId: bigint,
|
||||||
|
) {
|
||||||
|
const result = await rest.runMethod<Message>(
|
||||||
|
"get",
|
||||||
|
endpoints.WEBHOOK_MESSAGE(webhookId, webhookToken, messageId),
|
||||||
|
);
|
||||||
|
|
||||||
|
return await structures.createDiscordenoMessage(result);
|
||||||
|
}
|
||||||
@@ -66,8 +66,8 @@ export async function sendWebhook(
|
|||||||
|
|
||||||
const result = await rest.runMethod<Message>(
|
const result = await rest.runMethod<Message>(
|
||||||
"post",
|
"post",
|
||||||
`${endpoints.WEBHOOK(webhookId, webhookToken)}${
|
`${endpoints.WEBHOOK(webhookId, webhookToken)}?wait=${options.wait}${
|
||||||
options.wait ? "?wait=true" : ""
|
options.threadId ? `&thread_id=${options.threadId}` : ""
|
||||||
}`,
|
}`,
|
||||||
{
|
{
|
||||||
...options,
|
...options,
|
||||||
|
|||||||
@@ -8,13 +8,11 @@ import { MessageComponents } from "./components/message_components.ts";
|
|||||||
export interface CreateMessage {
|
export interface CreateMessage {
|
||||||
/** The message contents (up to 2000 characters) */
|
/** The message contents (up to 2000 characters) */
|
||||||
content?: string;
|
content?: string;
|
||||||
/** A nonce that can be used for optimistic message sending */
|
|
||||||
nonce?: number | string;
|
|
||||||
/** true if this is a TTS message */
|
/** true if this is a TTS message */
|
||||||
tts?: boolean;
|
tts?: boolean;
|
||||||
/** Embedded `rich` content */
|
/** Embedded `rich` content */
|
||||||
embed?: Embed;
|
embed?: Embed;
|
||||||
/** Allowed mentions for a message */
|
/** Allowed mentions for the message */
|
||||||
allowedMentions?: AllowedMentions;
|
allowedMentions?: AllowedMentions;
|
||||||
/** Include to make your message a reply */
|
/** Include to make your message a reply */
|
||||||
messageReference?: MessageReference;
|
messageReference?: MessageReference;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Embed } from "../embeds/embed.ts";
|
import { Embed } from "../embeds/embed.ts";
|
||||||
|
import { FileContent } from "../misc/file_content.ts";
|
||||||
import { AllowedMentions } from "./allowed_mentions.ts";
|
import { AllowedMentions } from "./allowed_mentions.ts";
|
||||||
import { Attachment } from "./attachment.ts";
|
import { Attachment } from "./attachment.ts";
|
||||||
|
|
||||||
@@ -10,6 +11,8 @@ export interface EditMessage {
|
|||||||
embed?: Embed | null;
|
embed?: Embed | null;
|
||||||
/** Edit the flags of the message (only `SUPRESS_EMBEDS` can currently be set/unset) */
|
/** Edit the flags of the message (only `SUPRESS_EMBEDS` can currently be set/unset) */
|
||||||
flags?: 4 | null;
|
flags?: 4 | null;
|
||||||
|
/** The contents of the file being sent/edited */
|
||||||
|
file?: FileContent | FileContent[] | null;
|
||||||
/** Allowed mentions for the message */
|
/** Allowed mentions for the message */
|
||||||
allowedMentions?: AllowedMentions | null;
|
allowedMentions?: AllowedMentions | null;
|
||||||
/** Attached files to keep */
|
/** Attached files to keep */
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Embed } from "../embeds/embed.ts";
|
import { Embed } from "../embeds/embed.ts";
|
||||||
import { AllowedMentions } from "../messages/allowed_mentions.ts";
|
import { AllowedMentions } from "../messages/allowed_mentions.ts";
|
||||||
import { FileContent } from "../misc/file_content.ts";
|
|
||||||
import { Attachment } from "../messages/attachment.ts";
|
import { Attachment } from "../messages/attachment.ts";
|
||||||
|
import { FileContent } from "../misc/file_content.ts";
|
||||||
|
|
||||||
/** https://discord.com/developers/docs/resources/webhook#edit-webhook-message-jsonform-params */
|
/** https://discord.com/developers/docs/resources/webhook#edit-webhook-message-jsonform-params */
|
||||||
export interface EditWebhookMessage {
|
export interface EditWebhookMessage {
|
||||||
@@ -10,7 +10,7 @@ export interface EditWebhookMessage {
|
|||||||
/** Embedded `rich` content */
|
/** Embedded `rich` content */
|
||||||
embeds?: Embed[] | null;
|
embeds?: Embed[] | null;
|
||||||
/** The contents of the file being sent/edited */
|
/** The contents of the file being sent/edited */
|
||||||
file?: FileContent | FileContent[];
|
file?: FileContent | FileContent[] | null;
|
||||||
/** Allowed mentions for the message */
|
/** Allowed mentions for the message */
|
||||||
allowedMentions?: AllowedMentions | null;
|
allowedMentions?: AllowedMentions | null;
|
||||||
/** Attached files to keep */
|
/** Attached files to keep */
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import { SnakeCasedPropertiesDeep } from "../util.ts";
|
|||||||
export interface ExecuteWebhook {
|
export interface ExecuteWebhook {
|
||||||
/** Waits for server confirmation of message send before response, and returns the created message body (defaults to `false`; when `false` a message that is not saved does not return an error) */
|
/** Waits for server confirmation of message send before response, and returns the created message body (defaults to `false`; when `false` a message that is not saved does not return an error) */
|
||||||
wait?: boolean;
|
wait?: boolean;
|
||||||
|
/** Send a message to the specified thread within a webhook's channel. The thread will automatically be unarchived. */
|
||||||
|
threadId?: bigint;
|
||||||
/** The message contents (up to 2000 characters) */
|
/** The message contents (up to 2000 characters) */
|
||||||
content?: string;
|
content?: string;
|
||||||
/** Override the default username of the webhook */
|
/** Override the default username of the webhook */
|
||||||
|
|||||||
Reference in New Issue
Block a user