diff --git a/database/0.6/1715967355818-daily/Up/01-table/User.sql b/database/0.6/1715967355818-daily/Up/01-table/User.sql deleted file mode 100644 index 8699650..0000000 --- a/database/0.6/1715967355818-daily/Up/01-table/User.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE `user` -ADD LastUsedDaily datetime null; \ No newline at end of file diff --git a/src/buttonEvents/Claim.ts b/src/buttonEvents/Claim.ts index a643905..f15e1ae 100644 --- a/src/buttonEvents/Claim.ts +++ b/src/buttonEvents/Claim.ts @@ -8,7 +8,6 @@ import CardDropHelperMetadata from "../helpers/CardDropHelperMetadata"; import { readFileSync } from "fs"; import path from "path"; import User from "../database/entities/app/User"; -import CardConstants from "../constants/CardConstants"; export default class Claim extends ButtonEvent { public override async execute(interaction: ButtonInteraction) { @@ -43,11 +42,11 @@ export default class Claim extends ButtonEvent { await inventory.Save(Inventory, inventory); - const user = await User.FetchOneById(User, userId) || new User(userId, CardConstants.StartingCurrency); + const user = await User.FetchOneById(User, userId) || new User(userId, 300); AppLogger.LogSilly("Button/Claim", `${user.Id} has ${user.Currency} currency`); - if (!user.RemoveCurrency(CardConstants.ClaimCost)) { + if (!user.RemoveCurrency(10)) { await interaction.reply(`Not enough currency! You need 10 currency, you have ${user.Currency}`); return; } diff --git a/src/commands/daily.ts b/src/commands/daily.ts deleted file mode 100644 index 172b942..0000000 --- a/src/commands/daily.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { CommandInteraction, SlashCommandBuilder } from "discord.js"; -import { Command } from "../type/command"; -import User from "../database/entities/app/User"; -import CardConstants from "../constants/CardConstants"; -import TimeLengthInput from "../helpers/TimeLengthInput"; - -export default class Daily extends Command { - constructor() { - super(); - - this.CommandBuilder = new SlashCommandBuilder() - .setName("daily") - .setDescription("Gain bonus currency, once a day"); - } - - public override async execute(interaction: CommandInteraction) { - const user = await User.FetchOneById(User, interaction.user.id) ?? new User(interaction.user.id, CardConstants.StartingCurrency); - - const dayAgo = new Date(Date.now() - (1000 * 60 * 60 * 24)); - - if (user.LastUsedDaily && user.LastUsedDaily > dayAgo) { - const timeNow = Date.now(); - const timeLength = 24 * 60 * 60 * 1000; // 1 day - - const timeLeft = Math.ceil(((timeLength - (timeNow - user.LastUsedDaily.getTime()))) / 1000 / 60); - - const timeLeftHours = Math.floor(timeLeft / 60); - const timeLeftMinutes = timeLeft % 60; - - const timeLeftString = new TimeLengthInput(`${timeLeftHours}h ${timeLeftMinutes}m`); - - await interaction.reply(`You have already used the daily command! You can use it again in **${timeLeftString.GetLength()}**.`); - return; - } - - user.AddCurrency(CardConstants.DailyCurrency); - user.UpdateLastUsedDaily(new Date()); - - await user.Save(User, user); - - await interaction.reply(`Given ${CardConstants.DailyCurrency} currency to ${interaction.user.username}`); - } -} \ No newline at end of file diff --git a/src/constants/CardConstants.ts b/src/constants/CardConstants.ts deleted file mode 100644 index dfc89b8..0000000 --- a/src/constants/CardConstants.ts +++ /dev/null @@ -1,5 +0,0 @@ -export default class CardConstants { - public static readonly ClaimCost = 10; - public static readonly DailyCurrency = 100; - public static readonly StartingCurrency = 300; -} \ No newline at end of file diff --git a/src/database/entities/app/User.ts b/src/database/entities/app/User.ts index c3d8437..a909552 100644 --- a/src/database/entities/app/User.ts +++ b/src/database/entities/app/User.ts @@ -13,9 +13,6 @@ export default class User extends AppBaseEntity { @Column() Currency: number; - @Column() - LastUsedDaily?: Date; - public AddCurrency(amount: number) { this.Currency += amount; } @@ -27,8 +24,4 @@ export default class User extends AppBaseEntity { return true; } - - public UpdateLastUsedDaily(lastUsedDaily: Date) { - this.LastUsedDaily = lastUsedDaily; - } } \ No newline at end of file diff --git a/src/database/migrations/app/0.6/1715967355818-daily.ts b/src/database/migrations/app/0.6/1715967355818-daily.ts deleted file mode 100644 index 1c81d18..0000000 --- a/src/database/migrations/app/0.6/1715967355818-daily.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; -import MigrationHelper from "../../../../helpers/MigrationHelper"; - -export class Daily1715967355818 implements MigrationInterface { - - public async up(queryRunner: QueryRunner): Promise { - MigrationHelper.Up("1715967355818-daily", "0.6", [ - "01-table/User", - ], queryRunner); - } - - public async down(): Promise { - } - -} diff --git a/src/registry.ts b/src/registry.ts index dc2770d..15202c5 100644 --- a/src/registry.ts +++ b/src/registry.ts @@ -3,7 +3,6 @@ import { Environment } from "./constants/Environment"; // Global Command Imports import About from "./commands/about"; -import Daily from "./commands/daily"; import Drop from "./commands/drop"; import Gdrivesync from "./commands/gdrivesync"; import Give from "./commands/give"; @@ -30,7 +29,6 @@ export default class Registry { public static RegisterCommands() { // Global Commands CoreClient.RegisterCommand("about", new About()); - CoreClient.RegisterCommand("daily", new Daily()); CoreClient.RegisterCommand("drop", new Drop()); CoreClient.RegisterCommand("gdrivesync", new Gdrivesync()); CoreClient.RegisterCommand("give", new Give());