Skip to content

Commit

Permalink
add message editing
Browse files Browse the repository at this point in the history
  • Loading branch information
devsnek committed Jul 3, 2017
1 parent bc09258 commit a98ee4c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "discord_bouncer",
"version": "1.0.0",
"version": "0.0.1",
"description": "",
"main": "./src/discord_bouncer.js",
"scripts": {
Expand Down
20 changes: 16 additions & 4 deletions src/api/APIDispatcherEvents.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,22 @@ module.exports = {
handler({ client, args }) {
const channel = client.channels.get(args.channel_id);
if (!channel) throw new APIError(APIErrors.INVALID_CHANNEL, args.channel_id);
return channel.send({
content: args.content,
embed: args.embed,
}).then((m) => transformTextMessage(m));
return channel.send(args).then((m) => transformTextMessage(m));
},
},

[Events.MESSAGE_EDIT]: {
validation: () =>
joi.object().keys({
channel_id: joi.string().required(),
message_id: joi.string().required(),
}),
handler({ client, args }) {
const channel = client.channels.get(args.channel_id);
if (!channel) throw new APIError(APIErrors.INVALID_CHANNEL, args.channel_id);
return channel.fetchMessage(args.message_id)
.then((message) => message.edit(args))
.then((m) => transformTextMessage(m));
},
},
};

0 comments on commit a98ee4c

Please sign in to comment.