-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.js
30 lines (26 loc) · 982 Bytes
/
utils.js
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 fs = require('node:fs');
const path = require('node:path');
const DONE_EMOJI = '👍';
function isMessageTodoDone(message) {
const messageReaction = message.reactions.resolve(DONE_EMOJI);
console.log(`-> Message "${message.content}" by ${message.author.username} has reactions=${messageReaction != null}`)
if (messageReaction) {
return messageReaction.count > 0;
}
return false;
}
function fetchFilesFromPath(folderName) {
var items = [];
const itemPath = path.join(__dirname, folderName);
const itemFiles = fs.readdirSync(itemPath).filter(file => file.endsWith('.js'));
for (const file of itemFiles) {
const filePath = path.join(itemPath, file);
const item = require(filePath);
items.push(item);
}
return items;
}
function linkPresentInMessage(message) {
return message.content.includes('http');
}
module.exports = { isMessageTodoDone, fetchFilesFromPath, linkPresentInMessage, DONE_EMOJI };