summaryrefslogtreecommitdiff
path: root/node_modules/discord.js/src/client/ClientDataManager.js
diff options
context:
space:
mode:
author8cy <[email protected]>2020-04-03 02:48:28 -0700
committer8cy <[email protected]>2020-04-03 02:48:28 -0700
commitf9159ea2d994e14180fb02ab562f0119513e67cf (patch)
tree09d14cdf05456567156738b681379d4bccd64e5c /node_modules/discord.js/src/client/ClientDataManager.js
parent2020/04/03, 02:42, V1.2.1 (diff)
downloads5nical-f9159ea2d994e14180fb02ab562f0119513e67cf.tar.xz
s5nical-f9159ea2d994e14180fb02ab562f0119513e67cf.zip
2020/04/03, 02:47, V1.2.2
Diffstat (limited to 'node_modules/discord.js/src/client/ClientDataManager.js')
-rw-r--r--node_modules/discord.js/src/client/ClientDataManager.js149
1 files changed, 0 insertions, 149 deletions
diff --git a/node_modules/discord.js/src/client/ClientDataManager.js b/node_modules/discord.js/src/client/ClientDataManager.js
deleted file mode 100644
index 4f0f2d7..0000000
--- a/node_modules/discord.js/src/client/ClientDataManager.js
+++ /dev/null
@@ -1,149 +0,0 @@
-const Constants = require('../util/Constants');
-const Util = require('../util/Util');
-const Guild = require('../structures/Guild');
-const User = require('../structures/User');
-const Emoji = require('../structures/Emoji');
-const GuildChannel = require('../structures/GuildChannel');
-const TextChannel = require('../structures/TextChannel');
-const VoiceChannel = require('../structures/VoiceChannel');
-const CategoryChannel = require('../structures/CategoryChannel');
-const NewsChannel = require('../structures/NewsChannel');
-const StoreChannel = require('../structures/StoreChannel');
-const DMChannel = require('../structures/DMChannel');
-const GroupDMChannel = require('../structures/GroupDMChannel');
-
-class ClientDataManager {
- constructor(client) {
- this.client = client;
- }
-
- get pastReady() {
- return this.client.ws.connection.status === Constants.Status.READY;
- }
-
- newGuild(data) {
- const already = this.client.guilds.has(data.id);
- const guild = new Guild(this.client, data);
- this.client.guilds.set(guild.id, guild);
- if (this.pastReady && !already) {
- /**
- * Emitted whenever the client joins a guild.
- * @event Client#guildCreate
- * @param {Guild} guild The created guild
- */
- if (this.client.options.fetchAllMembers) {
- guild.fetchMembers().then(() => { this.client.emit(Constants.Events.GUILD_CREATE, guild); });
- } else {
- this.client.emit(Constants.Events.GUILD_CREATE, guild);
- }
- }
-
- return guild;
- }
-
- newUser(data, cache = true) {
- if (this.client.users.has(data.id)) return this.client.users.get(data.id);
- const user = new User(this.client, data);
- if (cache) this.client.users.set(user.id, user);
- return user;
- }
-
- newChannel(data, guild) {
- const already = this.client.channels.has(data.id);
- let channel;
- if (data.type === Constants.ChannelTypes.DM) {
- channel = new DMChannel(this.client, data);
- } else if (data.type === Constants.ChannelTypes.GROUP_DM) {
- channel = new GroupDMChannel(this.client, data);
- } else {
- guild = guild || this.client.guilds.get(data.guild_id);
- if (already) {
- channel = this.client.channels.get(data.id);
- } else if (guild) {
- switch (data.type) {
- case Constants.ChannelTypes.TEXT:
- channel = new TextChannel(guild, data);
- break;
- case Constants.ChannelTypes.VOICE:
- channel = new VoiceChannel(guild, data);
- break;
- case Constants.ChannelTypes.CATEGORY:
- channel = new CategoryChannel(guild, data);
- break;
- case Constants.ChannelTypes.NEWS:
- channel = new NewsChannel(guild, data);
- break;
- case Constants.ChannelTypes.STORE:
- channel = new StoreChannel(guild, data);
- break;
- }
-
- guild.channels.set(channel.id, channel);
- }
- }
-
- if (channel && !already) {
- if (this.pastReady) this.client.emit(Constants.Events.CHANNEL_CREATE, channel);
- this.client.channels.set(channel.id, channel);
- return channel;
- } else if (already) {
- return channel;
- }
-
- return null;
- }
-
- newEmoji(data, guild) {
- const already = guild.emojis.has(data.id);
- if (data && !already) {
- let emoji = new Emoji(guild, data);
- this.client.emit(Constants.Events.GUILD_EMOJI_CREATE, emoji);
- guild.emojis.set(emoji.id, emoji);
- return emoji;
- } else if (already) {
- return guild.emojis.get(data.id);
- }
-
- return null;
- }
-
- killEmoji(emoji) {
- if (!(emoji instanceof Emoji && emoji.guild)) return;
- this.client.emit(Constants.Events.GUILD_EMOJI_DELETE, emoji);
- emoji.guild.emojis.delete(emoji.id);
- }
-
- killGuild(guild) {
- const already = this.client.guilds.has(guild.id);
- this.client.guilds.delete(guild.id);
- if (already && this.pastReady) this.client.emit(Constants.Events.GUILD_DELETE, guild);
- }
-
- killUser(user) {
- this.client.users.delete(user.id);
- }
-
- killChannel(channel) {
- this.client.channels.delete(channel.id);
- if (channel instanceof GuildChannel) channel.guild.channels.delete(channel.id);
- }
-
- updateGuild(currentGuild, newData) {
- const oldGuild = Util.cloneObject(currentGuild);
- currentGuild.setup(newData);
- if (this.pastReady) this.client.emit(Constants.Events.GUILD_UPDATE, oldGuild, currentGuild);
- }
-
- updateChannel(currentChannel, newData) {
- currentChannel.setup(newData);
- }
-
- updateEmoji(currentEmoji, newData) {
- const oldEmoji = Util.cloneObject(currentEmoji);
- currentEmoji.setup(newData);
- this.client.emit(Constants.Events.GUILD_EMOJI_UPDATE, oldEmoji, currentEmoji);
- return currentEmoji;
- }
-}
-
-module.exports = ClientDataManager;