mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 16:43:31 +01:00
Add timeout to Message#delete() (#563)
This commit is contained in:
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user