Skip to content

Commit

Permalink
breaking(Message): Remove system message content handling (#1501)
Browse files Browse the repository at this point in the history
  • Loading branch information
flav-code authored Jul 8, 2024
1 parent f48547b commit 1f61e8e
Showing 1 changed file with 29 additions and 89 deletions.
118 changes: 29 additions & 89 deletions lib/structures/Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const Base = require("./Base");
const Endpoints = require("../rest/Endpoints");
const Call = require("./Call");
const {SystemJoinMessages, MessageTypes, MessageFlags} = require("../Constants");
const {MessageTypes, MessageFlags} = require("../Constants");
const User = require("./User");

/**
Expand Down Expand Up @@ -140,20 +140,34 @@ class Message extends Base {
this.member = null;
}

switch(this.type) {
case MessageTypes.DEFAULT: {
break;
}
case MessageTypes.RECIPIENT_ADD: {
data.content = `${this.author.mention} added <@${data.mentions[0].id}>.`;
break;
}
case MessageTypes.RECIPIENT_REMOVE: {
if(this.author.id === data.mentions[0].id) {
data.content = `@${this.author.username} left the group.`;
} else {
data.content = `${this.author.mention} removed @${data.mentions[0].username}.`;
}
switch (this.type) {
case MessageTypes.DEFAULT:
case MessageTypes.RECIPIENT_ADD:
case MessageTypes.RECIPIENT_REMOVE:
case MessageTypes.CHANNEL_NAME_CHANGE:
case MessageTypes.CHANNEL_ICON_CHANGE:
case MessageTypes.CHANNEL_PINNED_MESSAGE:
case MessageTypes.GUILD_MEMBER_JOIN:
case MessageTypes.USER_PREMIUM_GUILD_SUBSCRIPTION:
case MessageTypes.USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_1:
case MessageTypes.USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_2:
case MessageTypes.USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_3:
case MessageTypes.CHANNEL_FOLLOW_ADD:
case MessageTypes.GUILD_DISCOVERY_DISQUALIFIED:
case MessageTypes.GUILD_DISCOVERY_REQUALIFIED:
case MessageTypes.GUILD_DISCOVERY_GRACE_PERIOD_INITIAL_WARNING:
case MessageTypes.GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING:
case MessageTypes.THREAD_CREATED:
case MessageTypes.REPLY:
case MessageTypes.CHAT_INPUT_COMMAND:
case MessageTypes.CONTEXT_MENU_COMMAND:
case MessageTypes.THREAD_STARTER_MESSAGE:
case MessageTypes.GUILD_INVITE_REMINDER:
case MessageTypes.AUTO_MODERATION_ACTION:
case MessageTypes.STAGE_START:
case MessageTypes.STAGE_END:
case MessageTypes.STAGE_SPEAKER:
case MessageTypes.STAGE_TOPIC: {
break;
}
case MessageTypes.CALL: {
Expand All @@ -162,88 +176,14 @@ class Message extends Base {
data.call.id = this.id;
this.channel.lastCall = new Call(data.call, this.channel);
}
if(data.call.participants.includes(this._client.user.id)) {
data.content = `You missed a call from ${this.author.mention}.`;
} else {
data.content = `${this.author.mention} started a call.`;
}
} else {
if(!this.channel.call) {
data.call.id = this.id;
this.channel.call = new Call(data.call, this.channel);
}
data.content = `${this.author.mention} started a call. — Join the call.`;
}
break;
}
case MessageTypes.CHANNEL_NAME_CHANGE: {
data.content = `${this.author.mention} changed the channel name: ${data.content}`;
break;
}
case MessageTypes.CHANNEL_ICON_CHANGE: {
data.content = `${this.author.mention} changed the channel icon.`;
break;
}
case MessageTypes.CHANNEL_PINNED_MESSAGE: {
data.content = `${this.author.mention} pinned a message to this channel. See all the pins.`;
break;
}
case MessageTypes.GUILD_MEMBER_JOIN: {
data.content = SystemJoinMessages[~~(this.createdAt % SystemJoinMessages.length)].replace(/%user%/g, this.author.mention);
break;
}
case MessageTypes.USER_PREMIUM_GUILD_SUBSCRIPTION: {
data.content = `${this.author.mention} just boosted the server!`;
break;
}
case MessageTypes.USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_1:
case MessageTypes.USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_2:
case MessageTypes.USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_3: {
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}!**`;
break;
}
case MessageTypes.CHANNEL_FOLLOW_ADD: {
data.content = `${this.author.mention} has added ${data.content} to this channel`;
break;
}
case MessageTypes.GUILD_DISCOVERY_DISQUALIFIED: {
data.content = "This server has been removed from Server Discovery because it no longer passes all the requirements. Check `Server Settings` for more details.";
break;
}
case MessageTypes.GUILD_DISCOVERY_REQUALIFIED: {
data.content = "This server is eligible for Server Discovery again and has been automatically relisted!";
break;
}
case MessageTypes.GUILD_DISCOVERY_GRACE_PERIOD_INITIAL_WARNING: {
data.content = "This server has failed Discovery activity requirements for 1 week. If this server fails for 4 weeks in a row, it will be automatically removed from Discovery.";
break;
}
case MessageTypes.GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING: {
data.content = "This server has failed Discovery activity requirements for 3 weeks in a row. If this server fails for 1 more week, it will be removed from Discovery.";
break;
}
case MessageTypes.THREAD_CREATED: {
break;
}
case MessageTypes.REPLY: {
break;
}
case MessageTypes.CHAT_INPUT_COMMAND: {
break;
}
case MessageTypes.CONTEXT_MENU_COMMAND: {
break;
}
case MessageTypes.THREAD_STARTER_MESSAGE: {
break;
}
case MessageTypes.GUILD_INVITE_REMINDER: {
data.content = "Wondering who to invite?\nStart by inviting anyone who can help you build the server!";
break;
}
case MessageTypes.AUTO_MODERATION_ACTION: {
break;
}
default: {
this._client.emit("warn", `Unhandled MESSAGE_CREATE type: ${JSON.stringify(data, null, 2)}`);
break;
Expand Down

0 comments on commit 1f61e8e

Please sign in to comment.