Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert remaining #client to #_client #1386

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2092,7 +2092,6 @@ declare namespace Eris {
}

export class Channel extends Base {
client: Client;
createdAt: number;
id: string;
mention: string;
Expand Down Expand Up @@ -3340,7 +3339,6 @@ declare namespace Eris {
}

export class Shard extends EventEmitter implements SimpleJSON {
client: Client;
connectAttempts: number;
connecting: boolean;
connectTimeout: NodeJS.Timeout | null;
Expand Down
388 changes: 194 additions & 194 deletions lib/gateway/Shard.js

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions lib/structures/Channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const {ChannelTypes} = require("../Constants");

/**
* Represents a channel. You also probably want to look at CategoryChannel, GroupChannel, NewsChannel, PrivateChannel, TextChannel, and TextVoiceChannel.
* @prop {Client} client The client that initialized the channel
* @prop {Number} createdAt Timestamp of the channel's creation
* @prop {String} id The ID of the channel
* @prop {String} mention A string that mentions the channel
Expand All @@ -15,7 +14,7 @@ class Channel extends Base {
constructor(data, client) {
super(data.id);
this.type = data.type;
this.client = client;
this._client = client;
}

get mention() {
Expand Down
10 changes: 5 additions & 5 deletions lib/structures/GroupChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class GroupChannel extends PrivateChannel { // (╯°□°)╯︵ ┻━┻
}

get iconURL() {
return this.icon ? this.client._formatImage(Endpoints.CHANNEL_ICON(this.id, this.icon)) : null;
return this.icon ? this._client._formatImage(Endpoints.CHANNEL_ICON(this.id, this.icon)) : null;
}

/**
Expand All @@ -49,7 +49,7 @@ class GroupChannel extends PrivateChannel { // (╯°□°)╯︵ ┻━┻
* @returns {Promise}
*/
addRecipient(userID) {
return this.client.addGroupRecipient.call(this.client, this.id, userID);
return this._client.addGroupRecipient.call(this._client, this.id, userID);
}

/**
Expand All @@ -59,7 +59,7 @@ class GroupChannel extends PrivateChannel { // (╯°□°)╯︵ ┻━┻
* @returns {String?}
*/
dynamicIconURL(format, size) {
return this.icon ? this.client._formatImage(Endpoints.CHANNEL_ICON(this.id, this.icon), format, size) : null;
return this.icon ? this._client._formatImage(Endpoints.CHANNEL_ICON(this.id, this.icon), format, size) : null;
}

/**
Expand All @@ -71,7 +71,7 @@ class GroupChannel extends PrivateChannel { // (╯°□°)╯︵ ┻━┻
* @returns {Promise<GroupChannel>}
*/
edit(options) {
return this.client.editChannel.call(this.client, this.id, options);
return this._client.editChannel.call(this._client, this.id, options);
}

/**
Expand All @@ -80,7 +80,7 @@ class GroupChannel extends PrivateChannel { // (╯°□°)╯︵ ┻━┻
* @returns {Promise}
*/
removeRecipient(userID) {
return this.client.removeGroupRecipient.call(this.client, this.id, userID);
return this._client.removeGroupRecipient.call(this._client, this.id, userID);
}

toJSON(props = []) {
Expand Down
6 changes: 3 additions & 3 deletions lib/structures/GuildAuditLogEntry.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class GuildAuditLogEntry extends Base {

this.actionType = data.action_type;
this.reason = data.reason || null;
this.user = guild.shard.client.users.get(data.user_id);
this.user = guild.shard._client.users.get(data.user_id);
this.before = null;
this.after = null;
if(data.changes) {
Expand Down Expand Up @@ -117,13 +117,13 @@ class GuildAuditLogEntry extends Base {
max_uses: changes.max_uses,
max_age: changes.max_age,
temporary: changes.temporary
}, this.guild && this.guild.shard.client);
}, this.guild && this.guild.shard._client);
} else if(this.actionType < 60) { // Webhook
return null; // Go get the webhook yourself
} else if(this.actionType < 70) { // Emoji
return this.guild && this.guild.emojis.find((emoji) => emoji.id === this.targetID);
} else if(this.actionType < 80) { // Message
return this.guild && this.guild.shard.client.users.get(this.targetID);
return this.guild && this.guild.shard._client.users.get(this.targetID);
} else if(this.actionType < 83) { // Integrations
return null;
} else if(this.actionType < 90) { // Stage Instances
Expand Down
10 changes: 5 additions & 5 deletions lib/structures/GuildChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class GuildChannel extends Channel {
* @returns {Promise}
*/
delete(reason) {
return this.client.deleteChannel.call(this.client, this.id, reason);
return this._client.deleteChannel.call(this._client, this.id, reason);
}

/**
Expand All @@ -65,7 +65,7 @@ class GuildChannel extends Channel {
* @returns {Promise}
*/
deletePermission(overwriteID, reason) {
return this.client.deleteChannelPermission.call(this.client, this.id, overwriteID, reason);
return this._client.deleteChannelPermission.call(this._client, this.id, overwriteID, reason);
}

/**
Expand All @@ -91,7 +91,7 @@ class GuildChannel extends Channel {
* @returns {Promise<CategoryChannel | GroupChannel | TextChannel | TextVoiceChannel | NewsChannel | NewsThreadChannel | PrivateThreadChannel | PublicThreadChannel>}
*/
edit(options, reason) {
return this.client.editChannel.call(this.client, this.id, options, reason);
return this._client.editChannel.call(this._client, this.id, options, reason);
}

/**
Expand All @@ -104,7 +104,7 @@ class GuildChannel extends Channel {
* @returns {Promise<PermissionOverwrite>}
*/
editPermission(overwriteID, allow, deny, type, reason) {
return this.client.editChannelPermission.call(this.client, this.id, overwriteID, allow, deny, type, reason);
return this._client.editChannelPermission.call(this._client, this.id, overwriteID, allow, deny, type, reason);
}

/**
Expand All @@ -116,7 +116,7 @@ class GuildChannel extends Channel {
* @returns {Promise}
*/
editPosition(position, options) {
return this.client.editChannelPosition.call(this.client, this.id, position, options);
return this._client.editChannelPosition.call(this._client, this.id, position, options);
}

/**
Expand Down
8 changes: 4 additions & 4 deletions lib/structures/GuildIntegration.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class GuildIntegration extends Base {
this.roleID = data.role_id;
}
if(data.user) {
this.user = guild.shard.client.users.add(data.user, guild.shard.client);
this.user = guild.shard._client.users.add(data.user, guild.shard._client);
}
this.account = data.account; // not worth making a class for
this.update(data);
Expand Down Expand Up @@ -72,7 +72,7 @@ class GuildIntegration extends Base {
* @returns {Promise}
*/
delete() {
return this.guild.shard.client.deleteGuildIntegration.call(this.guild.shard.client, this.guild.id, this.id);
return this.guild.shard._client.deleteGuildIntegration.call(this.guild.shard._client, this.guild.id, this.id);
}

/**
Expand All @@ -84,15 +84,15 @@ class GuildIntegration extends Base {
* @returns {Promise}
*/
edit(options) {
return this.guild.shard.client.editGuildIntegration.call(this.guild.shard.client, this.guild.id, this.id, options);
return this.guild.shard._client.editGuildIntegration.call(this.guild.shard._client, this.guild.id, this.id, options);
}

/**
* Force the guild integration to sync
* @returns {Promise}
*/
sync() {
return this.guild.shard.client.syncGuildIntegration.call(this.guild.shard.client, this.guild.id, this.id);
return this.guild.shard._client.syncGuildIntegration.call(this.guild.shard._client, this.guild.id, this.id);
}

toJSON(props = []) {
Expand Down
20 changes: 10 additions & 10 deletions lib/structures/Member.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ class Member extends Base {
data.id = data.user.id;
}
if((this.guild = guild)) {
this.user = guild.shard.client.users.get(data.id);
this.user = guild.shard._client.users.get(data.id);
if(!this.user && data.user) {
this.user = guild.shard.client.users.add(data.user, guild.shard.client);
this.user = guild.shard._client.users.add(data.user, guild.shard._client);
}
if(!this.user) {
throw new Error("User associated with Member not found: " + data.id);
Expand Down Expand Up @@ -124,7 +124,7 @@ class Member extends Base {
}

get avatarURL() {
return this.avatar ? this.guild.shard.client._formatImage(Endpoints.GUILD_AVATAR(this.guild.id, this.id, this.avatar)) : this.user.avatarURL;
return this.avatar ? this.guild.shard._client._formatImage(Endpoints.GUILD_AVATAR(this.guild.id, this.id, this.avatar)) : this.user.avatarURL;
}

get banner() {
Expand Down Expand Up @@ -160,7 +160,7 @@ class Member extends Base {
}

get permission() {
this.guild.shard.client.emit("warn", "[DEPRECATED] Member#permission is deprecated. Use Member#permissions instead");
this.guild.shard._client.emit("warn", "[DEPRECATED] Member#permission is deprecated. Use Member#permissions instead");
return this.permissions;
}

Expand Down Expand Up @@ -197,7 +197,7 @@ class Member extends Base {
* @returns {Promise}
*/
addRole(roleID, reason) {
return this.guild.shard.client.addGuildMemberRole.call(this.guild.shard.client, this.guild.id, this.id, roleID, reason);
return this.guild.shard._client.addGuildMemberRole.call(this.guild.shard._client, this.guild.id, this.id, roleID, reason);
}

/**
Expand All @@ -207,7 +207,7 @@ class Member extends Base {
* @returns {Promise}
*/
ban(deleteMessageDays, reason) {
return this.guild.shard.client.banGuildMember.call(this.guild.shard.client, this.guild.id, this.id, deleteMessageDays, reason);
return this.guild.shard._client.banGuildMember.call(this.guild.shard._client, this.guild.id, this.id, deleteMessageDays, reason);
}

/**
Expand All @@ -223,7 +223,7 @@ class Member extends Base {
* @returns {Promise}
*/
edit(options, reason) {
return this.guild.shard.client.editGuildMember.call(this.guild.shard.client, this.guild.id, this.id, options, reason);
return this.guild.shard._client.editGuildMember.call(this.guild.shard._client, this.guild.id, this.id, options, reason);
}

/**
Expand All @@ -245,7 +245,7 @@ class Member extends Base {
* @returns {Promise}
*/
kick(reason) {
return this.guild.shard.client.kickGuildMember.call(this.guild.shard.client, this.guild.id, this.id, reason);
return this.guild.shard._client.kickGuildMember.call(this.guild.shard._client, this.guild.id, this.id, reason);
}

/**
Expand All @@ -255,7 +255,7 @@ class Member extends Base {
* @returns {Promise}
*/
removeRole(roleID, reason) {
return this.guild.shard.client.removeGuildMemberRole.call(this.guild.shard.client, this.guild.id, this.id, roleID, reason);
return this.guild.shard._client.removeGuildMemberRole.call(this.guild.shard._client, this.guild.id, this.id, roleID, reason);
}

/**
Expand All @@ -264,7 +264,7 @@ class Member extends Base {
* @returns {Promise}
*/
unban(reason) {
return this.guild.shard.client.unbanGuildMember.call(this.guild.shard.client, this.guild.id, this.id, reason);
return this.guild.shard._client.unbanGuildMember.call(this.guild.shard._client, this.guild.id, this.id, reason);
}

toJSON(props = []) {
Expand Down
4 changes: 2 additions & 2 deletions lib/structures/NewsChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class NewsChannel extends TextChannel {
* @returns {Promise<Message>}
*/
crosspostMessage(messageID) {
return this.client.crosspostMessage.call(this.client, this.id, messageID);
return this._client.crosspostMessage.call(this._client, this.id, messageID);
}

/**
Expand All @@ -27,7 +27,7 @@ class NewsChannel extends TextChannel {
* @returns {Object} An object containing this channel's ID and the new webhook's ID
*/
follow(webhookChannelID) {
return this.client.followChannel.call(this.client, this.id, webhookChannelID);
return this._client.followChannel.call(this._client, this.id, webhookChannelID);
}
}

Expand Down
Loading