Create guild settings if not found (#911)

Co-authored-by: Max Isom <codetheweb@users.noreply.github.com>
This commit is contained in:
Federico Rapetti 2023-03-04 22:39:33 +01:00 committed by GitHub
parent 6926e39c56
commit 02ee8aefc8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 25 additions and 27 deletions

View file

@ -3,6 +3,7 @@ import {ChatInputCommandInteraction, EmbedBuilder, PermissionFlagsBits} from 'di
import {injectable} from 'inversify';
import {prisma} from '../utils/db.js';
import Command from './index.js';
import {getGuildSettings} from '../utils/get-guild-settings';
@injectable()
export default class implements Command {
@ -96,11 +97,7 @@ export default class implements Command {
case 'get': {
const embed = new EmbedBuilder().setTitle('Config');
const config = await prisma.setting.findUnique({where: {guildId: interaction.guild!.id}});
if (!config) {
throw new Error('no config found');
}
const config = await getGuildSettings(interaction.guild!.id);
const settingsToShow = {
'Playlist Limit': config.playlistLimit,