mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 19:43:29 +01:00
Fix parameter callback checks not setting default arguments
The `typeof X === "function"` checks to check whether the callback replaces any default arguments didn't set the default arguments afterwards, so internal functions would sometimes get called with the wrong attributes. This is now fixed.
This commit is contained in:
@@ -103,6 +103,7 @@ export default class Client extends EventEmitter {
|
|||||||
if (typeof options === "function") {
|
if (typeof options === "function") {
|
||||||
// options is the callback
|
// options is the callback
|
||||||
callback = options;
|
callback = options;
|
||||||
|
options = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.internal.sendMessage(where, content, options)
|
return this.internal.sendMessage(where, content, options)
|
||||||
@@ -120,6 +121,7 @@ export default class Client extends EventEmitter {
|
|||||||
if (typeof options === "function") {
|
if (typeof options === "function") {
|
||||||
// options is the callback
|
// options is the callback
|
||||||
callback = options;
|
callback = options;
|
||||||
|
options = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
var msg = this.internal.resolver.resolveMessage(where);
|
var msg = this.internal.resolver.resolveMessage(where);
|
||||||
@@ -146,6 +148,7 @@ export default class Client extends EventEmitter {
|
|||||||
if (typeof options === "function") {
|
if (typeof options === "function") {
|
||||||
// options is the callback
|
// options is the callback
|
||||||
callback = options;
|
callback = options;
|
||||||
|
options = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.internal.deleteMessage(msg, options)
|
return this.internal.deleteMessage(msg, options)
|
||||||
@@ -156,6 +159,7 @@ export default class Client extends EventEmitter {
|
|||||||
if (typeof options === "function") {
|
if (typeof options === "function") {
|
||||||
// options is the callback
|
// options is the callback
|
||||||
callback = options;
|
callback = options;
|
||||||
|
options = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.internal.updateMessage(msg, content, options)
|
return this.internal.updateMessage(msg, content, options)
|
||||||
@@ -167,6 +171,7 @@ export default class Client extends EventEmitter {
|
|||||||
if (typeof options === "function") {
|
if (typeof options === "function") {
|
||||||
// options is the callback
|
// options is the callback
|
||||||
callback = options;
|
callback = options;
|
||||||
|
options = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.internal.getChannelLogs(where, limit, options)
|
return this.internal.getChannelLogs(where, limit, options)
|
||||||
@@ -208,6 +213,7 @@ export default class Client extends EventEmitter {
|
|||||||
if (typeof region === "function") {
|
if (typeof region === "function") {
|
||||||
// region is the callback
|
// region is the callback
|
||||||
callback = region;
|
callback = region;
|
||||||
|
region = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.internal.updateServer(server, name, region)
|
return this.internal.updateServer(server, name, region)
|
||||||
@@ -225,6 +231,7 @@ export default class Client extends EventEmitter {
|
|||||||
if (typeof type === "function") {
|
if (typeof type === "function") {
|
||||||
// options is the callback
|
// options is the callback
|
||||||
callback = type;
|
callback = type;
|
||||||
|
type = "text";
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.internal.createChannel(server, name, type)
|
return this.internal.createChannel(server, name, type)
|
||||||
@@ -242,6 +249,7 @@ export default class Client extends EventEmitter {
|
|||||||
if (typeof length === "function") {
|
if (typeof length === "function") {
|
||||||
// length is the callback
|
// length is the callback
|
||||||
callback = length;
|
callback = length;
|
||||||
|
length = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.internal.banMember(user, server, length)
|
return this.internal.banMember(user, server, length)
|
||||||
@@ -265,6 +273,7 @@ export default class Client extends EventEmitter {
|
|||||||
if (typeof data === "function") {
|
if (typeof data === "function") {
|
||||||
// data is the callback
|
// data is the callback
|
||||||
callback = data;
|
callback = data;
|
||||||
|
data = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.internal.createRole(server, data)
|
return this.internal.createRole(server, data)
|
||||||
@@ -276,6 +285,7 @@ export default class Client extends EventEmitter {
|
|||||||
if (typeof data === "function") {
|
if (typeof data === "function") {
|
||||||
// data is the callback
|
// data is the callback
|
||||||
callback = data;
|
callback = data;
|
||||||
|
data = null;
|
||||||
}
|
}
|
||||||
return this.internal.updateRole(role, data)
|
return this.internal.updateRole(role, data)
|
||||||
.then(dataCallback(callback), errorCallback(callback));
|
.then(dataCallback(callback), errorCallback(callback));
|
||||||
@@ -336,6 +346,7 @@ export default class Client extends EventEmitter {
|
|||||||
if (typeof options === "function") {
|
if (typeof options === "function") {
|
||||||
// options is the callback
|
// options is the callback
|
||||||
callback = options;
|
callback = options;
|
||||||
|
options = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.internal.createInvite(chanServ, options)
|
return this.internal.createInvite(chanServ, options)
|
||||||
@@ -365,9 +376,11 @@ export default class Client extends EventEmitter {
|
|||||||
if (typeof game === "function") {
|
if (typeof game === "function") {
|
||||||
// game is the callback
|
// game is the callback
|
||||||
callback = game;
|
callback = game;
|
||||||
|
game = null;
|
||||||
} else if (typeof idleStatus === "function") {
|
} else if (typeof idleStatus === "function") {
|
||||||
// idleStatus is the callback
|
// idleStatus is the callback
|
||||||
callback = idleStatus;
|
callback = idleStatus;
|
||||||
|
game = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.internal.setStatus(idleStatus, game)
|
return this.internal.setStatus(idleStatus, game)
|
||||||
@@ -460,12 +473,15 @@ export default class Client extends EventEmitter {
|
|||||||
if (typeof toSend === "function") {
|
if (typeof toSend === "function") {
|
||||||
// (msg, callback)
|
// (msg, callback)
|
||||||
callback = toSend;
|
callback = toSend;
|
||||||
|
toSend = null;
|
||||||
|
options = null;
|
||||||
} else {
|
} else {
|
||||||
// (msg, toSend, ...)
|
// (msg, toSend, ...)
|
||||||
if (options) {
|
if (options) {
|
||||||
if (typeof options === "function") {
|
if (typeof options === "function") {
|
||||||
//(msg, toSend, callback)
|
//(msg, toSend, callback)
|
||||||
callback = options;
|
callback = options;
|
||||||
|
options = null;
|
||||||
ret = this.sendMessage(msg, toSend);
|
ret = this.sendMessage(msg, toSend);
|
||||||
} else {
|
} else {
|
||||||
//(msg, toSend, options, callback)
|
//(msg, toSend, options, callback)
|
||||||
|
|||||||
Reference in New Issue
Block a user