From 4d20d9e6080d30fae268c8be9516186f70208740 Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Sun, 29 Sep 2024 13:51:00 +0100 Subject: [PATCH] WIP: Start of moonset command --- src/commands/304276391837302787/moons/add.ts | 8 +++++- src/commands/304276391837302787/moonset.ts | 28 ++++++++++++++++++++ src/helpers/UserSettingsHelper.ts | 5 ++++ 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 src/commands/304276391837302787/moonset.ts create mode 100644 src/helpers/UserSettingsHelper.ts diff --git a/src/commands/304276391837302787/moons/add.ts b/src/commands/304276391837302787/moons/add.ts index 790153d..10a2d17 100644 --- a/src/commands/304276391837302787/moons/add.ts +++ b/src/commands/304276391837302787/moons/add.ts @@ -24,7 +24,13 @@ export default async function AddMoon(interaction: CommandInteraction) { const allMoons = await Moon.FetchMoonCountByUserId(interaction.user.id); - const moon = new Moon(allMoons + 1, description, interaction.user.id); + let moonNumber = allMoons + 1; + + if (allMoons < moonCount) { + moonNumber = moonCount + 1; + } + + const moon = new Moon(moonNumber, description, interaction.user.id); await moon.Save(Moon, moon); diff --git a/src/commands/304276391837302787/moonset.ts b/src/commands/304276391837302787/moonset.ts new file mode 100644 index 0000000..a4eeedb --- /dev/null +++ b/src/commands/304276391837302787/moonset.ts @@ -0,0 +1,28 @@ +import { CommandInteraction, PermissionFlagsBits, SlashCommandBuilder } from "discord.js"; +import { Command } from "../../type/command"; +import UserSetting from "../../database/entities/UserSetting"; + +export default class MoonSet extends Command { + constructor() { + super(); + + this.CommandBuilder = new SlashCommandBuilder() + .setName("moonset") + .setDescription("Manually set a user's moons") + .setDefaultMemberPermissions(PermissionFlagsBits.Administrator) + .addUserOption(x => x + .setName("user") + .setDescription("The user to set") + .setRequired(true)) + .addNumberOption(x => x + .setName("count") + .setDescription("The amount the user will have") + .setRequired(true) + .setMinValue(0)); + } + + public override async execute(interaction: CommandInteraction) { + const user = interaction.options.get("user", true).user!; + const count = interaction.options.get("count", true).value! as number; + } +} \ No newline at end of file diff --git a/src/helpers/UserSettingsHelper.ts b/src/helpers/UserSettingsHelper.ts new file mode 100644 index 0000000..683a39f --- /dev/null +++ b/src/helpers/UserSettingsHelper.ts @@ -0,0 +1,5 @@ +import DefaultValues from "../constants/DefaultValues"; +import UserSetting from "../database/entities/UserSetting"; + +export default class UserSettingsHelper { +} \ No newline at end of file