From e60965476114d127d39d1642ff4971f8fb94f4da Mon Sep 17 00:00:00 2001 From: "Ean Milligan (Bastion)" Date: Thu, 6 Apr 2023 23:23:52 -0400 Subject: [PATCH] Finalize event creation Add active_event db table Rename gameSelection button to gameSelection for consistency Fix prefill for DateTime modal to correctly parse time and to not misparse other embeds Add autoCleanup to finalize step Add whole createEvent step Code usability updates to event-creation utils --- db/initialize.ts | 16 ++++++ src/buttons/_index.ts | 5 +- .../event-creation/step1-gameSelection.ts | 9 +-- src/buttons/event-creation/step2-finalize.ts | 24 ++++++-- .../event-creation/step3-createEvent.ts | 55 +++++++++++++++++++ src/buttons/event-creation/utils.ts | 24 +++++--- src/commands/_index.ts | 4 +- src/db.ts | 1 + 8 files changed, 116 insertions(+), 22 deletions(-) create mode 100644 src/buttons/event-creation/step3-createEvent.ts diff --git a/db/initialize.ts b/db/initialize.ts index 279219b..94e1471 100644 --- a/db/initialize.ts +++ b/db/initialize.ts @@ -13,6 +13,7 @@ console.log('Attempt to drop all tables'); await dbClient.execute(`DROP PROCEDURE IF EXISTS INC_CNT;`); await dbClient.execute(`DROP TABLE IF EXISTS command_cnt;`); await dbClient.execute(`DROP TABLE IF EXISTS guild_settings;`); +await dbClient.execute(`DROP TABLE IF EXISTS active_event;`); console.log('Tables dropped'); console.log('Attempting to create table command_cnt'); @@ -51,5 +52,20 @@ await dbClient.execute(` `); console.log('Table created'); +console.log('Attempting to create table active_event'); +await dbClient.execute(` + CREATE TABLE active_event ( + messageId bigint unsigned NOT NULL, + channelId bigint unsigned NOT NULL, + guildId bigint unsigned NOT NULL, + ownerId bigint unsigned NOT NULL, + eventTime timestamp NOT NULL, + notifiedFlag tinyint(1) NOT NULL DEFAULT 0, + lockedFlag tinyint(1) NOT NULL DEFAULT 0, + PRIMARY KEY (messageId, channelId) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +`); +console.log('Table created'); + await dbClient.close(); console.log('Done!'); diff --git a/src/buttons/_index.ts b/src/buttons/_index.ts index 246e34e..e4b7dd6 100644 --- a/src/buttons/_index.ts +++ b/src/buttons/_index.ts @@ -1,7 +1,8 @@ import { Button } from '../types/commandTypes.ts'; -import { createEventButton } from './event-creation/step1-gameSelection.ts'; +import { gameSelectionButton } from './event-creation/step1-gameSelection.ts'; import { createCustomEventButton } from './event-creation/step1a-openCustomModal.ts'; import { verifyCustomEventButton } from './event-creation/step1b-verifyCustomActivity.ts'; import { finalizeEventButton } from './event-creation/step2-finalize.ts'; +import { createEventButton } from './event-creation/step3-createEvent.ts'; -export const buttons: Array