♻️ Migrate guildCreate to Prisma
This commit is contained in:
parent
a568daaadd
commit
10283f911b
1 changed files with 37 additions and 2 deletions
|
@ -1,7 +1,8 @@
|
||||||
import { Guild } from "discord.js";
|
import { Guild } from "discord.js";
|
||||||
import fetchGuild from "../../../helpers/guildData";
|
|
||||||
import updatePresence from "../../../helpers/updatePresence";
|
import updatePresence from "../../../helpers/updatePresence";
|
||||||
import { IEventOptions } from "../../../interfaces/EventOptions";
|
import { IEventOptions } from "../../../interfaces/EventOptions";
|
||||||
|
import logger from "../../../middlewares/logger";
|
||||||
|
import prisma from "../../../prisma";
|
||||||
|
|
||||||
export const options: IEventOptions = {
|
export const options: IEventOptions = {
|
||||||
type: "on",
|
type: "on",
|
||||||
|
@ -10,6 +11,40 @@ export const options: IEventOptions = {
|
||||||
export const execute = async (guild: Guild) => {
|
export const execute = async (guild: Guild) => {
|
||||||
const { client } = guild;
|
const { client } = guild;
|
||||||
|
|
||||||
await fetchGuild(guild);
|
|
||||||
await updatePresence(client);
|
await updatePresence(client);
|
||||||
|
|
||||||
|
// Create guildMember object
|
||||||
|
const createGuildMember = await prisma.guildMember.upsert({
|
||||||
|
where: {
|
||||||
|
userId_guildId: {
|
||||||
|
userId: guild.ownerId,
|
||||||
|
guildId: guild.id,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
update: {},
|
||||||
|
create: {
|
||||||
|
user: {
|
||||||
|
connectOrCreate: {
|
||||||
|
create: {
|
||||||
|
id: guild.ownerId,
|
||||||
|
},
|
||||||
|
where: {
|
||||||
|
id: guild.ownerId,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
guild: {
|
||||||
|
connectOrCreate: {
|
||||||
|
create: {
|
||||||
|
id: guild.id,
|
||||||
|
},
|
||||||
|
where: {
|
||||||
|
id: guild.id,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
logger.silly(createGuildMember);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue