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

Bug fixes #119

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
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
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,15 @@ Create a folder within your projects directory and run the following inside it:
Once finished:

- In the folder from where you ran the git command, run `npm install`, which will install the required packages.
- Rename `config.js.example` to `config.js`, and give it the required intents and any partials you may require.
- Rename `.env-example` to `.env` and put in your bot token in it and save.

- Make sure you're using node.js `v16.14.2`
- Rename `.env-example` to `.env` and put each key inside as follows
- DISCORD_TOKEN - Your bot token
- OWNER - Your discord ID
- API_URL - The URL of your API instance (for example: http://localhost:3000/v1, must include /v1/ at the end)
- API_KEY - The API key (Can be anything, shared between bot and API)
- GOOGLE_API_KEY - Google maps API key
- Set up the [API](https://github.com/Project-Skill-Tree/Skill-Tree-API)
- Set up the [editor](https://github.com/Project-Skill-Tree/Skill-Tree-Editor)
## Starting the bot

To start the bot, in the command prompt, run the following command:
Expand All @@ -46,4 +52,4 @@ Read the [documentation wiki](https://www.projectskilltree.com)
Read [Installation](#installation) to get started.

This project uses Eslint for code formatting. Install it [here](https://eslint.org/) and run it before making a pull request with your changes.<br>
You can run Eslint via `npx eslint --fix .`.
You can run Eslint via `npx eslint --fix .`.
12 changes: 11 additions & 1 deletion modules/XPHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,14 @@ exports.calcXPFromLevel = level => Math.floor(-2550*(1 - Math.pow(1.02, level)))
* @param {number} xp - total XP
* @returns {number} - XP required to level up
*/
exports.calcLevelFromXP = xp => Math.floor(Math.log(1/2550*xp + 1) / Math.log(1.02));
exports.calcLevelFromXP = xp => {
let currentXP = 0;
let lastXP = 0;
let i = 0;
for (; currentXP < xp; i++) {
const levelXP = exports.calcXPFromLevel(i);
currentXP += levelXP - lastXP;
lastXP = levelXP;
}
return i - 2;
}
2 changes: 1 addition & 1 deletion modules/menuHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ const createRow = (currentPage, length) => {
}

const createDropDownBox = actions => {
const actionList = actions.map(a => a.name).join("/");
const actionList = actions.map(a => a.name).join("/").slice(0,100);
return new MessageActionRow().addComponents(
new MessageSelectMenu().setCustomId("actions").setPlaceholder(actionList).addOptions(
actions.map(
Expand Down
6 changes: 3 additions & 3 deletions modules/skillAPIHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,16 @@ exports.cancel = (userID, toCancel) => {
* Sets the completed state of a user's skill task for a given date
* @param userid - userID
* @param task
* @param day
* @param date - javascript date object
* @param checked - T/F if checked/unchecked
*/
exports.updateTask = async (userid, task, day, checked) => {
exports.updateTask = async (userid, task, date, checked) => {
const res = await axios
.post(process.env.API_URL + "tasks/updateTask", {
userid: userid,
taskid: task.id,
checked: checked,
day: day
date: date.getTime()
}, {
headers: {
api_key: getAPIKey()
Expand Down
2 changes: 1 addition & 1 deletion modules/weeklyReviewRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const getWeeklyReview = async (user, tasks) => {
* @param canvas
* @return {Promise<void>}
*/
const drawHeaderFooter = async(canvas, user) => {
const drawHeaderFooter = async (canvas, user) => {
const context = canvas.getContext("2d");
context.font = "30px \"Akira\"";

Expand Down
2 changes: 1 addition & 1 deletion slash/skilltree/taskList.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const createTaskList = async (client, interaction, tasks, userID, timezoneOffset
//Toggle checked
task.setChecked(!task.isChecked(date, timezoneOffset), date, timezoneOffset);
//Get levelup and unlocks
const [levelUp, unlocked] = await updateTask(userID, task, day, task.isChecked(date, timezoneOffset));
const [levelUp, unlocked] = await updateTask(userID, task, date, task.isChecked(date, timezoneOffset));

if (levelUp !== 0) {
const user = await getUser(userID, interaction.user.username);
Expand Down