♻️ Prisma code
This commit is contained in:
parent
2010b63646
commit
46d95b59ef
1 changed files with 12 additions and 7 deletions
|
@ -2,7 +2,7 @@ import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
|
||||||
import { ChannelType } from "discord-api-types/v10";
|
import { ChannelType } from "discord-api-types/v10";
|
||||||
import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js";
|
import { ChatInputCommandInteraction, EmbedBuilder } from "discord.js";
|
||||||
import getEmbedConfig from "../../../../../helpers/getEmbedData";
|
import getEmbedConfig from "../../../../../helpers/getEmbedData";
|
||||||
import counterSchema from "../../../../../models/counter";
|
import prisma from "../../../../../prisma";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
metadata: { guildOnly: true, ephemeral: false },
|
metadata: { guildOnly: true, ephemeral: false },
|
||||||
|
@ -41,21 +41,26 @@ export default {
|
||||||
iconURL: footerIcon,
|
iconURL: footerIcon,
|
||||||
});
|
});
|
||||||
|
|
||||||
const counter = await counterSchema.findOne({
|
const channelCounter = await prisma.guildCounter.findUnique({
|
||||||
|
where: {
|
||||||
|
guildId_channelId: {
|
||||||
guildId: guild.id,
|
guildId: guild.id,
|
||||||
channelId: discordChannel.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: [
|
embeds: [
|
||||||
embed
|
embed
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`Viewing counter for channel ${discordChannel}: ${counter.counter}!`
|
`Viewing counter for channel ${discordChannel}: ${channelCounter.count}!`
|
||||||
)
|
)
|
||||||
.setColor(successColor),
|
.setColor(successColor),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue