Skip to content

Commit

Permalink
Merge pull request #34 from Habilya/dev
Browse files Browse the repository at this point in the history
Merge Add ReactionsReportTemplateFolderFullPath
  • Loading branch information
Habilya authored Feb 20, 2025
2 parents 0d2226c + 07e8f9f commit 42688c9
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 13 deletions.
15 changes: 8 additions & 7 deletions conf/config.test.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"Token": "[YOUR_BOT_TOKEN_HERE]",
"GuildId": "[YOUR_DISCORD_SERVER_ID_HERE]",
"ClientId": "[YOUR_BOT_ID_HERE]",
"BotActivityStatusName": "[YOUR_BOT_STATUS_ACTIVITY_NAME]",
"isReactionToUserMessagesEnabled": true,
"ChromiumBrowserPath": "[YOUR_CHROMIUM_BROWSER_PATH]",
"MongodbURI": "[YOUR_MONGODB_URI_HERE]"
"Token": "[YOUR_BOT_TOKEN_HERE]",
"GuildId": "[YOUR_DISCORD_SERVER_ID_HERE]",
"ClientId": "[YOUR_BOT_ID_HERE]",
"BotActivityStatusName": "[YOUR_BOT_STATUS_ACTIVITY_NAME]",
"isReactionToUserMessagesEnabled": true,
"ReactionsReportTemplateFolderFullPath": "[YOUR_REPORTS_TEMPLATES_PATH]",
"ChromiumBrowserPath": "[YOUR_CHROMIUM_BROWSER_PATH]",
"MongodbURI": "[YOUR_MONGODB_URI_HERE]"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wordcountingdiscordbotjs",
"version": "1.0.5",
"version": "1.0.6",
"description": "A discord bot to count how many times a specific word or a pattern was spoken",
"main": "src/index.js",
"scripts": {
Expand Down
3 changes: 1 addition & 2 deletions src/commands/reactions/topReactionsByUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ module.exports = {
}

// Read the templates
const pathToHTMLTemplates = '../../assets/templates/';
leaderBoardTemplator.initTemplates(pathToHTMLTemplates);
leaderBoardTemplator.initTemplates(discordBot.getConfig().ReactionsReportTemplateFolderFullPath);

const generatedLadderboard_li = await leaderBoardTemplator.PrepareLeaderBoardTable(interaction, topUsersReactionsByReactionName, LEADERBOARD_DISPLAY_LIMIT);

Expand Down
5 changes: 5 additions & 0 deletions src/configure/discordBot.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ exports.validateConfig = function () {
isValid = false;
logger.warning(`If isReactionToUserMessagesEnabled, ${validateStringInConfig('MongodbURI')}`);
}

if (config.isReactionToUserMessagesEnabled && stringFunctions.stringIsNullOrEmpty(config.ReactionsReportTemplateFolderFullPath)) {
isValid = false;
logger.warning(`If isReactionToUserMessagesEnabled, ${validateStringInConfig('ReactionsReportTemplateFolderFullPath')}`);
}
};

// Function Initializes the client property
Expand Down
2 changes: 1 addition & 1 deletion test/commands.misc.help.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('Command help.js tests', () => {
fields: [
{
name: "Ver.",
value: "1.0.5",
value: "1.0.6",
},
{
name: "Description",
Expand Down
11 changes: 11 additions & 0 deletions test/conf.config-reading.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,15 @@ describe('config.json reading test', () => {
expect(actual).toBe(expected);
});

it('can read config.json ReactionsReportTemplateFolderFullPath', () => {
// Arrange
let expected = "[YOUR_REPORTS_TEMPLATES_PATH]";

// Act
let actual = config.ReactionsReportTemplateFolderFullPath;

// Assert
expect(actual).toBe(expected);
});

});
5 changes: 3 additions & 2 deletions test/configure.discordBot.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@ describe('01initialized.js tests', () => {
discordBot.validateConfig();

// Assert
expect(discordBot.getLogger().warning.mock.calls).toHaveLength(5);
expect(discordBot.getLogger().warning.mock.calls).toHaveLength(6);
expect(discordBot.getLogger().warning.mock.calls).toEqual([
["Field Token must be configured in the conf/config.json file"],
["Field GuildId must be configured in the conf/config.json file"],
["Field ClientId must be configured in the conf/config.json file"],
["If isReactionToUserMessagesEnabled, Field ChromiumBrowserPath must be configured in the conf/config.json file"],
["If isReactionToUserMessagesEnabled, Field MongodbURI must be configured in the conf/config.json file"]
["If isReactionToUserMessagesEnabled, Field MongodbURI must be configured in the conf/config.json file"],
["If isReactionToUserMessagesEnabled, Field ReactionsReportTemplateFolderFullPath must be configured in the conf/config.json file"]
]);
});

Expand Down

0 comments on commit 42688c9

Please sign in to comment.