🔒️ fixed work command
This commit is contained in:
parent
1b0b9fb6bb
commit
f94f1192bf
2 changed files with 12 additions and 4 deletions
|
@ -26,9 +26,12 @@
|
|||
"dependencies": {
|
||||
"@discordjs/builders": "^0.12.0",
|
||||
"@discordjs/rest": "^0.3.0",
|
||||
"@nastyox/rando.js": "^2.0.5",
|
||||
"axios": "^0.26.0",
|
||||
"better-sqlite3": "^7.5.0",
|
||||
"chance": "^1.1.8",
|
||||
"common": "^0.2.5",
|
||||
"crypto": "^1.0.1",
|
||||
"dbd-dark-dashboard": "^1.6.45",
|
||||
"discord-api-types": "^0.31.0",
|
||||
"discord-dashboard": "^2.3.14",
|
||||
|
@ -45,6 +48,7 @@
|
|||
"uuid": "^8.3.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/chance": "^1.1.3",
|
||||
"@types/node-schedule": "^1.3.2",
|
||||
"@types/uuid": "^8.3.4",
|
||||
"@typescript-eslint/eslint-plugin": "^5.15.0",
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Dependencies
|
||||
import { CommandInteraction, ColorResolvable } from 'discord.js';
|
||||
import Chance from 'chance';
|
||||
|
||||
// Configurations
|
||||
import config from '../../../../config.json';
|
||||
|
@ -20,6 +21,9 @@ export default async (interaction: CommandInteraction) => {
|
|||
// Destructure member
|
||||
const { guild, user } = interaction;
|
||||
|
||||
// Chance module
|
||||
const chance = new Chance();
|
||||
|
||||
// Check if user has a timeout
|
||||
const isTimeout = await timeouts?.findOne({
|
||||
guildId: guild?.id,
|
||||
|
@ -33,10 +37,10 @@ export default async (interaction: CommandInteraction) => {
|
|||
|
||||
// If user is not on timeout
|
||||
if (!isTimeout) {
|
||||
// Make a variable of how much credits user will earn based on random multiplied with work rate
|
||||
const creditsEarned = Math?.floor(
|
||||
Math?.random() * guildDB?.credits?.workRate
|
||||
);
|
||||
const creditsEarned = chance.integer({
|
||||
min: 0,
|
||||
max: guildDB?.credits?.workRate,
|
||||
});
|
||||
|
||||
const userDB = await userSchema?.findOne({
|
||||
userId: user?.id,
|
||||
|
|
Loading…
Add table
Reference in a new issue