Compare commits
No commits in common. "476ff7cfc4257f5682d09c61da50378bf8b83dec" and "789d5d6410b377e76eed61c6e0c19236656528a4" have entirely different histories.
476ff7cfc4
...
789d5d6410
6 changed files with 7 additions and 25 deletions
|
@ -4,5 +4,8 @@ CREATE TABLE `user_setting` (
|
|||
`WhenUpdated` datetime NOT NULL,
|
||||
`UserId` varchar(255) NOT NULL,
|
||||
`Key` varchar(255) NOT NULL,
|
||||
`Value` varchar(255) NOT NULL
|
||||
`Value` varchar(255) NOT NULL,
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||||
|
||||
ALTER TABLE `user_setting`
|
||||
ADD PRIMARY KEY (`Id`);
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
ALTER TABLE user_setting
|
||||
ADD PRIMARY KEY (Id);
|
|
@ -1,7 +1,6 @@
|
|||
import {ActionRowBuilder, ButtonBuilder, ButtonInteraction, ButtonStyle, EmbedBuilder} from "discord.js";
|
||||
import Moon from "../../database/entities/304276391837302787/Moon";
|
||||
import EmbedColours from "../../constants/EmbedColours";
|
||||
import UserSetting from "../../database/entities/UserSetting";
|
||||
|
||||
export default async function List(interaction: ButtonInteraction) {
|
||||
if (!interaction.guild) return;
|
||||
|
@ -24,9 +23,6 @@ export default async function List(interaction: ButtonInteraction) {
|
|||
return;
|
||||
}
|
||||
|
||||
const moonSetting = await UserSetting.FetchOneByKey(userId, "moons");
|
||||
const totalMoons = moonSetting && Number(moonSetting.Value) ? Number(moonSetting.Value) : 0;
|
||||
|
||||
const totalPages = Math.ceil(moons[1] / pageLength);
|
||||
|
||||
const description = moons[0].flatMap(x => `**${x.MoonNumber} -** ${x.Description.slice(0, 15)}`);
|
||||
|
@ -35,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: `Page ${pageNumber + 1} of ${totalPages} · ${totalMoons} moons` });
|
||||
.setFooter({ text: `Page ${page + 1} of ${totalPages} · ${moons[1]} moons` });
|
||||
|
||||
const row = new ActionRowBuilder<ButtonBuilder>()
|
||||
.addComponents(
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import {CommandInteraction, EmbedBuilder} from "discord.js";
|
||||
import Moon from "../../../database/entities/304276391837302787/Moon";
|
||||
import EmbedColours from "../../../constants/EmbedColours";
|
||||
import UserSetting from "../../../database/entities/UserSetting";
|
||||
|
||||
export default async function AddMoon(interaction: CommandInteraction) {
|
||||
const description = interaction.options.get("description", true).value?.toString();
|
||||
|
@ -11,16 +10,7 @@ export default async function AddMoon(interaction: CommandInteraction) {
|
|||
return;
|
||||
}
|
||||
|
||||
let moonSetting = await UserSetting.FetchOneByKey(interaction.user.id, "moons");
|
||||
const moonCount = moonSetting && Number(moonSetting.Value) ? Number(moonSetting.Value) : 0;
|
||||
|
||||
if (moonSetting) {
|
||||
moonSetting.UpdateValue(`${moonCount + 1}`);
|
||||
} else {
|
||||
moonSetting = new UserSetting(interaction.user.id, "moons", `${moonCount + 1}`);
|
||||
}
|
||||
|
||||
await moonSetting.Save(UserSetting, moonSetting);
|
||||
const moonCount = await Moon.FetchMoonCountByUserId(interaction.user.id);
|
||||
|
||||
const moon = new Moon(moonCount + 1, description, interaction.user.id);
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import {ActionRowBuilder, ButtonBuilder, ButtonStyle, CommandInteraction, EmbedBuilder} from "discord.js";
|
||||
import Moon from "../../../database/entities/304276391837302787/Moon";
|
||||
import EmbedColours from "../../../constants/EmbedColours";
|
||||
import UserSetting from "../../../database/entities/UserSetting";
|
||||
|
||||
export default async function ListMoons(interaction: CommandInteraction) {
|
||||
const user = interaction.options.get("user")?.user ?? interaction.user;
|
||||
|
@ -16,9 +15,6 @@ export default async function ListMoons(interaction: CommandInteraction) {
|
|||
return;
|
||||
}
|
||||
|
||||
const moonSetting = await UserSetting.FetchOneByKey(interaction.user.id, "moons");
|
||||
const totalMoons = moonSetting && Number(moonSetting.Value) ? Number(moonSetting.Value) : 0;
|
||||
|
||||
const totalPages = Math.ceil(moons[1] / pageLength);
|
||||
|
||||
const description = moons[0].flatMap(x => `**${x.MoonNumber} -** ${x.Description.slice(0, 15)}`);
|
||||
|
@ -27,7 +23,7 @@ export default async function ListMoons(interaction: CommandInteraction) {
|
|||
.setTitle(`${user.username}'s Moons`)
|
||||
.setColor(EmbedColours.Ok)
|
||||
.setDescription(description.join("\n"))
|
||||
.setFooter({ text: `Page ${page + 1} of ${totalPages} · ${totalMoons} moons` });
|
||||
.setFooter({ text: `Page ${page + 1} of ${totalPages} · ${moons[1]} moons` });
|
||||
|
||||
const row = new ActionRowBuilder<ButtonBuilder>()
|
||||
.addComponents(
|
||||
|
|
|
@ -6,7 +6,6 @@ export class CreateUserSetting1727286976268 implements MigrationInterface {
|
|||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
MigrationHelper.Up('1727286976268-CreateUserSetting', '3.3.0', [
|
||||
"01-UserSetting",
|
||||
"02-UserSettingKey",
|
||||
], queryRunner);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue