Setup and migrate to Prisma (#456)

This commit is contained in:
Peerawas Archavanuntakun 2022-01-06 03:30:32 +07:00 committed by GitHub
parent 129d121364
commit 51d378e4cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 605 additions and 273 deletions

View file

@ -10,7 +10,7 @@ import LoadingMessage from '../utils/loading-message.js';
import errorMsg from '../utils/error-msg.js';
import Command from '.';
import GetSongs from '../services/get-songs.js';
import Settings from '../models/settings.js';
import {prisma} from '../utils/db.js';
@injectable()
export default class implements Command {
@ -41,8 +41,15 @@ export default class implements Command {
// eslint-disable-next-line complexity
public async execute(msg: Message, args: string[]): Promise<void> {
const [targetVoiceChannel] = getMemberVoiceChannel(msg.member!) ?? getMostPopularVoiceChannel(msg.guild!);
const settings = await Settings.findByPk(msg.guild!.id);
const {playlistLimit} = settings!;
const setting = await prisma.setting.findUnique({
where: {
guildId: msg.guild!.id,
}});
if (!setting) {
throw new Error(`Couldn't find settings for guild ${msg.guild!.id}`);
}
const {playlistLimit} = setting;
const res = new LoadingMessage(msg.channel as TextChannel);
await res.start();