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

@ -6,9 +6,9 @@ import {TYPES} from '../types.js';
import GetSongs from '../services/get-songs.js';
import {SongMetadata, STATUS} from './player.js';
import PlayerManager from '../managers/player.js';
import {prisma} from '../utils/db.js';
import {buildPlayingMessageEmbed} from '../utils/build-embed.js';
import {getMemberVoiceChannel, getMostPopularVoiceChannel} from '../utils/channels.js';
import {getGuildSettings} from '../utils/get-guild-settings';
@injectable()
export default class AddQueryToQueue {
@ -34,11 +34,7 @@ export default class AddQueryToQueue {
const [targetVoiceChannel] = getMemberVoiceChannel(interaction.member as GuildMember) ?? getMostPopularVoiceChannel(interaction.guild!);
const settings = await prisma.setting.findUnique({where: {guildId}});
if (!settings) {
throw new Error('Could not find settings for guild');
}
const settings = await getGuildSettings(guildId);
const {playlistLimit} = settings;

View file

@ -18,7 +18,7 @@ import {
} from '@discordjs/voice';
import FileCacheProvider from './file-cache.js';
import debug from '../utils/debug.js';
import {prisma} from '../utils/db.js';
import {getGuildSettings} from '../utils/get-guild-settings';
export enum MediaSource {
Youtube,
@ -272,11 +272,7 @@ export default class {
this.audioPlayer?.stop();
this.status = STATUS.IDLE;
const settings = await prisma.setting.findUnique({where: {guildId: this.guildId}});
if (!settings) {
throw new Error('Could not find settings for guild');
}
const settings = await getGuildSettings(this.guildId);
const {secondsToWaitAfterQueueEmpties} = settings;
if (secondsToWaitAfterQueueEmpties !== 0) {