Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ReactionsReportTemplateFolderFullPath #33

Merged
merged 1 commit into from
Feb 20, 2025
Merged
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
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