Add list moons command #449

Merged
Vylpes merged 15 commits from feature/195-list-moons into develop 2024-08-17 16:47:14 +01:00
4 changed files with 31 additions and 3 deletions
Showing only changes of commit 690b63470a - Show all commits

View file

@ -2,7 +2,7 @@ CREATE TABLE `moon` (
`Id` varchar(255) NOT NULL,
`WhenCreated` datetime NOT NULL,
`WhenUpdated` datetime NOT NULL,
`ServerId` varchar(255) NOT NULL,
`MoonNumber` int NOT NULL,
`UserId` varchar(255) NOT NULL,
`Description` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

View file

@ -1,5 +1,22 @@
import {CommandInteraction} from "discord.js";
import {CommandInteraction, EmbedBuilder} from "discord.js";
import Moon from "../../../database/entities/Moon";
import EmbedColours from "../../../constants/EmbedColours";
export default async function ListMoons(interaction: CommandInteraction) {
const moons = await Moon.FetchMoonsByUserId(interaction.user.id);
if (!moons || moons.length == 0) {
await interaction.reply("You do not have any moons.");
return;
}
const description = moons.flatMap(x => `${x.MoonNumber}. ${x.Description.slice(0, 15)}`);
const embed = new EmbedBuilder()
.setTitle(`${interaction.user.username}'s Moons`)
.setColor(EmbedColours.Ok)
.setDescription(description.join("\n"))
.setFooter({ text: `${moons.length} moons` });
await interaction.reply({ embeds: [ embed ] });
}

View file

@ -4,13 +4,17 @@ import AppDataSource from "../dataSources/appDataSource";
@Entity()
export default class Moon extends BaseEntity {
constructor(description: string, userId: string) {
constructor(moonNumber: number, description: string, userId: string) {
super();
this.MoonNumber = moonNumber;
this.Description = description;
this.UserId = userId;
}
@Column()
MoonNumber: number;
@Column()
Description: string;

View file

@ -30,6 +30,9 @@ import AddLobby from "./commands/501231711271780357/Lobby/add";
import RemoveLobby from "./commands/501231711271780357/Lobby/remove";
import ListLobby from "./commands/501231711271780357/Lobby/list";
// Command Imports: Potato Talk
import Moons from "./commands/304276391837302787/moons";
// Event Imports
import GuildMemberAdd from "./events/MemberEvents/GuildMemberAdd";
import GuildMemberRemove from "./events/MemberEvents/GuildMemberRemove";
@ -72,12 +75,16 @@ export default class Registry {
CoreClient.RegisterCommand("listlobby", new ListLobby(), "501231711271780357");
CoreClient.RegisterCommand("entry", new Entry(), "501231711271780357");
// Exclusive Commands: Potato Talk
CoreClient.RegisterCommand("moons", new Moons(), "304276391837302787");
// Add Exclusive Commands to Test Server
CoreClient.RegisterCommand("lobby", new Lobby(), "442730357897429002");
CoreClient.RegisterCommand("addlobby", new AddLobby(), "442730357897429002");
CoreClient.RegisterCommand("removelobby", new RemoveLobby(), "442730357897429002");
CoreClient.RegisterCommand("listlobby", new ListLobby(), "442730357897429002");
CoreClient.RegisterCommand("entry", new Entry(), "442730357897429002");
CoreClient.RegisterCommand("moons", new Moons(), "442730357897429002");
}
public static RegisterEvents() {