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,90 +1,90 @@
|
||||
'use strict';
|
||||
const getStructure = name => require(`../structures/${name}`);
|
||||
|
||||
const Structure = name => require(`../structures/${name}`);
|
||||
|
||||
const User = Structure('User');
|
||||
const Message = Structure('Message');
|
||||
const Guild = Structure('Guild');
|
||||
const Channel = Structure('Channel');
|
||||
const ServerChannel = Structure('ServerChannel');
|
||||
const TextChannel = Structure('TextChannel');
|
||||
const VoiceChannel = Structure('VoiceChannel');
|
||||
const GuildMember = Structure('GuildMember');
|
||||
const User = getStructure('User');
|
||||
const Message = getStructure('Message');
|
||||
const Guild = getStructure('Guild');
|
||||
const Channel = getStructure('Channel');
|
||||
const GuildMember = getStructure('GuildMember');
|
||||
|
||||
function $string(obj) {
|
||||
return (typeof obj === 'string' || obj instanceof String);
|
||||
return (typeof obj === 'string' || obj instanceof String);
|
||||
}
|
||||
|
||||
class ClientDataResolver {
|
||||
|
||||
constructor(client) {
|
||||
this.client = client;
|
||||
}
|
||||
constructor(client) {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
ResolveUser(user) {
|
||||
if (user instanceof User) {
|
||||
return user;
|
||||
}else if ($string(user)) {
|
||||
return this.client.store.get('users', user);
|
||||
}else if (user instanceof Message) {
|
||||
return user.author;
|
||||
}else if (user instanceof Guild) {
|
||||
return user.owner;
|
||||
}
|
||||
resolveUser(user) {
|
||||
if (user instanceof User) {
|
||||
return user;
|
||||
} else if ($string(user)) {
|
||||
return this.client.store.get('users', user);
|
||||
} else if (user instanceof Message) {
|
||||
return user.author;
|
||||
} else if (user instanceof Guild) {
|
||||
return user.owner;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
ResolveGuild(guild) {
|
||||
if (guild instanceof Guild) {
|
||||
return guild;
|
||||
}
|
||||
}
|
||||
resolveGuild(guild) {
|
||||
if (guild instanceof Guild) {
|
||||
return guild;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
ResolveGuildMember(guild, user) {
|
||||
if (user instanceof GuildMember) {
|
||||
return user;
|
||||
}
|
||||
resolveGuildMember($guild, $user) {
|
||||
let guild = $guild;
|
||||
let user = $user;
|
||||
if (user instanceof GuildMember) {
|
||||
return user;
|
||||
}
|
||||
|
||||
guild = this.ResolveGuild(guild);
|
||||
user = this.ResolveUser(user);
|
||||
guild = this.resolveGuild(guild);
|
||||
user = this.resolveUser(user);
|
||||
|
||||
if (!guild || !user) {
|
||||
return null;
|
||||
}
|
||||
if (!guild || !user) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return guild.store.get('members', user.id);
|
||||
}
|
||||
return guild.store.get('members', user.id);
|
||||
}
|
||||
|
||||
ResolveBase64(data) {
|
||||
if (data instanceof Buffer) {
|
||||
return 'data:image/jpg;base64,' + data.toString('base64');
|
||||
}
|
||||
resolveBase64(data) {
|
||||
if (data instanceof Buffer) {
|
||||
return `data:image/jpg;base64,${data.toString('base64')}`;
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
ResolveChannel(channel) {
|
||||
if (channel instanceof Channel) {
|
||||
return channel;
|
||||
}
|
||||
resolveChannel(channel) {
|
||||
if (channel instanceof Channel) {
|
||||
return channel;
|
||||
}
|
||||
|
||||
if ($string(channel)) {
|
||||
return this.client.store.get('channels', channel);
|
||||
}
|
||||
}
|
||||
if ($string(channel)) {
|
||||
return this.client.store.get('channels', channel);
|
||||
}
|
||||
|
||||
ResolveString(data) {
|
||||
if (data instanceof String) {
|
||||
return data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
if (data instanceof Array) {
|
||||
return data.join('\n');
|
||||
}
|
||||
resolveString(data) {
|
||||
if (data instanceof String) {
|
||||
return data;
|
||||
}
|
||||
|
||||
return String(data);
|
||||
}
|
||||
if (data instanceof Array) {
|
||||
return data.join('\n');
|
||||
}
|
||||
|
||||
return String(data);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ClientDataResolver;
|
||||
|
||||
Reference in New Issue
Block a user