Compare commits

..

3 commits

Author SHA1 Message Date
7b620dfd90 WIP: Create base moon command
All checks were successful
Test / build (push) Successful in 8s
2024-07-01 19:03:49 +01:00
50c237f6fa Add database entity 2024-07-01 19:03:25 +01:00
832f88fd85 Add missing values to example .env 2024-07-01 19:02:39 +01:00
7 changed files with 89 additions and 3 deletions

View file

@ -7,7 +7,7 @@
# any secret values. # any secret values.
BOT_TOKEN= BOT_TOKEN=
BOT_VER=3.2.1 BOT_VER=3.3.0
BOT_AUTHOR=Vylpes BOT_AUTHOR=Vylpes
BOT_OWNERID=147392775707426816 BOT_OWNERID=147392775707426816
BOT_CLIENTID=682942374040961060 BOT_CLIENTID=682942374040961060
@ -24,3 +24,5 @@ DB_AUTH_USER=dev
DB_AUTH_PASS=dev DB_AUTH_PASS=dev
DB_SYNC=true DB_SYNC=true
DB_LOGGING=true DB_LOGGING=true
DB_ROOT_HOST=0.0.0.0
DB_DATA_LOCATION=./.temp/database

1
.gitignore vendored
View file

@ -106,3 +106,4 @@ dist
config.json config.json
.DS_Store .DS_Store
ormconfig.json ormconfig.json
.temp/

View file

@ -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;

View file

@ -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;
}
}
}

View file

@ -0,0 +1,5 @@
import {CommandInteraction} from "discord.js";
export default async function ListMoons(interaction: CommandInteraction) {
}

View file

@ -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<Moon[] | null> {
const repository = AppDataSource.getRepository(Moon);
const all = await repository.find({ where: { UserId: userId } });
return all;
}
}

View file

@ -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<void> {
MigrationHelper.Up('1719856023429-CreateMoon', '3.3.0', [
"01-Moon",
], queryRunner);
}
public async down(queryRunner: QueryRunner): Promise<void> {
}
}