summaryrefslogtreecommitdiff
path: root/packages/gateway/src/commands/pin.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/gateway/src/commands/pin.ts')
-rw-r--r--packages/gateway/src/commands/pin.ts32
1 files changed, 24 insertions, 8 deletions
diff --git a/packages/gateway/src/commands/pin.ts b/packages/gateway/src/commands/pin.ts
index da89cf1..4980d43 100644
--- a/packages/gateway/src/commands/pin.ts
+++ b/packages/gateway/src/commands/pin.ts
@@ -1,4 +1,5 @@
import { Message } from "discord.js";
+import { replyWithCleanup } from "../utilities";
export const handlePinCommand = async (message: Message) => {
if (message.author.bot) return;
@@ -13,7 +14,7 @@ export const handlePinCommand = async (message: Message) => {
const parameters = message.content.split(" ");
if (parameters.length < 2) {
- await message.reply("❌ Usage: `uma!pin <message_id>`");
+ await replyWithCleanup(message, "❌ Usage: `uma!pin <message_id>`");
return;
}
@@ -24,13 +25,13 @@ export const handlePinCommand = async (message: Message) => {
const targetMessage = await message.channel.messages.fetch(messageId);
if (!targetMessage) {
- await message.reply("❌ Message not found.");
+ await replyWithCleanup(message, "❌ Message not found.");
return;
}
if (targetMessage.pinned) {
- await message.reply("❌ Message is already pinned.");
+ await replyWithCleanup(message, "❌ Message is already pinned.");
return;
}
@@ -40,12 +41,27 @@ export const handlePinCommand = async (message: Message) => {
} catch (error) {
console.error("Error pinning message:", error);
- if (error instanceof Error && error.message.includes("Missing Permissions")) {
- await message.reply("❌ Missing permissions to pin messages in this channel.");
- } else if (error instanceof Error && error.message.includes("Maximum number of pins")) {
- await message.reply("❌ Channel has reached maximum number of pinned messages (50). Unpin another message first.");
+ if (
+ error instanceof Error &&
+ error.message.includes("Missing Permissions")
+ ) {
+ await replyWithCleanup(
+ message,
+ "❌ Missing permissions to pin messages in this channel.",
+ );
+ } else if (
+ error instanceof Error &&
+ error.message.includes("Maximum number of pins")
+ ) {
+ await replyWithCleanup(
+ message,
+ "❌ Channel has reached maximum number of pinned messages (50). Unpin another message first.",
+ );
} else {
- await message.reply("❌ Failed to pin the message. Message ID may be invalid.");
+ await replyWithCleanup(
+ message,
+ "❌ Failed to pin the message. Message ID may be invalid.",
+ );
}
}
};