Skip to content

Commit 02daf1e

Browse files
author
xyzjesper
committed
Fixed User creation in Vote API
1 parent bbda381 commit 02daf1e

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

src/api/services/vote.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {Logger} from "../../main/logger.js";
77
import {LoggingAction} from "../../enums/loggingTypes.js";
88
import {database} from "../../main/database.js";
99
import {Config} from "../../main/config.js";
10+
import {initUsersToDatabase} from "../../helper/databaseHelper.js";
1011

1112
export async function vote(client: ExtendedClient) {
1213
const app = express();
@@ -85,7 +86,11 @@ export async function vote(client: ExtendedClient) {
8586
return;
8687
}
8788
const vote = req.body
88-
const data = await database.users.findFirst({
89+
const user = await client.users.fetch(vote.id);
90+
91+
await initUsersToDatabase(client, user)
92+
93+
let data = await database.users.findFirst({
8994
where: {
9095
UserId: vote.id
9196
}
@@ -125,7 +130,7 @@ export async function vote(client: ExtendedClient) {
125130
const webhook = new WebhookClient({
126131
url: "https://discord.com/api/webhooks/1231322811964854292/fLN_e9cNkywg3Hdoi25AKEUL_KDbeKFYTtgNhiwGmHmVa14CWNuF9iSbNAYNFmISD8r3",
127132
});
128-
const user = await client.users.fetch(vote.id);
133+
129134

130135
await webhook.send({
131136
embeds: [

src/helper/databaseHelper.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {LoggingAction} from "../enums/loggingTypes.js";
77
import colors from "colors"
88
import {User} from "discord.js";
99
import {Config} from "../main/config.js";
10-
import * as process from "node:process";
1110

1211
colors.enable();
1312

src/main/database.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {PrismaClient} from "../prisma/index.js";
33
import {LoggingAction} from "../enums/loggingTypes.js";
44
import {Logger} from "./logger.js";
55
import colors from "colors"
6-
import {initGuildsToDatabase, initUsersToDatabase, setupDisBotConfig} from "../helper/databaseHelper.js";
6+
import {initGuildsToDatabase, setupDisBotConfig} from "../helper/databaseHelper.js";
77
import {Config} from "./config.js";
88

99
colors.enable();

0 commit comments

Comments
 (0)