Create lobby command
All checks were successful
Test / build (push) Successful in 5s

This commit is contained in:
Ethan Lane 2024-07-03 20:50:47 +01:00
parent 7b620dfd90
commit 690b63470a
4 changed files with 31 additions and 3 deletions

View file

@ -2,7 +2,7 @@ CREATE TABLE `moon` (
`Id` varchar(255) NOT NULL, `Id` varchar(255) NOT NULL,
`WhenCreated` datetime NOT NULL, `WhenCreated` datetime NOT NULL,
`WhenUpdated` datetime NOT NULL, `WhenUpdated` datetime NOT NULL,
`ServerId` varchar(255) 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
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; ) 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) { 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() @Entity()
export default class Moon extends BaseEntity { export default class Moon extends BaseEntity {
constructor(description: string, userId: string) { constructor(moonNumber: number, description: string, userId: string) {
super(); super();
this.MoonNumber = moonNumber;
this.Description = description; this.Description = description;
this.UserId = userId; this.UserId = userId;
} }
@Column()
MoonNumber: number;
@Column() @Column()
Description: string; Description: string;

View file

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