Skip to content

Commit 725e491

Browse files
vinit717vikhyat187
authored andcommitted
Revert "remove feature flag (Real-Dev-Squad#275)" (Real-Dev-Squad#281)
This reverts commit b54d9c3.
1 parent 7433c40 commit 725e491

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

src/constants/commands.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ export const MENTION_EACH = {
8080
type: 3,
8181
require: false,
8282
},
83+
{
84+
name: "dev",
85+
description: "want to tag them individually?",
86+
type: 5,
87+
require: false,
88+
},
8389
],
8490
};
8591

src/controllers/mentionEachUser.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { env } from "../typeDefinitions/default.types";
66
import {
77
UserArray,
88
MentionEachUserOptions,
9+
DevFlag,
910
} from "../typeDefinitions/filterUsersByRole";
1011
import { mentionEachUserInMessage } from "../utils/guildRole";
1112
import { checkDisplayType } from "../utils/checkDisplayType";
@@ -15,27 +16,27 @@ export async function mentionEachUser(
1516
roleToBeTaggedObj: MentionEachUserOptions;
1617
displayMessageObj?: MentionEachUserOptions;
1718
channelId: number;
19+
dev?: DevFlag;
1820
},
1921
env: env,
2022
ctx: ExecutionContext
2123
) {
2224
const getMembersInServerResponse = await getMembersInServer(env);
2325
const roleId = transformedArgument.roleToBeTaggedObj.value;
2426
const msgToBeSent = transformedArgument?.displayMessageObj?.value;
25-
27+
const dev = transformedArgument?.dev?.value || false;
28+
// optional chaining here only because display message obj is optional argument
2629
const usersWithMatchingRole = filterUserByRoles(
2730
getMembersInServerResponse as UserArray[],
2831
roleId
2932
);
30-
3133
const payload = {
3234
channelId: transformedArgument.channelId,
3335
roleId: roleId,
3436
message: msgToBeSent,
3537
usersWithMatchingRole,
3638
};
37-
38-
if (usersWithMatchingRole.length === 0) {
39+
if (!dev || usersWithMatchingRole.length === 0) {
3940
const responseData = checkDisplayType({
4041
usersWithMatchingRole,
4142
msgToBeSent,

src/typeDefinitions/filterUsersByRole.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,8 @@ export type MentionEachUserOptions = {
1010
type: number;
1111
value: string;
1212
};
13+
export type DevFlag = {
14+
name: string;
15+
type: number;
16+
value: boolean;
17+
};

tests/unit/handlers/mentionEachUser.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe("Test mention each function", () => {
1919
expect(response).toBeInstanceOf(Promise);
2020
});
2121

22-
it("should run without displayMessageObj argument", async () => {
22+
it("should run without displayMessageObj argument in dev mode", async () => {
2323
const env = {
2424
BOT_PUBLIC_KEY: "xyz",
2525
DISCORD_GUILD_ID: "123",
@@ -28,6 +28,11 @@ describe("Test mention each function", () => {
2828
const response = mentionEachUser(
2929
{
3030
...onlyRoleToBeTagged,
31+
dev: {
32+
name: "dev",
33+
type: 4,
34+
value: true,
35+
},
3136
},
3237
env,
3338
ctx

0 commit comments

Comments
 (0)