fix merge conflict

This commit is contained in:
SpaceEEC
2017-06-23 21:49:56 +02:00
committed by Amish Shah
parent 830d8fb3b5
commit 86ec60bc00
2 changed files with 27 additions and 8 deletions

View File

@@ -299,14 +299,33 @@ class ClientUser extends User {
* @param {BufferResolvable|Base64Resolvable} [icon=null] The icon for the guild
* @returns {Promise<Guild>} The guild that was created
*/
createGuild(name, region, icon = null) {
if (!icon) return this.client.rest.methods.createGuild({ name, icon, region });
if (typeof icon === 'string' && icon.startsWith('data:')) {
return this.client.rest.methods.createGuild({ name, icon, region });
} else {
return this.client.resolver.resolveBuffer(icon).then(data =>
this.client.rest.methods.createGuild({ name, icon: data, region })
createGuild(name, { region, icon = null } = {}) {
if (!icon || (typeof icon === 'string' && icon.startsWith('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, icon: this.client.resolver.resolveBase64(data) || null }));
}
}