mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-12 22:17:44 +00:00
Compare commits
2 Commits
@revanced/
...
@revanced/
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
95a122a225 | ||
|
|
d234d79310 |
@@ -1,3 +1,10 @@
|
||||
# @revanced/discord-bot [1.0.0-dev.11](https://github.com/revanced/revanced-helper/compare/@revanced/discord-bot@1.0.0-dev.10...@revanced/discord-bot@1.0.0-dev.11) (2024-07-30)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **bots/discord:** reset counter when reconnected to api, redo message scan filter logic ([d234d79](https://github.com/revanced/revanced-helper/commit/d234d79310caed9c43e14a905f9ef46a110e071d))
|
||||
|
||||
# @revanced/discord-bot [1.0.0-dev.10](https://github.com/revanced/revanced-helper/compare/@revanced/discord-bot@1.0.0-dev.9...@revanced/discord-bot@1.0.0-dev.10) (2024-07-30)
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"name": "@revanced/discord-bot",
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"version": "1.0.0-dev.10",
|
||||
"version": "1.0.0-dev.11",
|
||||
"description": "🤖 Discord bot assisting ReVanced",
|
||||
"main": "src/index.ts",
|
||||
"scripts": {
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
import { on, withContext } from '$utils/api/events'
|
||||
|
||||
withContext(on, 'ready', ({ logger }) => void logger.info('Connected to the bot API'))
|
||||
withContext(on, 'ready', ({ api, logger }) => {
|
||||
// Reset disconnect count, so it doesn't meet the threshold for an accidental disconnect
|
||||
api.disconnectCount = 0
|
||||
logger.info('Connected to the bot API')
|
||||
})
|
||||
|
||||
@@ -113,15 +113,24 @@ export const messageMatchesFilter = (message: Message, filter: NonNullable<Confi
|
||||
if (!filter) return true
|
||||
|
||||
const memberRoles = new Set(message.member?.roles.cache.keys())
|
||||
const blFilter = filter.blacklist
|
||||
const { blacklist, whitelist } = filter
|
||||
|
||||
// If matches blacklist, will return false
|
||||
// Any other case, will return true
|
||||
return !(
|
||||
blFilter &&
|
||||
(blFilter.channels?.includes(message.channelId) ||
|
||||
blFilter.roles?.some(role => memberRoles.has(role)) ||
|
||||
blFilter.users?.includes(message.author.id))
|
||||
// If matches only blacklist, will return false
|
||||
// If matches whitelist but also matches blacklist, will return false
|
||||
// If matches only whitelist, will return true
|
||||
// If matches neither, will return true
|
||||
return (
|
||||
(whitelist
|
||||
? whitelist.channels?.includes(message.channelId) ||
|
||||
whitelist.roles?.some(role => memberRoles.has(role)) ||
|
||||
whitelist.users?.includes(message.author.id)
|
||||
: true) &&
|
||||
!(
|
||||
blacklist &&
|
||||
(blacklist.channels?.includes(message.channelId) ||
|
||||
blacklist.roles?.some(role => memberRoles.has(role)) ||
|
||||
blacklist.users?.includes(message.author.id))
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user