This commit is contained in:
ITOH
2021-05-05 20:20:45 +02:00
113 changed files with 267 additions and 250 deletions
+2 -2
View File
@@ -12,7 +12,7 @@ import {
calculateBits,
requireOverwritePermissions,
} from "../../util/permissions.ts";
import { camelKeysToSnakeCase } from "../../util/utils.ts";
import { snakelize } from "../../util/utils.ts";
/** Create a channel in your server. Bot needs MANAGE_CHANNEL permissions in the server. */
export async function createChannel(
@@ -34,7 +34,7 @@ export async function createChannel(
"post",
endpoints.GUILD_CHANNELS(guildId),
{
...camelKeysToSnakeCase<DiscordCreateGuildChannel>(options ?? {}),
...snakelize<DiscordCreateGuildChannel>(options ?? {}),
permission_overwrites: options?.permissionOverwrites?.map((perm) => ({
...perm,
allow: calculateBits(perm.allow),
+2 -2
View File
@@ -12,7 +12,7 @@ import {
requireBotChannelPermissions,
requireOverwritePermissions,
} from "../../util/permissions.ts";
import { camelKeysToSnakeCase, hasOwnProperty } from "../../util/utils.ts";
import { hasOwnProperty, snakelize } from "../../util/utils.ts";
//TODO: implement DM group channel edit
//TODO(threads): check thread perms
@@ -88,7 +88,7 @@ export async function editChannel(
}
const payload = {
...camelKeysToSnakeCase<Record<string, unknown>>(options),
...snakelize<Record<string, unknown>>(options),
// deno-lint-ignore camelcase
permission_overwrites:
hasOwnProperty<ModifyChannel>(options, "permissionOverwrites")
@@ -1,7 +1,7 @@
import { rest } from "../../../rest/rest.ts";
import { ListPublicArchivedThreads } from "../../../types/channels/threads/list_public_archived_threads.ts";
import { endpoints } from "../../../util/constants.ts";
import { camelKeysToSnakeCase } from "../../../util/utils.ts";
import { snakelize } from "../../../util/utils.ts";
export async function getArchivedThreads(
channelId: bigint,
@@ -19,6 +19,6 @@ export async function getArchivedThreads(
: options?.type === "private"
? endpoints.THREAD_ARCHIVED_PRIVATE(channelId)
: endpoints.THREAD_ARCHIVED_PUBLIC(channelId),
camelKeysToSnakeCase(options ?? {}),
snakelize(options ?? {}),
);
}
+2 -2
View File
@@ -4,7 +4,7 @@ import { ChannelTypes } from "../../../types/channels/channel_types.ts";
import { StartThread } from "../../../types/channels/threads/start_thread.ts";
import { Errors } from "../../../types/discordeno/errors.ts";
import { endpoints } from "../../../util/constants.ts";
import { camelKeysToSnakeCase } from "../../../util/utils.ts";
import { snakelize } from "../../../util/utils.ts";
/**
* Creates a new public thread from an existing message. Returns a channel on success, and a 400 BAD REQUEST on invalid parameters. Fires a Thread Create Gateway event.
@@ -33,6 +33,6 @@ export async function startThread(
options?.messageId
? endpoints.THREAD_START_PUBLIC(channelId, options.messageId)
: endpoints.THREAD_START_PRIVATE(channelId),
camelKeysToSnakeCase(options),
snakelize(options),
);
}