Skip to content

Commit

Permalink
Fixed math command + other minor errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherBThai committed Nov 3, 2024
1 parent 8b4f2fa commit 9aec92b
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/commands/commandList/battle/crate.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ module.exports = new CommandInterface({
} else if (p.args.length > 0 && p.args[0].toLowerCase() == 'all') {
let sql = `SELECT boxcount FROM crate INNER JOIN user ON crate.uid = user.uid WHERE id = ${p.msg.author.id};`;
let result = await p.query(sql);
if (!result || result[0].boxcount <= 0) {
if (!result[0] || result[0].boxcount <= 0) {
p.errorMsg(", you don't have any more weapon crates!");
return;
}
Expand Down
3 changes: 2 additions & 1 deletion src/commands/commandList/utils/mathWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ function compute(expression) {
return limitedEvaluate(expression);
}

if (process.send) {
// Not a child process if registering app commands, it will fail
if (!process.env.REGITER_COMMANDS) {
workerpool.worker({ compute: compute });
}
2 changes: 1 addition & 1 deletion src/commands/commandList/zoo/lootbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ module.exports = new CommandInterface({
) {
let sql = `SELECT boxcount FROM lootbox WHERE id = ${this.msg.author.id};`;
let result = await this.query(sql);
if (!result || result[0].boxcount <= 0) {
if (!result[0] || result[0].boxcount <= 0) {
this.errorMsg(", you don't have any more lootboxes!");
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/commandList/zoo/upgrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ module.exports = new CommandInterface({
all = true;

// owo upg duration lvl
} else if ((args[1] && 'lvl' == args[1].toLowerCase()) || 'level' == args[1].toLowerCase()) {
} else if (['lvl', 'level'].includes(args[1]?.toLowerCase())) {
if (args[0]) {
trait = traits[args[0].toLowerCase()];
}
Expand Down
3 changes: 2 additions & 1 deletion utils/registerAppCommands.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@

// Run this file to update all application commands
require('dotenv').config();
process.env['REGITER_COMMANDS'] = true;
const axios = require('axios');
const requireDir = require('require-dir');
const dir = requireDir('../src/commands/commandList', { recurse: true });
const CommandInterface = require('../src/commands/CommandInterface.js');

const url = `https://discord.com/api/v8/applications/${process.env.CLIENT_ID}/commands`;
const headers = {
'Authorization': `Bot ${process.env.CLIENT_SECRET}`,
'Authorization': `Bot ${process.env.BOT_TOKEN}`,
};

const newCommands = {};
Expand Down

0 comments on commit 9aec92b

Please sign in to comment.