From 51d378e4cb4584196b14132b4d330b8d370f8fb3 Mon Sep 17 00:00:00 2001 From: Peerawas Archavanuntakun Date: Thu, 6 Jan 2022 03:30:32 +0700 Subject: Setup and migrate to Prisma (#456) --- src/utils/create-database-url.ts | 5 +++++ src/utils/db.ts | 13 ++----------- src/utils/log-banner.ts | 16 ++++++++++++++++ 3 files changed, 23 insertions(+), 11 deletions(-) create mode 100644 src/utils/create-database-url.ts create mode 100644 src/utils/log-banner.ts (limited to 'src/utils') diff --git a/src/utils/create-database-url.ts b/src/utils/create-database-url.ts new file mode 100644 index 0000000..cab398e --- /dev/null +++ b/src/utils/create-database-url.ts @@ -0,0 +1,5 @@ +export const createDatabasePath = (directory: string) => `${directory}/db.sqlite`; + +const createDatabaseUrl = (directory: string) => `file:${createDatabasePath(directory)}`; + +export default createDatabaseUrl; diff --git a/src/utils/db.ts b/src/utils/db.ts index 15a2d79..b630320 100644 --- a/src/utils/db.ts +++ b/src/utils/db.ts @@ -1,12 +1,3 @@ -import {Sequelize} from 'sequelize-typescript'; -import path from 'path'; -import {DATA_DIR} from '../services/config.js'; -import {FileCache, KeyValueCache, Settings, Shortcut} from '../models/index.js'; +import Prisma from '@prisma/client'; -export const sequelize = new Sequelize({ - dialect: 'sqlite', - database: 'muse', - storage: path.join(DATA_DIR, 'db.sqlite'), - models: [FileCache, KeyValueCache, Settings, Shortcut], - logging: false, -}); +export const prisma = new Prisma.PrismaClient(); diff --git a/src/utils/log-banner.ts b/src/utils/log-banner.ts new file mode 100644 index 0000000..0ad6466 --- /dev/null +++ b/src/utils/log-banner.ts @@ -0,0 +1,16 @@ +import {makeLines} from 'nodesplash'; +import metadata from '../../package.json'; + +const logBanner = () => { + console.log(makeLines({ + user: 'codetheweb', + repository: 'muse', + version: metadata.version, + paypalUser: 'codetheweb', + githubSponsor: 'codetheweb', + madeByPrefix: 'Made with 🎶 by ', + }).join('\n')); + console.log('\n'); +}; + +export default logBanner; -- cgit v1.2.3 From 892c06a1109480ba581f99b09d55c929c9a37f0a Mon Sep 17 00:00:00 2001 From: Max Isom Date: Fri, 7 Jan 2022 12:38:07 -0600 Subject: Bump discord.js --- src/utils/channels.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/utils') diff --git a/src/utils/channels.ts b/src/utils/channels.ts index 2d074b4..f4e576a 100644 --- a/src/utils/channels.ts +++ b/src/utils/channels.ts @@ -42,10 +42,10 @@ export const getMostPopularVoiceChannel = (guild: Guild): [VoiceChannel, number] for (const [_, channel] of guild.channels.cache) { if (channel.type === 'GUILD_VOICE') { - const size = getSizeWithoutBots(channel as VoiceChannel); + const size = getSizeWithoutBots(channel); voiceChannels.push({ - channel: channel as VoiceChannel, + channel, n: size, }); } -- cgit v1.2.3 From 21c9dee6f856edf20d4f33f49f3f20d815be92d1 Mon Sep 17 00:00:00 2001 From: Max Isom Date: Sun, 9 Jan 2022 18:50:30 -0600 Subject: Fix database path for Windows --- src/utils/create-database-url.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/utils') diff --git a/src/utils/create-database-url.ts b/src/utils/create-database-url.ts index cab398e..becc973 100644 --- a/src/utils/create-database-url.ts +++ b/src/utils/create-database-url.ts @@ -1,4 +1,6 @@ -export const createDatabasePath = (directory: string) => `${directory}/db.sqlite`; +import {join} from 'path'; + +export const createDatabasePath = (directory: string) => join(directory, 'db.sqlite'); const createDatabaseUrl = (directory: string) => `file:${createDatabasePath(directory)}`; -- cgit v1.2.3