|
1 |
| -package permissions |
2 |
| - |
3 |
| -import ( |
4 |
| - "github.com/gofiber/fiber/v2" |
5 |
| - "github.com/zekroTJA/shinpuru/pkg/discordutil" |
6 |
| - "github.com/zekroTJA/shinpuru/pkg/permissions" |
7 |
| - "github.com/zekrotja/ken" |
8 |
| -) |
9 |
| - |
10 |
| -type Provider interface { |
11 |
| - ken.MiddlewareBefore |
12 |
| - |
13 |
| - HandleWs(s discordutil.ISession, required string) fiber.Handler |
14 |
| - |
15 |
| - // GetPermissions tries to fetch the permissions array of |
16 |
| - // the passed user of the specified guild. The merged |
17 |
| - // permissions array is returned as well as the override, |
18 |
| - // which is true when the specified user is the bot owner, |
19 |
| - // guild owner or an admin of the guild. |
20 |
| - GetPermissions( |
21 |
| - s discordutil.ISession, |
22 |
| - guildID string, |
23 |
| - userID string, |
24 |
| - ) (perm permissions.PermissionArray, overrideExplicits bool, err error) |
25 |
| - |
26 |
| - // CheckPermissions tries to fetch the permissions of the specified user |
27 |
| - // on the specified guild and returns true, if any of the passed dns match |
28 |
| - // the fetched permissions array. Also, the override status is returned as |
29 |
| - // well as errors occured during permissions fetching. |
30 |
| - // |
31 |
| - // If the userID matches the configured bot owner, all bot owner permissions |
32 |
| - // will be added to the fetched permissions array. |
33 |
| - // |
34 |
| - // If guildID is passed as non-mepty string, all configured guild owner |
35 |
| - // permissions will be added to the fetched permissions array as well. |
36 |
| - CheckPermissions( |
37 |
| - s discordutil.ISession, |
38 |
| - guildID string, |
39 |
| - userID string, |
40 |
| - dns ...string, |
41 |
| - ) (bool, bool, error) |
42 |
| - |
43 |
| - // GetMemberPermissions returns a PermissionsArray based on the passed |
44 |
| - // members roles permissions rulesets for the given guild. |
45 |
| - GetMemberPermission( |
46 |
| - s discordutil.ISession, |
47 |
| - guildID string, |
48 |
| - memberID string, |
49 |
| - ) (permissions.PermissionArray, error) |
50 |
| - |
51 |
| - // CheckSubPerm takes a command context and checks is the given |
52 |
| - // subDN is permitted. |
53 |
| - CheckSubPerm( |
54 |
| - ctx ken.Context, |
55 |
| - subDN string, |
56 |
| - explicit bool, |
57 |
| - message ...string, |
58 |
| - ) (ok bool, err error) |
59 |
| -} |
| 1 | +package permissions |
| 2 | + |
| 3 | +import ( |
| 4 | + "github.com/gofiber/fiber/v2" |
| 5 | + "github.com/zekroTJA/shinpuru/pkg/permissions" |
| 6 | + "github.com/zekrotja/ken" |
| 7 | +) |
| 8 | + |
| 9 | +type Provider interface { |
| 10 | + ken.MiddlewareBefore |
| 11 | + |
| 12 | + HandleWs(s Session, required string) fiber.Handler |
| 13 | + |
| 14 | + // GetPermissions tries to fetch the permissions array of |
| 15 | + // the passed user of the specified guild. The merged |
| 16 | + // permissions array is returned as well as the override, |
| 17 | + // which is true when the specified user is the bot owner, |
| 18 | + // guild owner or an admin of the guild. |
| 19 | + GetPermissions( |
| 20 | + s Session, |
| 21 | + guildID string, |
| 22 | + userID string, |
| 23 | + ) (perm permissions.PermissionArray, overrideExplicits bool, err error) |
| 24 | + |
| 25 | + // CheckPermissions tries to fetch the permissions of the specified user |
| 26 | + // on the specified guild and returns true, if any of the passed dns match |
| 27 | + // the fetched permissions array. Also, the override status is returned as |
| 28 | + // well as errors occured during permissions fetching. |
| 29 | + // |
| 30 | + // If the userID matches the configured bot owner, all bot owner permissions |
| 31 | + // will be added to the fetched permissions array. |
| 32 | + // |
| 33 | + // If guildID is passed as non-mepty string, all configured guild owner |
| 34 | + // permissions will be added to the fetched permissions array as well. |
| 35 | + CheckPermissions( |
| 36 | + s Session, |
| 37 | + guildID string, |
| 38 | + userID string, |
| 39 | + dns ...string, |
| 40 | + ) (bool, bool, error) |
| 41 | + |
| 42 | + // GetMemberPermissions returns a PermissionsArray based on the passed |
| 43 | + // members roles permissions rulesets for the given guild. |
| 44 | + GetMemberPermission( |
| 45 | + s Session, |
| 46 | + guildID string, |
| 47 | + memberID string, |
| 48 | + ) (permissions.PermissionArray, error) |
| 49 | + |
| 50 | + // CheckSubPerm takes a command context and checks is the given |
| 51 | + // subDN is permitted. |
| 52 | + CheckSubPerm( |
| 53 | + ctx ken.Context, |
| 54 | + subDN string, |
| 55 | + explicit bool, |
| 56 | + message ...string, |
| 57 | + ) (ok bool, err error) |
| 58 | +} |
0 commit comments