mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2025-02-23 18:51:29 +02:00
fix(api): move guild delete route to index
This commit is contained in:
parent
71547aa142
commit
4278d24e0b
@ -1,4 +1,5 @@
|
|||||||
/* eslint-disable no-underscore-dangle */
|
/* eslint-disable no-underscore-dangle */
|
||||||
|
const { logAdminEvent } = require('../../../../../lib/logging.js');
|
||||||
const { iconURL } = require('../../../../../lib/misc');
|
const { iconURL } = require('../../../../../lib/misc');
|
||||||
const {
|
const {
|
||||||
getAvgResolutionTime,
|
getAvgResolutionTime,
|
||||||
@ -6,6 +7,28 @@ const {
|
|||||||
} = require('../../../../../lib/stats');
|
} = require('../../../../../lib/stats');
|
||||||
const ms = require('ms');
|
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 => ({
|
module.exports.get = fastify => ({
|
||||||
handler: async req => {
|
handler: async req => {
|
||||||
/** @type {import("client")} */
|
/** @type {import("client")} */
|
||||||
|
@ -1,28 +1,6 @@
|
|||||||
const { logAdminEvent } = require('../../../../../lib/logging.js');
|
const { logAdminEvent } = require('../../../../../lib/logging.js');
|
||||||
const { Colors } = require('discord.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 => ({
|
module.exports.get = fastify => ({
|
||||||
handler: async req => {
|
handler: async req => {
|
||||||
/** @type {import('client')} */
|
/** @type {import('client')} */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user