Skip to content

Commit b3dc7ca

Browse files
authored
[FEAT] Adds !everyone command
[FEAT] Adds !everyone command & updates command !command
2 parents c7f41d3 + 927d11c commit b3dc7ca

File tree

4 files changed

+55
-0
lines changed

4 files changed

+55
-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/commands.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Os seguintes comandos estão disponiveis:
1414
- !coin
1515
- !commands
1616
- !cron
17+
- !everyone
1718
- !links
1819
- !lyric
1920
- !report

src/commands/everyone.js

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