Skip to content

Commit

Permalink
Allow some channel types to not depend on Client
Browse files Browse the repository at this point in the history
  • Loading branch information
TTtie committed Oct 25, 2023
1 parent d42e242 commit 22f1ea3
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/structures/GuildChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class GuildChannel extends Channel {
* The guild that owns the channel
* @type {Guild}
*/
this.guild = client.guilds.get(data.guild_id) || {
this.guild = client?.guilds.get(data.guild_id) || {
id: data.guild_id
};

Expand Down
4 changes: 2 additions & 2 deletions lib/structures/PrivateChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const Channel = require("./Channel");
const Collection = require("../util/Collection");
const Message = require("./Message");
const {ChannelTypes} = require("../Constants");
const {ChannelTypes, DefaultClientOptions} = require("../Constants");
const User = require("./User");

/**
Expand Down Expand Up @@ -33,7 +33,7 @@ class PrivateChannel extends Channel {
* Collection of Messages in this channel
* @type {Collection<Message>}
*/
this.messages = new Collection(Message, client.options.messageLimit);
this.messages = new Collection(Message, client?.options.messageLimit ?? DefaultClientOptions.messageLimit);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion lib/structures/TextChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const Collection = require("../util/Collection");
const GuildChannel = require("./GuildChannel");
const Message = require("./Message");
const PermissionOverwrite = require("./PermissionOverwrite");
const Constants = require("../Constants");

/**
* Represents a guild text channel. See GuildChannel for more properties and methods.
Expand All @@ -18,7 +19,7 @@ class TextChannel extends GuildChannel {
* Collection of Messages in this channel
* @type {Collection<Message>}
*/
this.messages = new Collection(Message, messageLimit == null ? client.options.messageLimit : messageLimit);
this.messages = new Collection(Message, messageLimit == null ? (client?.options.messageLimit ?? Constants.DefaultClientOptions.messageLimit) : messageLimit);
/**
* The ID of the last message in this channel
* @type {String?}
Expand Down
3 changes: 2 additions & 1 deletion lib/structures/TextVoiceChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const VoiceChannel = require("./VoiceChannel");
const Collection = require("../util/Collection");
const Message = require("./Message");
const Constants = require("../Constants");

/**
* Represents a Text-in-Voice channel. See VoiceChannel for more properties and methods.
Expand All @@ -17,7 +18,7 @@ class TextVoiceChannel extends VoiceChannel {
* Collection of Messages in this channel
* @type {Collection<Message>}
*/
this.messages = new Collection(Message, messageLimit == null ? client.options.messageLimit : messageLimit);
this.messages = new Collection(Message, messageLimit == null ? (client.options.messageLimit ?? Constants.DefaultClientOptions.messageLimit) : messageLimit);
/**
* Whether the channel is an NSFW channel or not
* @type {Boolean}
Expand Down

0 comments on commit 22f1ea3

Please sign in to comment.