Backfill missed pins and pins from the past
This commit is contained in:
parent
ed7404ea19
commit
8987107685
9 changed files with 147 additions and 13 deletions
|
@ -34,7 +34,7 @@ function getPermissions(userRoles, guildRoles, userID, channelOverwrites) {
|
|||
// Role deny
|
||||
overwrite => userRoles.includes(overwrite.id) && (allowed &= ~BigInt(overwrite.deny)),
|
||||
// Role allow
|
||||
overwrite => userRoles.includes(overwrite.id) && (allowed |= ~BigInt(overwrite.allow)),
|
||||
overwrite => userRoles.includes(overwrite.id) && (allowed |= BigInt(overwrite.allow)),
|
||||
// User deny
|
||||
overwrite => overwrite.id === userID && (allowed &= ~BigInt(overwrite.deny)),
|
||||
// User allow
|
||||
|
|
|
@ -18,6 +18,67 @@ test("discord utils: converts snowflake to timestamp", t => {
|
|||
t.equal(utils.snowflakeToTimestampExact("86913608335773696"), 1440792219004)
|
||||
})
|
||||
|
||||
test("discerd utils: converts timestamp to snowflake", t => {
|
||||
test("discord utils: converts timestamp to snowflake", t => {
|
||||
t.match(utils.timestampToSnowflakeInexact(1440792219004), /^869136083357.....$/)
|
||||
})
|
||||
|
||||
test("getPermissions: channel overwrite to allow role works", t => {
|
||||
const guildRoles = [
|
||||
{
|
||||
version: 1695412489043,
|
||||
unicode_emoji: null,
|
||||
tags: {},
|
||||
position: 0,
|
||||
permissions: "559623605571137",
|
||||
name: "@everyone",
|
||||
mentionable: false,
|
||||
managed: false,
|
||||
id: "1154868424724463687",
|
||||
icon: null,
|
||||
hoist: false,
|
||||
flags: 0,
|
||||
color: 0
|
||||
},
|
||||
{
|
||||
version: 1695412604262,
|
||||
unicode_emoji: null,
|
||||
tags: { bot_id: "466378653216014359" },
|
||||
position: 1,
|
||||
permissions: "536995904",
|
||||
name: "PluralKit",
|
||||
mentionable: false,
|
||||
managed: true,
|
||||
id: "1154868908336099444",
|
||||
icon: null,
|
||||
hoist: false,
|
||||
flags: 0,
|
||||
color: 0
|
||||
},
|
||||
{
|
||||
version: 1698778936921,
|
||||
unicode_emoji: null,
|
||||
tags: {},
|
||||
position: 1,
|
||||
permissions: "536870912",
|
||||
name: "web hookers",
|
||||
mentionable: false,
|
||||
managed: false,
|
||||
id: "1168988246680801360",
|
||||
icon: null,
|
||||
hoist: false,
|
||||
flags: 0,
|
||||
color: 0
|
||||
}
|
||||
]
|
||||
const userRoles = [ "1168988246680801360" ]
|
||||
const userID = "684280192553844747"
|
||||
const overwrites = [
|
||||
{ type: 0, id: "1154868908336099444", deny: "0", allow: "1024" },
|
||||
{ type: 0, id: "1154868424724463687", deny: "1024", allow: "0" },
|
||||
{ type: 0, id: "1168988246680801360", deny: "0", allow: "1024" },
|
||||
{ type: 1, id: "353373325575323648", deny: "0", allow: "1024" }
|
||||
]
|
||||
const permissions = utils.getPermissions(userRoles, guildRoles, userID, overwrites)
|
||||
const want = BigInt(1 << 10 | 1 << 16)
|
||||
t.equal((permissions & want), want)
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue