generated from lucxjo/template
Now role auto creation on boost can be disabled
Signed-off-by: Louis Hollingworth <louis@hollingworth.ch>
This commit is contained in:
parent
9f53ee668c
commit
a37a8a6935
|
@ -0,0 +1,2 @@
|
|||
-- AlterTable
|
||||
ALTER TABLE "guild" ADD COLUMN "auto_create_booster_roles" BOOLEAN NOT NULL DEFAULT true;
|
|
@ -12,6 +12,7 @@ model guild {
|
|||
id String @id @unique
|
||||
name String
|
||||
reports_channel_id String?
|
||||
auto_create_booster_roles Boolean @default(true)
|
||||
}
|
||||
|
||||
model member {
|
||||
|
|
|
@ -133,4 +133,34 @@ export class AdminCmds {
|
|||
ephemeral: true,
|
||||
});
|
||||
}
|
||||
|
||||
@Slash({
|
||||
description: "Enable or disable auto perk roles",
|
||||
defaultMemberPermissions: PermissionsBitField.Flags.Administrator,
|
||||
})
|
||||
async toggle_perk_role_creation(interaction: CommandInteraction) {
|
||||
if (interaction.guildId) {
|
||||
const g = await prisma.guild.findUnique({
|
||||
where: {
|
||||
id: interaction.guildId,
|
||||
},
|
||||
});
|
||||
|
||||
await prisma.guild.update({
|
||||
where: {
|
||||
id: interaction.guildId,
|
||||
},
|
||||
data: {
|
||||
auto_create_booster_roles: !g?.auto_create_booster_roles,
|
||||
},
|
||||
});
|
||||
|
||||
interaction.reply({
|
||||
content: `Booster role creation is now ${
|
||||
g?.auto_create_booster_roles ? "disabled" : "enabled"
|
||||
}`,
|
||||
ephemeral: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,13 @@ export class MemberEvent {
|
|||
|
||||
@On({ event: "guildMemberUpdate" })
|
||||
async memberUpdate([oldM, newM]: ArgsOf<"guildMemberUpdate">) {
|
||||
const g = await prisma.guild.findUnique({
|
||||
where: {
|
||||
id: newM.guild.id,
|
||||
},
|
||||
});
|
||||
|
||||
if (g?.auto_create_booster_roles) {
|
||||
if (oldM.premiumSince !== newM.premiumSince) {
|
||||
if (newM != null) {
|
||||
const m = await prisma.member.findUnique({
|
||||
|
@ -96,4 +103,5 @@ export class MemberEvent {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue