From 04ef7c9d8d2fe4bd9c70a70f75cc67548c2cd449 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Mon, 29 May 2023 17:09:33 +0200 Subject: [PATCH] fix: :bug: create user if not exist before create quote Create missing users before creating a new quote in database to ensure that it can have a relation --- src/commands/quotes/subcommands/post/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/commands/quotes/subcommands/post/index.ts b/src/commands/quotes/subcommands/post/index.ts index 3963528..f5ec828 100644 --- a/src/commands/quotes/subcommands/post/index.ts +++ b/src/commands/quotes/subcommands/post/index.ts @@ -7,6 +7,7 @@ import { import CooldownManager from "../../../../handlers/CooldownManager"; import prisma from "../../../../handlers/prisma"; import generateCooldownName from "../../../../helpers/generateCooldownName"; +import upsertGuildMember from "../../../../helpers/upsertGuildMember"; import deferReply from "../../../../utils/deferReply"; import sendResponse from "../../../../utils/sendResponse"; @@ -36,11 +37,13 @@ export const execute = async ( await deferReply(interaction, true); const { options, guild, user } = interaction; + if (!guild) throw new Error("A guild is required."); const quoteUser = options.getUser("user", true); const quoteString = options.getString("message", true); - if (!guild) throw new Error("A guild is required."); + await upsertGuildMember(guild, user); + await upsertGuildMember(guild, quoteUser); const guildQuotesSettings = await prisma.guildQuotesSettings.findUnique({ where: { id: guild.id },