Fix some types

This commit is contained in:
ayntee
2021-04-12 22:21:26 +04:00
parent 56661e508c
commit b21df06719
6 changed files with 45 additions and 24 deletions
+8 -5
View File
@@ -3,7 +3,10 @@ import { cacheHandlers } from "../../cache.ts";
import { rest } from "../../rest/rest.ts";
import { structures } from "../../structures/mod.ts";
import { DiscordChannel } from "../../types/channels/channel.ts";
import { CreateGuildChannel } from "../../types/guilds/create_guild_channel.ts";
import {
CreateGuildChannel,
DiscordCreateGuildChannel,
} from "../../types/guilds/create_guild_channel.ts";
import { PermissionStrings } from "../../types/permissions/permission_strings.ts";
import { endpoints } from "../../util/constants.ts";
import { requireBotGuildPermissions } from "../../util/permissions.ts";
@@ -14,14 +17,14 @@ import { calculateBits } from "../../util/permissions.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);
@@ -36,7 +39,7 @@ export async function createChannel(
"post",
endpoints.GUILD_CHANNELS(guildId),
{
...camelKeysToSnakeCase(options),
...camelKeysToSnakeCase<DiscordCreateGuildChannel>(options ?? {}),
permission_overwrites: options?.permissionOverwrites?.map((perm) => ({
...perm,
@@ -44,7 +47,7 @@ export async function createChannel(
deny: calculateBits(perm.deny),
})),
type: options?.type || DiscordChannelTypes.GUILD_TEXT,
}
},
)) as DiscordChannel;
const discordenoChannel = await structures.createDiscordenoChannel(result);