mirror of
https://github.com/veganhacktivists/arabot.git
synced 2025-05-18 17:14:15 +02:00
refactor(arabot): change StatRole to one to one relationship in Prisma
This commit is contained in:
parent
086d1d50c6
commit
80d90256d5
@ -96,6 +96,8 @@ model LeaveLog {
|
|||||||
roles String[]
|
roles String[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Outreach
|
||||||
|
|
||||||
model Event {
|
model Event {
|
||||||
id Int @id @default(autoincrement())
|
id Int @id @default(autoincrement())
|
||||||
type EventType @relation(fields: [eventType], references: [type])
|
type EventType @relation(fields: [eventType], references: [type])
|
||||||
@ -125,7 +127,7 @@ model Stat {
|
|||||||
documentary Int @default(0)
|
documentary Int @default(0)
|
||||||
educated Int @default(0)
|
educated Int @default(0)
|
||||||
participants ParticipantStat[]
|
participants ParticipantStat[]
|
||||||
role StatRole[]
|
role StatRole?
|
||||||
}
|
}
|
||||||
|
|
||||||
model StatRole {
|
model StatRole {
|
||||||
@ -143,6 +145,8 @@ model ParticipantStat {
|
|||||||
@@id([statId, userId])
|
@@id([statId, userId])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Moderation
|
||||||
|
|
||||||
model Sus {
|
model Sus {
|
||||||
id Int @id @default(autoincrement())
|
id Int @id @default(autoincrement())
|
||||||
user User @relation("susUser", fields: [userId], references: [id])
|
user User @relation("susUser", fields: [userId], references: [id])
|
||||||
|
@ -75,7 +75,7 @@ export class OutreachCommand extends Subcommand {
|
|||||||
.addSubcommandGroup((group) => group.setName('event')
|
.addSubcommandGroup((group) => group.setName('event')
|
||||||
.setDescription('Commands to do with outreach events')
|
.setDescription('Commands to do with outreach events')
|
||||||
.addSubcommand((command) => command.setName('create')
|
.addSubcommand((command) => command.setName('create')
|
||||||
.setDescription('Start an outreach event')))
|
.setDescription('Start an outreach event'))
|
||||||
/*
|
/*
|
||||||
TODO add this back at a later date
|
TODO add this back at a later date
|
||||||
|
|
||||||
@ -83,9 +83,9 @@ export class OutreachCommand extends Subcommand {
|
|||||||
.setDescription('Start the event immediately'))
|
.setDescription('Start the event immediately'))
|
||||||
.addSubcommand((command) => command.setName('start')
|
.addSubcommand((command) => command.setName('start')
|
||||||
.setDescription('Start an outreach event'))
|
.setDescription('Start an outreach event'))
|
||||||
|
*/
|
||||||
.addSubcommand((command) => command.setName('end')
|
.addSubcommand((command) => command.setName('end')
|
||||||
.setDescription('End an outreach event')))
|
.setDescription('End an outreach event')))
|
||||||
*/
|
|
||||||
.addSubcommandGroup((group) => group.setName('group')
|
.addSubcommandGroup((group) => group.setName('group')
|
||||||
.setDescription('Commands to do with groups')
|
.setDescription('Commands to do with groups')
|
||||||
.addSubcommand((command) => command.setName('create')
|
.addSubcommand((command) => command.setName('create')
|
||||||
@ -210,8 +210,10 @@ export class OutreachCommand extends Subcommand {
|
|||||||
|
|
||||||
const [stat] = await Promise.all([getStatGroups(event.id)]);
|
const [stat] = await Promise.all([getStatGroups(event.id)]);
|
||||||
|
|
||||||
stat.forEach((group) => {
|
stat.forEach(({ role }) => {
|
||||||
guild.roles.delete(group.role[0].roleId);
|
if (role !== null) {
|
||||||
|
guild.roles.delete(role.roleId);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
await endEvent(event.id);
|
await endEvent(event.id);
|
||||||
@ -331,7 +333,7 @@ export class OutreachCommand extends Subcommand {
|
|||||||
await interaction.deferReply({ ephemeral: true });
|
await interaction.deferReply({ ephemeral: true });
|
||||||
|
|
||||||
let statId: number;
|
let statId: number;
|
||||||
let roleId: Snowflake;
|
let roleId: Snowflake | undefined;
|
||||||
|
|
||||||
// Find group from role
|
// Find group from role
|
||||||
if (group !== null) {
|
if (group !== null) {
|
||||||
@ -375,7 +377,7 @@ export class OutreachCommand extends Subcommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
statId = stat.id;
|
statId = stat.id;
|
||||||
roleId = stat.role[0].roleId;
|
roleId = stat.role?.roleId;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await userInStats(statId, user.id)) {
|
if (await userInStats(statId, user.id)) {
|
||||||
@ -398,7 +400,9 @@ export class OutreachCommand extends Subcommand {
|
|||||||
|
|
||||||
await addStatUser(statId, user.id);
|
await addStatUser(statId, user.id);
|
||||||
|
|
||||||
await member.roles.add(roleId);
|
if (roleId !== undefined) {
|
||||||
|
await member.roles.add(roleId);
|
||||||
|
}
|
||||||
|
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
content: `Added ${user} to the group!`,
|
content: `Added ${user} to the group!`,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user