feat(moderation): enhance message capture and storage with thread support

- Added functions to retrieve message location, sticker metadata, and display content in messageCapture.ts.
- Updated captureMessage function to store thread information and sticker metadata in the database.
- Modified messageStore.ts to support querying messages and attachments by thread ID.
- Updated types.ts to include thread_id in AttachmentRecord.
- Altered database schema in muxer-queue.ts to add thread_id column to attachments.
- Introduced ChannelSummary interface and listWatchableChannels method in voiceController.ts to fetch watchable channels.
- Added API endpoint in webserver.ts to retrieve channels for a given guild.
This commit is contained in:
MythEclipse
2026-05-13 20:52:37 +07:00
parent c7d8353403
commit d55b56c897
9 changed files with 1071 additions and 477 deletions

View File

@@ -96,12 +96,12 @@ export function getMessagesByChannel(
try {
const stmt = db.prepare(`
SELECT * FROM messages
WHERE channel_id = ?
WHERE channel_id = ? OR thread_id = ?
ORDER BY created_at DESC
LIMIT ? OFFSET ?
`);
const rows = stmt.all(channelId, limit, offset) as MessageRecord[];
const rows = stmt.all(channelId, channelId, limit, offset) as MessageRecord[];
return rows;
} catch (error) {
logger.error(
@@ -116,9 +116,9 @@ export function insertAttachment(db: SqliteDatabase, attachment: AttachmentRecor
try {
const stmt = db.prepare(`
INSERT INTO attachments (
id, message_id, guild_id, channel_id, user_id, filename, size, type,
id, message_id, guild_id, channel_id, thread_id, user_id, filename, size, type,
discord_url, uploaded_url, upload_status, upload_error, created_at, uploaded_at
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
`);
stmt.run(
@@ -126,6 +126,7 @@ export function insertAttachment(db: SqliteDatabase, attachment: AttachmentRecor
attachment.message_id,
attachment.guild_id,
attachment.channel_id,
attachment.thread_id,
attachment.user_id,
attachment.filename,
attachment.size,
@@ -157,12 +158,12 @@ export function getAttachmentsByChannel(
try {
const stmt = db.prepare(`
SELECT * FROM attachments
WHERE channel_id = ?
WHERE channel_id = ? OR thread_id = ?
ORDER BY created_at DESC
LIMIT ? OFFSET ?
`);
const rows = stmt.all(channelId, limit, offset) as AttachmentRecord[];
const rows = stmt.all(channelId, channelId, limit, offset) as AttachmentRecord[];
return rows;
} catch (error) {
logger.error(