From 832f88fd859dbf4a1e7e9d7b6655e748c07b089f Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Mon, 1 Jul 2024 19:02:39 +0100 Subject: [PATCH 1/3] Add missing values to example .env --- .env.example | 6 ++++-- .gitignore | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.env.example b/.env.example index 674b0f8..9c92b48 100644 --- a/.env.example +++ b/.env.example @@ -7,7 +7,7 @@ # any secret values. BOT_TOKEN= -BOT_VER=3.2.1 +BOT_VER=3.3.0 BOT_AUTHOR=Vylpes BOT_OWNERID=147392775707426816 BOT_CLIENTID=682942374040961060 @@ -23,4 +23,6 @@ DB_NAME=vylbot DB_AUTH_USER=dev DB_AUTH_PASS=dev DB_SYNC=true -DB_LOGGING=true \ No newline at end of file +DB_LOGGING=true +DB_ROOT_HOST=0.0.0.0 +DB_DATA_LOCATION=./.temp/database diff --git a/.gitignore b/.gitignore index 1707d85..c6754e1 100644 --- a/.gitignore +++ b/.gitignore @@ -105,4 +105,5 @@ dist config.json .DS_Store -ormconfig.json \ No newline at end of file +ormconfig.json +.temp/ From 50c237f6fa59efe7098307d77695fdfcdf7494e7 Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Mon, 1 Jul 2024 19:03:25 +0100 Subject: [PATCH 2/3] Add database entity --- .../1719856023429-CreateMoon/Up/01-Moon.sql | 9 +++++++ src/database/entities/Moon.ts | 27 +++++++++++++++++++ .../3.3/1719856023429-CreateMoon.ts | 15 +++++++++++ 3 files changed, 51 insertions(+) create mode 100644 database/3.3.0/1719856023429-CreateMoon/Up/01-Moon.sql create mode 100644 src/database/entities/Moon.ts create mode 100644 src/database/migrations/3.3/1719856023429-CreateMoon.ts diff --git a/database/3.3.0/1719856023429-CreateMoon/Up/01-Moon.sql b/database/3.3.0/1719856023429-CreateMoon/Up/01-Moon.sql new file mode 100644 index 0000000..38ef6b2 --- /dev/null +++ b/database/3.3.0/1719856023429-CreateMoon/Up/01-Moon.sql @@ -0,0 +1,9 @@ +CREATE TABLE `moon` ( + `Id` varchar(255) NOT NULL, + `WhenCreated` datetime NOT NULL, + `WhenUpdated` datetime NOT NULL, + `ServerId` varchar(255) NOT NULL, + `UserId` varchar(255) NOT NULL, + `Description` varchar(255) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; + diff --git a/src/database/entities/Moon.ts b/src/database/entities/Moon.ts new file mode 100644 index 0000000..cedf96f --- /dev/null +++ b/src/database/entities/Moon.ts @@ -0,0 +1,27 @@ +import { Column, Entity } from "typeorm"; +import BaseEntity from "../../contracts/BaseEntity"; +import AppDataSource from "../dataSources/appDataSource"; + +@Entity() +export default class Moon extends BaseEntity { + constructor(description: string, userId: string) { + super(); + + this.Description = description; + this.UserId = userId; + } + + @Column() + Description: string; + + @Column() + UserId: string; + + public static async FetchMoonsByUserId(userId: string): Promise { + const repository = AppDataSource.getRepository(Moon); + + const all = await repository.find({ where: { UserId: userId } }); + + return all; + } +} diff --git a/src/database/migrations/3.3/1719856023429-CreateMoon.ts b/src/database/migrations/3.3/1719856023429-CreateMoon.ts new file mode 100644 index 0000000..0ccc820 --- /dev/null +++ b/src/database/migrations/3.3/1719856023429-CreateMoon.ts @@ -0,0 +1,15 @@ +import { MigrationInterface, QueryRunner } from "typeorm" +import MigrationHelper from "../../../helpers/MigrationHelper" + +export class CreateMoon1719856023429 implements MigrationInterface { + + public async up(queryRunner: QueryRunner): Promise { + MigrationHelper.Up('1719856023429-CreateMoon', '3.3.0', [ + "01-Moon", + ], queryRunner); + } + + public async down(queryRunner: QueryRunner): Promise { + } + +} From 7b620dfd90c2439833e785cd572b24fa642c4981 Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Mon, 1 Jul 2024 19:03:49 +0100 Subject: [PATCH 3/3] WIP: Create base moon command --- src/commands/304276391837302787/moons.ts | 27 +++++++++++++++++++ src/commands/304276391837302787/moons/list.ts | 5 ++++ 2 files changed, 32 insertions(+) create mode 100644 src/commands/304276391837302787/moons.ts create mode 100644 src/commands/304276391837302787/moons/list.ts diff --git a/src/commands/304276391837302787/moons.ts b/src/commands/304276391837302787/moons.ts new file mode 100644 index 0000000..1556d97 --- /dev/null +++ b/src/commands/304276391837302787/moons.ts @@ -0,0 +1,27 @@ +import { Command } from "../../type/command"; +import { CommandInteraction, SlashCommandBuilder } from "discord.js"; +import ListMoons from "./moons/list"; + +export default class Moons extends Command { + constructor() { + super(); + + this.CommandBuilder = new SlashCommandBuilder() + .setName("moons") + .setDescription("View and create moons") + .addSubcommand(subcommand => + subcommand + .setName('list') + .setDescription('List moons you have obtained')); + } + + public override async execute(interaction: CommandInteraction) { + if (!interaction.isChatInputCommand()) return; + + switch (interaction.options.getSubcommand()) { + case "list": + await ListMoons(interaction); + break; + } + } +} diff --git a/src/commands/304276391837302787/moons/list.ts b/src/commands/304276391837302787/moons/list.ts new file mode 100644 index 0000000..023fa89 --- /dev/null +++ b/src/commands/304276391837302787/moons/list.ts @@ -0,0 +1,5 @@ +import {CommandInteraction} from "discord.js"; + +export default async function ListMoons(interaction: CommandInteraction) { + +}