From 46d95b59efac41d401dd7b8f362b699546eee5c3 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 10:41:47 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Prisma=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../commands/counters/modules/view/index.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/plugins/commands/counters/modules/view/index.ts b/src/plugins/commands/counters/modules/view/index.ts index 321206c..cc72c32 100644 --- a/src/plugins/commands/counters/modules/view/index.ts +++ b/src/plugins/commands/counters/modules/view/index.ts @@ -2,7 +2,7 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; import { ChannelType } from "discord-api-types/v10"; import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js"; import getEmbedConfig from "../../../../../helpers/getEmbedData"; -import counterSchema from "../../../../../models/counter"; +import prisma from "../../../../../prisma"; export default { metadata: { guildOnly: true, ephemeral: false }, @@ -41,21 +41,26 @@ export default { iconURL: footerIcon, }); - const counter = await counterSchema.findOne({ - guildId: guild.id, - channelId: discordChannel.id, + const channelCounter = await prisma.guildCounter.findUnique({ + where: { + guildId_channelId: { + guildId: guild.id, + channelId: discordChannel.id, + }, + }, }); - if (!counter) throw new Error("No counter found for channel"); + if (!channelCounter) throw new Error("No counter found for channel"); - return interaction.editReply({ + await interaction.editReply({ embeds: [ embed .setDescription( - `Viewing counter for channel ${discordChannel}: ${counter.counter}!` + `Viewing counter for channel ${discordChannel}: ${channelCounter.count}!` ) .setColor(successColor), ], }); + return; }, };