mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-13 01:53:30 +01:00
feat(GuildChannel): support conversion between text and news (#5022)
* feat(GuildChannel): support conversion between text and news * fix(Typings): add type to ChannelData * fix(GuildChannel): use ChannelUpdate action handler to change class type * Update src/structures/TextChannel.js Co-authored-by: Sugden <28943913+NotSugden@users.noreply.github.com> * fix(Typings): re-use ChannelType from GuildCreateChannelOptions * fix(Typings): only allow text-news conversion * fix(Typings): exclude -> pick (vlads suggestion) * fix(Typings): pick -> exclude in two other spots Co-authored-by: Sugden <28943913+NotSugden@users.noreply.github.com>
This commit is contained in:
@@ -6,6 +6,7 @@ const PermissionOverwrites = require('./PermissionOverwrites');
|
||||
const Role = require('./Role');
|
||||
const { Error, TypeError } = require('../errors');
|
||||
const Collection = require('../util/Collection');
|
||||
const { ChannelTypes } = require('../util/Constants');
|
||||
const Permissions = require('../util/Permissions');
|
||||
const Util = require('../util/Util');
|
||||
|
||||
@@ -294,6 +295,7 @@ class GuildChannel extends Channel {
|
||||
* The data for a guild channel.
|
||||
* @typedef {Object} ChannelData
|
||||
* @property {string} [name] The name of the channel
|
||||
* @property {string} [type] The type of the the channel (only conversion between text and news is supported)
|
||||
* @property {number} [position] The position of the channel
|
||||
* @property {string} [topic] The topic of the text channel
|
||||
* @property {boolean} [nsfw] Whether the channel is NSFW
|
||||
@@ -355,6 +357,7 @@ class GuildChannel extends Channel {
|
||||
const newData = await this.client.api.channels(this.id).patch({
|
||||
data: {
|
||||
name: (data.name || this.name).trim(),
|
||||
type: data.type ? ChannelTypes[data.type.toUpperCase()] : this.type,
|
||||
topic: data.topic,
|
||||
nsfw: data.nsfw,
|
||||
bitrate: data.bitrate || this.bitrate,
|
||||
@@ -367,9 +370,7 @@ class GuildChannel extends Channel {
|
||||
reason,
|
||||
});
|
||||
|
||||
const clone = this._clone();
|
||||
clone._patch(newData);
|
||||
return clone;
|
||||
return this.client.actions.ChannelUpdate.handle(newData).updated;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user