Skip to content

Commit

Permalink
Test remove old birthday model
Browse files Browse the repository at this point in the history
  • Loading branch information
holzmaster committed Mar 25, 2024
1 parent be291e7 commit b8d4230
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 62 deletions.
5 changes: 3 additions & 2 deletions src/commands/geburtstag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
} from "discord.js";

import type { ApplicationCommand } from "./command.js";
import { isOneBasedMonth } from "../storage/model/Birthday.js";
import log from "../utils/logger.js";
import * as birthday from "../storage/birthday.js";

Expand Down Expand Up @@ -47,7 +46,9 @@ export class GeburtstagCommand implements ApplicationCommand {
const day = command.options.getInteger("day", true);
const month = command.options.getInteger("month", true);

if (!isOneBasedMonth(month)) return;
if (!birthday.isOneBasedMonth(month)) {
return;
}

const date = moment(`${month}-${day}`, "MM-DD");

Expand Down
1 change: 0 additions & 1 deletion src/handler/bdayHandler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { GuildMember, Role } from "discord.js";

import log from "../utils/logger.js";
import Birthday from "../storage/model/Birthday.js";
import * as birthday from "../storage/birthday.js";

import type { BotContext } from "../context.js";
Expand Down
10 changes: 7 additions & 3 deletions src/storage/birthday.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import type { Snowflake } from "discord.js";
import type { Birthday } from "./model";
import type { OneBasedMonth } from "./model/Birthday";

import db from "./kysely";
import type { Birthday } from "./model.js";
import db from "./kysely.js";

export function getBirthday(
userId: Snowflake,
Expand Down Expand Up @@ -60,3 +59,8 @@ export function getAll(ctx = db()) {
function convertMonth(monthId: number): OneBasedMonth {
return (monthId + 1) as OneBasedMonth;
}

export type OneBasedMonth = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
export function isOneBasedMonth(v: unknown): v is OneBasedMonth {
return typeof v === "number" && Number.isInteger(v) && v >= 1 && v <= 12;
}
2 changes: 1 addition & 1 deletion src/storage/model.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Snowflake } from "discord.js";
import type { ColumnType, GeneratedAlways, Selectable } from "kysely";

import type { OneBasedMonth } from "./model/Birthday";
import type { OneBasedMonth } from "./birthday.js";

export interface Database {
birthdays: BirthdayTable;
Expand Down
53 changes: 0 additions & 53 deletions src/storage/model/Birthday.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/storage/storage.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Sequelize } from "sequelize";

import AdditionalMessageData from "./model/AdditionalMessageData.js";
import Birthday from "./model/Birthday.js";
import FadingMessage from "./model/FadingMessage.js";
import GuildRagequit from "./model/GuildRagequit.js";
import Stempel from "./model/Stempel.js";
Expand Down Expand Up @@ -36,7 +35,6 @@ export async function initialize(databasePath: string) {
AdditionalMessageData.initialize(sequelize);
GuildRagequit.initialize(sequelize);
Stempel.initialize(sequelize);
Birthday.initialize(sequelize);
Ban.initialize(sequelize);
Penis.initialize(sequelize);
Boob.initialize(sequelize);
Expand Down

0 comments on commit b8d4230

Please sign in to comment.