mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 19:28:17 +00:00
refactor: rename *ID to *Id (#710)
* refactor: rename *ID to *Id * Update src/helpers/commands/delete_slash_command.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/helpers/commands/delete_slash_command.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/helpers/commands/delete_slash_response.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/helpers/commands/edit_slash_response.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/util/utils.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/util/utils.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/util/utils.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/util/utils.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/util/utils.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/helpers/commands/get_slash_command.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/helpers/commands/send_interaction_response.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/helpers/commands/upsert_slash_command.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/helpers/guilds/edit_widget.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/helpers/guilds/get_widget.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/helpers/guilds/get_widget.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/helpers/guilds/get_widget_image_url.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/helpers/guilds/get_widget_image_url.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/helpers/guilds/get_widget_settings.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update .gitignore Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update LICENSE Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/helpers/members/edit_bot_profile.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/helpers/members/edit_bot_profile.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/helpers/webhooks/create_webhook.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/helpers/webhooks/delete_webhook.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/util/constants.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/helpers/webhooks/edit_webhook.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/helpers/webhooks/execute_webhook.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/helpers/webhooks/get_webhook.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/rest/cache.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/rest/request.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/util/constants.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/helpers/commands/delete_slash_response.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/util/constants.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/util/constants.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/util/constants.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/util/constants.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/util/utils.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Update src/util/utils.ts Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com> * Revert docs file Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com>
This commit is contained in:
@@ -4,11 +4,11 @@ import { requireBotChannelPermissions } from "../../util/permissions.ts";
|
||||
|
||||
/** Create a reaction for the message. Reaction takes the form of **name:id** for custom guild emoji, or Unicode characters. Requires READ_MESSAGE_HISTORY and ADD_REACTIONS */
|
||||
export async function addReaction(
|
||||
channelID: string,
|
||||
messageID: string,
|
||||
channelId: string,
|
||||
messageId: string,
|
||||
reaction: string,
|
||||
) {
|
||||
await requireBotChannelPermissions(channelID, [
|
||||
await requireBotChannelPermissions(channelId, [
|
||||
"ADD_REACTIONS",
|
||||
"READ_MESSAGE_HISTORY",
|
||||
]);
|
||||
@@ -20,7 +20,7 @@ export async function addReaction(
|
||||
}
|
||||
|
||||
const result = await RequestManager.put(
|
||||
endpoints.CHANNEL_MESSAGE_REACTION_ME(channelID, messageID, reaction),
|
||||
endpoints.CHANNEL_MESSAGE_REACTION_ME(channelId, messageId, reaction),
|
||||
);
|
||||
|
||||
return result;
|
||||
|
||||
@@ -2,18 +2,18 @@ import { addReaction } from "./add_reaction.ts";
|
||||
|
||||
/** Adds multiple reactions to a message. If `ordered` is true(default is false), it will add the reactions one at a time in the order provided. Note: Reaction takes the form of **name:id** for custom guild emoji, or Unicode characters. Requires READ_MESSAGE_HISTORY and ADD_REACTIONS */
|
||||
export async function addReactions(
|
||||
channelID: string,
|
||||
messageID: string,
|
||||
channelId: string,
|
||||
messageId: string,
|
||||
reactions: string[],
|
||||
ordered = false,
|
||||
) {
|
||||
if (!ordered) {
|
||||
await Promise.all(
|
||||
reactions.map((reaction) => addReaction(channelID, messageID, reaction)),
|
||||
reactions.map((reaction) => addReaction(channelId, messageId, reaction)),
|
||||
);
|
||||
} else {
|
||||
for (const reaction of reactions) {
|
||||
await addReaction(channelID, messageID, reaction);
|
||||
await addReaction(channelId, messageId, reaction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { botID } from "../../bot.ts";
|
||||
import { botId } from "../../bot.ts";
|
||||
import { cacheHandlers } from "../../cache.ts";
|
||||
import { RequestManager } from "../../rest/request_manager.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
@@ -7,21 +7,21 @@ import { delay } from "../../util/utils.ts";
|
||||
|
||||
/** Delete a message with the channel id and message id only. */
|
||||
export async function deleteMessage(
|
||||
channelID: string,
|
||||
messageID: string,
|
||||
channelId: string,
|
||||
messageId: string,
|
||||
reason?: string,
|
||||
delayMilliseconds = 0,
|
||||
) {
|
||||
const message = await cacheHandlers.get("messages", messageID);
|
||||
const message = await cacheHandlers.get("messages", messageId);
|
||||
|
||||
if (message && message.author.id !== botID) {
|
||||
await requireBotChannelPermissions(message.channelID, ["MANAGE_MESSAGES"]);
|
||||
if (message && message.author.id !== botId) {
|
||||
await requireBotChannelPermissions(message.channelId, ["MANAGE_MESSAGES"]);
|
||||
}
|
||||
|
||||
if (delayMilliseconds) await delay(delayMilliseconds);
|
||||
|
||||
const result = await RequestManager.delete(
|
||||
endpoints.CHANNEL_MESSAGE(channelID, messageID),
|
||||
endpoints.CHANNEL_MESSAGE(channelId, messageId),
|
||||
{ reason },
|
||||
);
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@ import { requireBotChannelPermissions } from "../../util/permissions.ts";
|
||||
|
||||
/** Delete messages from the channel. 2-100. Requires the MANAGE_MESSAGES permission */
|
||||
export async function deleteMessages(
|
||||
channelID: string,
|
||||
channelId: string,
|
||||
ids: string[],
|
||||
reason?: string,
|
||||
) {
|
||||
await requireBotChannelPermissions(channelID, ["MANAGE_MESSAGES"]);
|
||||
await requireBotChannelPermissions(channelId, ["MANAGE_MESSAGES"]);
|
||||
|
||||
if (ids.length < 2) {
|
||||
throw new Error(Errors.DELETE_MESSAGES_MIN);
|
||||
@@ -21,7 +21,7 @@ export async function deleteMessages(
|
||||
}
|
||||
|
||||
const result = await RequestManager.post(
|
||||
endpoints.CHANNEL_BULK_DELETE(channelID),
|
||||
endpoints.CHANNEL_BULK_DELETE(channelId),
|
||||
{
|
||||
messages: ids.splice(0, 100),
|
||||
reason,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { botID } from "../../bot.ts";
|
||||
import { botId } from "../../bot.ts";
|
||||
import { RequestManager } from "../../rest/request_manager.ts";
|
||||
import { Message, structures } from "../../structures/mod.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
@@ -9,7 +9,7 @@ export async function editMessage(
|
||||
message: Message,
|
||||
content: string | MessageContent,
|
||||
) {
|
||||
if (message.author.id !== botID) {
|
||||
if (message.author.id !== botId) {
|
||||
throw "You can only edit a message that was sent by the bot.";
|
||||
}
|
||||
|
||||
@@ -19,14 +19,14 @@ export async function editMessage(
|
||||
|
||||
if (content.tts) requiredPerms.push("SEND_TTS_MESSAGES");
|
||||
|
||||
await requireBotChannelPermissions(message.channelID, requiredPerms);
|
||||
await requireBotChannelPermissions(message.channelId, requiredPerms);
|
||||
|
||||
if (content.content && content.content.length > 2000) {
|
||||
throw new Error(Errors.MESSAGE_MAX_LENGTH);
|
||||
}
|
||||
|
||||
const result = await RequestManager.patch(
|
||||
endpoints.CHANNEL_MESSAGE(message.channelID, message.id),
|
||||
endpoints.CHANNEL_MESSAGE(message.channelId, message.id),
|
||||
content,
|
||||
);
|
||||
|
||||
|
||||
@@ -4,14 +4,14 @@ import { endpoints } from "../../util/constants.ts";
|
||||
import { requireBotChannelPermissions } from "../../util/permissions.ts";
|
||||
|
||||
/** Fetch a single message from the server. Requires VIEW_CHANNEL and READ_MESSAGE_HISTORY */
|
||||
export async function getMessage(channelID: string, id: string) {
|
||||
await requireBotChannelPermissions(channelID, [
|
||||
export async function getMessage(channelId: string, id: string) {
|
||||
await requireBotChannelPermissions(channelId, [
|
||||
"VIEW_CHANNEL",
|
||||
"READ_MESSAGE_HISTORY",
|
||||
]);
|
||||
|
||||
const result = (await RequestManager.get(
|
||||
endpoints.CHANNEL_MESSAGE(channelID, id),
|
||||
endpoints.CHANNEL_MESSAGE(channelId, id),
|
||||
)) as MessageCreateOptions;
|
||||
|
||||
return structures.createMessageStruct(result);
|
||||
|
||||
@@ -5,14 +5,14 @@ import { requireBotChannelPermissions } from "../../util/permissions.ts";
|
||||
|
||||
/** Fetches between 2-100 messages. Requires VIEW_CHANNEL and READ_MESSAGE_HISTORY */
|
||||
export async function getMessages(
|
||||
channelID: string,
|
||||
channelId: string,
|
||||
options?:
|
||||
| GetMessagesAfter
|
||||
| GetMessagesBefore
|
||||
| GetMessagesAround
|
||||
| GetMessages,
|
||||
) {
|
||||
await requireBotChannelPermissions(channelID, [
|
||||
await requireBotChannelPermissions(channelId, [
|
||||
"VIEW_CHANNEL",
|
||||
"READ_MESSAGE_HISTORY",
|
||||
]);
|
||||
@@ -20,7 +20,7 @@ export async function getMessages(
|
||||
if (options?.limit && options.limit > 100) return;
|
||||
|
||||
const result = (await RequestManager.get(
|
||||
endpoints.CHANNEL_MESSAGES(channelID),
|
||||
endpoints.CHANNEL_MESSAGES(channelId),
|
||||
options,
|
||||
)) as MessageCreateOptions[];
|
||||
|
||||
|
||||
@@ -4,13 +4,13 @@ import { endpoints } from "../../util/constants.ts";
|
||||
|
||||
/** Get a list of users that reacted with this emoji. */
|
||||
export async function getReactions(
|
||||
channelID: string,
|
||||
messageID: string,
|
||||
channelId: string,
|
||||
messageId: string,
|
||||
reaction: string,
|
||||
options?: DiscordGetReactionsParams,
|
||||
) {
|
||||
const users = (await RequestManager.get(
|
||||
endpoints.CHANNEL_MESSAGE_REACTION(channelID, messageID, reaction),
|
||||
endpoints.CHANNEL_MESSAGE_REACTION(channelId, messageId, reaction),
|
||||
options,
|
||||
)) as UserPayload[];
|
||||
|
||||
|
||||
@@ -3,11 +3,11 @@ import { endpoints } from "../../util/constants.ts";
|
||||
import { requireBotChannelPermissions } from "../../util/permissions.ts";
|
||||
|
||||
/** Pin a message in a channel. Requires MANAGE_MESSAGES. Max pins allowed in a channel = 50. */
|
||||
export async function pin(channelID: string, messageID: string) {
|
||||
await requireBotChannelPermissions(channelID, ["MANAGE_MESSAGES"]);
|
||||
export async function pin(channelId: string, messageId: string) {
|
||||
await requireBotChannelPermissions(channelId, ["MANAGE_MESSAGES"]);
|
||||
|
||||
const result = await RequestManager.put(
|
||||
endpoints.CHANNEL_PIN(channelID, messageID),
|
||||
endpoints.CHANNEL_PIN(channelId, messageId),
|
||||
);
|
||||
|
||||
return result;
|
||||
|
||||
@@ -3,9 +3,9 @@ import { structures } from "../../structures/mod.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
|
||||
/** Crosspost a message in a News Channel to following channels. */
|
||||
export async function publishMessage(channelID: string, messageID: string) {
|
||||
export async function publishMessage(channelId: string, messageId: string) {
|
||||
const data = (await RequestManager.post(
|
||||
endpoints.CHANNEL_MESSAGE_CROSSPOST(channelID, messageID),
|
||||
endpoints.CHANNEL_MESSAGE_CROSSPOST(channelId, messageId),
|
||||
)) as MessageCreateOptions;
|
||||
|
||||
return structures.createMessageStruct(data);
|
||||
|
||||
@@ -3,11 +3,11 @@ import { endpoints } from "../../util/constants.ts";
|
||||
import { requireBotChannelPermissions } from "../../util/permissions.ts";
|
||||
|
||||
/** Removes all reactions for all emojis on this message. */
|
||||
export async function removeAllReactions(channelID: string, messageID: string) {
|
||||
await requireBotChannelPermissions(channelID, ["MANAGE_MESSAGES"]);
|
||||
export async function removeAllReactions(channelId: string, messageId: string) {
|
||||
await requireBotChannelPermissions(channelId, ["MANAGE_MESSAGES"]);
|
||||
|
||||
const result = await RequestManager.delete(
|
||||
endpoints.CHANNEL_MESSAGE_REACTIONS(channelID, messageID),
|
||||
endpoints.CHANNEL_MESSAGE_REACTIONS(channelId, messageId),
|
||||
);
|
||||
|
||||
return result;
|
||||
|
||||
@@ -3,8 +3,8 @@ import { endpoints } from "../../util/constants.ts";
|
||||
|
||||
/** Removes a reaction from the bot on this message. Reaction takes the form of **name:id** for custom guild emoji, or Unicode characters. */
|
||||
export async function removeReaction(
|
||||
channelID: string,
|
||||
messageID: string,
|
||||
channelId: string,
|
||||
messageId: string,
|
||||
reaction: string,
|
||||
) {
|
||||
if (reaction.startsWith("<:")) {
|
||||
@@ -14,7 +14,7 @@ export async function removeReaction(
|
||||
}
|
||||
|
||||
const result = await RequestManager.delete(
|
||||
endpoints.CHANNEL_MESSAGE_REACTION_ME(channelID, messageID, reaction),
|
||||
endpoints.CHANNEL_MESSAGE_REACTION_ME(channelId, messageId, reaction),
|
||||
);
|
||||
|
||||
return result;
|
||||
|
||||
@@ -4,11 +4,11 @@ import { requireBotChannelPermissions } from "../../util/permissions.ts";
|
||||
|
||||
/** Removes all reactions for a single emoji on this message. Reaction takes the form of **name:id** for custom guild emoji, or Unicode characters. */
|
||||
export async function removeReactionEmoji(
|
||||
channelID: string,
|
||||
messageID: string,
|
||||
channelId: string,
|
||||
messageId: string,
|
||||
reaction: string,
|
||||
) {
|
||||
await requireBotChannelPermissions(channelID, ["MANAGE_MESSAGES"]);
|
||||
await requireBotChannelPermissions(channelId, ["MANAGE_MESSAGES"]);
|
||||
|
||||
if (reaction.startsWith("<:")) {
|
||||
reaction = reaction.substring(2, reaction.length - 1);
|
||||
@@ -17,7 +17,7 @@ export async function removeReactionEmoji(
|
||||
}
|
||||
|
||||
const result = await RequestManager.delete(
|
||||
endpoints.CHANNEL_MESSAGE_REACTION(channelID, messageID, reaction),
|
||||
endpoints.CHANNEL_MESSAGE_REACTION(channelId, messageId, reaction),
|
||||
);
|
||||
|
||||
return result;
|
||||
|
||||
@@ -4,12 +4,12 @@ import { requireBotChannelPermissions } from "../../util/permissions.ts";
|
||||
|
||||
/** Removes a reaction from the specified user on this message. Reaction takes the form of **name:id** for custom guild emoji, or Unicode characters. */
|
||||
export async function removeUserReaction(
|
||||
channelID: string,
|
||||
messageID: string,
|
||||
channelId: string,
|
||||
messageId: string,
|
||||
reaction: string,
|
||||
userID: string,
|
||||
userId: string,
|
||||
) {
|
||||
await requireBotChannelPermissions(channelID, ["MANAGE_MESSAGES"]);
|
||||
await requireBotChannelPermissions(channelId, ["MANAGE_MESSAGES"]);
|
||||
|
||||
if (reaction.startsWith("<:")) {
|
||||
reaction = reaction.substring(2, reaction.length - 1);
|
||||
@@ -19,10 +19,10 @@ export async function removeUserReaction(
|
||||
|
||||
const result = await RequestManager.delete(
|
||||
endpoints.CHANNEL_MESSAGE_REACTION_USER(
|
||||
channelID,
|
||||
messageID,
|
||||
channelId,
|
||||
messageId,
|
||||
reaction,
|
||||
userID,
|
||||
userId,
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
@@ -6,12 +6,12 @@ import { requireBotChannelPermissions } from "../../util/permissions.ts";
|
||||
|
||||
/** Send a message to the channel. Requires SEND_MESSAGES permission. */
|
||||
export async function sendMessage(
|
||||
channelID: string,
|
||||
channelId: string,
|
||||
content: string | MessageContent,
|
||||
) {
|
||||
if (typeof content === "string") content = { content };
|
||||
|
||||
const channel = await cacheHandlers.get("channels", channelID);
|
||||
const channel = await cacheHandlers.get("channels", channelId);
|
||||
if (channel) {
|
||||
if (
|
||||
![
|
||||
@@ -30,11 +30,11 @@ export async function sendMessage(
|
||||
|
||||
if (content.tts) requiredPerms.add("SEND_TTS_MESSAGES");
|
||||
if (content.embed) requiredPerms.add("EMBED_LINKS");
|
||||
if (content.replyMessageID || content.mentions?.repliedUser) {
|
||||
if (content.replyMessageId || content.mentions?.repliedUser) {
|
||||
requiredPerms.add("READ_MESSAGE_HISTORY");
|
||||
}
|
||||
|
||||
await requireBotChannelPermissions(channelID, [...requiredPerms]);
|
||||
await requireBotChannelPermissions(channelId, [...requiredPerms]);
|
||||
}
|
||||
|
||||
// Use ... for content length due to unicode characters and js .length handling
|
||||
@@ -69,7 +69,7 @@ export async function sendMessage(
|
||||
}
|
||||
|
||||
const result = (await RequestManager.post(
|
||||
endpoints.CHANNEL_MESSAGES(channelID),
|
||||
endpoints.CHANNEL_MESSAGES(channelId),
|
||||
{
|
||||
...content,
|
||||
allowed_mentions: content.mentions
|
||||
@@ -78,10 +78,10 @@ export async function sendMessage(
|
||||
replied_user: content.mentions.repliedUser,
|
||||
}
|
||||
: undefined,
|
||||
...(content.replyMessageID
|
||||
...(content.replyMessageId
|
||||
? {
|
||||
message_reference: {
|
||||
message_id: content.replyMessageID,
|
||||
message_id: content.replyMessageId,
|
||||
fail_if_not_exists: content.failReplyIfNotExists === true,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -3,11 +3,11 @@ import { endpoints } from "../../util/constants.ts";
|
||||
import { requireBotChannelPermissions } from "../../util/permissions.ts";
|
||||
|
||||
/** Unpin a message in a channel. Requires MANAGE_MESSAGES. */
|
||||
export async function unpin(channelID: string, messageID: string) {
|
||||
await requireBotChannelPermissions(channelID, ["MANAGE_MESSAGES"]);
|
||||
export async function unpin(channelId: string, messageId: string) {
|
||||
await requireBotChannelPermissions(channelId, ["MANAGE_MESSAGES"]);
|
||||
|
||||
const result = await RequestManager.delete(
|
||||
endpoints.CHANNEL_PIN(channelID, messageID),
|
||||
endpoints.CHANNEL_PIN(channelId, messageId),
|
||||
);
|
||||
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user