Compare commits
4 commits
dc3cb93653
...
e7527abdf9
Author | SHA1 | Date | |
---|---|---|---|
e7527abdf9 | |||
89b3af9523 | |||
afbee94a75 | |||
736cbe0ac1 |
5 changed files with 11 additions and 8 deletions
|
@ -5,5 +5,6 @@ CREATE TABLE `moon` (
|
|||
`MoonNumber` int NOT NULL,
|
||||
`UserId` varchar(255) NOT NULL,
|
||||
`Description` varchar(255) NOT NULL
|
||||
`WhenArchived` datetime NULL,
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import List from "./moons/list";
|
|||
|
||||
export default class Moons extends ButtonEvent {
|
||||
public override async execute(interaction: ButtonInteraction): Promise<void> {
|
||||
const action = interaction.customId.split(" ")[0];
|
||||
const action = interaction.customId.split(" ")[1];
|
||||
|
||||
switch (action) {
|
||||
case "list":
|
||||
|
|
|
@ -5,11 +5,10 @@ import EmbedColours from "../../constants/EmbedColours";
|
|||
export default async function List(interaction: ButtonInteraction) {
|
||||
if (!interaction.guild) return;
|
||||
|
||||
const userId = interaction.customId.split(" ")[1];
|
||||
const page = interaction.customId.split(" ")[2];
|
||||
const userId = interaction.customId.split(" ")[2];
|
||||
const page = interaction.customId.split(" ")[3];
|
||||
|
||||
if (!userId || !page) return;
|
||||
if (!Number(page)) return;
|
||||
|
||||
const pageNumber = Number(page);
|
||||
|
||||
|
@ -32,7 +31,7 @@ export default async function List(interaction: ButtonInteraction) {
|
|||
.setTitle(`${member?.user.username}'s Moons`)
|
||||
.setColor(EmbedColours.Ok)
|
||||
.setDescription(description.join("\n"))
|
||||
.setFooter({ text: `${moons.length} moons` });
|
||||
.setFooter({ text: `Page ${page + 1} of ${totalPages} · ${moons[1]} moons` });
|
||||
|
||||
const row = new ActionRowBuilder<ButtonBuilder>()
|
||||
.addComponents(
|
||||
|
|
|
@ -23,7 +23,7 @@ export default async function ListMoons(interaction: CommandInteraction) {
|
|||
.setTitle(`${user.username}'s Moons`)
|
||||
.setColor(EmbedColours.Ok)
|
||||
.setDescription(description.join("\n"))
|
||||
.setFooter({ text: `${moons.length} moons` });
|
||||
.setFooter({ text: `Page ${page + 1} of ${totalPages} · ${moons[1]} moons` });
|
||||
|
||||
const row = new ActionRowBuilder<ButtonBuilder>()
|
||||
.addComponents(
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Column, Entity } from "typeorm";
|
||||
import { Column, Entity, IsNull } from "typeorm";
|
||||
import BaseEntity from "../../contracts/BaseEntity";
|
||||
import AppDataSource from "../dataSources/appDataSource";
|
||||
|
||||
|
@ -18,6 +18,9 @@ export default class Moon extends BaseEntity {
|
|||
@Column()
|
||||
Description: string;
|
||||
|
||||
@Column({ nullable: true })
|
||||
WhenArchived?: Date;
|
||||
|
||||
@Column()
|
||||
UserId: string;
|
||||
|
||||
|
@ -35,7 +38,7 @@ export default class Moon extends BaseEntity {
|
|||
const repository = AppDataSource.getRepository(Moon);
|
||||
|
||||
const moons = await repository.findAndCount({
|
||||
where: { UserId: userId },
|
||||
where: { UserId: userId, WhenArchived: IsNull() },
|
||||
order: { MoonNumber: "ASC" },
|
||||
skip: rangeStart,
|
||||
take: pageLength,
|
||||
|
|
Loading…
Reference in a new issue