Files
TTtie dc3129e2a4 refactor: switch to ESLint flat config, add JSDoc linting (#147)
This commit switches Dysnomia over to ESLint flat config for
futureproofing and better maintainability. For the most part, the
codebase will pass the test suite, apart from a few exceptions
introduced by the stylistic plugin which I believe are reasonable to
include.

Additionally, JSDoc linting was added to maintain proper 
alignment of various features.
2024-08-02 18:56:44 +00:00

63 lines
1.7 KiB
JavaScript

"use strict";
const Collection = require("../util/Collection");
const GuildChannel = require("./GuildChannel");
const PermissionOverwrite = require("./PermissionOverwrite");
/**
* Represents a guild category channel. See GuildChannel for more properties and methods.
* @extends GuildChannel
*/
class CategoryChannel extends GuildChannel {
constructor(data, client) {
super(data, client);
}
update(data, client) {
super.update(data, client);
if(data.permission_overwrites) {
/**
* Collection of PermissionOverwrites in this channel
* @type {Collection<PermissionOverwrite>}
*/
this.permissionOverwrites = new Collection(PermissionOverwrite);
data.permission_overwrites.forEach((overwrite) => {
this.permissionOverwrites.add(overwrite);
});
}
if(data.position !== undefined) {
/**
* The position of the channel
* @type {Number}
*/
this.position = data.position;
}
}
/**
* A collection of guild channels that are part of this category
* @type {Collection<GuildChannel>}
*/
get channels() {
const channels = new Collection(GuildChannel);
if(this.guild?.channels) {
for(const channel of this.guild.channels.values()) {
if(channel.parentID === this.id) {
channels.add(channel);
}
}
}
return channels;
}
toJSON(props = []) {
return super.toJSON([
"permissionOverwrites",
"position",
...props
]);
}
}
module.exports = CategoryChannel;