Skip to content

Commit

Permalink
added automatic DB update on manually given break role
Browse files Browse the repository at this point in the history
  • Loading branch information
hasanlatch007 committed Feb 20, 2022
1 parent ecb4235 commit ff0ed96
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/programs/menu/break-handler/break-role-events.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { GuildMember } from "discord.js";
import {
Command,
CommandHandler,
DiscordEvent,
} from "../../../event-distribution";
import prisma from "../../../prisma";

@Command({
event: DiscordEvent.GUILD_MEMBER_UPDATE,
roleNamesAdded: ["Break"],
})
class BreakAdded implements CommandHandler<DiscordEvent.GUILD_MEMBER_UPDATE> {
async handle(member: GuildMember): Promise<void> {
await prisma.usersOnBreak.create({ data: { userId: member.id } });
}
}

@Command({
event: DiscordEvent.GUILD_MEMBER_UPDATE,
roleNamesRemoved: ["Break"],
})
class BreakRemove implements CommandHandler<DiscordEvent.GUILD_MEMBER_UPDATE> {
async handle(member: GuildMember): Promise<void> {
await prisma.usersOnBreak.delete({ where: { userId: member.id } });
}
}

0 comments on commit ff0ed96

Please sign in to comment.