mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 11:28:15 +00:00
tests: add channel tests (#807)
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user