diff --git a/src/routes/api/admin/guilds/[guild]/index.js b/src/routes/api/admin/guilds/[guild]/index.js index 06f4c65..0ae4538 100644 --- a/src/routes/api/admin/guilds/[guild]/index.js +++ b/src/routes/api/admin/guilds/[guild]/index.js @@ -1,4 +1,5 @@ /* eslint-disable no-underscore-dangle */ +const { logAdminEvent } = require('../../../../../lib/logging.js'); const { iconURL } = require('../../../../../lib/misc'); const { getAvgResolutionTime, @@ -6,6 +7,28 @@ const { } = require('../../../../../lib/stats'); const ms = require('ms'); +module.exports.delete = fastify => ({ + handler: async req => { + /** @type {import('client')} */ + const client = req.routeOptions.config.client; + const id = req.params.guild; + await client.prisma.guild.delete({ where: { id } }); + await client.prisma.guild.create({ data: { id } }); + logAdminEvent(client, { + action: 'delete', + guildId: id, + target: { + id, + name: client.guilds.cache.get(id), + type: 'settings', + }, + userId: req.user.id, + }); + return true; + }, + onRequest: [fastify.authenticate, fastify.isAdmin], +}); + module.exports.get = fastify => ({ handler: async req => { /** @type {import("client")} */ diff --git a/src/routes/api/admin/guilds/[guild]/settings.js b/src/routes/api/admin/guilds/[guild]/settings.js index 2f5af99..c167c70 100644 --- a/src/routes/api/admin/guilds/[guild]/settings.js +++ b/src/routes/api/admin/guilds/[guild]/settings.js @@ -1,28 +1,6 @@ const { logAdminEvent } = require('../../../../../lib/logging.js'); const { Colors } = require('discord.js'); -module.exports.delete = fastify => ({ - handler: async req => { - /** @type {import('client')} */ - const client = req.routeOptions.config.client; - const id = req.params.guild; - await client.prisma.guild.delete({ where: { id } }); - const settings = await client.prisma.guild.create({ data: { id } }); - logAdminEvent(client, { - action: 'delete', - guildId: id, - target: { - id, - name: client.guilds.cache.get(id), - type: 'settings', - }, - userId: req.user.id, - }); - return settings; - }, - onRequest: [fastify.authenticate, fastify.isAdmin], -}); - module.exports.get = fastify => ({ handler: async req => { /** @type {import('client')} */