mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 16:43:31 +01:00
45 lines
785 B
JavaScript
45 lines
785 B
JavaScript
/**
|
|
* Represents any Channel on Discord
|
|
*/
|
|
class Channel {
|
|
constructor(client, data, guild) {
|
|
/**
|
|
* The client that instantiated the Channel
|
|
* @type {Channel}
|
|
*/
|
|
this.client = client;
|
|
this.typingMap = {};
|
|
this.typingTimeouts = [];
|
|
if (guild) {
|
|
this.guild = guild;
|
|
}
|
|
|
|
if (data) {
|
|
this.setup(data);
|
|
}
|
|
}
|
|
|
|
setup(data) {
|
|
/**
|
|
* The unique ID of the channel
|
|
* @type {String}
|
|
*/
|
|
this.id = data.id;
|
|
}
|
|
|
|
/**
|
|
* Deletes the channel
|
|
* @return {Promise<Channel>}
|
|
* @example
|
|
* // delete the channel
|
|
* channel.delete()
|
|
* .then() // success
|
|
* .catch(console.log); // log error
|
|
*/
|
|
delete() {
|
|
return this.client.rest.methods.deleteChannel(this);
|
|
}
|
|
}
|
|
|
|
module.exports = Channel;
|