fix: do not send forwarded messages

This commit is contained in:
devilreef 2026-01-08 23:03:20 +06:00
parent 53177e554f
commit 790abfd692
2 changed files with 81 additions and 0 deletions

77
src/debug-message.ts Normal file
View file

@ -0,0 +1,77 @@
import process from 'node:process'
import { Client } from 'discord.js-selfbot-v13'
import env from './env.js'
const link = process.argv[2]
if (!link) {
console.error('Usage: pnpm tsx src/debug-message.ts <discord-message-link>')
process.exit(1)
}
const match = link.match(/channels\/(\d+)\/(\d+)\/(\d+)/)
if (!match) {
console.error('Invalid Discord message link')
process.exit(1)
}
const [, guildId, channelId, messageId] = match
const client = new Client()
client.once('ready', async () => {
console.log(`Logged in as ${client.user?.tag}\n`)
try {
const guild = client.guilds.cache.get(guildId)
if (!guild) {
console.error(`Guild ${guildId} not found`)
process.exit(1)
}
const channel = guild.channels.cache.get(channelId)
if (!channel || !('messages' in channel)) {
console.error(`Channel ${channelId} not found or not a text channel`)
process.exit(1)
}
const message = await channel.messages.fetch(messageId)
console.log('=== MESSAGE PAYLOAD ===\n')
console.log(JSON.stringify({
id: message.id,
content: message.content,
author: {
id: message.author.id,
username: message.author.username,
displayName: message.author.displayName,
bot: message.author.bot,
},
type: message.type,
flags: message.flags.toArray(),
reference: message.reference,
messageSnapshots: (message as any).messageSnapshots,
embeds: message.embeds.map(e => ({
type: e.type,
title: e.title,
description: e.description?.slice(0, 100),
url: e.url,
author: e.author,
})),
attachments: message.attachments.map(a => ({
id: a.id,
name: a.name,
contentType: a.contentType,
url: a.url,
})),
components: message.components.length,
}, null, 2))
}
catch (err) {
console.error('Error fetching message:', err)
}
client.destroy()
process.exit(0)
})
client.login(env.discordToken)

View file

@ -18,6 +18,10 @@ async function handleMessage(message: Message): Promise<void> {
if (!message.guild)
return
// Skip forwarded messages
if ((message.reference as any)?.type === 'FORWARD')
return
const serverConfig = config.servers.find((s: { guildId: string }) => s.guildId === message.guild!.id)
if (!serverConfig)
return