Skip to content

Commit

Permalink
threads do not have permission overwrites (and linting)
Browse files Browse the repository at this point in the history
  • Loading branch information
DonovanDMC committed Aug 7, 2022
1 parent 37e98c2 commit 842333f
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 18 deletions.
21 changes: 12 additions & 9 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1757,9 +1757,9 @@ declare namespace Eris {
AGE_RESTRICTED: 3;
};
HubTypes: {
DEFAULT: 0;
HIGH_SCHOOL: 1;
COLLEGE: 2;
DEFAULT: 0;
HIGH_SCHOOL: 1;
COLLEGE: 2;
};
ImageFormats: [
"jpg",
Expand Down Expand Up @@ -1978,8 +1978,8 @@ declare namespace Eris {
"Yay you made it, %user%!"
];
TextComponentStyle: {
SMALL: 1,
PARAGRAPH: 2
SMALL: 1;
PARAGRAPH: 2;
};
ThreadMemberFlags: {
HAS_INTERACTED: 1;
Expand Down Expand Up @@ -2100,7 +2100,7 @@ declare namespace Eris {
connected_accounts: { id: string; name: string; type: string; verified: boolean }[];
mutual_guilds: { id: string; nick?: string }[];
premium_since?: number;
user: PartialUser
user: PartialUser;
}
interface UserSettings {
afk_timeout: number;
Expand Down Expand Up @@ -2184,6 +2184,7 @@ declare namespace Eris {

export class CategoryChannel extends GuildChannel {
channels: Collection<Exclude<AnyGuildChannel, CategoryChannel>>;
permissionOverwrites: Collection<PermissionOverwrite>;
type: Constants["ChannelTypes"]["GUILD_CATEGORY"];
edit(options: Omit<CreateChannelOptions, "permissionOverwrites" | "reason">, reason?: string): Promise<this>;
}
Expand Down Expand Up @@ -2927,7 +2928,6 @@ declare namespace Eris {
name: string;
nsfw: boolean;
parentID: string | null;
permissionOverwrites: Collection<PermissionOverwrite>;
position: number;
type: GuildChannelTypes;
constructor(data: BaseData, client: Client);
Expand Down Expand Up @@ -3010,10 +3010,10 @@ declare namespace Eris {
}

export class TextVoiceChannel extends VoiceChannel implements GuildTextable {
type: Constants["ChannelTypes"]["GUILD_VOICE"];
lastMessageID: string;
messages: Collection<Message<this>>;
rateLimitPerUser: number;
type: Constants["ChannelTypes"]["GUILD_VOICE"];
userLimit: number;
videoQualityMode: VideoQualityMode;
addMessageReaction(messageID: string, reaction: string): Promise<void>;
Expand Down Expand Up @@ -3166,14 +3166,14 @@ declare namespace Eris {
code: string;
// @ts-ignore: Property is only not null when invite metadata is supplied
createdAt: CT extends "withMetadata" ? number : null;
expiresAt?: CT extends "withMetadata" | "withoutExpiration" ? never : number;
guild: CT extends "withMetadata"
? Guild // Invite with Metadata always has guild prop
: CH extends Extract<InviteChannel, GroupChannel> // Invite without Metadata
? never // If the channel is GroupChannel, there is no guild
: CH extends Exclude<InviteChannel, InvitePartialChannel> // Invite without Metadata and not GroupChanel
? Guild // If the invite channel is not partial
: Guild | undefined; // If the invite channel is partial
expiresAt?: CT extends "withMetadata" | "withoutExpiration" ? never : number;
inviter?: User;
maxAge: CT extends "withMetadata" ? number : null;
maxUses: CT extends "withMetadata" ? number : null;
Expand Down Expand Up @@ -3572,6 +3572,7 @@ declare namespace Eris {
}

export class StoreChannel extends GuildChannel {
permissionOverwrites: Collection<PermissionOverwrite>;
type: Constants["ChannelTypes"]["GUILD_STORE"];
edit(options: Omit<EditChannelOptions, "icon" | "ownerID">, reason?: string): Promise<this>;
}
Expand All @@ -3581,6 +3582,7 @@ declare namespace Eris {
lastMessageID: string;
lastPinTimestamp: number | null;
messages: Collection<Message<this>>;
permissionOverwrites: Collection<PermissionOverwrite>;
rateLimitPerUser: number;
topic?: string | null;
type: GuildTextChannelTypes;
Expand Down Expand Up @@ -3712,6 +3714,7 @@ declare namespace Eris {

export class VoiceChannel extends GuildChannel implements Invitable {
bitrate: number;
permissionOverwrites: Collection<PermissionOverwrite>;
rtcRegion: string | null;
type: GuildVoiceChannelTypes;
voiceMembers: Collection<Member>;
Expand Down
19 changes: 19 additions & 0 deletions lib/structures/CategoryChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,30 @@

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
* @prop {Collection<GuildChannel>} channels A collection of guild channels that are part of this category
* @prop {Collection<PermissionOverwrite>} permissionOverwrites Collection of PermissionOverwrites in this channel
*/
class CategoryChannel extends GuildChannel {
constructor(data, client) {
super(data, client);
this.update(data);
}

update(data) {
super.update(data);
if(data.permission_overwrites) {
this.permissionOverwrites = new Collection(PermissionOverwrite);
data.permission_overwrites.forEach((overwrite) => {
this.permissionOverwrites.add(overwrite);
});
}
}

get channels() {
const channels = new Collection(GuildChannel);
if(this.guild && this.guild.channels) {
Expand All @@ -20,6 +37,8 @@ class CategoryChannel extends GuildChannel {
}
return channels;
}


}

module.exports = CategoryChannel;
9 changes: 0 additions & 9 deletions lib/structures/GuildChannel.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
"use strict";

const Channel = require("./Channel");
const Collection = require("../util/Collection");
const Permission = require("./Permission");
const {Permissions} = require("../Constants");
const PermissionOverwrite = require("./PermissionOverwrite");

/**
* Represents a guild channel. You also probably want to look at CategoryChannel, NewsChannel, StoreChannel, TextChannel, ThreadChannel, and TextVoiceChannel. See Channel for extra properties.
Expand All @@ -13,7 +11,6 @@ const PermissionOverwrite = require("./PermissionOverwrite");
* @prop {String} id The ID of the channel
* @prop {String} name The name of the channel
* @prop {String?} parentID The ID of the category this channel belongs to or the channel ID where the thread originated from (thread channels only)
* @prop {Collection<PermissionOverwrite>} permissionOverwrites Collection of PermissionOverwrites in this channel
* @prop {Number} position The position of the channel
*/
class GuildChannel extends Channel {
Expand All @@ -39,12 +36,6 @@ class GuildChannel extends Channel {
if(data.parent_id !== undefined) {
this.parentID = data.parent_id;
}
if(data.permission_overwrites) {
this.permissionOverwrites = new Collection(PermissionOverwrite);
data.permission_overwrites.forEach((overwrite) => {
this.permissionOverwrites.add(overwrite);
});
}
}

/**
Expand Down
17 changes: 17 additions & 0 deletions lib/structures/StoreChannel.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
"use strict";

const Collection = require("../util/Collection");
const GuildChannel = require("./GuildChannel");
const PermissionOverwrite = require("./PermissionOverwrite");

/**
* Represents a store channel. See GuildChannel for more properties and methods. Bots cannot read or send messages in a store channel.
* @prop {Collection<PermissionOverwrite>} permissionOverwrites Collection of PermissionOverwrites in this channel
* @extends GuildChannel
*/
class StoreChannel extends GuildChannel {
constructor(data, client) {
super(data, client);
this.update(data);
}

update(data) {
super.update(data);
if(data.permission_overwrites) {
this.permissionOverwrites = new Collection(PermissionOverwrite);
data.permission_overwrites.forEach((overwrite) => {
this.permissionOverwrites.add(overwrite);
});
}
}
}

module.exports = StoreChannel;
8 changes: 8 additions & 0 deletions lib/structures/TextChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const Collection = require("../util/Collection");
const GuildChannel = require("./GuildChannel");
const Message = require("./Message");
const PermissionOverwrite = require("./PermissionOverwrite");

/**
* Represents a guild text channel. See GuildChannel for more properties and methods.
Expand All @@ -11,6 +12,7 @@ const Message = require("./Message");
* @prop {String} lastMessageID The ID of the last message in this channel
* @prop {Number} lastPinTimestamp The timestamp of the last pinned message
* @prop {Collection<Message>} messages Collection of Messages in this channel
* @prop {Collection<PermissionOverwrite>} permissionOverwrites Collection of PermissionOverwrites in this channel
* @prop {Number} rateLimitPerUser The ratelimit of the channel, in seconds. 0 means no ratelimit is enabled
* @prop {String?} topic The topic of the channel
*/
Expand All @@ -35,6 +37,12 @@ class TextChannel extends GuildChannel {
if(data.default_auto_archive_duration !== undefined) {
this.defaultAutoArchiveDuration = data.default_auto_archive_duration;
}
if(data.permission_overwrites) {
this.permissionOverwrites = new Collection(PermissionOverwrite);
data.permission_overwrites.forEach((overwrite) => {
this.permissionOverwrites.add(overwrite);
});
}
}

/**
Expand Down
8 changes: 8 additions & 0 deletions lib/structures/VoiceChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
const Collection = require("../util/Collection");
const GuildChannel = require("./GuildChannel");
const Member = require("./Member");
const PermissionOverwrite = require("./PermissionOverwrite");

/**
* Represents a guild voice channel. See GuildChannel for more properties and methods.
* @extends GuildChannel
* @prop {Number?} bitrate The bitrate of the channel
* @prop {Collection<PermissionOverwrite>} permissionOverwrites Collection of PermissionOverwrites in this channel
* @prop {String?} rtcRegion The RTC region ID of the channel (automatic when `null`)
* @prop {String?} topic The topic of the channel
* @prop {Collection<Member>} voiceMembers Collection of Members in this channel
Expand All @@ -28,6 +30,12 @@ class VoiceChannel extends GuildChannel {
if(data.rtc_region !== undefined) {
this.rtcRegion = data.rtc_region;
}
if(data.permission_overwrites) {
this.permissionOverwrites = new Collection(PermissionOverwrite);
data.permission_overwrites.forEach((overwrite) => {
this.permissionOverwrites.add(overwrite);
});
}
}

/**
Expand Down

0 comments on commit 842333f

Please sign in to comment.