mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-18 04:23:31 +01:00
Create a utility function to wrap those on-the-fly callbacks
This commit is contained in:
@@ -14,6 +14,16 @@ function constructErrorCallback(callback) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This utility function creates an anonymous handler function to separate the
|
||||||
|
// error and the data arguments inside a callback and return the data if it is
|
||||||
|
// eventually done (for promise propagation).
|
||||||
|
function dataCallback(callback) {
|
||||||
|
return data => {
|
||||||
|
callback(null, data);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default class Client extends EventEmitter {
|
export default class Client extends EventEmitter {
|
||||||
/*
|
/*
|
||||||
this class is an interface for the internal
|
this class is an interface for the internal
|
||||||
@@ -253,25 +263,25 @@ export default class Client extends EventEmitter {
|
|||||||
|
|
||||||
//def banMember
|
//def banMember
|
||||||
banMember(user, server, length = 1, callback = (/*err*/) => { }) {
|
banMember(user, server, length = 1, callback = (/*err*/) => { }) {
|
||||||
|
|
||||||
if (typeof length === "function") {
|
if (typeof length === "function") {
|
||||||
// length is the callback
|
// length is the callback
|
||||||
callback = length;
|
callback = length;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.internal.banMember(user, server, length)
|
return this.internal.banMember(user, server, length)
|
||||||
.then(callback, constructErrorCallback(callback));
|
.then(() => {}, constructErrorCallback(callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
//def unbanMember
|
//def unbanMember
|
||||||
unbanMember(user, server, callback = (/*err*/) => { }) {
|
unbanMember(user, server, callback = (/*err*/) => { }) {
|
||||||
return this.internal.unbanMember(user, server)
|
return this.internal.unbanMember(user, server)
|
||||||
.then(callback, constructErrorCallback(callback));
|
.then(() => {}, constructErrorCallback(callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
//def kickMember
|
//def kickMember
|
||||||
kickMember(user, server, callback = (/*err*/) => { }) {
|
kickMember(user, server, callback = (/*err*/) => { }) {
|
||||||
return this.internal.kickMember(user, server)
|
return this.internal.kickMember(user, server)
|
||||||
.then(callback, constructErrorCallback(callback));
|
.then(() => {}, constructErrorCallback(callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
//def createRole
|
//def createRole
|
||||||
|
|||||||
Reference in New Issue
Block a user