Crosspost listener not working

I have a bot listening for message updates, and then filtering it out to be a crossposted message, but it isn't working
import { Events, Listener } from "@sapphire/framework";
import { Message, MessageFlags } from "discord.js";
import { lexer } from "marked";
import {
discordImageToGuilded,
convertToGuilded,
announceToGuilded,
} from "../resources/modules/convertToGuilded";

export class CrosspostedListener extends Listener {
public constructor(context: Listener.LoaderContext, options: Listener.Options) {
super(context, {
...options,
event: Events.MessageUpdate,
});
}

public async run(message: Message) {
if (!message.flags.has(MessageFlags.Crossposted)) return;
console.log(message);

const messageContent = message.content;
const regex = /<:[a-zA-Z0-9]+:\d+>/g;
const messageContentWithoutCustomEmojis = messageContent.replace(regex, "");
const parsed = lexer(messageContentWithoutCustomEmojis);

const image = await discordImageToGuilded(message.attachments.first());
const convertedToGuilded = convertToGuilded(parsed, image);

await announceToGuilded(convertedToGuilded);
}
}
import { Events, Listener } from "@sapphire/framework";
import { Message, MessageFlags } from "discord.js";
import { lexer } from "marked";
import {
discordImageToGuilded,
convertToGuilded,
announceToGuilded,
} from "../resources/modules/convertToGuilded";

export class CrosspostedListener extends Listener {
public constructor(context: Listener.LoaderContext, options: Listener.Options) {
super(context, {
...options,
event: Events.MessageUpdate,
});
}

public async run(message: Message) {
if (!message.flags.has(MessageFlags.Crossposted)) return;
console.log(message);

const messageContent = message.content;
const regex = /<:[a-zA-Z0-9]+:\d+>/g;
const messageContentWithoutCustomEmojis = messageContent.replace(regex, "");
const parsed = lexer(messageContentWithoutCustomEmojis);

const image = await discordImageToGuilded(message.attachments.first());
const convertedToGuilded = convertToGuilded(parsed, image);

await announceToGuilded(convertedToGuilded);
}
}
Solution:
Discordjs handles whether the flag is set or not so you're better off consulting then why it's false when you expect it to be true. Make sure to provide a screenshot of the message in question.
Jump to solution
2 Replies
fisher
fisherOP5mo ago
I have the needed intents when i console log if it has the message flag message.flags.has(MessageFlags.Crossposted)) ^^ it says "false" but it is crossposted so
Solution
Favna
Favna4mo ago
Discordjs handles whether the flag is set or not so you're better off consulting then why it's false when you expect it to be true. Make sure to provide a screenshot of the message in question.
Want results from more Discord servers?
Add your server