Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support for channel following and messageCreate type 12. #514

Merged
merged 9 commits into from
Aug 21, 2019
6 changes: 6 additions & 0 deletions lib/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,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