From bdcce1ee72781975caaf1da45a474cb1bd724442 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20Olausson=20Holten=C3=A4s?= Date: Mon, 14 Mar 2022 23:16:56 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9=20fix=20api=20config?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/dashboard/index.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/dashboard/index.js b/src/dashboard/index.js index c6e9b5a..0fdaacd 100644 --- a/src/dashboard/index.js +++ b/src/dashboard/index.js @@ -218,13 +218,15 @@ module.exports = async (client) => { optionType: DBD.formTypes.input('https://bg.zyner.org/api/'), getActualSet: async ({ guild, user }) => { const api = await apis.findOne({ guildId: guild.id }); + + if (!api) { + apis.create({ guildId: guild.id }); + } + return api.url; }, setNew: async ({ guild, newData }) => { - const api = await apis.findOne( - { guildId: guild.id }, - { new: true, upsert: true } - ); + const api = await apis.findOne({ guildId: guild.id }); api.url = newData || api.url; @@ -239,10 +241,10 @@ module.exports = async (client) => { optionDescription: 'Configure your controlpanel.gg Token', optionType: DBD.formTypes.input('1'), getActualSet: async ({ guild, user }) => { - const api = await apis.findOne( - { guildId: guild.id }, - { new: true, upsert: true } - ); + const api = await apis.findOne({ guildId: guild.id }); + if (!api) { + apis.create({ guildId: guild.id }); + } return api.token; }, setNew: async ({ guild, newData }) => {