From fbb423fd7d2684bb2d894bd440683808493f658e Mon Sep 17 00:00:00 2001 From: Jacob Jackson Date: Thu, 24 Aug 2023 11:54:23 -0400 Subject: [PATCH 1/3] chore: update dependencies --- package.json | 6 +++--- src/utils.ts | 2 +- tsconfig.json | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 8066142..5532f25 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,8 @@ "module": "src/index.ts", "type": "module", "devDependencies": { - "better-sqlite3": "^8.5.1", - "bun-types": "^0.7.3", + "better-sqlite3": "^8.5.2", + "bun-types": "^0.8.0", "drizzle-kit": "^0.19.13", "rome": "^12.1.3" }, @@ -15,7 +15,7 @@ "bufferutil": "^4.0.7", "discord.js": "^14.13.0", "djs-fsrouter": "^0.0.4", - "drizzle-orm": "^0.28.3", + "drizzle-orm": "^0.28.5", "erlpack": "^0.1.4", "utf-8-validate": "^6.0.3", "zlib-sync": "^0.1.8" diff --git a/src/utils.ts b/src/utils.ts index 303ebba..96c7605 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,5 +1,5 @@ import db from "./db.ts"; -import { Config } from "./schemas/config"; +import { Config } from "./schemas/config.ts"; import { sql, eq } from "drizzle-orm"; /** * Casts a value into an array. diff --git a/tsconfig.json b/tsconfig.json index 9481ce7..1b4a064 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,7 +11,7 @@ "allowImportingTsExtensions": true, "moduleDetection": "force", // drizzle orm errors with nodenext - "moduleResolution": "Bundler", + "moduleResolution": "NodeNext", "esModuleInterop": true, "strict": true, From b5f8de682f8f9253aa0c382399c4fb94b14e7630 Mon Sep 17 00:00:00 2001 From: stifskere Date: Sat, 26 Aug 2023 21:32:31 +0200 Subject: [PATCH 2/3] cool commit added some types, provisional database global keyvaluepair, the qotw reminder and manager Signed-off-by: stifskere --- .idea/.gitignore | 5 + .idea/JavaScripters-Bot.iml | 12 + .idea/dataSources.local.xml | 17 + .idea/dataSources.xml | 12 + .../23972307-5e57-4eed-951d-e85ea59a1d80.xml | 1532 +++++++++++++++++ .../storage_v2/_src_/schema/main.uQUzAA.meta | 2 + .idea/misc.xml | 7 + .idea/modules.xml | 8 + .idea/vcs.xml | 6 + src/Exports.ts | 10 + src/commands/info.ts | 7 +- src/commands/qotw-date.ts | 49 + src/index.ts | 14 +- src/listeners/qotwReminder.ts | 14 + src/schemas/config.ts | 2 +- src/schemas/keyvaluepair.ts | 11 + src/types/IntRange.ts | 6 + src/types/qotw.ts | 81 + src/utils.ts | 4 + 19 files changed, 1782 insertions(+), 17 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/JavaScripters-Bot.iml create mode 100644 .idea/dataSources.local.xml create mode 100644 .idea/dataSources.xml create mode 100644 .idea/dataSources/23972307-5e57-4eed-951d-e85ea59a1d80.xml create mode 100644 .idea/dataSources/23972307-5e57-4eed-951d-e85ea59a1d80/storage_v2/_src_/schema/main.uQUzAA.meta create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 src/Exports.ts create mode 100644 src/commands/qotw-date.ts create mode 100644 src/listeners/qotwReminder.ts create mode 100644 src/schemas/keyvaluepair.ts create mode 100644 src/types/IntRange.ts create mode 100644 src/types/qotw.ts diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..b58b603 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,5 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/JavaScripters-Bot.iml b/.idea/JavaScripters-Bot.iml new file mode 100644 index 0000000..24643cc --- /dev/null +++ b/.idea/JavaScripters-Bot.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/dataSources.local.xml b/.idea/dataSources.local.xml new file mode 100644 index 0000000..47a6c9c --- /dev/null +++ b/.idea/dataSources.local.xml @@ -0,0 +1,17 @@ + + + + + + " + + + no-auth + + + + + + + + \ No newline at end of file diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml new file mode 100644 index 0000000..c2d1753 --- /dev/null +++ b/.idea/dataSources.xml @@ -0,0 +1,12 @@ + + + + + sqlite.xerial + true + org.sqlite.JDBC + jdbc:sqlite:$PROJECT_DIR$/main.db + $ProjectFileDir$ + + + \ No newline at end of file diff --git a/.idea/dataSources/23972307-5e57-4eed-951d-e85ea59a1d80.xml b/.idea/dataSources/23972307-5e57-4eed-951d-e85ea59a1d80.xml new file mode 100644 index 0000000..c12a1db --- /dev/null +++ b/.idea/dataSources/23972307-5e57-4eed-951d-e85ea59a1d80.xml @@ -0,0 +1,1532 @@ + + + + + 3.40.1 + + + + + + + + + + + + + + + + + 1 + + + 1 + + + 1 + + + 1 + + + 1 + + + 1 + + + 1 + + + 1 + + + 1 + + + 1 + + + + window + + + 1 + + + 1 + + + 1 + + + + 1 + 1 + + + + + 1 + 1 + + + 1 + + + 1 + + + + + window + + + window + + + + + + 1 + 1 + + + 1 + 1 + + + 1 + + + window + + + + 1 + + + window + + + 1 + + + 1 + 1 + + + + + + + 1 + + + window + + + 1 + + + 1 + + + 1 + + + 1 + + + 1 + + + 1 + + + 1 + 1 + + + 1 + + + 1 + 1 + + + 1 + window + + + 1 + window + + + 1 + 1 + + + 1 + 1 + + + 1 + + + 1 + + + 1 + 1 + + + 1 + 1 + + + 1 + 1 + + + 1 + + + 1 + + + 1 + 1 + + + window + + + window + + + + window + + + window + + + window + + + + 1 + + + 1 + + + 1 + + + 1 + + + 1 + + + + 1 + + + 1 + + + 1 + + + 1 + + + aggregate + + + 1 + + + + + + 1 + 1 + + + window + + + aggregate + + + 1 + 1 + + + window + + + 1 + + + aggregate + + + window + + + window + + + 1 + + + + + + + + window + + + 1 + + + 1 + + + 1 + + + 1 + 1 + + + + 1 + + + 1 + + + + + window + + + 1 + + + 1 + + + + + + 1 + + + window + + + 1 + + + + + 1 + + + 1 + + + 1 + + + 1 + + + 1 + + + + + 1 + + + + + 1 + + + + aggregate + + + + 1 + 1 + + + 1 + + + 1 + + + 1 + + + window + + + 1 + + + 1 + + + 1 + 1 + + + window + + + + 1 + + + 1 + + + 1 + + + 1 + + + 1 + 1 + + + 1 + + + 1 + + + aggregate + + + aggregate + + + 1 + + + 1 + 2023-08-26.21:25:30.235 + 2023-08-26.19:25:30 + + + R + + + 1 + + + 2 + + + R + + + 1 + + + 2 + + + R + + + 1 + + + R + + + 1 + + + R + + + 1 + + + R + + + 1 + + + R + + + 1 + + + R + + + 1 + + + R + + + 1 + + + 2 + + + R + + + 1 + + + R + + + 1 + + + 2 + + + R + + + 1 + + + R + + + R + + + 1 + + + R + + + 1 + + + R + + + R + + + R + + + 1 + + + 2 + + + R + + + 1 + + + 2 + + + 3 + + + R + + + R + + + 1 + + + R + + + 1 + + + R + + + 1 + + + R + + + 1 + + + R + + + 1 + + + R + + + R + + + R + + + R + + + R + + + R + + + R + + + 1 + + + R + + + R + + + 1 + + + 2 + + + R + + + 1 + + + R + + + 1 + + + R + + + 1 + + + R + + + R + + + 1 + + + R + + + 1 + + + 2 + + + R + + + 1 + + + R + + + R + + + 1 + + + 2 + + + R + + + 1 + + + 2 + + + R + + + 1 + + + R + + + R + + + 1 + + + 2 + + + R + + + 1 + + + 2 + + + 3 + + + R + + + 1 + + + 2 + + + R + + + 1 + + + R + + + R + + + 1 + + + 2 + + + R + + + R + + + 1 + + + R + + + 1 + + + 2 + + + R + + + R + + + R + + + 1 + + + 2 + + + R + + + 1 + + + R + + + R + + + R + + + R + + + 1 + + + 2 + + + R + + + 1 + + + R + + + R + + + 1 + + + 2 + + + R + + + 1 + + + 2 + + + 3 + + + R + + + R + + + 1 + + + R + + + 1 + + + 2 + + + R + + + 1 + + + 2 + + + 3 + + + R + + + 1 + + + 2 + + + R + + + 1 + + + R + + + 1 + + + 2 + + + 3 + + + R + + + 1 + + + 2 + + + R + + + 1 + + + R + + + 1 + + + R + + + 1 + + + 2 + + + R + + + 1 + + + 2 + + + R + + + 1 + + + R + + + 1 + + + R + + + 1 + + + R + + + 1 + + + R + + + 1 + + + 2 + + + R + + + 1 + + + 2 + + + R + + + 1 + + + R + + + 1 + + + 2 + + + R + + + R + + + 1 + + + R + + + 1 + + + R + + + R + + + 1 + + + R + + + 1 + + + 2 + + + R + + + 1 + + + R + + + 1 + + + 2 + + + R + + + 1 + + + R + + + 1 + + + 2 + + + R + + + 1 + + + R + + + 1 + + + R + + + 1 + + + 2 + + + R + + + 1 + + + 2 + + + R + + + 1 + + + 2 + + + R + + + R + + + R + + + 1 + + + 2 + + + R + + + 1 + + + 2 + + + R + + + R + + + 1 + + + R + + + 1 + + + R + + + 1 + + + R + + + R + + + 1 + + + R + + + R + + + R + + + 1 + + + 2 + + + 3 + + + R + + + 1 + + + 2 + + + R + + + 1 + + + R + + + 1 + + + 2 + + + R + + + 1 + + + 2 + + + R + + + R + + + R + + + 1 + + + R + + + 1 + + + 2 + + + R + + + 1 + + + 2 + + + R + + + 1 + + + R + + + 1 + + + R + + + 1 + + + R + + + R + + + 1 + + + R + + + 1 + + + R + + + 1 + + + 2 + + + R + + + R + + + R + + + 1 + + + R + + + 1 + + + R + + + 1 + + + R + + + 1 + + + 2 + + + R + + + R + + + 1 + + + 2 + + + 3 + + + R + + + 1 + + + 2 + + + 3 + + + R + + + 1 + + + R + + + 1 + + + R + + + 1 + + + R + + + 1 + + + R + + + R + + + 1 + + + R + + + R + + + 1 + + + 2 + + + R + + + 1 + + + R + + + 1 + + + R + + + 1 + + + R + + + R + + + 1 + + + R + + + 1 + + + R + + + 1 + + + R + + + 1 + + + R + + + 1 + + +
+
+
+ 1 +
+ + SERIAL|0s + 1 + + + text|0s + 1 + 2 + + + numeric|0s + 3 + + + id + 1 + 1 + + + id + 1 + sqlite_autoindex___drizzle_migrations_1 + + + text|0s + 1 + 1 + + + text|0s + 2 + + + text|0s + 3 + + + text|0s + 4 + + + text|0s + 5 + + + text|0s + 6 + + + guildId + 1 + 1 + + + guildId + 1 + sqlite_autoindex_guildConfig_1 + + + text|0s + 1 + 1 + + + text|0s + 2 + + + key + 1 + 1 + + + key + 1 + sqlite_autoindex_keyvaluepair_1 + + + TEXT|0s + 1 + + + TEXT|0s + 2 + + + TEXT|0s + 3 + + + INT|0s + 4 + + + TEXT|0s + 5 + +
+
\ No newline at end of file diff --git a/.idea/dataSources/23972307-5e57-4eed-951d-e85ea59a1d80/storage_v2/_src_/schema/main.uQUzAA.meta b/.idea/dataSources/23972307-5e57-4eed-951d-e85ea59a1d80/storage_v2/_src_/schema/main.uQUzAA.meta new file mode 100644 index 0000000..e224bdf --- /dev/null +++ b/.idea/dataSources/23972307-5e57-4eed-951d-e85ea59a1d80/storage_v2/_src_/schema/main.uQUzAA.meta @@ -0,0 +1,2 @@ +#n:main +! [1693077930235, 0, null, null, -2147483648, -2147483648] diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..30bab2a --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..239b9df --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/Exports.ts b/src/Exports.ts new file mode 100644 index 0000000..0127752 --- /dev/null +++ b/src/Exports.ts @@ -0,0 +1,10 @@ +import {Client, GatewayIntentBits} from "discord.js"; + +export const client: Client = new Client({ + intents: [ + GatewayIntentBits.Guilds, + GatewayIntentBits.GuildMessages, + GatewayIntentBits.MessageContent, + GatewayIntentBits.GuildMembers, + ], +}); \ No newline at end of file diff --git a/src/commands/info.ts b/src/commands/info.ts index 2a8b65a..61da665 100644 --- a/src/commands/info.ts +++ b/src/commands/info.ts @@ -1,18 +1,17 @@ +// noinspection JSUnusedGlobalSymbols + import { - type ChatInputCommandInteraction, type APIEmbed, - ApplicationCommandType, channelMention, } from "discord.js"; import type { Command } from "djs-fsrouter"; -export const type = ApplicationCommandType.ChatInput; const Info: Command = { description: "Get info about the bot and server", defaultMemberPermissions: "0", async run(interaction) { if (!interaction.guild) { - interaction.reply({ + await interaction.reply({ content: "Run this command in a server to get server info", ephemeral: true, }); diff --git a/src/commands/qotw-date.ts b/src/commands/qotw-date.ts new file mode 100644 index 0000000..bf3d4c2 --- /dev/null +++ b/src/commands/qotw-date.ts @@ -0,0 +1,49 @@ +// noinspection JSUnusedGlobalSymbols + +import type {Command} from "djs-fsrouter"; +import type { + ChatInputCommandInteraction, + ApplicationCommandOptionData, + InteractionReplyOptions +} from "discord.js"; +import {EmbedBuilder, GuildMemberRoleManager, Role, SlashCommandStringOption,} from "discord.js"; +import {type QotwDate, QotwReminderManager} from "../types/qotw.js"; +import type {IntRange} from "../types/IntRange.js"; + +export default { + dmPermission: false, + description: "lets you change the next QOTW reminder date.", + options: [new SlashCommandStringOption().setName("time").setDescription("the time formatted as dd:hh:mm").setRequired(true)] as ApplicationCommandOptionData[], + + async run(interaction: ChatInputCommandInteraction): Promise { + function errMsg(title: string, desc: string): InteractionReplyOptions { + return {embeds: [new EmbedBuilder().setTitle(title).setColor(0xFF0000).setDescription(desc)], ephemeral: true}; + } + + // if (!(interaction.member!.roles).cache.find(r => r.id === "1140826891599757382" || r.id === "722933309633462274")) { + // await interaction.reply(errMsg("Insufficient permissions", "You require the following roles: `Owner` | `QOTW Manger`")); + // return; + // } + + const timeRegex: RegExpExecArray | null = /^(\d+):(\d+):(\d+)$/gm.exec(interaction.options.getString("time")!); + + if (!timeRegex || timeRegex.length !== 4) { + await interaction.reply(errMsg("Invalid time", "The time format should follow the `1-7:1-24:0-59` format.")); + return; + } + + const newDate: QotwDate = { + weekDay: parseInt(timeRegex[1]) as IntRange<1, 7>, + hour: parseInt(timeRegex[2]) as IntRange<1, 24>, + minute: parseInt(timeRegex[3]) as IntRange<0, 59> + } + + QotwReminderManager.uploadDate(newDate); + + await interaction.reply({embeds: [new EmbedBuilder() + .setTitle("Success") + .setColor(0x00FF00) + .setDescription(`Set the new date for reminder to:\`\`\`\nday of the week: ${newDate.weekDay}\nhour of the day: ${newDate.hour}:${newDate.minute}\`\`\``) + ]}); + } +} as Command; \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 584010c..e06d826 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,5 @@ import loadCommands from "djs-fsrouter"; import { - Client, - GatewayIntentBits, Events, type ClientEvents, type Awaitable, @@ -10,15 +8,7 @@ import { join } from "path"; import { readdir } from "fs/promises"; import { castArray } from "./utils.ts"; import type { Listener } from "./types/listener.ts"; - -const client = new Client({ - intents: [ - GatewayIntentBits.Guilds, - GatewayIntentBits.GuildMessages, - GatewayIntentBits.MessageContent, - GatewayIntentBits.GuildMembers, - ], -}); +import { client } from "./Exports.js"; client.once(Events.ClientReady, async (bot) => { try { @@ -57,4 +47,4 @@ client.once(Events.ClientReady, async (bot) => { console.log(`Bot ${bot.user.username} ready!`); }); -client.login(process.env.TOKEN); +await client.login(process.env.TOKEN); diff --git a/src/listeners/qotwReminder.ts b/src/listeners/qotwReminder.ts new file mode 100644 index 0000000..730c9f0 --- /dev/null +++ b/src/listeners/qotwReminder.ts @@ -0,0 +1,14 @@ +// noinspection JSUnusedGlobalSymbols + +import type { Listener } from "../types/listener.ts"; +import {QotwReminderManager} from "../types/qotw.js"; + +export default [ + { + event: "ready", + + handler(): void { + QotwReminderManager.reloadInterval(); + } + } +] as Listener[] \ No newline at end of file diff --git a/src/schemas/config.ts b/src/schemas/config.ts index 5a2d4ed..95f0d1f 100644 --- a/src/schemas/config.ts +++ b/src/schemas/config.ts @@ -11,4 +11,4 @@ export const Config = sqliteTable("guildConfig", { gatewayLeaveContent: text("gatewayLeaveContent"), }); export type ConfigSelect = InferSelectModel; -export type ConfigInsert = InferInsertModel; +export type ConfigInsert = InferInsertModel; \ No newline at end of file diff --git a/src/schemas/keyvaluepair.ts b/src/schemas/keyvaluepair.ts new file mode 100644 index 0000000..6b37637 --- /dev/null +++ b/src/schemas/keyvaluepair.ts @@ -0,0 +1,11 @@ +import { sqliteTable, text } from "drizzle-orm/sqlite-core"; + +export const Keyvaluepair = sqliteTable("keyvaluepair", { + key: text("key").notNull().primaryKey(), + value: text("value") +}); + +export interface KeyValuePairDisposition { + key: string; + value: string | null; +} \ No newline at end of file diff --git a/src/types/IntRange.ts b/src/types/IntRange.ts new file mode 100644 index 0000000..9257a74 --- /dev/null +++ b/src/types/IntRange.ts @@ -0,0 +1,6 @@ + +type Enumerate = Acc['length'] extends N + ? Acc[number] + : Enumerate; + +export type IntRange = Exclude, Enumerate> | F | T; diff --git a/src/types/qotw.ts b/src/types/qotw.ts new file mode 100644 index 0000000..5ea449b --- /dev/null +++ b/src/types/qotw.ts @@ -0,0 +1,81 @@ +import type {IntRange} from "./IntRange.js"; +import {client} from "../Exports.js"; +import {EmbedBuilder} from "discord.js"; +import db from "../db.js"; +import {Keyvaluepair, type KeyValuePairDisposition} from "../schemas/keyvaluepair.js"; +import {eq} from "drizzle-orm"; + +export interface QotwDate { + weekDay: IntRange<1, 7>; + hour: IntRange<1, 24>; + minute: IntRange<0, 59>; +} + +export class QotwReminderManager { + private static currentInterval: NodeJS.Timeout | undefined; + private static currentTimeout: NodeJS.Timeout | undefined; + + public static uploadDate(date: QotwDate) { + (!QotwReminderManager.getDate() + ? db.insert(Keyvaluepair).values({key: "qotwdate", value: JSON.stringify(date)}) + : db.update(Keyvaluepair).set({value: JSON.stringify(date)}).where(eq(Keyvaluepair.key, "qotwdate"))) + .execute().then() + + QotwReminderManager.reloadInterval(); + } + + public static getDate(): QotwDate | undefined { + const value: KeyValuePairDisposition[] = db.select().from(Keyvaluepair).where(eq(Keyvaluepair.key, "qotwdate")).all() + return value.length === 0 ? undefined : JSON.parse(value[0].value!); + } + + public static reloadInterval(): void { + if (QotwReminderManager.currentInterval) { + clearInterval(QotwReminderManager.currentInterval); + QotwReminderManager.currentInterval = undefined; + } + + if (QotwReminderManager.currentTimeout) { + clearInterval(QotwReminderManager.currentTimeout); + QotwReminderManager.currentTimeout = undefined; + } + + const qotwRemindDate: QotwDate | undefined = QotwReminderManager.getDate(); + + if (!qotwRemindDate) { + QotwReminderManager.currentInterval = undefined; + QotwReminderManager.currentTimeout = undefined; + return; + } + + async function searchAndSendReminder() { + for (const [_, member] of (await (await client.guilds.fetch("779474636780863488")).roles.fetch("1140826891599757382"))!.members) + await member.send({embeds: [new EmbedBuilder() + .setColor(0x9b59b6) + .setTitle("QOTW reminder") + .setDescription("The time for a new QOTW is here, go to <#779826597729271828> and create a new question thread.")]}); + } + + QotwReminderManager.currentTimeout = setTimeout(async () => { + await searchAndSendReminder(); + QotwReminderManager.currentInterval = setInterval(async () => { + await searchAndSendReminder(); + }, 604800000); + QotwReminderManager.currentTimeout = undefined; + }, QotwReminderManager.getRemainingMilliseconds(qotwRemindDate as QotwDate)) + } + + private static getRemainingMilliseconds(qotw: QotwDate): number { + const now: Date = new Date(), + currentDay: number = now.getDay() || 7, + targetDay: number = qotw.weekDay === 7 ? 0 : qotw.weekDay, + cd: boolean = currentDay < targetDay || (currentDay === targetDay && now.getHours() < qotw.hour) || (currentDay === targetDay && now.getHours() === qotw.hour && now.getMinutes() < qotw.minute), + targetDate: Date = cd + ? new Date(now.getFullYear(), now.getMonth(), now.getDate() + (targetDay - currentDay)) + : new Date(now.getFullYear(), now.getMonth(), now.getDate() + (7 - currentDay + (targetDay === 0 ? 7 : targetDay))); + + cd ? targetDate.setHours(qotw.hour, qotw.minute, 0, 0) : targetDate.setHours(qotw.hour, qotw.minute, 0, 0); + + return targetDate.getTime() - now.getTime(); + } +} diff --git a/src/utils.ts b/src/utils.ts index 96c7605..6d7b927 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -19,3 +19,7 @@ export const getConfig = db .from(Config) .where(eq(Config.id, sql.placeholder("guildId"))) .prepare(); + +export function isEmptyObject(obj: T): boolean { + return typeof obj === "object" && Object.keys(obj).length === 0; +} \ No newline at end of file From 970109ff8044878f0bd5179d7543d1b8aeb4f01c Mon Sep 17 00:00:00 2001 From: stifskere Date: Sat, 26 Aug 2023 21:39:37 +0200 Subject: [PATCH 3/3] error fix fix Signed-off-by: stifskere --- .gitignore | 2 + .idea/.gitignore | 5 - .idea/JavaScripters-Bot.iml | 12 - .idea/dataSources.local.xml | 17 - .idea/dataSources.xml | 12 - .../23972307-5e57-4eed-951d-e85ea59a1d80.xml | 1532 ----------------- .../storage_v2/_src_/schema/main.uQUzAA.meta | 2 - .idea/misc.xml | 7 - .idea/modules.xml | 8 - .idea/vcs.xml | 6 - src/commands/qotw-date.ts | 8 +- 11 files changed, 6 insertions(+), 1605 deletions(-) delete mode 100644 .idea/.gitignore delete mode 100644 .idea/JavaScripters-Bot.iml delete mode 100644 .idea/dataSources.local.xml delete mode 100644 .idea/dataSources.xml delete mode 100644 .idea/dataSources/23972307-5e57-4eed-951d-e85ea59a1d80.xml delete mode 100644 .idea/dataSources/23972307-5e57-4eed-951d-e85ea59a1d80/storage_v2/_src_/schema/main.uQUzAA.meta delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/vcs.xml diff --git a/.gitignore b/.gitignore index 062cec5..a103daa 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,5 @@ main.db main.db-shm main.db-wal migrations + +.idea \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index b58b603..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ diff --git a/.idea/JavaScripters-Bot.iml b/.idea/JavaScripters-Bot.iml deleted file mode 100644 index 24643cc..0000000 --- a/.idea/JavaScripters-Bot.iml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/dataSources.local.xml b/.idea/dataSources.local.xml deleted file mode 100644 index 47a6c9c..0000000 --- a/.idea/dataSources.local.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - " - - - no-auth - - - - - - - - \ No newline at end of file diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml deleted file mode 100644 index c2d1753..0000000 --- a/.idea/dataSources.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - sqlite.xerial - true - org.sqlite.JDBC - jdbc:sqlite:$PROJECT_DIR$/main.db - $ProjectFileDir$ - - - \ No newline at end of file diff --git a/.idea/dataSources/23972307-5e57-4eed-951d-e85ea59a1d80.xml b/.idea/dataSources/23972307-5e57-4eed-951d-e85ea59a1d80.xml deleted file mode 100644 index c12a1db..0000000 --- a/.idea/dataSources/23972307-5e57-4eed-951d-e85ea59a1d80.xml +++ /dev/null @@ -1,1532 +0,0 @@ - - - - - 3.40.1 - - - - - - - - - - - - - - - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - - window - - - 1 - - - 1 - - - 1 - - - - 1 - 1 - - - - - 1 - 1 - - - 1 - - - 1 - - - - - window - - - window - - - - - - 1 - 1 - - - 1 - 1 - - - 1 - - - window - - - - 1 - - - window - - - 1 - - - 1 - 1 - - - - - - - 1 - - - window - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - 1 - - - 1 - - - 1 - 1 - - - 1 - window - - - 1 - window - - - 1 - 1 - - - 1 - 1 - - - 1 - - - 1 - - - 1 - 1 - - - 1 - 1 - - - 1 - 1 - - - 1 - - - 1 - - - 1 - 1 - - - window - - - window - - - - window - - - window - - - window - - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - - 1 - - - 1 - - - 1 - - - 1 - - - aggregate - - - 1 - - - - - - 1 - 1 - - - window - - - aggregate - - - 1 - 1 - - - window - - - 1 - - - aggregate - - - window - - - window - - - 1 - - - - - - - - window - - - 1 - - - 1 - - - 1 - - - 1 - 1 - - - - 1 - - - 1 - - - - - window - - - 1 - - - 1 - - - - - - 1 - - - window - - - 1 - - - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - - - 1 - - - - - 1 - - - - aggregate - - - - 1 - 1 - - - 1 - - - 1 - - - 1 - - - window - - - 1 - - - 1 - - - 1 - 1 - - - window - - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - 1 - - - 1 - - - 1 - - - aggregate - - - aggregate - - - 1 - - - 1 - 2023-08-26.21:25:30.235 - 2023-08-26.19:25:30 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - R - - - 1 - - - R - - - 1 - - - R - - - R - - - R - - - 1 - - - 2 - - - R - - - 1 - - - 2 - - - 3 - - - R - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - R - - - R - - - R - - - R - - - R - - - R - - - 1 - - - R - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - R - - - 1 - - - 2 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - R - - - 1 - - - 2 - - - R - - - 1 - - - 2 - - - 3 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - R - - - 1 - - - 2 - - - R - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - R - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - R - - - R - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - R - - - 1 - - - 2 - - - R - - - 1 - - - 2 - - - 3 - - - R - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - 2 - - - 3 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - 3 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - R - - - 1 - - - R - - - 1 - - - R - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - 2 - - - R - - - R - - - R - - - 1 - - - 2 - - - R - - - 1 - - - 2 - - - R - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - R - - - 1 - - - R - - - R - - - R - - - 1 - - - 2 - - - 3 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - 2 - - - R - - - R - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - R - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - 2 - - - R - - - R - - - 1 - - - 2 - - - 3 - - - R - - - 1 - - - 2 - - - 3 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - R - - - 1 - - - R - - - R - - - 1 - - - 2 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - - R - - - 1 - - -
-
-
- 1 -
- - SERIAL|0s - 1 - - - text|0s - 1 - 2 - - - numeric|0s - 3 - - - id - 1 - 1 - - - id - 1 - sqlite_autoindex___drizzle_migrations_1 - - - text|0s - 1 - 1 - - - text|0s - 2 - - - text|0s - 3 - - - text|0s - 4 - - - text|0s - 5 - - - text|0s - 6 - - - guildId - 1 - 1 - - - guildId - 1 - sqlite_autoindex_guildConfig_1 - - - text|0s - 1 - 1 - - - text|0s - 2 - - - key - 1 - 1 - - - key - 1 - sqlite_autoindex_keyvaluepair_1 - - - TEXT|0s - 1 - - - TEXT|0s - 2 - - - TEXT|0s - 3 - - - INT|0s - 4 - - - TEXT|0s - 5 - -
-
\ No newline at end of file diff --git a/.idea/dataSources/23972307-5e57-4eed-951d-e85ea59a1d80/storage_v2/_src_/schema/main.uQUzAA.meta b/.idea/dataSources/23972307-5e57-4eed-951d-e85ea59a1d80/storage_v2/_src_/schema/main.uQUzAA.meta deleted file mode 100644 index e224bdf..0000000 --- a/.idea/dataSources/23972307-5e57-4eed-951d-e85ea59a1d80/storage_v2/_src_/schema/main.uQUzAA.meta +++ /dev/null @@ -1,2 +0,0 @@ -#n:main -! [1693077930235, 0, null, null, -2147483648, -2147483648] diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 30bab2a..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 239b9df..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1dd..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/commands/qotw-date.ts b/src/commands/qotw-date.ts index bf3d4c2..00f978a 100644 --- a/src/commands/qotw-date.ts +++ b/src/commands/qotw-date.ts @@ -20,10 +20,10 @@ export default { return {embeds: [new EmbedBuilder().setTitle(title).setColor(0xFF0000).setDescription(desc)], ephemeral: true}; } - // if (!(interaction.member!.roles).cache.find(r => r.id === "1140826891599757382" || r.id === "722933309633462274")) { - // await interaction.reply(errMsg("Insufficient permissions", "You require the following roles: `Owner` | `QOTW Manger`")); - // return; - // } + if (!(interaction.member!.roles).cache.find(r => r.id === "1140826891599757382" || r.id === "722933309633462274")) { + await interaction.reply(errMsg("Insufficient permissions", "You require the following roles: `Owner` | `QOTW Manger`")); + return; + } const timeRegex: RegExpExecArray | null = /^(\d+):(\d+):(\d+)$/gm.exec(interaction.options.getString("time")!);