Skip to content

Commit ccc18f6

Browse files
committed
[FEAT] adds Command util file
1 parent 5adf115 commit ccc18f6

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/utils/Command.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* Utils related to commands.
3+
*/
4+
class Command {
5+
/**
6+
* Tag to format a string to be sended as a message.
7+
* @param {string[]} strings
8+
* @param {...any} values
9+
* @returns {string} - formatted string
10+
*/
11+
static message(strings, ...values) {
12+
const STR = strings.map((s, i) =>
13+
i + 1 === strings.length ? s : s + values[i]
14+
);
15+
16+
return STR.join('')
17+
.split('\n')
18+
.map((s) => s.trim())
19+
.join('\n')
20+
.trim();
21+
}
22+
}
23+
24+
module.exports = Command;

src/utils/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
module.exports = {
44
Parse: require('./Parse'),
55
chattools: require('./chattools'),
6+
Command: require('./Command'),
67
search: require('./search'),
78
Time: require('./time'),
89
};

0 commit comments

Comments
 (0)