fix channel permission thing

This commit is contained in:
ITOH
2021-05-01 18:35:19 +02:00
parent 642cf58bae
commit cff1b61af5
4 changed files with 46 additions and 31 deletions
+10 -3
View File
@@ -1,20 +1,27 @@
import { eventHandlers } from "../../bot.ts";
import { cacheHandlers } from "../../cache.ts";
import { rest } from "../../rest/rest.ts";
import { ModifyChannel } from "../../types/channels/modify_channel.ts";
import { Channel } from "../../types/mod.ts";
import { endpoints } from "../../util/constants.ts";
import {
calculateBits,
requireBotChannelPermissions,
requireOverwritePermissions,
} from "../../util/permissions.ts";
//TODO: implement DM group channel edit
/** Update a channel's settings. Requires the `MANAGE_CHANNELS` permission for the guild. */
export async function editChannel(
channelId: string,
options: ModifyChannel,
reason?: string,
) {
await requireBotChannelPermissions(channelId, ["MANAGE_CHANNELS"]);
const channel = await cacheHandlers.get("channels", channelId);
if (channel?.guildId) {
await requireOverwritePermissions(
channel.guildId,
options.permissionOverwrites || [],
);
}
if (options.name || options.topic) {
const request = editChannelNameTopicQueue.get(channelId);