mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 00:23:30 +01:00
add clientUser#createGuild (#832)
* add clientUser#createGuild merge docs * almost caused a memory leak! * muh triggers
This commit is contained in:
@@ -163,6 +163,27 @@ class ClientUser extends User {
|
||||
return this.client.rest.methods.removeFriend(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a guild
|
||||
* <warn>This is only available for user accounts, not bot accounts!</warn>
|
||||
* @param {string} name The name of the guild
|
||||
* @param {string} region The region for the server
|
||||
* @param {FileResolvable|Base64Resolvable} [icon=null] The icon for the guild
|
||||
* @returns {Promise<Guild>} The guild that was created
|
||||
*/
|
||||
createGuild(name, region, icon = null) {
|
||||
return new Promise(resolve => {
|
||||
if (!icon) resolve(this.client.rest.methods.createGuild({ name, icon, region }));
|
||||
if (icon.startsWith('data:')) {
|
||||
resolve(this.client.rest.methods.createGuild({ name, icon, region }));
|
||||
} else {
|
||||
this.client.resolver.resolveFile(icon).then(data => {
|
||||
resolve(this.client.rest.methods.createGuild({ name, icon: data, region }));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the full presence of the current user.
|
||||
* @param {Object} data the data to provide
|
||||
|
||||
Reference in New Issue
Block a user