diff options
| author | Fuwn <[email protected]> | 2025-09-30 01:46:22 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2025-09-30 01:46:22 -0700 |
| commit | 316609026a7432cf12ca9b51445700e1d3970f4f (patch) | |
| tree | 50d0e2111bd8f122ae00aa7b760bdc9c220e2613 /packages/gateway | |
| parent | style(gateway:aiModeration): Lint (diff) | |
| download | umabotdiscord-316609026a7432cf12ca9b51445700e1d3970f4f.tar.xz umabotdiscord-316609026a7432cf12ca9b51445700e1d3970f4f.zip | |
feat(commands:pin): Add channel ID parameter
Diffstat (limited to 'packages/gateway')
| -rw-r--r-- | packages/gateway/src/commands/pin.ts | 48 |
1 files changed, 45 insertions, 3 deletions
diff --git a/packages/gateway/src/commands/pin.ts b/packages/gateway/src/commands/pin.ts index 4980d43..1667c50 100644 --- a/packages/gateway/src/commands/pin.ts +++ b/packages/gateway/src/commands/pin.ts @@ -14,18 +14,60 @@ export const handlePinCommand = async (message: Message) => { const parameters = message.content.split(" "); if (parameters.length < 2) { - await replyWithCleanup(message, "❌ Usage: `uma!pin <message_id>`"); + await replyWithCleanup( + message, + "❌ Usage: `uma!pin <message_id> [channel_id]`", + ); return; } const messageId = parameters[1]; + const channelId = parameters[2]; + + if (!/^\d{17,19}$/.test(messageId)) { + await replyWithCleanup( + message, + "❌ Invalid message ID format. Please provide a valid Discord message ID.", + ); + + return; + } + + if (channelId && !/^\d{17,19}$/.test(channelId)) { + await replyWithCleanup( + message, + "❌ Invalid channel ID format. Please provide a valid Discord channel ID.", + ); + + return; + } try { - const targetMessage = await message.channel.messages.fetch(messageId); + let targetChannel = message.channel; + + if (channelId) { + const specifiedChannel = message.client.channels.cache.get(channelId); + + if (!specifiedChannel || !specifiedChannel.isTextBased()) { + await replyWithCleanup( + message, + "❌ Channel not found or is not a text channel.", + ); + + return; + } + + targetChannel = specifiedChannel; + } + + const targetMessage = await targetChannel.messages.fetch(messageId); if (!targetMessage) { - await replyWithCleanup(message, "❌ Message not found."); + await replyWithCleanup( + message, + "❌ Message not found in the specified channel.", + ); return; } |