From c1267ab846dcb386af8af37d4c9506fece862437 Mon Sep 17 00:00:00 2001 From: "Rhys (SunburntRock89)" Date: Sun, 21 May 2023 19:50:47 +0100 Subject: [PATCH] Fix deassign command --- src/commands/support/deassign.ts | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/commands/support/deassign.ts b/src/commands/support/deassign.ts index 5422ff61..8333207d 100644 --- a/src/commands/support/deassign.ts +++ b/src/commands/support/deassign.ts @@ -1,3 +1,4 @@ +import { Numbers } from "@prisma/client"; import Command from "../../internals/commandProcessor"; import { parseNumber } from "../../internals/utils"; @@ -5,13 +6,22 @@ export default class Deassign extends Command { async run(): Promise { this.interaction.deferReply(); - const numberToDeassign = parseNumber(this.interaction.options.getString("number", true)); + const numberToDeassign = parseNumber(this.interaction.options.getString("number_or_channel", true)); - const number = await this.db.numbers.findUnique({ - where: { - number: numberToDeassign, - }, - }); + let number: Numbers | null; + if (numberToDeassign.length > 11) { + number = await this.db.numbers.findUnique({ + where: { + channelID: numberToDeassign, + }, + }); + } else { + number = await this.db.numbers.findUnique({ + where: { + number: numberToDeassign, + }, + }); + } if (!number) { this.interaction.editReply({