(#2) Members can now be in multiple guilds

Signed-off-by: Louis Hollingworth <louis@hollingworth.ch>
This commit is contained in:
Louis Hollingworth 2023-06-18 14:05:21 +01:00
parent e8f797d1e0
commit 530e99a7d0
Signed by: lucxjo
GPG key ID: A11415CB3DC7809B
4 changed files with 27 additions and 22 deletions

View file

@ -6,14 +6,7 @@ import {
PermissionsBitField,
Role,
} from "discord.js";
import {
Discord,
Guard,
GuardFunction,
Slash,
SlashGroup,
SlashOption,
} from "discordx";
import { Discord, Slash, SlashGroup, SlashOption } from "discordx";
import { prisma } from "../main.js";
@Discord()
@ -108,24 +101,28 @@ export class AdminCmds {
) {
let mem = await prisma.member.findUnique({
where: {
id: member.id,
dgid_duid: {
duid: member.id,
dgid: member.guild.id,
},
},
});
if (mem) {
await prisma.member.update({
where: {
id: member.id,
id: mem.id,
},
data: {
name: mem.name != member.displayName ? member.displayName : undefined,
booster_role_id: role.id,
name: member.displayName,
},
});
} else {
await prisma.member.create({
data: {
id: member.id,
duid: member.id,
dgid: interaction.guildId!,
name: member.displayName,
booster_role_id: role.id,
},