feat(handlers/guild): change createGuildChannel() to use guild ID (#528)

* guild > guildID

* fix(test): createGuildChannel test

* Update test/mod.test.ts

* Update test/mod.test.ts

* fmt

Co-authored-by: ayntee <ayyantee@gmail.com>
This commit is contained in:
ITOH
2021-03-08 15:23:04 +01:00
committed by GitHub
parent 9715ab4274
commit ebc48156aa
2 changed files with 13 additions and 17 deletions
+12 -13
View File
@@ -112,30 +112,29 @@ export function guildBannerURL(
/** Create a channel in your server. Bot needs MANAGE_CHANNEL permissions in the server. */
export async function createGuildChannel(
guild: Guild,
guildID: string,
name: string,
options?: ChannelCreateOptions,
) {
const hasPerm = await botHasPermission(
guild.id,
guildID,
["MANAGE_CHANNELS"],
);
if (!hasPerm) {
throw new Error(Errors.MISSING_MANAGE_CHANNELS);
}
const result =
(await RequestManager.post(endpoints.GUILD_CHANNELS(guild.id), {
...options,
name,
permission_overwrites: options?.permissionOverwrites?.map((perm) => ({
...perm,
const result = (await RequestManager.post(endpoints.GUILD_CHANNELS(guildID), {
...options,
name,
permission_overwrites: options?.permissionOverwrites?.map((perm) => ({
...perm,
allow: calculateBits(perm.allow),
deny: calculateBits(perm.deny),
})),
type: options?.type || ChannelTypes.GUILD_TEXT,
})) as ChannelCreatePayload;
allow: calculateBits(perm.allow),
deny: calculateBits(perm.deny),
})),
type: options?.type || ChannelTypes.GUILD_TEXT,
})) as ChannelCreatePayload;
const channelStruct = await structures.createChannel(result);