Add OP to message.mentions when replied to
The `message.message_reference` stores: 1. `message_id` 2. `channel_id` 3. `guild_id` We use the `message_id` and `channel_id` to `.findOne(...)` Message, and find the author. If the author is the same as OP, we skip (so replying to yourself doesn't add you to the mentions array) otherwise, it adds the author_id to the mentions array. Resolves: #1247
This commit is contained in:
parent
e8d3f655a3
commit
4f75919651
@ -79,6 +79,7 @@ export async function handleMessage(opts: MessageOptions): Promise<Message> {
|
||||
embeds: opts.embeds || [],
|
||||
reactions: opts.reactions || [],
|
||||
type: opts.type ?? 0,
|
||||
mentions: [],
|
||||
});
|
||||
|
||||
if (
|
||||
@ -256,12 +257,35 @@ export async function handleMessage(opts: MessageOptions): Promise<Message> {
|
||||
}
|
||||
}
|
||||
|
||||
if (message.message_reference?.message_id) {
|
||||
const referencedMessage = await Message.findOne({
|
||||
where: {
|
||||
id: message.message_reference.message_id,
|
||||
channel_id: message.channel_id,
|
||||
},
|
||||
});
|
||||
if (
|
||||
referencedMessage &&
|
||||
referencedMessage.author_id !== message.author_id
|
||||
) {
|
||||
message.mentions.push(
|
||||
User.create({
|
||||
id: referencedMessage.author_id,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// root@Rory - 20/02/2023 - This breaks channel mentions in test client. We're not sure this was used in older clients.
|
||||
/*message.mention_channels = mention_channel_ids.map((x) =>
|
||||
Channel.create({ id: x }),
|
||||
);*/
|
||||
message.mention_roles = mention_role_ids.map((x) => Role.create({ id: x }));
|
||||
message.mentions = mention_user_ids.map((x) => User.create({ id: x }));
|
||||
message.mentions = [
|
||||
...message.mentions,
|
||||
...mention_user_ids.map((x) => User.create({ id: x })),
|
||||
];
|
||||
|
||||
message.mention_everyone = mention_everyone;
|
||||
|
||||
// TODO: check and put it all in the body
|
||||
|
||||
Reference in New Issue
Block a user