Skip to content

Commit

Permalink
clean up endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
devsnek committed Nov 19, 2016
1 parent 5462bb2 commit 23f582f
Show file tree
Hide file tree
Showing 5 changed files with 41,054 additions and 8 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "discord-rpc",
"version": "1.1.1",
"description": "",
"version": "1.1.2",
"description": "A simple RPC client for Discord somewhat stolen from the Discord StreamKit.",
"main": "src/index.js",
"repository": {
"type": "git",
Expand Down
5 changes: 5 additions & 0 deletions src/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,8 @@ module.exports.ChannelTypes = {
GUILD_TEXT: 0,
GUILD_VOICE: 2
};

module.exports.Endpoints = {
channelMessages: (cID) => `/channels/${cID}/messages`,
channelMessage: (cID, mID) => `/channels/${cID}/messages/${mID}`
}
13 changes: 7 additions & 6 deletions src/RESTClient.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const superagent = require('superagent');
const { Endpoints } = require('./Constants');

module.exports = class RESTClient {
constructor (client) {
Expand All @@ -13,15 +14,15 @@ module.exports = class RESTClient {
});
}

sendMessage (channelId, content) {
return this.makeRequest('post', `/channels/${channelId}/messages`, { content });
sendMessage (channelID, content) {
return this.makeRequest('post', Endpoints.channelMessages(channelID), { content });
}

editMessage (channelId, messageId, content) {
return this.makeRequest('patch', `/channels/${channelId}/messages/${messageId}`, { content });
editMessage (channelID, messageID, content) {
return this.makeRequest('patch', Endpoints.channelMessage(channelID, messageID), { content });
}

deleteMessage (channelId, messageId) {
return this.makeRequest('delete', `/channels/${channelId}/messages/${messageId}`);
deleteMessage (channelID, messageID) {
return this.makeRequest('delete', Endpoints.channelMessage(channelID, messageID));
}
}
Loading

0 comments on commit 23f582f

Please sign in to comment.