mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-19 04:53:30 +01:00
Remove partial classes (#1794)
* remove partial objects * remove partial evil * Update Invite.js * Update Invite.js
This commit is contained in:
@@ -47,8 +47,6 @@ module.exports = {
|
|||||||
MessageMentions: require('./structures/MessageMentions'),
|
MessageMentions: require('./structures/MessageMentions'),
|
||||||
MessageReaction: require('./structures/MessageReaction'),
|
MessageReaction: require('./structures/MessageReaction'),
|
||||||
ClientApplication: require('./structures/ClientApplication'),
|
ClientApplication: require('./structures/ClientApplication'),
|
||||||
PartialGuild: require('./structures/PartialGuild'),
|
|
||||||
PartialGuildChannel: require('./structures/PartialGuildChannel'),
|
|
||||||
PermissionOverwrites: require('./structures/PermissionOverwrites'),
|
PermissionOverwrites: require('./structures/PermissionOverwrites'),
|
||||||
Presence: require('./structures/Presence').Presence,
|
Presence: require('./structures/Presence').Presence,
|
||||||
ReactionEmoji: require('./structures/ReactionEmoji'),
|
ReactionEmoji: require('./structures/ReactionEmoji'),
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ class Guild {
|
|||||||
* @param {*} data The raw data of the guild
|
* @param {*} data The raw data of the guild
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
setup(data) {
|
setup(data) { // eslint-disable-line complexity
|
||||||
/**
|
/**
|
||||||
* The name of the guild
|
* The name of the guild
|
||||||
* @type {string}
|
* @type {string}
|
||||||
@@ -225,7 +225,7 @@ class Guild {
|
|||||||
* @type {Collection<Snowflake, Emoji>}
|
* @type {Collection<Snowflake, Emoji>}
|
||||||
*/
|
*/
|
||||||
this.emojis = new Collection();
|
this.emojis = new Collection();
|
||||||
for (const emoji of data.emojis) this.emojis.set(emoji.id, new Emoji(this, emoji));
|
if (data.emojis) for (const emoji of data.emojis) this.emojis.set(emoji.id, new Emoji(this, emoji));
|
||||||
} else {
|
} else {
|
||||||
this.client.actions.GuildEmojisUpdate.handle({
|
this.client.actions.GuildEmojisUpdate.handle({
|
||||||
guild_id: this.id,
|
guild_id: this.id,
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
const PartialGuild = require('./PartialGuild');
|
|
||||||
const PartialGuildChannel = require('./PartialGuildChannel');
|
|
||||||
const Constants = require('../util/Constants');
|
const Constants = require('../util/Constants');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -20,12 +18,14 @@ class Invite {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setup(data) {
|
setup(data) {
|
||||||
|
const Guild = require('./Guild');
|
||||||
|
const Channel = require('./Channel');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The guild the invite is for. If this guild is already known, this will be a guild object. If the guild is
|
* The guild the invite is for
|
||||||
* unknown, this will be a PartialGuild object
|
* @type {Guild}
|
||||||
* @type {Guild|PartialGuild}
|
|
||||||
*/
|
*/
|
||||||
this.guild = this.client.guilds.get(data.guild.id) || new PartialGuild(this.client, data.guild);
|
this.guild = this.client.guilds.get(data.guild.id) || new Guild(this.client, data.guild);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The code for this invite
|
* The code for this invite
|
||||||
@@ -90,11 +90,10 @@ class Invite {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The channel the invite is for. If this channel is already known, this will be a GuildChannel object.
|
* The channel the invite is for
|
||||||
* If the channel is unknown, this will be a PartialGuildChannel object.
|
* @type {GuildChannel}
|
||||||
* @type {GuildChannel|PartialGuildChannel}
|
|
||||||
*/
|
*/
|
||||||
this.channel = this.client.channels.get(data.channel.id) || new PartialGuildChannel(this.client, data.channel);
|
this.channel = this.client.channels.get(data.channel.id) || Channel.create(this.client, data.channel, this.guild);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The timestamp the invite was created at
|
* The timestamp the invite was created at
|
||||||
|
|||||||
@@ -1,51 +0,0 @@
|
|||||||
/*
|
|
||||||
{ splash: null,
|
|
||||||
id: '123123123',
|
|
||||||
icon: '123123123',
|
|
||||||
name: 'name' }
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a guild that the client only has limited information for - e.g. from invites.
|
|
||||||
*/
|
|
||||||
class PartialGuild {
|
|
||||||
constructor(client, data) {
|
|
||||||
/**
|
|
||||||
* The client that instantiated this PartialGuild
|
|
||||||
* @name PartialGuild#client
|
|
||||||
* @type {Client}
|
|
||||||
* @readonly
|
|
||||||
*/
|
|
||||||
Object.defineProperty(this, 'client', { value: client });
|
|
||||||
|
|
||||||
this.setup(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
setup(data) {
|
|
||||||
/**
|
|
||||||
* The ID of this guild
|
|
||||||
* @type {Snowflake}
|
|
||||||
*/
|
|
||||||
this.id = data.id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The name of this guild
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
this.name = data.name;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The hash of this guild's icon
|
|
||||||
* @type {?string}
|
|
||||||
*/
|
|
||||||
this.icon = data.icon;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The hash of the guild splash image (VIP only)
|
|
||||||
* @type {?string}
|
|
||||||
*/
|
|
||||||
this.splash = data.splash;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = PartialGuild;
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
const Constants = require('../util/Constants');
|
|
||||||
|
|
||||||
/*
|
|
||||||
{ type: 0, id: '123123', name: 'heavy-testing' } }
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a guild channel that the client only has limited information for - e.g. from invites.
|
|
||||||
*/
|
|
||||||
class PartialGuildChannel {
|
|
||||||
constructor(client, data) {
|
|
||||||
/**
|
|
||||||
* The client that instantiated this PartialGuildChannel
|
|
||||||
* @name PartialGuildChannel#client
|
|
||||||
* @type {Client}
|
|
||||||
* @readonly
|
|
||||||
*/
|
|
||||||
Object.defineProperty(this, 'client', { value: client });
|
|
||||||
|
|
||||||
this.setup(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
setup(data) {
|
|
||||||
/**
|
|
||||||
* The ID of this guild channel
|
|
||||||
* @type {Snowflake}
|
|
||||||
*/
|
|
||||||
this.id = data.id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The name of this guild channel
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
this.name = data.name;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The type of this guild channel - `text` or `voice`
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
this.type = Constants.ChannelTypes.TEXT === data.type ? 'text' : 'voice';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = PartialGuildChannel;
|
|
||||||
@@ -14,7 +14,7 @@ class VoiceChannel extends GuildChannel {
|
|||||||
* The members in this voice channel
|
* The members in this voice channel
|
||||||
* @type {Collection<Snowflake, GuildMember>}
|
* @type {Collection<Snowflake, GuildMember>}
|
||||||
*/
|
*/
|
||||||
this.members = new Collection();
|
Object.defineProperty(this, 'members', { value: new Collection() });
|
||||||
}
|
}
|
||||||
|
|
||||||
setup(data) {
|
setup(data) {
|
||||||
|
|||||||
Reference in New Issue
Block a user