mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 00:23:30 +01:00
ESLint stuff...
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const AbstractDataStore = require('./AbstractDataStore');
|
||||
const Constants = require('../../util/Constants');
|
||||
const CloneObject = require('../../util/CloneObject');
|
||||
const cloneObject = require('../../util/CloneObject');
|
||||
const Guild = require('../Guild');
|
||||
const User = require('../User');
|
||||
const DMChannel = require('../DMChannel');
|
||||
@@ -10,98 +8,99 @@ const TextChannel = require('../TextChannel');
|
||||
const VoiceChannel = require('../VoiceChannel');
|
||||
const ServerChannel = require('../ServerChannel');
|
||||
|
||||
class ClientDataStore extends AbstractDataStore{
|
||||
constructor(client) {
|
||||
super();
|
||||
class ClientDataStore extends AbstractDataStore {
|
||||
constructor(client) {
|
||||
super();
|
||||
|
||||
this.client = client;
|
||||
this.token = null;
|
||||
this.session = null;
|
||||
this.user = null;
|
||||
this.email = null;
|
||||
this.password = null;
|
||||
this.client = client;
|
||||
this.token = null;
|
||||
this.session = null;
|
||||
this.user = null;
|
||||
this.email = null;
|
||||
this.password = null;
|
||||
|
||||
this.register('users');
|
||||
this.register('guilds');
|
||||
this.register('channels');
|
||||
}
|
||||
this.register('users');
|
||||
this.register('guilds');
|
||||
this.register('channels');
|
||||
}
|
||||
|
||||
get pastReady() {
|
||||
return this.client.ws.status === Constants.Status.READY;
|
||||
}
|
||||
get pastReady() {
|
||||
return this.client.ws.status === Constants.Status.READY;
|
||||
}
|
||||
|
||||
NewGuild(data) {
|
||||
let already = this.get('guilds', data.id);
|
||||
let guild = this.add('guilds', new Guild(this.client, data));
|
||||
if (this.pastReady && !already) {
|
||||
this.client.emit(Constants.Events.GUILD_CREATE, guild);
|
||||
}
|
||||
newGuild(data) {
|
||||
const already = this.get('guilds', data.id);
|
||||
const guild = this.add('guilds', new Guild(this.client, data));
|
||||
if (this.pastReady && !already) {
|
||||
this.client.emit(Constants.Events.GUILD_CREATE, guild);
|
||||
}
|
||||
|
||||
return guild;
|
||||
}
|
||||
return guild;
|
||||
}
|
||||
|
||||
NewUser(data) {
|
||||
return this.add('users', new User(this.client, data));
|
||||
}
|
||||
newUser(data) {
|
||||
return this.add('users', new User(this.client, data));
|
||||
}
|
||||
|
||||
NewChannel(data, guild) {
|
||||
let already = this.get('channels', data.id);
|
||||
let channel;
|
||||
if (data.is_private) {
|
||||
channel = new DMChannel(this.client, data);
|
||||
}else {
|
||||
guild = guild || this.get('guilds', data.guild_id);
|
||||
if (guild) {
|
||||
if (data.type === 'text') {
|
||||
channel = new TextChannel(guild, data);
|
||||
guild.store.add('channels', channel);
|
||||
}else if (data.type === 'voice') {
|
||||
channel = new VoiceChannel(guild, data);
|
||||
guild.store.add('channels', channel);
|
||||
}
|
||||
}
|
||||
}
|
||||
newChannel(data, $guild) {
|
||||
let guild = $guild;
|
||||
const already = this.get('channels', data.id);
|
||||
let channel;
|
||||
if (data.is_private) {
|
||||
channel = new DMChannel(this.client, data);
|
||||
} else {
|
||||
guild = guild || this.get('guilds', data.guild_id);
|
||||
if (guild) {
|
||||
if (data.type === 'text') {
|
||||
channel = new TextChannel(guild, data);
|
||||
guild.store.add('channels', channel);
|
||||
} else if (data.type === 'voice') {
|
||||
channel = new VoiceChannel(guild, data);
|
||||
guild.store.add('channels', channel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (channel) {
|
||||
if (this.pastReady && !already) {
|
||||
this.client.emit(Constants.Events.CHANNEL_CREATE, channel);
|
||||
}
|
||||
if (channel) {
|
||||
if (this.pastReady && !already) {
|
||||
this.client.emit(Constants.Events.CHANNEL_CREATE, channel);
|
||||
}
|
||||
|
||||
return this.add('channels', channel);
|
||||
}
|
||||
}
|
||||
return this.add('channels', channel);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
KillGuild(guild) {
|
||||
let already = this.get('guilds', guilds.id);
|
||||
this.remove('guilds', guild);
|
||||
if (already && this.pastReady) {
|
||||
this.client.emit(Constants.Events.GUILD_DELETE, guild);
|
||||
}
|
||||
}
|
||||
killGuild(guild) {
|
||||
const already = this.get('guilds', guild.id);
|
||||
this.remove('guilds', guild);
|
||||
if (already && this.pastReady) {
|
||||
this.client.emit(Constants.Events.GUILD_DELETE, guild);
|
||||
}
|
||||
}
|
||||
|
||||
KillUser(user) {
|
||||
this.remove('users', user);
|
||||
}
|
||||
killUser(user) {
|
||||
this.remove('users', user);
|
||||
}
|
||||
|
||||
KillChannel(channel) {
|
||||
this.remove('channels', channel);
|
||||
if (channel instanceof ServerChannel) {
|
||||
channel.guild.store.remove('channels', channel);
|
||||
}
|
||||
}
|
||||
killChannel(channel) {
|
||||
this.remove('channels', channel);
|
||||
if (channel instanceof ServerChannel) {
|
||||
channel.guild.store.remove('channels', channel);
|
||||
}
|
||||
}
|
||||
|
||||
UpdateGuild(currentGuild, newData) {
|
||||
let oldGuild = CloneObject(currentGuild);
|
||||
currentGuild.setup(newData);
|
||||
if (this.pastReady) {
|
||||
this.client.emit(Constants.Events.GUILD_UPDATE, oldGuild, currentGuild);
|
||||
}
|
||||
}
|
||||
updateGuild(currentGuild, newData) {
|
||||
const oldGuild = cloneObject(currentGuild);
|
||||
currentGuild.setup(newData);
|
||||
if (this.pastReady) {
|
||||
this.client.emit(Constants.Events.GUILD_UPDATE, oldGuild, currentGuild);
|
||||
}
|
||||
}
|
||||
|
||||
UpdateChannel(currentChannel, newData) {
|
||||
let oldChannel = CloneObject(currentChannel);
|
||||
currentChannel.setup(newData);
|
||||
}
|
||||
updateChannel(currentChannel, newData) {
|
||||
currentChannel.setup(newData);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ClientDataStore;
|
||||
|
||||
Reference in New Issue
Block a user