mirror of
https://github.com/keanuplayz/TravBot-v3.git
synced 2024-08-15 02:33:12 +00:00
Compare commits
2 commits
31c68a5d09
...
fb2335dda5
Author | SHA1 | Date | |
---|---|---|---|
|
fb2335dda5 | ||
|
73278b7e88 |
4 changed files with 37 additions and 4955 deletions
|
@ -1,3 +0,0 @@
|
|||
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": "gulp && tsc --project tsconfig.prod.json && npm prune --production",
|
||||
"build": "rimraf dist && 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": "gulp && tsc && node . dev",
|
||||
"dev-instance": "rimraf dist && tsc && node . dev",
|
||||
"test": "jest",
|
||||
"format": "prettier --write **/*",
|
||||
"postinstall": "husky install"
|
||||
|
@ -40,11 +40,10 @@
|
|||
"@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,7 +1,11 @@
|
|||
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.",
|
||||
|
@ -11,11 +15,24 @@ 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();
|
||||
send({
|
||||
await send({
|
||||
embed: {
|
||||
title: "Daily Reward",
|
||||
description: "You received 1 Mon!",
|
||||
|
@ -28,8 +45,9 @@ export const DailyCommand = new NamedCommand({
|
|||
]
|
||||
}
|
||||
});
|
||||
} else
|
||||
send({
|
||||
return;
|
||||
} else {
|
||||
await send({
|
||||
embed: {
|
||||
title: "Daily Reward",
|
||||
description: `It's too soon to pick up your daily Mons. Try again at <t:${Math.floor(
|
||||
|
@ -38,8 +56,20 @@ 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`.");
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
export const GuildCommand = new NamedCommand({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue