async function deleteChannel(
  channelId,
  reason,
) {
  const channel = await cacheHandlers.get("channels", channelId);
  if (channel?.guildId) {
    const guild = await cacheHandlers.get("guilds", channel.guildId);
    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",
        ],
    );
    if (guild.rulesChannelId === channelId) {
      throw new Error(Errors.RULES_CHANNEL_CANNOT_BE_DELETED);
    }
    if (guild.publicUpdatesChannelId === channelId) {
      throw new Error(Errors.UPDATES_CHANNEL_CANNOT_BE_DELETED);
    }
  }
  return await rest.runMethod("delete", endpoints.CHANNEL_BASE(channelId), {
    reason,
  });
}
/** Delete a channel in your server. Bot needs MANAGE_CHANNEL permissions in the server. */
Delete a channel in your server. Bot needs MANAGE_CHANNEL permissions in the server.
Delete a channel in your server . Bot needs MANAGE_CHANNEL permissions in the server .
async function deleteChannel(
  channelId,
  reason,
) {
  const channel = await cacheHandlers.get("channels", channelId);
  if (channel?.guildId) {
    const guild = await cacheHandlers.get("guilds", channel.guildId);
    if (!guild) throw new Error(Errors.GUILD_NOT_FOUND);
    await requireBotGuildPermissions(
      guild,
      [
          ChannelTypes.GuildNewsThread,
          ChannelTypes.GuildPivateThread,
          ChannelTypes.GuildPublicThread,
        ].includes(channel.type)
        ? [
          "MANAGE_THREADS",
        ]
        : [
          "MANAGE_CHANNELS",
        ],
    );
    if (guild.rulesChannelId === channelId) {
      throw new Error(Errors.RULES_CHANNEL_CANNOT_BE_DELETED);
    }
    if (guild.publicUpdatesChannelId === channelId) {
      throw new Error(Errors.UPDATES_CHANNEL_CANNOT_BE_DELETED);
    }
  }
  return await rest.runMethod("delete", endpoints.CHANNEL_BASE(channelId), {
    reason,
  });
}
async function deleteChannel ( channelId , reason , ) { const channel = await cacheHandlers . get ( "channels" , channelId ) ; if ( channel ?. guildId ) { const guild = await cacheHandlers . get ( "guilds" , channel . guildId ) ; if ( ! guild ) throw new Error ( Errors . GUILD_NOT_FOUND ) ; await requireBotGuildPermissions ( guild , [ ChannelTypes . GuildNewsThread , ChannelTypes . GuildPivateThread , ChannelTypes . GuildPublicThread , ] . includes ( channel . type ) ? [ "MANAGE_THREADS" , ] : [ "MANAGE_CHANNELS" , ] , ) ; if ( guild . rulesChannelId === channelId ) { throw new Error ( Errors . RULES_CHANNEL_CANNOT_BE_DELETED ) ; } if ( guild . publicUpdatesChannelId === channelId ) { throw new Error ( Errors . UPDATES_CHANNEL_CANNOT_BE_DELETED ) ; } } return await rest . runMethod ( "delete" , endpoints . CHANNEL_BASE ( channelId ) , { reason , } ) ; }
Delete a channel in your server.
Delete a channel in your server .
// TODO(threads): check if this requires guild perms or channel is enough