mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-17 19:58:18 +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:
@@ -5,18 +5,18 @@ import { urlToBase64 } from "../../util/utils.ts";
|
||||
|
||||
/** Create an emoji in the server. Emojis and animated emojis have a maximum file size of 256kb. Attempting to upload an emoji larger than this limit will fail and return 400 Bad Request and an error message, but not a JSON status code. If a URL is provided to the image parameter, Discordeno will automatically convert it to a base64 string internally. */
|
||||
export async function createEmoji(
|
||||
guildID: string,
|
||||
guildId: string,
|
||||
name: string,
|
||||
image: string,
|
||||
options: CreateEmojisOptions,
|
||||
) {
|
||||
await requireBotGuildPermissions(guildID, ["MANAGE_EMOJIS"]);
|
||||
await requireBotGuildPermissions(guildId, ["MANAGE_EMOJIS"]);
|
||||
|
||||
if (image && !image.startsWith("data:image/")) {
|
||||
image = await urlToBase64(image);
|
||||
}
|
||||
|
||||
const result = await RequestManager.post(endpoints.GUILD_EMOJIS(guildID), {
|
||||
const result = await RequestManager.post(endpoints.GUILD_EMOJIS(guildId), {
|
||||
...options,
|
||||
name,
|
||||
image,
|
||||
|
||||
@@ -4,14 +4,14 @@ import { requireBotGuildPermissions } from "../../util/permissions.ts";
|
||||
|
||||
/** Delete the given emoji. Requires the MANAGE_EMOJIS permission. Returns 204 No Content on success. */
|
||||
export async function deleteEmoji(
|
||||
guildID: string,
|
||||
guildId: string,
|
||||
id: string,
|
||||
reason?: string,
|
||||
) {
|
||||
await requireBotGuildPermissions(guildID, ["MANAGE_EMOJIS"]);
|
||||
await requireBotGuildPermissions(guildId, ["MANAGE_EMOJIS"]);
|
||||
|
||||
const result = await RequestManager.delete(
|
||||
endpoints.GUILD_EMOJI(guildID, id),
|
||||
endpoints.GUILD_EMOJI(guildId, id),
|
||||
{ reason },
|
||||
);
|
||||
|
||||
|
||||
@@ -4,14 +4,14 @@ import { requireBotGuildPermissions } from "../../util/permissions.ts";
|
||||
|
||||
/** Modify the given emoji. Requires the MANAGE_EMOJIS permission. */
|
||||
export async function editEmoji(
|
||||
guildID: string,
|
||||
guildId: string,
|
||||
id: string,
|
||||
options: EditEmojisOptions,
|
||||
) {
|
||||
await requireBotGuildPermissions(guildID, ["MANAGE_EMOJIS"]);
|
||||
await requireBotGuildPermissions(guildId, ["MANAGE_EMOJIS"]);
|
||||
|
||||
const result = await RequestManager.patch(
|
||||
endpoints.GUILD_EMOJI(guildID, id),
|
||||
endpoints.GUILD_EMOJI(guildId, id),
|
||||
{
|
||||
name: options.name,
|
||||
roles: options.roles,
|
||||
|
||||
@@ -3,26 +3,26 @@ import { RequestManager } from "../../rest/request_manager.ts";
|
||||
import { endpoints } from "../../util/constants.ts";
|
||||
|
||||
/**
|
||||
* Returns an emoji for the given guild and emoji ID.
|
||||
* Returns an emoji for the given guild and emoji Id.
|
||||
*
|
||||
* ⚠️ **If you need this, you are probably doing something wrong. Always use cache.guilds.get()?.emojis
|
||||
*/
|
||||
export async function getEmoji(
|
||||
guildID: string,
|
||||
emojiID: string,
|
||||
guildId: string,
|
||||
emojiId: string,
|
||||
addToCache = true,
|
||||
) {
|
||||
const result = (await RequestManager.get(
|
||||
endpoints.GUILD_EMOJI(guildID, emojiID),
|
||||
endpoints.GUILD_EMOJI(guildId, emojiId),
|
||||
)) as Emoji;
|
||||
|
||||
if (addToCache) {
|
||||
const guild = await cacheHandlers.get("guilds", guildID);
|
||||
const guild = await cacheHandlers.get("guilds", guildId);
|
||||
if (!guild) throw new Error(Errors.GUILD_NOT_FOUND);
|
||||
guild.emojis.set(result.id ?? result.name, result);
|
||||
cacheHandlers.set(
|
||||
"guilds",
|
||||
guildID,
|
||||
guildId,
|
||||
guild,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -7,18 +7,18 @@ import { endpoints } from "../../util/constants.ts";
|
||||
*
|
||||
* ⚠️ **If you need this, you are probably doing something wrong. Always use cache.guilds.get()?.emojis
|
||||
*/
|
||||
export async function getEmojis(guildID: string, addToCache = true) {
|
||||
export async function getEmojis(guildId: string, addToCache = true) {
|
||||
const result = (await RequestManager.get(
|
||||
endpoints.GUILD_EMOJIS(guildID),
|
||||
endpoints.GUILD_EMOJIS(guildId),
|
||||
)) as Emoji[];
|
||||
|
||||
if (addToCache) {
|
||||
const guild = await cacheHandlers.get("guilds", guildID);
|
||||
const guild = await cacheHandlers.get("guilds", guildId);
|
||||
if (!guild) throw new Error(Errors.GUILD_NOT_FOUND);
|
||||
|
||||
result.forEach((emoji) => guild.emojis.set(emoji.id ?? emoji.name, emoji));
|
||||
|
||||
cacheHandlers.set("guilds", guildID, guild);
|
||||
cacheHandlers.set("guilds", guildId, guild);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user