blob: eafb2f183aca60f7164117e6a3e43db9dd0ce4cd (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
import { Message } from "discord.js";
import { replyWithCleanup } from "../utilities";
export const handleSaycCommand = async (message: Message): Promise<boolean> => {
if (message.author.bot) return false;
const content = message.content.trim();
const commandMatch = content.match(/^uma!sayc\s+(\d+)\s+(.+)$/s);
if (!commandMatch) return false;
const [, channelId, messageContent] = commandMatch;
if (!messageContent.trim()) {
await replyWithCleanup(
message,
"❌ You need to provide a message to send.",
);
return true;
}
try {
const targetChannel = message.client.channels.cache.get(channelId);
if (
!targetChannel ||
!targetChannel.isTextBased() ||
targetChannel.isDMBased()
) {
await replyWithCleanup(
message,
"❌ Channel not found or is not a text channel.",
);
return true;
}
await targetChannel.send(messageContent);
await replyWithCleanup(message, `✅ Message sent to <#${channelId}>.`);
return true;
} catch (error) {
console.error("Error in sayc command:", error);
await replyWithCleanup(
message,
"❌ Failed to send message to the specified channel.",
);
return true;
}
};
|