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