Skip to content

Commit d45ddb0

Browse files
committed
[FEAT] Adds !everyone command
1 parent 8813093 commit d45ddb0

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const {
55
Coin,
66
Commands,
77
Cron,
8+
Everyone,
89
Links,
910
Lyric,
1011
Report,
@@ -18,6 +19,7 @@ const alice = new Alice([
1819
new Coin(),
1920
new Commands(),
2021
new Cron(),
22+
new Everyone(),
2123
new Links(),
2224
new Lyric(),
2325
new Report(),

src/commands/everyone.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
const { chattools } = require('../utils');
2+
3+
const STRINGS = {
4+
help: `
5+
Marca todos os membros do grupo.
6+
7+
*uso:* \`\`\`!everyone [--args] [text]\`\`\`
8+
9+
*args válidos:*
10+
\`\`\`--quoted\`\`\` -> _marca com a mensagem citada._
11+
\`\`\`--help\`\`\` -> _mostra esta mensagem._
12+
`.trim(),
13+
defaultMessage: 'Marcando todo mundo.',
14+
};
15+
16+
class Everyone {
17+
constructor() {
18+
this.name = 'everyone';
19+
this.strings = STRINGS;
20+
}
21+
22+
async execute(data, message) {
23+
const { text, args } = data;
24+
const isAdm = await chattools.isAdm(message);
25+
26+
if (!isAdm) {
27+
message.reply('staff only.');
28+
return;
29+
}
30+
31+
if (args.includes('help')) {
32+
message.reply(this.strings.help);
33+
return;
34+
}
35+
36+
const chat = await message.getChat();
37+
const { participants } = chat;
38+
39+
if (args.includes('quoted')) {
40+
const quotedMessage = await message.getQuotedMessage();
41+
await chat.sendMessage(quotedMessage.body, {
42+
mentions: participants,
43+
});
44+
return;
45+
}
46+
47+
if (text) {
48+
await chat.sendMessage(text, {
49+
mentions: participants,
50+
});
51+
return;
52+
}
53+
54+
await chat.sendMessage(this.strings.defaultMessage, {
55+
mentions: participants,
56+
});
57+
}
58+
}
59+
60+
module.exports = Everyone;

src/commands/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module.exports = {
55
Coin: require('./coin'),
66
Commands: require('./commands'),
77
Cron: require('./cron'),
8+
Everyone: require('./everyone'),
89
Links: require('./links'),
910
Lyric: require('./lyric'),
1011
Report: require('./report'),

0 commit comments

Comments
 (0)