Skip to content

Commit

Permalink
Add support for channel following (#514)
Browse files Browse the repository at this point in the history
  • Loading branch information
Khaaz authored and abalabahaha committed Aug 21, 2019
1 parent 400ee76 commit af9854e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lib/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,9 @@ module.exports.AuditLogActions = {

MESSAGE_DELETE: 72
};

module.exports.MessageFlags = {
CROSSPOSTED: 1 << 0,
IS_CROSSPOST: 1 << 1,
SUPPRESS_EMBEDS: 1 << 2,
};
22 changes: 21 additions & 1 deletion lib/structures/Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ const User = require("./User");
* @prop {Number?} editedTimestamp Timestamp of latest message edit
* @prop {Boolean} tts Whether to play the message using TTS or not
* @prop {Boolean} mentionEveryone Whether the message mentions everyone/here or not
* @prop {Object?} messageReference An object containing the reference to the original message if it is a crossposted message
* @prop {String} messageReference.messageID The id of the original message this message was crossposted from
* @prop {String} messageReference.channelID The id of the channel this message was crossposted from
* @prop {String} messageReference.guildID The id of the guild this message was crossposted from
* @prop {Number} flags Message flags (see constants)
* @prop {Object[]} attachments Array of attachments
* @prop {Object[]} embeds Array of embeds
* @prop {Object?} activity The activity specified in the message
Expand All @@ -43,6 +48,19 @@ class Message extends Base {
this.content = "";
this.hit = !!data.hit;
this.reactions = {};

if (data.message_reference) {
this.messageReference = {
messageID: data.message_reference.message_id,
channelID: data.message_reference.channel_id,
guildID: data.message_reference.guild_id,
};
} else {
this.messageReference = null;
}

this.flags = data.flags || 0;

if(data.author) {
if(data.author.discriminator !== "0000") {
this.author = client.users.add(data.author, client);
Expand Down Expand Up @@ -103,7 +121,9 @@ class Message extends Base {
data.content = `${this.author.mention} just boosted the server!`;
} else if(this.type === 9 || this.type === 10 || this.type === 11) {
data.content = `${this.author.mention} just boosted the server! ${this.channel.guild ? this.channel.guild.name : data.guild_id} has achieved **Level ${this.type - 8}!**`;
} else {
} else if(this.type === 12) {
data.content = `${this.author.mention} has added ${data.content} to this channel`;
} else {
client.emit("warn", "Unhandled MESSAGE_CREATE type: " + JSON.stringify(data, null, 2));
}

Expand Down

0 comments on commit af9854e

Please sign in to comment.