fix: snakelize request body

This commit is contained in:
ITOH
2021-05-31 19:48:13 +02:00
parent 220ea9ebb8
commit 83b7a708e7
12 changed files with 54 additions and 46 deletions
+14 -10
View File
@@ -17,16 +17,20 @@ export async function createChannel(guildId: bigint, options?: CreateGuildChanne
// 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<Channel>("post", endpoints.GUILD_CHANNELS(guildId), {
...snakelize<DiscordCreateGuildChannel>(options ?? {}),
permission_overwrites: options?.permissionOverwrites?.map((perm) => ({
...perm,
allow: calculateBits(perm.allow),
deny: calculateBits(perm.deny),
})),
type: options?.type || DiscordChannelTypes.GuildText,
reason,
});
const result = await rest.runMethod<Channel>(
"post",
endpoints.GUILD_CHANNELS(guildId),
snakelize<DiscordCreateGuildChannel>({
...options,
permissionOverwrites: options?.permissionOverwrites?.map((perm) => ({
...perm,
allow: calculateBits(perm.allow),
deny: calculateBits(perm.deny),
})),
type: options?.type || DiscordChannelTypes.GuildText,
reason,
})
);
const discordenoChannel = await structures.createDiscordenoChannel(result);
await cacheHandlers.set("channels", discordenoChannel.id, discordenoChannel);