mirror of
https://github.com/danbulant/discord.js
synced 2026-09-20 06:53:53 +00:00
Add message.pin() and .unpin();
This commit is contained in:
parent
6ea2a523d6
commit
a57d6b723a
3 changed files with 33 additions and 1 deletions
File diff suppressed because one or more lines are too long
|
|
@ -476,6 +476,22 @@ class RESTMethods {
|
||||||
.catch(reject);
|
.catch(reject);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pinMessage(message) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
this.rest.makeRequest('put', `${Constants.Endpoints.channel(message.channel.id)}/pins/${message.id}`, true)
|
||||||
|
.then(() => resolve(message))
|
||||||
|
.catch(reject);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
unpinMessage(message) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
this.rest.makeRequest('del', `${Constants.Endpoints.channel(message.channel.id)}/pins/${message.id}`, true)
|
||||||
|
.then(() => resolve(message))
|
||||||
|
.catch(reject);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = RESTMethods;
|
module.exports = RESTMethods;
|
||||||
|
|
|
||||||
|
|
@ -265,6 +265,22 @@ class Message {
|
||||||
const newContent = this.guild ? `${this.author}, ${content}` : content;
|
const newContent = this.guild ? `${this.author}, ${content}` : content;
|
||||||
return this.client.rest.methods.sendMessage(this.channel, newContent, options.tts);
|
return this.client.rest.methods.sendMessage(this.channel, newContent, options.tts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pins this message to the channel's pinned messages
|
||||||
|
* @returns {Promise<Message, Error>}
|
||||||
|
*/
|
||||||
|
pin() {
|
||||||
|
return this.client.rest.methods.pinMessage(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unpins this message from the channel's pinned messages
|
||||||
|
* @returns {Promise<Message, Error>}
|
||||||
|
*/
|
||||||
|
unpin() {
|
||||||
|
return this.client.rest.methods.unpinMessage(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Message;
|
module.exports = Message;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue