Compare commits
1 commit
81483a8cf0
...
894fcdc9f4
Author | SHA1 | Date | |
---|---|---|---|
894fcdc9f4 |
7 changed files with 33 additions and 88 deletions
|
@ -1,5 +1,5 @@
|
|||
import {ActionRowBuilder, ButtonBuilder, ButtonInteraction, ButtonStyle, EmbedBuilder} from "discord.js";
|
||||
import Moon from "../../database/entities/304276391837302787/Moon";
|
||||
import Moon from "../../database/entities/Moon";
|
||||
import EmbedColours from "../../constants/EmbedColours";
|
||||
|
||||
export default async function List(interaction: ButtonInteraction) {
|
||||
|
@ -25,7 +25,7 @@ export default async function List(interaction: ButtonInteraction) {
|
|||
|
||||
const totalPages = Math.ceil(moons[1] / pageLength);
|
||||
|
||||
const description = moons[0].flatMap(x => `**${x.MoonNumber} -** ${x.Description.slice(0, 15)}`);
|
||||
const description = moons[0].flatMap(x => `${x.MoonNumber}. ${x.Description.slice(0, 15)}`);
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle(`${member?.user.username}'s Moons`)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { Command } from "../../type/command";
|
||||
import { CommandInteraction, SlashCommandBuilder } from "discord.js";
|
||||
import ListMoons from "./moons/list";
|
||||
import AddMoon from "./moons/add";
|
||||
|
||||
export default class Moons extends Command {
|
||||
constructor() {
|
||||
|
@ -21,16 +20,7 @@ export default class Moons extends Command {
|
|||
.addNumberOption(option =>
|
||||
option
|
||||
.setName("page")
|
||||
.setDescription("The page to start with")))
|
||||
.addSubcommand(subcommand =>
|
||||
subcommand
|
||||
.setName('add')
|
||||
.setDescription('Add a moon to your count!')
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName("description")
|
||||
.setDescription("What deserved a moon?")
|
||||
.setRequired(true)));
|
||||
.setDescription("The page to start with")));
|
||||
}
|
||||
|
||||
public override async execute(interaction: CommandInteraction) {
|
||||
|
@ -40,9 +30,6 @@ export default class Moons extends Command {
|
|||
case "list":
|
||||
await ListMoons(interaction);
|
||||
break;
|
||||
case "add":
|
||||
await AddMoon(interaction);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
import {CommandInteraction, EmbedBuilder} from "discord.js";
|
||||
import Moon from "../../../database/entities/304276391837302787/Moon";
|
||||
import EmbedColours from "../../../constants/EmbedColours";
|
||||
|
||||
export default async function AddMoon(interaction: CommandInteraction) {
|
||||
const description = interaction.options.get("description", true).value?.toString();
|
||||
|
||||
if (!description || description.length > 255) {
|
||||
await interaction.reply("Name must be less than 255 characters!");
|
||||
return;
|
||||
}
|
||||
|
||||
const moonCount = await Moon.FetchMoonCountByUserId(interaction.user.id);
|
||||
|
||||
const moon = new Moon(moonCount + 1, description, interaction.user.id);
|
||||
|
||||
await moon.Save(Moon, moon);
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle(`${interaction.user.globalName} Got A Moon!`)
|
||||
.setColor(EmbedColours.Moon)
|
||||
.setDescription(`**${moon.MoonNumber} -** ${moon.Description}`)
|
||||
.setThumbnail("https://cdn.discordapp.com/emojis/374131312182689793.webp?size=96&quality=lossless");
|
||||
|
||||
await interaction.reply({ embeds: [ embed ] });
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
import {ActionRowBuilder, ButtonBuilder, ButtonStyle, CommandInteraction, EmbedBuilder} from "discord.js";
|
||||
import Moon from "../../../database/entities/304276391837302787/Moon";
|
||||
import Moon from "../../../database/entities/Moon";
|
||||
import EmbedColours from "../../../constants/EmbedColours";
|
||||
|
||||
export default async function ListMoons(interaction: CommandInteraction) {
|
||||
|
@ -17,7 +17,7 @@ export default async function ListMoons(interaction: CommandInteraction) {
|
|||
|
||||
const totalPages = Math.ceil(moons[1] / pageLength);
|
||||
|
||||
const description = moons[0].flatMap(x => `**${x.MoonNumber} -** ${x.Description.slice(0, 15)}`);
|
||||
const description = moons[0].flatMap(x => `${x.MoonNumber}. ${x.Description.slice(0, 15)}`);
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle(`${user.username}'s Moons`)
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
export default class EmbedColours {
|
||||
public static readonly Ok = 0x3050ba;
|
||||
public static readonly Moon = 0x50C878;
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
import { Column, Entity, IsNull } from "typeorm";
|
||||
import BaseEntity from "../../../contracts/BaseEntity";
|
||||
import AppDataSource from "../../dataSources/appDataSource";
|
||||
import BaseEntity from "../../contracts/BaseEntity";
|
||||
import AppDataSource from "../dataSources/appDataSource";
|
||||
|
||||
@Entity()
|
||||
export default class Moon extends BaseEntity {
|
||||
|
@ -46,12 +46,4 @@ export default class Moon extends BaseEntity {
|
|||
|
||||
return moons;
|
||||
}
|
||||
|
||||
public static async FetchMoonCountByUserId(userId: string): Promise<number> {
|
||||
const repository = AppDataSource.getRepository(Moon);
|
||||
|
||||
const count = await repository.count({ where: { UserId: userId } });
|
||||
|
||||
return count;
|
||||
}
|
||||
}
|
59
yarn.lock
59
yarn.lock
|
@ -767,19 +767,12 @@
|
|||
expect "^29.0.0"
|
||||
pretty-format "^29.0.0"
|
||||
|
||||
"@types/node@*":
|
||||
version "22.5.0"
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-22.5.0.tgz#10f01fe9465166b4cab72e75f60d8b99d019f958"
|
||||
integrity sha512-DkFrJOe+rfdHTqqMg0bSNlGlQ85hSoh2TPzZyhHsXnMtligRWpxUySiyw8FY14ITt24HVCiQPWxS3KO/QlGmWg==
|
||||
"@types/node@*", "@types/node@^22.0.0":
|
||||
version "22.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-22.2.0.tgz#7cf046a99f0ba4d628ad3088cb21f790df9b0c5b"
|
||||
integrity sha512-bm6EG6/pCpkxDf/0gDNDdtDILMOHgaQBVOJGdwsqClnxA3xL6jtMv76rLBc006RVMWbmaf0xbmom4Z/5o2nRkQ==
|
||||
dependencies:
|
||||
undici-types "~6.19.2"
|
||||
|
||||
"@types/node@^22.0.0":
|
||||
version "22.5.5"
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-22.5.5.tgz#52f939dd0f65fc552a4ad0b392f3c466cc5d7a44"
|
||||
integrity sha512-Xjs4y5UPO/CLdzpgR6GirZJx36yScjh73+2NlLlkFRSoQN8B0DpfXPdZGnvVmLRLOsqDpOfTNv7D9trgGhmOIA==
|
||||
dependencies:
|
||||
undici-types "~6.19.2"
|
||||
undici-types "~6.13.0"
|
||||
|
||||
"@types/normalize-package-data@^2.4.3":
|
||||
version "2.4.4"
|
||||
|
@ -951,9 +944,9 @@ argparse@^2.0.1:
|
|||
integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==
|
||||
|
||||
async@^3.2.3:
|
||||
version "3.2.6"
|
||||
resolved "https://registry.yarnpkg.com/async/-/async-3.2.6.tgz#1b0728e14929d51b85b449b7f06e27c1145e38ce"
|
||||
integrity sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==
|
||||
version "3.2.5"
|
||||
resolved "https://registry.yarnpkg.com/async/-/async-3.2.5.tgz#ebd52a8fdaf7a2289a24df399f8d8485c8a46b66"
|
||||
integrity sha512-baNZyqaaLhyLVKm/DlvdW051MSgO6b8eVfIezl9E5PqWxFgzLm/wQntEW4zOytVburDEr0JlALEpdOFwvErLsg==
|
||||
|
||||
babel-jest@^29.7.0:
|
||||
version "29.7.0"
|
||||
|
@ -1085,7 +1078,7 @@ browserslist@^4.23.1:
|
|||
node-releases "^2.0.18"
|
||||
update-browserslist-db "^1.1.0"
|
||||
|
||||
bs-logger@^0.2.6:
|
||||
bs-logger@0.x:
|
||||
version "0.2.6"
|
||||
resolved "https://registry.yarnpkg.com/bs-logger/-/bs-logger-0.2.6.tgz#eb7d365307a72cf974cc6cda76b68354ad336bd8"
|
||||
integrity sha512-pd8DCoxmbgc7hyPKOvxtqNcjYoOsABPQdcCUjGp3d42VR2CX1ORhk2A87oqqu5R1kk+76nsxZupkmyd+MVtCog==
|
||||
|
@ -2998,7 +2991,7 @@ locate-path@^5.0.0:
|
|||
dependencies:
|
||||
p-locate "^4.1.0"
|
||||
|
||||
lodash.memoize@^4.1.2:
|
||||
lodash.memoize@4.x:
|
||||
version "4.1.2"
|
||||
resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe"
|
||||
integrity sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==
|
||||
|
@ -3084,7 +3077,7 @@ make-dir@^4.0.0:
|
|||
dependencies:
|
||||
semver "^7.5.3"
|
||||
|
||||
make-error@^1.3.6:
|
||||
make-error@1.x:
|
||||
version "1.3.6"
|
||||
resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2"
|
||||
integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==
|
||||
|
@ -3890,7 +3883,7 @@ semver-diff@^4.0.0:
|
|||
dependencies:
|
||||
semver "^7.3.5"
|
||||
|
||||
semver@^6.3.0, semver@^6.3.1, semver@^7.3.5, semver@^7.5.2, semver@^7.5.3, semver@^7.5.4, semver@^7.6.0, semver@^7.6.2, semver@^7.6.3:
|
||||
semver@^6.3.0, semver@^6.3.1, semver@^7.3.5, semver@^7.5.2, semver@^7.5.3, semver@^7.5.4, semver@^7.6.0, semver@^7.6.2:
|
||||
version "7.6.2"
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.2.tgz#1e3b34759f896e8f14d6134732ce798aeb0c6e13"
|
||||
integrity sha512-FNAIBWCx9qcRhoHcgcJ0gvU7SN1lYU2ZXuSfl04bSC5OpvDHFyJCjdNHomPXxjQlCBU67YW64PzY7/VIEH7F2w==
|
||||
|
@ -4249,19 +4242,19 @@ ts-essentials@^10.0.0:
|
|||
integrity sha512-HPH+H2bkkO8FkMDau+hFvv7KYozzned9Zr1Urn7rRPXMF4mZmCKOq+u4AI1AAW+2bofIOXTuSdKo9drQuni2dQ==
|
||||
|
||||
ts-jest@^29.2.4:
|
||||
version "29.2.5"
|
||||
resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-29.2.5.tgz#591a3c108e1f5ebd013d3152142cb5472b399d63"
|
||||
integrity sha512-KD8zB2aAZrcKIdGk4OwpJggeLcH1FgrICqDSROWqlnJXGCXK4Mn6FcdK2B6670Xr73lHMG1kHw8R87A0ecZ+vA==
|
||||
version "29.2.4"
|
||||
resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-29.2.4.tgz#38ccf487407d7a63054a72689f6f99b075e296e5"
|
||||
integrity sha512-3d6tgDyhCI29HlpwIq87sNuI+3Q6GLTTCeYRHCs7vDz+/3GCMwEtV9jezLyl4ZtnBgx00I7hm8PCP8cTksMGrw==
|
||||
dependencies:
|
||||
bs-logger "^0.2.6"
|
||||
bs-logger "0.x"
|
||||
ejs "^3.1.10"
|
||||
fast-json-stable-stringify "^2.1.0"
|
||||
fast-json-stable-stringify "2.x"
|
||||
jest-util "^29.0.0"
|
||||
json5 "^2.2.3"
|
||||
lodash.memoize "^4.1.2"
|
||||
make-error "^1.3.6"
|
||||
semver "^7.6.3"
|
||||
yargs-parser "^21.1.1"
|
||||
lodash.memoize "4.x"
|
||||
make-error "1.x"
|
||||
semver "^7.5.3"
|
||||
yargs-parser "^21.0.1"
|
||||
|
||||
ts-mixer@^6.0.4:
|
||||
version "6.0.4"
|
||||
|
@ -4346,10 +4339,10 @@ typescript@^5.0.0:
|
|||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.5.4.tgz#d9852d6c82bad2d2eda4fd74a5762a8f5909e9ba"
|
||||
integrity sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==
|
||||
|
||||
undici-types@~6.19.2:
|
||||
version "6.19.8"
|
||||
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.19.8.tgz#35111c9d1437ab83a7cdc0abae2f26d88eda0a02"
|
||||
integrity sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==
|
||||
undici-types@~6.13.0:
|
||||
version "6.13.0"
|
||||
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.13.0.tgz#e3e79220ab8c81ed1496b5812471afd7cf075ea5"
|
||||
integrity sha512-xtFJHudx8S2DSoujjMd1WeWvn7KKWFRESZTMeL1RptAYERu29D6jphMjjY+vn96jvN3kVPDNxU/E13VTaXj6jg==
|
||||
|
||||
undici@6.13.0, undici@^6.0.0:
|
||||
version "6.19.2"
|
||||
|
@ -4546,7 +4539,7 @@ yargs-parser@^20.2.2:
|
|||
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee"
|
||||
integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==
|
||||
|
||||
yargs-parser@^21.1.1:
|
||||
yargs-parser@^21.0.1, yargs-parser@^21.1.1:
|
||||
version "21.1.1"
|
||||
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.1.1.tgz#9096bceebf990d21bb31fa9516e0ede294a77d35"
|
||||
integrity sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==
|
||||
|
|
Loading…
Reference in a new issue