diff --git a/README.md b/README.md index 95b20f4b5..826c5ed14 100644 --- a/README.md +++ b/README.md @@ -47,22 +47,22 @@ Discordeno is actively maintained to guarantee **excellent performance and ease. - REST does not rest! - Separate rest guarantees that your queued requests will continue to be processed even if your bot breaks for whatever reason. - - Seamless updates! There's a chance you'll lose a tonne of messages or replies that are waiting to be given when - you wish to update and restart the bot. You may restart your bot using this technique and never have to worry about + - Seamless updates! There's a chance you'll lose a lot of messages or replies that are waiting to be given when you + wish to update and restart the bot. You may restart your bot using this technique and never have to worry about losing any answers. - Single source of contact to Discord API - - As a result, you will be able to send requests to Discord from any location, even a bot dashboard. You are no - longer need to interact with your bot processes in order to submit a request or do anything else. Your bot process - should be freed up to handle bot events. + - As a result, you will be able to send requests to Discord from any location, even a bot dashboard. You are no longer + need to interact with your bot processes in order to submit a request or do anything else. Your bot process should + be freed up to handle bot events. - Scalability! Scalability! Scalability! ### Gateway - **Zero Downtime Updates:** - - A few seconds are needed to update your bot. When using conventional sharding, you must restart in addition to - going through a 1/5s rate-limited process of identifying all of your shards. As WS processing has been relocated to - a proxy process, you may resume the bot code right away without worrying about any delays. Normally, if you had a - bot that was spread across 200,000 servers, restarting it after making a simple modification would take 20 minutes. + - A few seconds are needed to update your bot. When using conventional sharding, you must restart in addition to going + through a 1/5s rate-limited process of identifying all of your shards. As WS processing has been relocated to a + proxy process, you may resume the bot code right away without worrying about any delays. Normally, if you had a bot + that was spread across 200,000 servers, restarting it after making a simple modification would take 20 minutes. - **Zero Downtime Resharding:** - At various periods in time, Discord stops allowing your bot to be added to new servers. Consider 150 shards operating on 150,000 servers, for instance. Your shards may support a maximum of 150 * 2500 = 375,000 servers. Your @@ -90,8 +90,8 @@ Discordeno is actively maintained to guarantee **excellent performance and ease. handler, you may supply a function. For instance, you may simply give a method to override a specific function if you want it to behave differently rather than forking and maintaining your fork. - **Clustering With Workers:** - - Utilize all of your CPU cores to their greatest potential by distributing the workload across employees. To - enhance efficiency, manage how many employees and shards there are each worker! + - Utilize all of your CPU cores to their greatest potential by distributing the workload across employees. To enhance + efficiency, manage how many employees and shards there are each worker! ### Custom Cache diff --git a/helpers/stickers/createGuildSticker.ts b/helpers/stickers/createGuildSticker.ts index d4b883878..2e2322bcd 100644 --- a/helpers/stickers/createGuildSticker.ts +++ b/helpers/stickers/createGuildSticker.ts @@ -22,10 +22,6 @@ export async function createGuildSticker( guildId: bigint, options: CreateGuildStickerOptions, ): Promise { - if (options.file && !options.file.startsWith("data:image/")) { - options.file = await bot.utils.urlToBase64(options.file); - } - const result = await bot.rest.runMethod(bot.rest, "POST", bot.constants.routes.GUILD_STICKERS(guildId), { name: options.name, description: options.description, @@ -44,5 +40,5 @@ export interface CreateGuildStickerOptions extends WithReason { /** Autocomplete/suggestion tags for the sticker (max 200 characters) */ tags: string; /** The sticker file to upload, must be a PNG, APNG, or Lottie JSON file, max 500 KB */ - file: string; + file: FileContent; } diff --git a/tests/stickers/createGuildSticker.test.ts b/tests/stickers/createGuildSticker.test.ts index dab250fe1..f1472675b 100644 --- a/tests/stickers/createGuildSticker.test.ts +++ b/tests/stickers/createGuildSticker.test.ts @@ -1,28 +1,31 @@ -// import { StickerFormatTypes } from "../../mod.ts"; -// import { assertEquals } from "../deps.ts"; -// import { loadBot } from "../mod.ts"; -// import { CACHED_COMMUNITY_GUILD_ID } from "../utils.ts"; +import { StickerFormatTypes } from "../../mod.ts"; +import { assertEquals } from "../deps.ts"; +import { loadBot } from "../mod.ts"; +import { CACHED_COMMUNITY_GUILD_ID } from "../utils.ts"; -// Deno.test("[stickers] Create guild sticker", async () => { -// const bot = loadBot(); -// const sticker = await bot.helpers.createGuildSticker(CACHED_COMMUNITY_GUILD_ID, { -// name: "stickeranme.png", -// description: "stickerdescription", -// tags: "stickertags", -// file: "https://cdn.discordapp.com/emojis/785403373817823272.png", -// }); +Deno.test("[stickers] Create guild sticker", async () => { + const bot = loadBot(); + const sticker = await bot.helpers.createGuildSticker(CACHED_COMMUNITY_GUILD_ID, { + name: "sticker name", + description: "sticker description", + tags: "sticker tags", + file: { + blob: await (await fetch("https://i.imgur.com/ejqd6Ro.png")).blob(), + name: "ddlogo.png", + }, + }); -// assertEquals(sticker.name, "sticker name"); -// assertEquals(sticker.description, "sticker description"); -// assertEquals(sticker.tags, "sticker tags"); + assertEquals(sticker.name, "sticker name"); + assertEquals(sticker.description, "sticker description"); + assertEquals(sticker.tags, "sticker tags"); -// const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { name: "test" }); -// const message = await bot.helpers.sendMessage(channel.id, { stickerIds: [sticker.id] }); + const channel = await bot.helpers.createChannel(CACHED_COMMUNITY_GUILD_ID, { name: "test" }); + const message = await bot.helpers.sendMessage(channel.id, { stickerIds: [sticker.id] }); -// assertEquals(message.stickerItems?.[0].formatType, StickerFormatTypes.Png); -// assertEquals(message.stickerItems?.[0].id, sticker.id); -// assertEquals(message.stickerItems?.[0].name, sticker.name); + assertEquals(message.stickerItems?.[0].formatType, StickerFormatTypes.Png); + assertEquals(message.stickerItems?.[0].id, sticker.id); + assertEquals(message.stickerItems?.[0].name, sticker.name); -// await bot.helpers.deleteGuildSticker(CACHED_COMMUNITY_GUILD_ID, sticker.id); -// await bot.helpers.deleteChannel(channel.id); -// }); + await bot.helpers.deleteGuildSticker(CACHED_COMMUNITY_GUILD_ID, sticker.id); + await bot.helpers.deleteChannel(channel.id); +}); diff --git a/tests/stickers/deleteGuildSticker.test.ts b/tests/stickers/deleteGuildSticker.test.ts index 3f75512b8..59b5e36d9 100644 --- a/tests/stickers/deleteGuildSticker.test.ts +++ b/tests/stickers/deleteGuildSticker.test.ts @@ -1,15 +1,18 @@ -// import { assertRejects } from "../deps.ts"; -// import { loadBot } from "../mod.ts"; -// import { CACHED_COMMUNITY_GUILD_ID } from "../utils.ts"; +import { assertRejects } from "../deps.ts"; +import { loadBot } from "../mod.ts"; +import { CACHED_COMMUNITY_GUILD_ID } from "../utils.ts"; -// Deno.test("[stickers] Delete guild sticker", async () => { -// const bot = loadBot(); -// const sticker = await bot.helpers.createGuildSticker(CACHED_COMMUNITY_GUILD_ID, { -// name: "sticker name", -// description: "sticker description", -// tags: "sticker tags", -// file: "https://cdn.discordapp.com/emojis/785403373817823272.png", -// }); -// await bot.helpers.deleteGuildSticker(CACHED_COMMUNITY_GUILD_ID, sticker.id); -// await assertRejects(() => bot.helpers.getGuildSticker(CACHED_COMMUNITY_GUILD_ID, sticker.id)); -// }); +Deno.test("[stickers] Delete guild sticker", async () => { + const bot = loadBot(); + const sticker = await bot.helpers.createGuildSticker(CACHED_COMMUNITY_GUILD_ID, { + name: "sticker name", + description: "sticker description", + tags: "sticker tags", + file: { + blob: await (await fetch("https://i.imgur.com/ejqd6Ro.png")).blob(), + name: "ddlogo.png", + }, + }); + await bot.helpers.deleteGuildSticker(CACHED_COMMUNITY_GUILD_ID, sticker.id); + await assertRejects(() => bot.helpers.getGuildSticker(CACHED_COMMUNITY_GUILD_ID, sticker.id)); +}); diff --git a/tests/stickers/editGuildSticker.test.ts b/tests/stickers/editGuildSticker.test.ts index f852982b9..f6e28da04 100644 --- a/tests/stickers/editGuildSticker.test.ts +++ b/tests/stickers/editGuildSticker.test.ts @@ -1,23 +1,26 @@ -// import { assertEquals } from "../deps.ts"; -// import { loadBot } from "../mod.ts"; -// import { CACHED_COMMUNITY_GUILD_ID } from "../utils.ts"; +import { assertEquals } from "../deps.ts"; +import { loadBot } from "../mod.ts"; +import { CACHED_COMMUNITY_GUILD_ID } from "../utils.ts"; -// Deno.test("[stickers] Edit guild sticker", async () => { -// const bot = loadBot(); -// const createSticker = await bot.helpers.createGuildSticker(CACHED_COMMUNITY_GUILD_ID, { -// name: "test", -// description: "test", -// tags: "test", -// file: "https://cdn.discordapp.com/emojis/785403373817823272.png", -// }); -// const editSticker = await bot.helpers.editGuildSticker(CACHED_COMMUNITY_GUILD_ID, createSticker.id, { -// name: "sticker name", -// description: "sticker description", -// tags: "sticker tags", -// }); -// assertEquals(editSticker.name, "sticker name"); -// assertEquals(editSticker.description, "sticker description"); -// assertEquals(editSticker.tags, "sticker tags"); +Deno.test("[stickers] Edit guild sticker", async () => { + const bot = loadBot(); + const createSticker = await bot.helpers.createGuildSticker(CACHED_COMMUNITY_GUILD_ID, { + name: "test", + description: "test", + tags: "test", + file: { + blob: await (await fetch("https://i.imgur.com/ejqd6Ro.png")).blob(), + name: "ddlogo.png", + }, + }); + const editSticker = await bot.helpers.editGuildSticker(CACHED_COMMUNITY_GUILD_ID, createSticker.id, { + name: "sticker name", + description: "sticker description", + tags: "sticker tags", + }); + assertEquals(editSticker.name, "sticker name"); + assertEquals(editSticker.description, "sticker description"); + assertEquals(editSticker.tags, "sticker tags"); -// await bot.helpers.deleteGuildSticker(CACHED_COMMUNITY_GUILD_ID, editSticker.id); -// }); + await bot.helpers.deleteGuildSticker(CACHED_COMMUNITY_GUILD_ID, editSticker.id); +}); diff --git a/tests/stickers/getGuildSticker.test.ts b/tests/stickers/getGuildSticker.test.ts index e862e69c8..f530c2372 100644 --- a/tests/stickers/getGuildSticker.test.ts +++ b/tests/stickers/getGuildSticker.test.ts @@ -1,19 +1,22 @@ -// import { assertEquals } from "../deps.ts"; -// import { loadBot } from "../mod.ts"; -// import { CACHED_COMMUNITY_GUILD_ID } from "../utils.ts"; +import { assertEquals } from "../deps.ts"; +import { loadBot } from "../mod.ts"; +import { CACHED_COMMUNITY_GUILD_ID } from "../utils.ts"; -// Deno.test("[stickers] Get guild sticker", async () => { -// const bot = loadBot(); -// const createSticker = await bot.helpers.createGuildSticker(CACHED_COMMUNITY_GUILD_ID, { -// name: "sticker name", -// description: "sticker description", -// tags: "sticker tags", -// file: "https://cdn.discordapp.com/emojis/785403373817823272.png", -// }); -// const getSticker = await bot.helpers.getGuildSticker(CACHED_COMMUNITY_GUILD_ID, createSticker.id); -// assertEquals(getSticker.name, "sticker name"); -// assertEquals(getSticker.description, "sticker description"); -// assertEquals(getSticker.tags, "sticker tags"); +Deno.test("[stickers] Get guild sticker", async () => { + const bot = loadBot(); + const createSticker = await bot.helpers.createGuildSticker(CACHED_COMMUNITY_GUILD_ID, { + name: "sticker name", + description: "sticker description", + tags: "sticker tags", + file: { + blob: await (await fetch("https://i.imgur.com/ejqd6Ro.png")).blob(), + name: "ddlogo.png", + }, + }); + const getSticker = await bot.helpers.getGuildSticker(CACHED_COMMUNITY_GUILD_ID, createSticker.id); + assertEquals(getSticker.name, "sticker name"); + assertEquals(getSticker.description, "sticker description"); + assertEquals(getSticker.tags, "sticker tags"); -// await bot.helpers.deleteGuildSticker(CACHED_COMMUNITY_GUILD_ID, getSticker.id); -// }); + await bot.helpers.deleteGuildSticker(CACHED_COMMUNITY_GUILD_ID, getSticker.id); +}); diff --git a/tests/stickers/getGuildStickers.test.ts b/tests/stickers/getGuildStickers.test.ts index 763343b85..5d0662b9a 100644 --- a/tests/stickers/getGuildStickers.test.ts +++ b/tests/stickers/getGuildStickers.test.ts @@ -1,23 +1,29 @@ -// import { assertEquals } from "../deps.ts"; -// import { loadBot } from "../mod.ts"; -// import { CACHED_COMMUNITY_GUILD_ID } from "../utils.ts"; +import { assertEquals } from "../deps.ts"; +import { loadBot } from "../mod.ts"; +import { CACHED_COMMUNITY_GUILD_ID } from "../utils.ts"; -// Deno.test("[stickers] Get guild stickers", async () => { -// const bot = loadBot(); -// const sticker1 = await bot.helpers.createGuildSticker(CACHED_COMMUNITY_GUILD_ID, { -// name: "sticker 1", -// description: "sticker 1", -// tags: "sticker tags 1", -// file: "https://cdn.discordapp.com/emojis/785403373817823272.png", -// }); -// const sticker2 = await bot.helpers.createGuildSticker(CACHED_COMMUNITY_GUILD_ID, { -// name: "sticker 2", -// description: "sticker 2", -// tags: "sticker tags 2", -// file: "https://cdn.discordapp.com/emojis/785403373817823272.png", -// }); -// const stickers = await bot.helpers.getGuildStickers(CACHED_COMMUNITY_GUILD_ID); -// assertEquals(stickers.size > 1, true); -// await bot.helpers.deleteGuildSticker(CACHED_COMMUNITY_GUILD_ID, sticker1.id); -// await bot.helpers.deleteGuildSticker(CACHED_COMMUNITY_GUILD_ID, sticker2.id); -// }); +Deno.test("[stickers] Get guild stickers", async () => { + const bot = loadBot(); + const sticker1 = await bot.helpers.createGuildSticker(CACHED_COMMUNITY_GUILD_ID, { + name: "sticker 1", + description: "sticker 1", + tags: "sticker tags 1", + file: { + blob: await (await fetch("https://i.imgur.com/ejqd6Ro.png")).blob(), + name: "ddlogo.png", + }, + }); + const sticker2 = await bot.helpers.createGuildSticker(CACHED_COMMUNITY_GUILD_ID, { + name: "sticker 2", + description: "sticker 2", + tags: "sticker tags 2", + file: { + blob: await (await fetch("https://i.imgur.com/ejqd6Ro.png")).blob(), + name: "ddlogo.png", + }, + }); + const stickers = await bot.helpers.getGuildStickers(CACHED_COMMUNITY_GUILD_ID); + assertEquals(stickers.size > 1, true); + await bot.helpers.deleteGuildSticker(CACHED_COMMUNITY_GUILD_ID, sticker1.id); + await bot.helpers.deleteGuildSticker(CACHED_COMMUNITY_GUILD_ID, sticker2.id); +});