mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 19:28:17 +00:00
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:
+12
-13
@@ -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);
|
||||
|
||||
|
||||
+1
-4
@@ -138,10 +138,7 @@ Deno.test({
|
||||
Deno.test({
|
||||
name: "[channel] create a channel in a guild",
|
||||
async fn() {
|
||||
const guild = cache.guilds.get(tempData.guildID);
|
||||
if (!guild) throw new Error("Guild not found");
|
||||
|
||||
const channel = await createGuildChannel(guild, "test");
|
||||
const channel = await createGuildChannel(tempData.guildID, "test");
|
||||
|
||||
// Assertions
|
||||
assertExists(channel);
|
||||
|
||||
Reference in New Issue
Block a user