mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
updateServer with options
This commit is contained in:
@@ -497,7 +497,7 @@ var InternalClient = (function () {
|
||||
|
||||
//def updateServer
|
||||
|
||||
InternalClient.prototype.updateServer = function updateServer(server, name, region) {
|
||||
InternalClient.prototype.updateServer = function updateServer(server, options) {
|
||||
var _this9 = this;
|
||||
|
||||
var server = this.resolver.resolveServer(server);
|
||||
@@ -505,7 +505,14 @@ var InternalClient = (function () {
|
||||
return Promise.reject(new Error("server did not resolve"));
|
||||
}
|
||||
|
||||
return this.apiRequest("patch", _Constants.Endpoints.SERVER(server.id), true, { name: name || server.name, region: region || server.region }).then(function (res) {
|
||||
if (!options.name) {
|
||||
options.name = server.name;
|
||||
}
|
||||
if (!options.region) {
|
||||
options.region = server.region;
|
||||
}
|
||||
|
||||
return this.apiRequest("patch", _Constants.Endpoints.SERVER(server.id), true, options).then(function (res) {
|
||||
// wait until the name and region are updated
|
||||
return waitFor(function () {
|
||||
return _this9.servers.get("name", res.name) ? _this9.servers.get("name", res.name).region === res.region ? _this9.servers.get("id", res.id) : false : false;
|
||||
|
||||
@@ -407,13 +407,20 @@ export default class InternalClient {
|
||||
}
|
||||
|
||||
//def updateServer
|
||||
updateServer(server, name, region) {
|
||||
updateServer(server, options) {
|
||||
var server = this.resolver.resolveServer(server);
|
||||
if (!server) {
|
||||
return Promise.reject(new Error("server did not resolve"));
|
||||
}
|
||||
|
||||
return this.apiRequest("patch", Endpoints.SERVER(server.id), true, { name: name || server.name, region: region || server.region })
|
||||
if (!options.name) {
|
||||
options.name = server.name;
|
||||
}
|
||||
if (!options.region) {
|
||||
options.region = server.region;
|
||||
}
|
||||
|
||||
return this.apiRequest("patch", Endpoints.SERVER(server.id), true, options)
|
||||
.then(res => {
|
||||
// wait until the name and region are updated
|
||||
return waitFor(() =>
|
||||
|
||||
Reference in New Issue
Block a user