

























@@ -27,76 +27,64 @@ describe("resolveDiscordTextCommandAccess", () => {
2727};
28282929it("authorizes guild text commands from owner allowlists", async () => {
30-await expect(
31-resolveDiscordTextCommandAccess({
32-accountId: "default",
33- sender,
34-ownerAllowFrom: ["discord:123"],
35-memberAccessConfigured: false,
36-memberAllowed: false,
37-allowNameMatching: false,
38-allowTextCommands: true,
39-hasControlCommand: true,
40-}),
41-).resolves.toMatchObject({
42-authorized: true,
43-shouldBlockControlCommand: false,
30+const result = await resolveDiscordTextCommandAccess({
31+accountId: "default",
32+ sender,
33+ownerAllowFrom: ["discord:123"],
34+memberAccessConfigured: false,
35+memberAllowed: false,
36+allowNameMatching: false,
37+allowTextCommands: true,
38+hasControlCommand: true,
4439});
40+expect(result.authorized).toBe(true);
41+expect(result.shouldBlockControlCommand).toBe(false);
4542});
46434744it("authorizes guild text commands from member access facts", async () => {
48-await expect(
49-resolveDiscordTextCommandAccess({
50-accountId: "default",
51- sender,
52-ownerAllowFrom: [],
53-memberAccessConfigured: true,
54-memberAllowed: true,
55-allowNameMatching: false,
56-allowTextCommands: true,
57-hasControlCommand: true,
58-}),
59-).resolves.toMatchObject({
60-authorized: true,
61-shouldBlockControlCommand: false,
45+const result = await resolveDiscordTextCommandAccess({
46+accountId: "default",
47+ sender,
48+ownerAllowFrom: [],
49+memberAccessConfigured: true,
50+memberAllowed: true,
51+allowNameMatching: false,
52+allowTextCommands: true,
53+hasControlCommand: true,
6254});
55+expect(result.authorized).toBe(true);
56+expect(result.shouldBlockControlCommand).toBe(false);
6357});
64586559it("blocks unauthorized guild text control commands", async () => {
66-await expect(
67-resolveDiscordTextCommandAccess({
68-accountId: "default",
69- sender,
70-ownerAllowFrom: ["discord:999"],
71-memberAccessConfigured: true,
72-memberAllowed: false,
73-allowNameMatching: false,
74-allowTextCommands: true,
75-hasControlCommand: true,
76-}),
77-).resolves.toMatchObject({
78-authorized: false,
79-shouldBlockControlCommand: true,
60+const result = await resolveDiscordTextCommandAccess({
61+accountId: "default",
62+ sender,
63+ownerAllowFrom: ["discord:999"],
64+memberAccessConfigured: true,
65+memberAllowed: false,
66+allowNameMatching: false,
67+allowTextCommands: true,
68+hasControlCommand: true,
8069});
70+expect(result.authorized).toBe(false);
71+expect(result.shouldBlockControlCommand).toBe(true);
8172});
82738374it("preserves configured mode when access groups are disabled", async () => {
84-await expect(
85-resolveDiscordTextCommandAccess({
86-accountId: "default",
87- sender,
88-ownerAllowFrom: [],
89-memberAccessConfigured: false,
90-memberAllowed: false,
91-allowNameMatching: false,
92-cfg: { commands: { useAccessGroups: false } },
93-allowTextCommands: true,
94-hasControlCommand: true,
95-}),
96-).resolves.toMatchObject({
97-authorized: true,
98-shouldBlockControlCommand: false,
75+const result = await resolveDiscordTextCommandAccess({
76+accountId: "default",
77+ sender,
78+ownerAllowFrom: [],
79+memberAccessConfigured: false,
80+memberAllowed: false,
81+allowNameMatching: false,
82+cfg: { commands: { useAccessGroups: false } },
83+allowTextCommands: true,
84+hasControlCommand: true,
9985});
86+expect(result.authorized).toBe(true);
87+expect(result.shouldBlockControlCommand).toBe(false);
10088});
10189});
10290此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。