This repository was archived by the owner on Oct 15, 2020. It is now read-only.
forked from redxtech/devmod
-
Notifications
You must be signed in to change notification settings - Fork 1
Seniors and Staff Exempt from Anti-Raid #1
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
0f91c55
:art: Get senior and staff role
7099c56
:poop: Senior bypass
0aa52f2
:art: Senior Bypass Anti-Raid
43b28ae
:twisted_rightwards_arrows: Merge
austinmccalley b9db873
:art: Staff and Seniors are exempt
austinmccalley 1434bcb
Merge pull request #1 from austinmccalley/anti-raid-senior-staff-fix
austinmccalley 2e0ee95
:art: Updated logic for if statement and var names
austinmccalley 5a55729
:twisted_rightwards_arrows: Merge, forgot to switch branches
austinmccalley 1f0bdcb
:art: Reset Timer and Dynamic Member & Role Count
austinmccalley d94318c
Update src/processes/antiraidListener.ts
austinmccalley c464bab
Update config.example.ts
austinmccalley f64fff1
:art: Removed comment
austinmccalley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -16,29 +16,44 @@ export const antiraidListener: ProcessInterface = { | |
| const mentions = new Map() | ||
| const mutedRole = config.roleIDs.muted | ||
|
|
||
| // TODO: fix staffRole to mention properly, cannot be string | ||
| //const staffRole = config.roleIDs.staff | ||
| const staffRole = 662405675107876864 | ||
| // NOTE: Pull from config, same role is achieved | ||
| const staffRoleId = config.roleIDs.staff | ||
|
|
||
| // NOTE: Get role from config | ||
| const seniorRoleId = config.roleIDs.senior | ||
|
|
||
| const maxMentionedRoles = config.antiRaidRoles | ||
| const maxMentionedMemebers = config.antiRaidMembers | ||
| const maxMentionedEverything = maxMentionedRoles + maxMentionedMemebers | ||
|
|
||
| // DEBUG: Debug console log for role comparison | ||
| // console.log(staffRole, seniorRole) | ||
|
|
||
| client.on('message', async (message: Message) => { | ||
| const lastKnownTimestamp = mentions.get(message.author.id) ?? null | ||
|
|
||
| // TODO: escape check if user is senior | ||
| //message.member.roles | ||
|
|
||
| const { | ||
| users: { size: mentionedUsers }, | ||
| roles: { size: mentionedRoles } | ||
| } = message.mentions | ||
|
|
||
| if ( | ||
| mentionedRoles > 1 || | ||
| mentionedUsers > 2 || | ||
| mentionedUsers + mentionedRoles > 2 | ||
| ) { | ||
| lastKnownTimestamp | ||
| ? checkOffender(message, lastKnownTimestamp) | ||
| : addOffenderToList(message) | ||
| const userRoleIds = message.member.roles.cache.map(r => r.id) | ||
|
|
||
| const isStaff = userRoleIds.find(r => r === staffRoleId) | ||
| const isSenior = userRoleIds.find(r => r === seniorRoleId) | ||
|
|
||
| if (isStaff || isSenior) { | ||
| return | ||
| } else { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No else! return -> end of function |
||
| const { | ||
| users: { size: mentionedUsers }, | ||
| roles: { size: mentionedRoles } | ||
| } = message.mentions | ||
|
|
||
| if ( | ||
| mentionedRoles > maxMentionedRoles || | ||
| mentionedUsers > maxMentionedMemebers || | ||
| mentionedUsers + mentionedRoles > maxMentionedEverything | ||
| ) { | ||
| lastKnownTimestamp | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Specific comparison like === null |
||
| ? checkOffender(message, lastKnownTimestamp) | ||
| : addOffenderToList(message) | ||
| } | ||
| } | ||
| }) | ||
|
|
||
|
|
@@ -58,8 +73,11 @@ export const antiraidListener: ProcessInterface = { | |
| const triggerAntiraid = async message => { | ||
| await message.delete() | ||
| message.member.roles.add(mutedRole) | ||
| addOffenderToList(message) | ||
|
|
||
| // TODO: Send message to #mod-log | ||
| message.channel.send( | ||
| `<@${message.author.id}> messed with the honk, so he got the bonk. (<@&${staffRole}>)` | ||
| `<@${message.author.id}> messed with the honk, so he got the bonk. (<@&${staffRoleId}>)` | ||
| ) | ||
| } | ||
| } | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.