feat: fix typo in name and add isThreadChannel

This commit is contained in:
Skillz4Killz
2021-06-17 18:13:54 +00:00
committed by GitHub
parent 2d004ba156
commit d1b4ee8047
5 changed files with 13 additions and 19 deletions
+1 -9
View File
@@ -1,7 +1,6 @@
import { cacheHandlers } from "../../cache.ts";
import { rest } from "../../rest/rest.ts";
import { Errors } from "../../types/discordeno/errors.ts";
import { ChannelTypes } from "../../types/channels/channel_types.ts";
import { endpoints } from "../../util/constants.ts";
import { requireBotGuildPermissions } from "../../util/permissions.ts";
@@ -14,14 +13,7 @@ export async function deleteChannel(channelId: bigint, reason?: string) {
if (!guild) throw new Error(Errors.GUILD_NOT_FOUND);
// TODO(threads): check if this requires guild perms or channel is enough
await requireBotGuildPermissions(
guild,
[ChannelTypes.GuildNewsThread, ChannelTypes.GuildPivateThread, ChannelTypes.GuildPublicThread].includes(
channel.type
)
? ["MANAGE_THREADS"]
: ["MANAGE_CHANNELS"]
);
await requireBotGuildPermissions(guild, channel.isThreadChannel ? ["MANAGE_THREADS"] : ["MANAGE_CHANNELS"]);
if (guild.rulesChannelId === channelId) {
throw new Error(Errors.RULES_CHANNEL_CANNOT_BE_DELETED);
}
+1 -8
View File
@@ -4,7 +4,6 @@ import { rest } from "../../rest/rest.ts";
import type { DiscordenoChannel } from "../../structures/channel.ts";
import { structures } from "../../structures/mod.ts";
import type { Channel } from "../../types/channels/channel.ts";
import { DiscordChannelTypes } from "../../types/channels/channel_types.ts";
import type { ModifyChannel } from "../../types/channels/modify_channel.ts";
import type { ModifyThread } from "../../types/channels/threads/modify_thread.ts";
import type { PermissionStrings } from "../../types/permissions/permission_strings.ts";
@@ -19,13 +18,7 @@ export async function editChannel(channelId: bigint, options: ModifyChannel | Mo
const channel = await cacheHandlers.get("channels", channelId);
if (channel) {
if (
[
DiscordChannelTypes.GuildNewsThread,
DiscordChannelTypes.GuildPivateThread,
DiscordChannelTypes.GuildPublicThread,
].includes(channel.type)
) {
if (channel.isThreadChannel) {
const permissions = new Set<PermissionStrings>();
if (hasOwnProperty(options, "archive") && options.archive === false) {
+1 -1
View File
@@ -20,7 +20,7 @@ export async function startTyping(channelId: bigint) {
DiscordChannelTypes.GuildNews,
DiscordChannelTypes.GuildText,
DiscordChannelTypes.GuildNewsThread,
DiscordChannelTypes.GuildPivateThread,
DiscordChannelTypes.GuildPrivateThread,
DiscordChannelTypes.GuildPublicThread,
].includes(channel.type)
) {