mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-15 11:03:30 +01:00
Add timeout to Message#delete() (#563)
This commit is contained in:
@@ -233,6 +233,7 @@ class Message {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes the message
|
* Deletes the message
|
||||||
|
* @param {Number} [timeout=0] How long to wait to delete the message in milliseconds
|
||||||
* @returns {Promise<Message, Error>}
|
* @returns {Promise<Message, Error>}
|
||||||
* @example
|
* @example
|
||||||
* // delete a message
|
* // delete a message
|
||||||
@@ -240,8 +241,14 @@ class Message {
|
|||||||
* .then(msg => console.log(`Deleted message from ${msg.author}`))
|
* .then(msg => console.log(`Deleted message from ${msg.author}`))
|
||||||
* .catch(console.log);
|
* .catch(console.log);
|
||||||
*/
|
*/
|
||||||
delete() {
|
delete(timeout = 0) {
|
||||||
return this.client.rest.methods.deleteMessage(this);
|
return new Promise((resolve, reject) => {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.client.rest.methods.deleteMessage(this)
|
||||||
|
.then(resolve)
|
||||||
|
.catch(reject);
|
||||||
|
}, timeout);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user