mirror of
https://github.com/danbulant/discord.js
synced 2026-06-24 17:21:59 +00:00
Webpack build for branch master: 4f23822264
This commit is contained in:
parent
e2bca6763f
commit
7eefcb29be
2 changed files with 25 additions and 6 deletions
|
|
@ -5432,8 +5432,8 @@ class Guild {
|
||||||
*/
|
*/
|
||||||
this.id = data.id;
|
this.id = data.id;
|
||||||
} else {
|
} else {
|
||||||
this.available = true;
|
|
||||||
this.setup(data);
|
this.setup(data);
|
||||||
|
if (!data.channels) this.available = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -12002,11 +12002,30 @@ class ClientUser extends User {
|
||||||
*/
|
*/
|
||||||
createGuild(name, { region, icon = null } = {}) {
|
createGuild(name, { region, icon = null } = {}) {
|
||||||
if (!icon || (typeof icon === 'string' && icon.startsWith('data:'))) {
|
if (!icon || (typeof icon === 'string' && icon.startsWith('data:'))) {
|
||||||
return this.client.api.guilds.post({ data: { name, region, icon } })
|
return new Promise((resolve, reject) =>
|
||||||
.then(data => this.client.dataManager.newGuild(data));
|
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 {
|
} else {
|
||||||
return this.client.resolver.resolveBuffer(icon)
|
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 }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
4
discord.master.min.js
vendored
4
discord.master.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue