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
53
54
55
56
57
58
59
|
function startSignal() {
try {
const { Client } = require('@equestria.dev/signal.js');
async function send(channel, text, options) {
await channel.setTyping(false);
if (!options) options = {};
options.markdown = true;
await channel.send(text, options);
}
global.signalSend = send;
const client = new Client({
account: require('./credentials.json').signal
});
client.on('message', async (msg) => {
if (!require('./credentials.json').allowed.includes(msg.author.number)) return;
let message = msg.content;
if (message.startsWith(".") && !message.startsWith("..") && message.trim() !== "." && message.trim() !== ".c." && !message.trim().startsWith(".c.") && !message.trim().startsWith(".❤️")) {
let command;
msg.channel.setTyping(true);
msg.markAsRead();
try {
command = message.replaceAll(/ +/g, " ");
if (command.startsWith(". ")) command = "." + command.substring(2);
command = command.split(" ")[0].substring(1).replaceAll("/", "-");
let parameter = message.split(" ").splice(1).join(" ");
require('./handler')({
command,
parameter,
source: "signal",
message: msg,
channel: msg.channel,
client,
signalSend: send
});
} catch (e) {
send(msg.channel, "❓ Hmm, something isn't quite right! I was trying to process your message and something wrong happened. I think you need to report this so it can be fixed!\n\n```plaintext\n" + e.stack + "\n```");
}
} else if (msg.mentions?.map(i => i.number).includes(require('./credentials.json').signal)) {
send(msg.channel, "👋 Hello! I think you forgot my prefix is `.`, use `.help` to get help.");
}
});
} catch (e) {
setTimeout(() => {
startSignal();
}, 300000);
}
}
startSignal();
|