Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ TrellordConnector bridges the gap between Trello and Discord, providing a unique
```
Now edit the .env file to fit your needs
4. **Set Up Webhooks**
- Configure Trello and Discord webhooks in `server.js`.
- Configure Trello and Discord webhooks in `config.js`.
5. **Run TrellordConnector**
```bash
node server.js
Expand Down
17 changes: 17 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
trellos: [
{
boardName: 'ROADMAP',
boardId: '......', // This is the board trello id
disableComments: false, // This is to disable the comments in the console
timer_duration: 20 * 60 * 1000, // 20 minutes in milliseconds
check_interval: 5 * 60 * 1000, // 5 minutes in milliseconds
discord_configs: {
mentions: ['@everyone'],
webhookUrl: 'https://discord.com/api/webhooks/..../....',
username: 'TrellordConnector - ROADMAP', // Optional: Username of the Webhook User
avatar_url: '.....', // Optional: Link to a image file
}
}
],
};
61 changes: 34 additions & 27 deletions server.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const express = require('express');
const fetch = require('node-fetch');
const fs = require('fs');
const i18n = require('./scripts/language');
const app = express();
let serverStart;
Expand All @@ -12,24 +13,40 @@ let lastActionId = '';
let messagesSended = [];
let messagesQueue = [];

const config = {
trellos: [
{
'boardName': 'ROADMAP',
'boardId': '......', // This is the board trello id
'disableComments': false, // This is to disable the comments in the console
'timer_duration': 20 * 60 * 1000, // 20 minutes in milliseconds
'check_interval': 5 * 60 * 1000, // 5 minutes in milliseconds
'discord_configs': {
'mentions': ['@everyone'],
'webhookUrl': 'https://discord.com/api/webhooks/..../....',
'username': 'TrellordConnector - ROADMAP', // Optional: Username of the Webhook User
'avatar_url': '.....', // Optional: Link to a image file
}
}
],
let config = require('./config');
let checkIntervals = [];
let sendIntervals = [];

function loadConfig() {
delete require.cache[require.resolve('./config')];
try {
config = require('./config');
restartIntervals();
console.log('Configuration reloaded');
} catch (err) {
console.error('Error loading configuration:', err);
}
}

function restartIntervals() {
checkIntervals.forEach(clearInterval);
sendIntervals.forEach(clearInterval);
checkIntervals = [];
sendIntervals = [];

for (let c of config.trellos) {
checkIntervals.push(setInterval(() => {
checkForTrelloUpdates(c);
}, c.check_interval));

sendIntervals.push(setInterval(() => {
sendMessagesToDiscord(c);
}, c.timer_duration));
}
}

fs.watchFile('./config.js', loadConfig);

app.listen(process.env.PORT, () => {
console.clear();
serverStart = new Date();
Expand All @@ -49,17 +66,7 @@ app.listen(process.env.PORT, () => {
░╚═════╝░╚═╝░░╚═╝╚═╝░░░░░╚═╝╚══════╝  ╚═════╝░░░░╚═╝░░░░╚═════╝░╚═════╝░╚═╝░╚════╝░╚═════╝░
`);

for (let c of config.trellos) {
setInterval(() => {
checkForTrelloUpdates(c);

}, c.check_interval);

setInterval(() => {
sendMessagesToDiscord(c);
}, c.timer_duration);

}
restartIntervals();
console.log(language.server_start + new Date().toLocaleTimeString());
});

Expand Down