-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUtils.js
More file actions
30 lines (24 loc) · 789 Bytes
/
Utils.js
File metadata and controls
30 lines (24 loc) · 789 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
const errorPhrases = require('../assets/errorPhrases.json');
const logAndMsg = (channel, msg) => {
console.log(msg);
channel.send(msg);
};
const getRandomIndex = (arr) => Math.floor(Math.random() * arr.length);
const errAndMsg = (channel, err) => {
console.error(err);
channel.send(`${errorPhrases[getRandomIndex(errorPhrases)]} ${err}`);
};
// There is actually a character in here to make Discord believe it's not sending an empty message.
const sendBlankLine = async channel => await channel.send('');
// Hack to tag authors but not notify them.
const sendSilentTag = async (channel, msg) => {
const placeholder = await channel.send('...');
placeholder.edit(msg);
}
module.exports = {
logAndMsg,
getRandomIndex,
errAndMsg,
sendBlankLine,
sendSilentTag,
};