mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-02 17:00:08 +00:00
* refactor(helpers): Organise functions. (#2425) * refactor: Move stage instance helper functions into `/stages` subdirectory. * refactor: Move `followChannel.ts` to `/announcements` subdirectory. * refactor: Move `updateVoiceState.ts` to `/guilds` directory. * refactor: Move `getPins.ts` to `/messages` directory. * refactor: Move voice-related helper functions into `/voice` subdirectory. * refactor: Rename `/scheduledEvents` to `/events`. * refactor: Move widget-related helper functions into `/widgets` subdirectory. * refactor: Make `/integrations` a subdirectory of `/guilds`. * refactor: Move helper functions related to interaction responses into the `/responses` subdirectory. * refactor: Move `verifySignature.ts` to `/util` directory. * refactor: Move `getChannelInvites.ts` to `/channels` directory. * refactor: Make `/invites` a subdirectory of `/guilds`. * refactor: Move reaction-related helper functions into the /reactions subdirectory. * refactor: Move `getApplicationInfo.ts` into the `/misc` directory. * refactor: Move voice-related helper functions from `/voice` to `/guilds/voice`. * fix: Update and simplify type imports. * refactor!(helpers): Rename helpers to match Discord API. Create a 1:1 helper-to-endpoint correspondence. (#2427) * refactor: Move stage instance helper functions into `/stages` subdirectory. * refactor: Move `followChannel.ts` to `/announcements` subdirectory. * refactor: Move `updateVoiceState.ts` to `/guilds` directory. * refactor: Move `getPins.ts` to `/messages` directory. * refactor: Move voice-related helper functions into `/voice` subdirectory. * refactor: Rename `/scheduledEvents` to `/events`. * refactor: Move widget-related helper functions into `/widgets` subdirectory. * refactor: Make `/integrations` a subdirectory of `/guilds`. * refactor: Move helper functions related to interaction responses into the `/responses` subdirectory. * refactor: Move `verifySignature.ts` to `/util` directory. * refactor: Move `getChannelInvites.ts` to `/channels` directory. * refactor: Make `/invites` a subdirectory of `/guilds`. * refactor: Move reaction-related helper functions into the /reactions subdirectory. * refactor: Move `getApplicationInfo.ts` into the `/misc` directory. * refactor: Move voice-related helper functions from `/voice` to `/guilds/voice`. * fix: Update and simplify type imports. * refactor: Rename `followChannel` -> `followAnnouncementChannel`. * refactor: Rename `createForumPost` -> `startForumThread`. * refactor: Normalise keyword `update` -> `edit`. * refactor: Rename `addToThread` -> `addThreadMember`. * refactor: Rename `ChannelOverwrite` -> `ChannelPermissions`. * refactor: Rename `startTyping` -> `triggerTypingIndicator`. * refactor: Rename `swapChannels` -> `editChannelPositions`. * refactor: Rename `getPins` -> `getPinnedMessages`. * refactor: Rename `publish` -> `crosspost`. * refactor: Normalise keyword `modify` -> `edit`. * refactor: Normalise naming. * fix: Imports. * style: Remove empty object. * refactor: Split `getArchivedThreads` into three files for public, private and private joined threads. * refactor: Split `getApplicationCommands` into two files, for guild and global commands respectively. * refactor: Split `getApplicationCommand` into two files, for guild and global commands respectively. * fmt: Organise imports. * misc: Include application command reverse transformer. * misc: Make ordering of fields match up with the Discord API. * fix: Add missing payload properties. * refactor: Split `createApplicationCommand` into two files, for guild and global commands respectively. * refactor: Split `upsertApplicationCommand` into two files, for guild and global commands respectively. * refactor: Split `upsertApplicationCommands` into two files, for guild and global commands respectively. * fix: Update exports. * refactor: Split `deleteApplicationCommand` into two files, for guild and global commands respectively. * fix: Add missing exports. * refactor: Separate file into two to make 1 file correspond to 1 endpoint. * refactor: Separate file into two to make 1 file correspond to 1 endpoint. * feat: Create `getInteractionResponse.ts`. * refactor: Matching API: `InteractionResponse` -> `FollowupMessage`. * refactor: Separate file into two to make 1 file correspond to 1 endpoint. * refactor: Remove `/followups` directory in favour of newly created files in `/responses`. * refactor: Rename `bot`/`self` -> `own`, `others` -> `user`. * refactor: Split function into `deleteOwnReaction` and `deleteUserReaction`. * refactor: Reduce code duplication in processing reaction string. * refactor: Separate file into two to make 1 file correspond to 1 endpoint. * refactor: Rename function name. * misc: Add aliases to functions to reduce breakage. * refactor: Rename `startForumThread` -> `createForumThread`. * misc: Move types from helper file to `/types` and create transformer. * fix: Imports. * style: Rename parameter `command` -> `payload`. * feat: Create interaction response transformer. * misc: Adapt code to use the interaction response transformer. * misc: Adapt code to use interaction response transformer. * refactor: Re-include the keyword `Override` in the file + function names. * refactor: Rename `updateVoiceState` -> `editVoiceState` for consistency reasons. Co-authored-by: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com> * BREAKING: docs(helpers): Document helper functions. (#2437) * refactor: Move stage instance helper functions into `/stages` subdirectory. * refactor: Move `followChannel.ts` to `/announcements` subdirectory. * refactor: Move `updateVoiceState.ts` to `/guilds` directory. * refactor: Move `getPins.ts` to `/messages` directory. * refactor: Move voice-related helper functions into `/voice` subdirectory. * refactor: Rename `/scheduledEvents` to `/events`. * refactor: Move widget-related helper functions into `/widgets` subdirectory. * refactor: Make `/integrations` a subdirectory of `/guilds`. * refactor: Move helper functions related to interaction responses into the `/responses` subdirectory. * refactor: Move `verifySignature.ts` to `/util` directory. * refactor: Move `getChannelInvites.ts` to `/channels` directory. * refactor: Make `/invites` a subdirectory of `/guilds`. * refactor: Move reaction-related helper functions into the /reactions subdirectory. * refactor: Move `getApplicationInfo.ts` into the `/misc` directory. * refactor: Move voice-related helper functions from `/voice` to `/guilds/voice`. * fix: Update and simplify type imports. * refactor: Rename `followChannel` -> `followAnnouncementChannel`. * refactor: Rename `createForumPost` -> `startForumThread`. * refactor: Normalise keyword `update` -> `edit`. * refactor: Rename `addToThread` -> `addThreadMember`. * refactor: Rename `ChannelOverwrite` -> `ChannelPermissions`. * refactor: Rename `startTyping` -> `triggerTypingIndicator`. * refactor: Rename `swapChannels` -> `editChannelPositions`. * refactor: Rename `getPins` -> `getPinnedMessages`. * refactor: Rename `publish` -> `crosspost`. * refactor: Normalise keyword `modify` -> `edit`. * refactor: Normalise naming. * fix: Imports. * style: Remove empty object. * refactor: Split `getArchivedThreads` into three files for public, private and private joined threads. * refactor: Split `getApplicationCommands` into two files, for guild and global commands respectively. * refactor: Split `getApplicationCommand` into two files, for guild and global commands respectively. * fmt: Organise imports. * misc: Include application command reverse transformer. * misc: Make ordering of fields match up with the Discord API. * fix: Add missing payload properties. * refactor: Split `createApplicationCommand` into two files, for guild and global commands respectively. * refactor: Split `upsertApplicationCommand` into two files, for guild and global commands respectively. * refactor: Split `upsertApplicationCommands` into two files, for guild and global commands respectively. * fix: Update exports. * refactor: Split `deleteApplicationCommand` into two files, for guild and global commands respectively. * fix: Add missing exports. * refactor: Separate file into two to make 1 file correspond to 1 endpoint. * refactor: Separate file into two to make 1 file correspond to 1 endpoint. * feat: Create `getInteractionResponse.ts`. * refactor: Matching API: `InteractionResponse` -> `FollowupMessage`. * refactor: Separate file into two to make 1 file correspond to 1 endpoint. * refactor: Remove `/followups` directory in favour of newly created files in `/responses`. * refactor: Rename `bot`/`self` -> `own`, `others` -> `user`. * refactor: Split function into `deleteOwnReaction` and `deleteUserReaction`. * refactor: Reduce code duplication in processing reaction string. * refactor: Separate file into two to make 1 file correspond to 1 endpoint. * refactor: Rename function name. * misc: Add aliases to functions to reduce breakage. * refactor: Rename `startForumThread` -> `createForumThread`. * misc: Move types from helper file to `/types` and create transformer. * fix: Imports. * style: Rename parameter `command` -> `payload`. * feat: Create interaction response transformer. * misc: Adapt code to use the interaction response transformer. * misc: Adapt code to use interaction response transformer. * docs: Document announcement channel helpers. * docs: Document forum channel helpers. * docs: Document stage instance helpers. * misc: Update wording. * docs: Document thread channel helpers. * refactor: Re-include the keyword `Override` in the file + function names. * refactor: Rename `updateVoiceState` -> `editVoiceState` for consistency reasons. * docs: Document channel helpers. * docs: Use `parameters` instead of `options` for descriptions. * docs: Document guild discovery helpers. * docs: Document emoji helpers. * docs: Add missing information about which gateway events are fired. * docs: Document auto moderation helpers. * docs: Document scheduled event helpers. * docs: Document integration helpers. * docs: Document invite helpers. * refactor: Rename `editWidget` -> `editWidgetSettings`. * docs: Document guild widget helpers. * docs: 'event' -> 'gateway event'. * refactor: Rename `getAuditLogs` -> `getAuditLog`. * docs: Document guild helpers. * refactor: Rename `upsert*ApplicationCommand` -> `edit*ApplicationCommand`. * docs: Document application command helpers. * docs: Improve consistency in indentation. * docs: Document interaction response + follow-up message helpers. * docs: Document gateway event firings for endpoints. * refactor: Delete `editBotNickname` due to being a subset of `editMember`. * docs: Fix inconsistency. * docs: Document member helpers. * docs: Document reaction helpers. * docs: Improve consistency. * docs: Document message helpers. * docs: Document role helpers. * docs: Document guild template helpers. * docs: Fix incorrect gateway event. * refactor: Rename `sendWebhookMessage` -> `executeWebhook`. * docs: Document webhook helpers. * docs: Document voice helpers. * fmt: Run Deno formatter. * docs: Improve consistency. * refactor: Rename the `/widgets` directory to `/widget`. * fmt: Run Deno formatter. * misc: Re-add the deleted `editBotNickname()` helper. (#2443) * refactor: Move stage instance helper functions into `/stages` subdirectory. * refactor: Move `followChannel.ts` to `/announcements` subdirectory. * refactor: Move `updateVoiceState.ts` to `/guilds` directory. * refactor: Move `getPins.ts` to `/messages` directory. * refactor: Move voice-related helper functions into `/voice` subdirectory. * refactor: Rename `/scheduledEvents` to `/events`. * refactor: Move widget-related helper functions into `/widgets` subdirectory. * refactor: Make `/integrations` a subdirectory of `/guilds`. * refactor: Move helper functions related to interaction responses into the `/responses` subdirectory. * refactor: Move `verifySignature.ts` to `/util` directory. * refactor: Move `getChannelInvites.ts` to `/channels` directory. * refactor: Make `/invites` a subdirectory of `/guilds`. * refactor: Move reaction-related helper functions into the /reactions subdirectory. * refactor: Move `getApplicationInfo.ts` into the `/misc` directory. * refactor: Move voice-related helper functions from `/voice` to `/guilds/voice`. * fix: Update and simplify type imports. * refactor: Rename `followChannel` -> `followAnnouncementChannel`. * refactor: Rename `createForumPost` -> `startForumThread`. * refactor: Normalise keyword `update` -> `edit`. * refactor: Rename `addToThread` -> `addThreadMember`. * refactor: Rename `ChannelOverwrite` -> `ChannelPermissions`. * refactor: Rename `startTyping` -> `triggerTypingIndicator`. * refactor: Rename `swapChannels` -> `editChannelPositions`. * refactor: Rename `getPins` -> `getPinnedMessages`. * refactor: Rename `publish` -> `crosspost`. * refactor: Normalise keyword `modify` -> `edit`. * refactor: Normalise naming. * fix: Imports. * style: Remove empty object. * refactor: Split `getArchivedThreads` into three files for public, private and private joined threads. * refactor: Split `getApplicationCommands` into two files, for guild and global commands respectively. * refactor: Split `getApplicationCommand` into two files, for guild and global commands respectively. * fmt: Organise imports. * misc: Include application command reverse transformer. * misc: Make ordering of fields match up with the Discord API. * fix: Add missing payload properties. * refactor: Split `createApplicationCommand` into two files, for guild and global commands respectively. * refactor: Split `upsertApplicationCommand` into two files, for guild and global commands respectively. * refactor: Split `upsertApplicationCommands` into two files, for guild and global commands respectively. * fix: Update exports. * refactor: Split `deleteApplicationCommand` into two files, for guild and global commands respectively. * fix: Add missing exports. * refactor: Separate file into two to make 1 file correspond to 1 endpoint. * refactor: Separate file into two to make 1 file correspond to 1 endpoint. * feat: Create `getInteractionResponse.ts`. * refactor: Matching API: `InteractionResponse` -> `FollowupMessage`. * refactor: Separate file into two to make 1 file correspond to 1 endpoint. * refactor: Remove `/followups` directory in favour of newly created files in `/responses`. * refactor: Rename `bot`/`self` -> `own`, `others` -> `user`. * refactor: Split function into `deleteOwnReaction` and `deleteUserReaction`. * refactor: Reduce code duplication in processing reaction string. * refactor: Separate file into two to make 1 file correspond to 1 endpoint. * refactor: Rename function name. * misc: Add aliases to functions to reduce breakage. * refactor: Rename `startForumThread` -> `createForumThread`. * misc: Move types from helper file to `/types` and create transformer. * fix: Imports. * style: Rename parameter `command` -> `payload`. * feat: Create interaction response transformer. * misc: Adapt code to use the interaction response transformer. * misc: Adapt code to use interaction response transformer. * docs: Document announcement channel helpers. * docs: Document forum channel helpers. * docs: Document stage instance helpers. * misc: Update wording. * docs: Document thread channel helpers. * refactor: Re-include the keyword `Override` in the file + function names. * refactor: Rename `updateVoiceState` -> `editVoiceState` for consistency reasons. * docs: Document channel helpers. * docs: Use `parameters` instead of `options` for descriptions. * docs: Document guild discovery helpers. * docs: Document emoji helpers. * docs: Add missing information about which gateway events are fired. * docs: Document auto moderation helpers. * docs: Document scheduled event helpers. * docs: Document integration helpers. * docs: Document invite helpers. * refactor: Rename `editWidget` -> `editWidgetSettings`. * docs: Document guild widget helpers. * docs: 'event' -> 'gateway event'. * refactor: Rename `getAuditLogs` -> `getAuditLog`. * docs: Document guild helpers. * refactor: Rename `upsert*ApplicationCommand` -> `edit*ApplicationCommand`. * docs: Document application command helpers. * docs: Improve consistency in indentation. * docs: Document interaction response + follow-up message helpers. * docs: Document gateway event firings for endpoints. * refactor: Delete `editBotNickname` due to being a subset of `editMember`. * docs: Fix inconsistency. * docs: Document member helpers. * docs: Document reaction helpers. * docs: Improve consistency. * docs: Document message helpers. * docs: Document role helpers. * docs: Document guild template helpers. * docs: Fix incorrect gateway event. * refactor: Rename `sendWebhookMessage` -> `executeWebhook`. * docs: Document webhook helpers. * docs: Document voice helpers. * fmt: Run Deno formatter. * docs: Improve consistency. * refactor: Rename the `/widgets` directory to `/widget`. * fmt: Run Deno formatter. * feat: Re-add `editBotNickname.ts`. * Update helpers/members/editBotNickname.ts Co-authored-by: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com> * fix: tests * fix: bot member tests * fix: remove submode * fix: edit bot member returns full member Co-authored-by: Dorian Oszczęda <vxern@wordcollector.co.uk>
276 lines
8.6 KiB
TypeScript
276 lines
8.6 KiB
TypeScript
import { ChannelTypes } from "../../mod.ts";
|
|
import { assertEquals, assertExists, assertNotEquals, assertRejects } from "../deps.ts";
|
|
import { loadBot } from "../mod.ts";
|
|
|
|
Deno.test({
|
|
name: "[guild] Create a guild",
|
|
async fn(t) {
|
|
const bot = loadBot();
|
|
|
|
// Delete the oldest guild(most likely to have finished tests).
|
|
|
|
const guild = await bot.helpers.createGuild({
|
|
name: "Discordeno-test",
|
|
});
|
|
assertExists(guild.id);
|
|
|
|
try {
|
|
await t.step("[guild] Get a guild", async () => {
|
|
const exists = await bot.helpers.getGuild(guild.id);
|
|
assertExists(exists);
|
|
assertExists(exists.id);
|
|
assertEquals(exists.name, guild.name);
|
|
});
|
|
|
|
await t.step("[guild] Edit a guild", async (t) => {
|
|
const voiceChannel = await bot.helpers.createChannel(guild.id, {
|
|
name: "edit-guild-test",
|
|
type: ChannelTypes.GuildVoice,
|
|
});
|
|
assertExists(voiceChannel.id);
|
|
|
|
const edited = await bot.helpers.editGuild(guild.id, {
|
|
name: "Discordeno-test-edited",
|
|
afkChannelId: voiceChannel.id,
|
|
// afkTimeout: 5,
|
|
}, guild.shardId);
|
|
assertEquals(edited.name, "Discordeno-test-edited");
|
|
assertNotEquals(guild.afkChannelId, voiceChannel.id);
|
|
assertEquals(edited.afkChannelId, voiceChannel.id);
|
|
// assertEquals(guild.afkTimeout, 0);
|
|
// assertEquals(edited.afkTimeout, 5);
|
|
|
|
await t.step("[guild] Reset a guild's afk channel id", async () => {
|
|
const edited2 = await bot.helpers.editGuild(guild.id, { afkChannelId: null }, guild.shardId);
|
|
assertNotEquals(edited.afkChannelId, edited2.afkChannelId);
|
|
assertEquals(edited2.afkChannelId, undefined);
|
|
});
|
|
|
|
await bot.helpers.deleteChannel(voiceChannel.id);
|
|
});
|
|
|
|
// await t.step("[guild] Edit a guild's afk settings", async () => {
|
|
|
|
// });
|
|
|
|
await t.step("[guild] Get audit logs", async () => {
|
|
const auditLogs = await bot.helpers.getAuditLog(guild.id, { limit: 1 });
|
|
assertExists(auditLogs.auditLogEntries.length);
|
|
});
|
|
|
|
// Get available voice regions
|
|
await t.step("[guild] Get available voice regions", async () => {
|
|
const regions = await bot.helpers.getVoiceRegions(guild.id);
|
|
assertExists(regions.size);
|
|
});
|
|
|
|
// Get a guild ban
|
|
await t.step("[guild] Get a guild ban", async (t) => {
|
|
await bot.helpers.banMember(guild.id, 379643682984296448n);
|
|
|
|
const fetchedBan = await bot.helpers.getBan(guild.id, 379643682984296448n);
|
|
|
|
// Assertions
|
|
assertExists(fetchedBan);
|
|
assertEquals(fetchedBan.user.id, 379643682984296448n);
|
|
|
|
// Get multiple guild bans
|
|
await t.step("[guild] Get multiple guild bans", async () => {
|
|
await bot.helpers.banMember(guild.id, 416477607966670869n);
|
|
await bot.helpers.banMember(guild.id, 635383782576357407n);
|
|
|
|
const fetchedBans = await bot.helpers.getBans(guild.id);
|
|
|
|
// Assertions
|
|
assertExists(fetchedBans);
|
|
});
|
|
});
|
|
|
|
// Get vanity URL
|
|
await t.step("[guild] Get vanity URL", async () => {
|
|
await assertRejects(() => bot.helpers.getVanityUrl(guild.id));
|
|
});
|
|
|
|
// Emoji related tests
|
|
|
|
// Create an emoji
|
|
await t.step({
|
|
name: "[emoji] create an emoji",
|
|
fn: async (t) => {
|
|
const bot = loadBot();
|
|
const emoji = await bot.helpers.createEmoji(guild.id, {
|
|
name: "blamewolf",
|
|
image: "https://cdn.discordapp.com/emojis/814955268123000832.png",
|
|
roles: [],
|
|
});
|
|
|
|
// Assertions
|
|
assertExists(emoji.id);
|
|
|
|
await bot.helpers.deleteEmoji(guild.id, emoji.id);
|
|
},
|
|
});
|
|
|
|
// delete an emoji without a reason
|
|
await t.step({
|
|
name: "[emoji] delete an emoji without a reason",
|
|
fn: async (t) => {
|
|
const bot = loadBot();
|
|
const emoji = await bot.helpers.createEmoji(guild.id, {
|
|
name: "blamewolf",
|
|
image: "https://cdn.discordapp.com/emojis/814955268123000832.png",
|
|
roles: [],
|
|
});
|
|
|
|
// Assertions
|
|
assertExists(emoji.id);
|
|
|
|
await bot.helpers.deleteEmoji(guild.id, emoji.id);
|
|
|
|
await assertRejects(() => bot.helpers.getEmoji(guild.id, emoji.id!));
|
|
},
|
|
});
|
|
|
|
// delete an emoji with a reason
|
|
await t.step({
|
|
name: "[emoji] delete an emoji with a reason",
|
|
fn: async (t) => {
|
|
const bot = loadBot();
|
|
const emoji = await bot.helpers.createEmoji(guild.id, {
|
|
name: "blamewolf",
|
|
image: "https://cdn.discordapp.com/emojis/814955268123000832.png",
|
|
roles: [],
|
|
});
|
|
|
|
// Assertions
|
|
assertExists(emoji.id);
|
|
|
|
await bot.helpers.deleteEmoji(guild.id, emoji.id, "with a reason");
|
|
|
|
await assertRejects(() => bot.helpers.getEmoji(guild.id, emoji.id!));
|
|
},
|
|
});
|
|
|
|
// edit an emoji name
|
|
await t.step({
|
|
name: "[emoji] Edit an emoji name",
|
|
fn: async (t) => {
|
|
const bot = loadBot();
|
|
const emoji = await bot.helpers.createEmoji(guild.id, {
|
|
name: "blamewolf",
|
|
image: "https://cdn.discordapp.com/emojis/814955268123000832.png",
|
|
roles: [],
|
|
});
|
|
|
|
// Assertions
|
|
assertExists(emoji.id);
|
|
assertEquals(emoji.name, "blamewolf");
|
|
|
|
await bot.helpers.editEmoji(guild.id, emoji.id, {
|
|
name: "edited",
|
|
});
|
|
|
|
const edited = await bot.helpers.getEmoji(guild.id, emoji.id);
|
|
|
|
assertEquals(edited.name, "edited");
|
|
|
|
await bot.helpers.deleteEmoji(guild.id, emoji.id);
|
|
},
|
|
});
|
|
|
|
// edit an emoji roles
|
|
await t.step({
|
|
name: "[emoji] Edit an emoji's roles",
|
|
fn: async (t) => {
|
|
const bot = loadBot();
|
|
const emoji = await bot.helpers.createEmoji(guild.id, {
|
|
name: "blamewolf",
|
|
image: "https://cdn.discordapp.com/emojis/814955268123000832.png",
|
|
roles: [],
|
|
});
|
|
|
|
// Assertions
|
|
assertExists(emoji.id);
|
|
assertEquals(emoji.name, "blamewolf");
|
|
|
|
const role = await bot.helpers.createRole(guild.id, {
|
|
name: "dd-test-emoji",
|
|
});
|
|
await bot.helpers.editEmoji(guild.id, emoji.id, {
|
|
roles: [role.id],
|
|
});
|
|
|
|
const edited = await bot.helpers.getEmoji(guild.id, emoji.id);
|
|
|
|
assertEquals(edited.roles?.length, 1);
|
|
|
|
await bot.helpers.deleteEmoji(guild.id, emoji.id);
|
|
await bot.helpers.deleteRole(guild.id, role.id);
|
|
},
|
|
});
|
|
|
|
// get an emoji
|
|
await t.step({
|
|
name: "[emoji] get an emoji",
|
|
fn: async (t) => {
|
|
const bot = loadBot();
|
|
const emoji = await bot.helpers.createEmoji(guild.id, {
|
|
name: "blamewolf",
|
|
image: "https://cdn.discordapp.com/emojis/814955268123000832.png",
|
|
roles: [],
|
|
});
|
|
|
|
// Assertions
|
|
assertExists(emoji.id);
|
|
|
|
const exists = await bot.helpers.getEmoji(guild.id, emoji.id);
|
|
assertExists(exists.id);
|
|
assertEquals(emoji.id, exists.id);
|
|
|
|
await bot.helpers.deleteEmoji(guild.id, emoji.id);
|
|
},
|
|
});
|
|
|
|
await t.step({
|
|
name: "[emoji] get all guild emojis",
|
|
fn: async (t) => {
|
|
const bot = loadBot();
|
|
const emoji = await bot.helpers.createEmoji(guild.id, {
|
|
name: "blamewolf",
|
|
image: "https://cdn.discordapp.com/emojis/814955268123000832.png",
|
|
roles: [],
|
|
});
|
|
|
|
const emoji2 = await bot.helpers.createEmoji(guild.id, {
|
|
name: "blamewolf2",
|
|
image: "https://cdn.discordapp.com/emojis/814955268123000832.png",
|
|
roles: [],
|
|
});
|
|
|
|
// Assertions
|
|
assertExists(emoji.id);
|
|
assertExists(emoji2.id);
|
|
|
|
const exists = await bot.helpers.getEmojis(guild.id);
|
|
assertEquals(exists.size > 1, true);
|
|
|
|
await bot.helpers.deleteEmoji(guild.id, emoji.id);
|
|
await bot.helpers.deleteEmoji(guild.id, emoji2.id);
|
|
},
|
|
});
|
|
|
|
// Delete a guild
|
|
await t.step("[guild] Delete a guild", async () => {
|
|
await bot.helpers.deleteGuild(guild.id);
|
|
// Make sure the guild was deleted
|
|
await assertRejects(() => bot.helpers.getGuild(guild.id));
|
|
});
|
|
} catch (error) {
|
|
// If any errors arise, delete the guild
|
|
await bot.helpers.deleteGuild(guild.id);
|
|
// then throw the error
|
|
throw error;
|
|
}
|
|
},
|
|
});
|