Webpack build for branch master: 4f23822264

This commit is contained in:
Travis CI 2017-06-23 19:51:37 +00:00
parent e2bca6763f
commit 7eefcb29be
2 changed files with 25 additions and 6 deletions

View file

@ -5432,8 +5432,8 @@ class Guild {
*/
this.id = data.id;
} else {
this.available = true;
this.setup(data);
if (!data.channels) this.available = false;
}
}
@ -12002,11 +12002,30 @@ class ClientUser extends User {
*/
createGuild(name, { region, icon = null } = {}) {
if (!icon || (typeof icon === 'string' && icon.startsWith('data:'))) {
return this.client.api.guilds.post({ data: { name, region, icon } })
.then(data => this.client.dataManager.newGuild(data));
return new Promise((resolve, reject) =>
this.client.api.guilds.post({ data: { name, region, icon } })
.then(data => {
if (this.client.guilds.has(data.id)) return resolve(this.client.guilds.get(data.id));
const handleGuild = guild => {
if (guild.id === data.id) {
this.client.removeListener(Constants.Events.GUILD_CREATE, handleGuild);
this.client.clearTimeout(timeout);
resolve(guild);
}
};
this.client.on(Constants.Events.GUILD_CREATE, handleGuild);
const timeout = this.client.setTimeout(() => {
this.client.removeListener(Constants.Events.GUILD_CREATE, handleGuild);
resolve(this.client.dataManager.newGuild(data));
}, 10000);
return undefined;
}, reject)
);
} else {
return this.client.resolver.resolveBuffer(icon)
.then(data => this.createGuild(name, region, this.client.resolver.resolveBase64(data) || null));
.then(data => this.createGuild(name, { region, icon: this.client.resolver.resolveBase64(data) || null }));
}
}

File diff suppressed because one or more lines are too long