-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- will only accept interactions from moderators or higher
- Loading branch information
1 parent
37b7fb0
commit eaf37aa
Showing
4 changed files
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { DiscordGuard } from '@discord-nestjs/core'; | ||
import { ConfigService } from '@nestjs/config'; | ||
import { GuildMemberRoleManager, Interaction } from 'discord.js'; | ||
|
||
export class InteractionFromPermittedUserGuard implements DiscordGuard { | ||
constructor(private readonly configService: ConfigService) {} | ||
|
||
async canActive(event: 'interactionCreate', [interaction]: [Interaction]): Promise<boolean> { | ||
const roleManager = interaction.member.roles as GuildMemberRoleManager; | ||
const modRole = await interaction.guild.roles.fetch(process.env.DISCORD_MOD_ROLE_ID); | ||
return roleManager.member.roles.highest.position >= modRole.position; | ||
} | ||
} |