tests: add channel tests (#807)

This commit is contained in:
Skillz4Killz
2021-04-10 09:38:58 -04:00
committed by GitHub
parent 55d73d1937
commit 66b0aa3685
11 changed files with 179 additions and 70 deletions
+6 -3
View File
@@ -15,14 +15,14 @@ import { DiscordChannelTypes } from "../../types/channels/channel_types.ts";
/** Create a channel in your server. Bot needs MANAGE_CHANNEL permissions in the server. */
export async function createChannel(
guildId: string,
options?: CreateGuildChannel,
options?: CreateGuildChannel
) {
const requiredPerms: Set<PermissionStrings> = new Set(["MANAGE_CHANNELS"]);
options?.permissionOverwrites?.forEach((overwrite) => {
eventHandlers.debug?.(
"loop",
`Running forEach loop in create_channel file.`,
`Running forEach loop in create_channel file.`
);
overwrite.allow.forEach(requiredPerms.add, requiredPerms);
overwrite.deny.forEach(requiredPerms.add, requiredPerms);
@@ -30,6 +30,9 @@ export async function createChannel(
await requireBotGuildPermissions(guildId, [...requiredPerms]);
// BITRATES ARE IN THOUSANDS SO IF USER PROVIDES 32 WE CONVERT TO 32000
if (options?.bitrate && options.bitrate < 1000) options.bitrate *= 1000;
const result = (await rest.runMethod(
"post",
endpoints.GUILD_CHANNELS(guildId),
@@ -42,7 +45,7 @@ export async function createChannel(
deny: calculateBits(perm.deny),
})),
type: options?.type || DiscordChannelTypes.GUILD_TEXT,
},
}
)) as DiscordChannel;
const discordenoChannel = await structures.createDiscordenoChannel(result);