Files
discordeno/tests/helpers/channels/editChannel.ts
ITOH 81f8e0377c style: move to deno fmt (#1992)
* Create deno.json

* run format

* run format

* ci: only check formatting

* f

* Update settings.json

* Update settings.json
2022-02-04 15:00:04 +01:00

31 lines
963 B
TypeScript

import { assertEquals } from "../../deps.ts";
import { bot } from "../../mod.ts";
import { delayUntil } from "../../utils.ts";
export async function editChannelTests(guildId: bigint, options: { reason?: string }) {
// Create the necessary channels
const channel = await bot.helpers.createChannel(guildId, {
name: "edit-channel",
});
// wait to give it time for events to process
await delayUntil(3000, () => bot.channels.has(channel.id));
// Make sure the channel was created.
if (!bot.channels.has(channel.id)) {
throw new Error("The channel should have been created but it is not in the cache.");
}
// Edit the channel now
await bot.helpers.editChannel(
channel.id,
{
name: "new-name",
},
options.reason,
);
// wait to give it time for events to process
await delayUntil(3000, () => bot.channels.get(channel.id)?.name === "new-name");
assertEquals(bot.channels.get(channel.id)?.name, "new-name");
}