mirror of
https://github.com/discordeno/discordeno.git
synced 2026-09-17 08:47:22 +00:00
tests: fix stickers test (#2497)
* tests: fix stickers test * tests: fix stickers size must be 320x320 * deno fmt * Update README.md Co-authored-by: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com>
This commit is contained in:
co-authored by
Skillz4Killz
parent
05e2d6cbe1
commit
e7b3a1fff9
@@ -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
|
||||
|
||||
|
||||
@@ -22,10 +22,6 @@ export async function createGuildSticker(
|
||||
guildId: bigint,
|
||||
options: CreateGuildStickerOptions,
|
||||
): Promise<Sticker> {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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));
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user