fix: remove cloneChannel helper

This commit is contained in:
Skillz4Killz
2021-12-03 14:11:43 +00:00
committed by GitHub
parent 69230ae78e
commit 7c171faf3c
4 changed files with 0 additions and 72 deletions
-33
View File
@@ -1,33 +0,0 @@
import type { Bot } from "../../bot.ts";
import { DiscordenoChannel, separateOverwrites } from "../../transformers/channel.ts";
import type { CreateGuildChannel } from "../../types/guilds/createGuildChannel.ts";
/** Create a copy of a channel */
export async function cloneChannel(bot: Bot, channel: DiscordenoChannel, reason?: string) {
if (!channel.guildId) throw new Error(`Cannot clone a channel outside a guild`);
const createChannelOptions: CreateGuildChannel = {
type: channel.type,
bitrate: channel.bitrate,
userLimit: channel.userLimit,
rateLimitPerUser: channel.rateLimitPerUser,
position: channel.position,
parentId: channel.parentId,
nsfw: channel.nsfw,
name: channel.name!,
topic: channel.topic || undefined,
permissionOverwrites: channel.permissionOverwrites.map((overwrite) => {
const [type, id, allow, deny] = separateOverwrites(overwrite);
return {
id,
type,
allow: bot.utils.calculatePermissions(BigInt(allow)),
deny: bot.utils.calculatePermissions(BigInt(deny)),
};
}),
};
//Create the channel (also handles permissions)
return await bot.helpers.createChannel(channel.guildId!, createChannelOptions, reason);
}
-1
View File
@@ -169,7 +169,6 @@ export * from "./channels/threads/leaveThread.ts";
export * from "./channels/threads/removeThreadMember.ts";
export * from "./channels/threads/startThreadWithMessage.ts";
export * from "./channels/threads/startThreadWithoutMessage.ts";
export * from "./channels/cloneChannel.ts";
//guilds
export * from "./guilds/scheduledEvents/createScheduledEvent.ts";
-23
View File
@@ -1,23 +0,0 @@
import { DiscordenoChannel } from "../../../src/transformers/channel.ts";
import { assertExists, assertEquals } from "../../deps.ts";
import { bot, channel } from "../../mod.ts";
import { delayUntil } from "../../utils.ts";
export async function cloneChannelTests(
options: { reason?: string },
) {
// @ts-ignore for itoh
const cloned = await bot.helpers.cloneChannel(channel, options.reason);
//Assertations
assertExists(cloned);
assertEquals(cloned.type, channel.type);
// Delay the execution to allow CHANNEL_CREATE event to be processed
await delayUntil(10000, () => bot.channels.has(cloned.id));
assertExists(bot.channels.has(cloned.id));
assertEquals(channel.topic, cloned.topic);
assertEquals(channel.bitrate, cloned.bitrate);
assertEquals(channel.permissionOverwrites.length, cloned.permissionOverwrites.length);
}
-15
View File
@@ -31,7 +31,6 @@ import { getGuildTests } from "./helpers/guilds/getGuild.ts";
import { getVanityURLTests } from "./helpers/guilds/getVanityUrl.ts";
import { categoryChildrenTest } from "./helpers/channels/categoryChannels.ts";
import { channelOverwriteHasPermissionTest } from "./helpers/channels/channelOverwriteHasPermission.ts";
import { cloneChannelTests } from "./helpers/channels/cloneChannel.ts";
import { deleteChannelOverwriteTests } from "./helpers/channels/deleteChannelOverwrite.ts";
import { editChannelTests } from "./helpers/channels/editChannel.ts";
import { CACHED_COMMUNITY_GUILD_ID, sanitizeMode } from "./constants.ts";
@@ -275,20 +274,6 @@ Deno.test({
},
...sanitizeMode,
});
Deno.test({
name: "[channel] clone a channel w/o a reason",
async fn(t) {
await cloneChannelTests({});
},
...sanitizeMode,
});
Deno.test({
name: "[channel] clone a channel w/ a reason",
async fn(t) {
await cloneChannelTests({ reason: "Blame wolf" });
},
...sanitizeMode,
});
Deno.test({
name: "[channel] delete a channel overwrite",
async fn(t) {