Docs update and updateServer option processing

This commit is contained in:
abalabahaha
2016-04-16 00:32:36 -07:00
parent dd71bb9e27
commit 0d93ce9fbd
3 changed files with 106 additions and 16 deletions

View File

@@ -415,11 +415,36 @@ export default class InternalClient {
return Promise.reject(new Error("server did not resolve"));
}
if (!options.name) {
options.name = server.name;
var newOptions = {
name: options.name || server.name,
region: options.region || server.region
};
if (options.icon) {
newOptions.icon = this.resolver.resolveToBase64(options.icon);
}
if (!options.region) {
options.region = server.region;
if (options.splash) {
newOptions.splash = this.resolver.resolveToBase64(options.splash);
}
if (options.owner) {
var user = this.resolver.resolveUser(options.owner);
if (!user) {
return Promise.reject(new Error("owner could not be resolved"));
}
options.owner_id = user.id;
}
if (options.verificationLevel) {
options.verification_level = user.verificationLevel;
}
if (options.afkChannel) {
var channel = this.resolver.resolveUser(options.afkChannel);
if (!channel) {
return Promise.reject(new Error("afkChannel could not be resolved"));
}
options.afk_channel_id = channel.id;
}
if (options.afkTimeout) {
options.afk_timeout = user.afkTimeout;
}
return this.apiRequest("patch", Endpoints.SERVER(server.id), true, options)