mirror of
https://github.com/keanuplayz/TravBot-v3.git
synced 2024-08-15 02:33:12 +00:00
Compare commits
No commits in common. "fb2335dda5a34d5e828235b8451fd3b2a6b5cd81" and "31c68a5d090f334cd32e0f3dc0fdb173eaf7be83" have entirely different histories.
fb2335dda5
...
31c68a5d09
4 changed files with 4955 additions and 37 deletions
3
gulpfile.js
Normal file
3
gulpfile.js
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
const gulp = require("gulp");
|
||||
const del = require("del");
|
||||
gulp.task("default", () => del(["dist/**/*"]));
|
||||
4946
package-lock.json
generated
4946
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -4,12 +4,12 @@
|
|||
"description": "TravBot Discord bot.",
|
||||
"main": "dist/index.js",
|
||||
"scripts": {
|
||||
"build": "rimraf dist && tsc --project tsconfig.prod.json && npm prune --production",
|
||||
"build": "gulp && tsc --project tsconfig.prod.json && npm prune --production",
|
||||
"start": "node .",
|
||||
"once": "tsc && npm start",
|
||||
"dev": "tsc-watch --onSuccess \"npm run dev-instance\"",
|
||||
"dev-fast": "tsc-watch --onSuccess \"node . dev\"",
|
||||
"dev-instance": "rimraf dist && tsc && node . dev",
|
||||
"dev-instance": "gulp && tsc && node . dev",
|
||||
"test": "jest",
|
||||
"format": "prettier --write **/*",
|
||||
"postinstall": "husky install"
|
||||
|
|
@ -40,10 +40,11 @@
|
|||
"@types/ms": "^0.7.31",
|
||||
"@types/node": "^14.14.20",
|
||||
"@types/ws": "^7.4.0",
|
||||
"del": "^6.0.0",
|
||||
"gulp": "^4.0.2",
|
||||
"husky": "^5.0.6",
|
||||
"jest": "^26.6.3",
|
||||
"prettier": "2.1.2",
|
||||
"rimraf": "^3.0.2",
|
||||
"ts-jest": "^26.4.4",
|
||||
"tsc-watch": "^4.2.9",
|
||||
"typescript": "^3.9.7"
|
||||
|
|
|
|||
|
|
@ -1,11 +1,7 @@
|
|||
import {Command, getUserByNickname, NamedCommand, confirm, RestCommand} from "onion-lasers";
|
||||
import moment from "moment";
|
||||
import {pluralise} from "../../../lib";
|
||||
import {Storage} from "../../../structures";
|
||||
import {isAuthorized, getMoneyEmbed, getSendEmbed, ECO_EMBED_COLOR} from "./eco-utils";
|
||||
import {Collection} from "discord.js";
|
||||
|
||||
const lastUsedTimestamps = new Collection<string, number>();
|
||||
|
||||
export const DailyCommand = new NamedCommand({
|
||||
description: "Pick up your daily Mons. The cooldown is per user and every 22 hours to allow for some leeway.",
|
||||
|
|
@ -15,24 +11,11 @@ export const DailyCommand = new NamedCommand({
|
|||
const user = Storage.getUser(author.id);
|
||||
const now = Date.now();
|
||||
|
||||
const startTime = Date.now();
|
||||
const cooldown = 3600000;
|
||||
const lastUsedTimestamp = lastUsedTimestamps.get(guild!.id) ?? 0;
|
||||
const difference = startTime - lastUsedTimestamp;
|
||||
const howLong = moment(startTime).to(lastUsedTimestamp + cooldown);
|
||||
|
||||
if (difference < cooldown) {
|
||||
await send(
|
||||
`This command requires half an hour to cooldown. You'll be able to use this command ${howLong}.`
|
||||
);
|
||||
return;
|
||||
} else lastUsedTimestamps.set(guild!.id, startTime);
|
||||
|
||||
if (now - user.lastReceived >= 79200000) {
|
||||
user.money++;
|
||||
user.lastReceived = now;
|
||||
Storage.save();
|
||||
await send({
|
||||
send({
|
||||
embed: {
|
||||
title: "Daily Reward",
|
||||
description: "You received 1 Mon!",
|
||||
|
|
@ -45,9 +28,8 @@ export const DailyCommand = new NamedCommand({
|
|||
]
|
||||
}
|
||||
});
|
||||
return;
|
||||
} else {
|
||||
await send({
|
||||
} else
|
||||
send({
|
||||
embed: {
|
||||
title: "Daily Reward",
|
||||
description: `It's too soon to pick up your daily Mons. Try again at <t:${Math.floor(
|
||||
|
|
@ -56,19 +38,7 @@ export const DailyCommand = new NamedCommand({
|
|||
color: ECO_EMBED_COLOR
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
},
|
||||
subcommands: {
|
||||
cooldown: new NamedCommand({
|
||||
description: "Forces the cooldown timer to reset.",
|
||||
permission: PERMISSIONS.BOT_SUPPORT,
|
||||
async run({send, guild}) {
|
||||
lastUsedTimestamps.set(guild!.id, 0);
|
||||
send("Reset the cooldown on `.eco daily`.");
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue