mirror of
https://github.com/danbulant/discord.js
synced 2026-05-24 20:42:27 +00:00
Add timeout to Message#delete() (#563)
This commit is contained in:
parent
52adb3d8b2
commit
817bea5a70
1 changed files with 9 additions and 2 deletions
|
|
@ -233,6 +233,7 @@ class Message {
|
|||
|
||||
/**
|
||||
* Deletes the message
|
||||
* @param {Number} [timeout=0] How long to wait to delete the message in milliseconds
|
||||
* @returns {Promise<Message, Error>}
|
||||
* @example
|
||||
* // delete a message
|
||||
|
|
@ -240,8 +241,14 @@ class Message {
|
|||
* .then(msg => console.log(`Deleted message from ${msg.author}`))
|
||||
* .catch(console.log);
|
||||
*/
|
||||
delete() {
|
||||
return this.client.rest.methods.deleteMessage(this);
|
||||
delete(timeout = 0) {
|
||||
return new Promise((resolve, reject) => {
|
||||
setTimeout(() => {
|
||||
this.client.rest.methods.deleteMessage(this)
|
||||
.then(resolve)
|
||||
.catch(reject);
|
||||
}, timeout);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue