-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathrule.js
More file actions
42 lines (31 loc) · 864 Bytes
/
rule.js
File metadata and controls
42 lines (31 loc) · 864 Bytes
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
const fetch = require('node-fetch');
module.exports = {
active: true,
title: {
ru: 'Отправляет текст пункта Устава',
en: 'Sends the text of the clause of the Charter',
uk: 'Надсилає текст пункту Статуту'
},
allChannels: true,
allowedChannels: {},
init: async function () {
try {
this.rules = await (await fetch(
constants.SITE_LINK + '/rules?j=true'
)).json();
} catch (e) {
this.active = false;
}
return this;
},
call: async function (msg) {
if (msg.content.length < 2) return;
msg.content = msg.content.replace('а', 'a');
msg.content = msg.content.replace(/^r\.?/, '');
if (!this.rules[msg.content]) return;
await msg.channel.send({
content: constants.SITE_LINK + '/rules?f=' + msg.content,
messageReference: msg.reference?.messageId
});
}
};