From 18a435947469c18a334728bb8f33f271eb12d575 Mon Sep 17 00:00:00 2001 From: RishiChaubey31 Date: Thu, 17 Oct 2024 00:48:55 +0530 Subject: [PATCH] remove feature flag --- src/constants/commands.ts | 6 ------ src/controllers/mentionEachUser.ts | 9 ++++----- src/typeDefinitions/filterUsersByRole.d.ts | 5 ----- tests/unit/handlers/mentionEachUser.test.ts | 7 +------ 4 files changed, 5 insertions(+), 22 deletions(-) diff --git a/src/constants/commands.ts b/src/constants/commands.ts index 47a83d65..f98b1380 100644 --- a/src/constants/commands.ts +++ b/src/constants/commands.ts @@ -44,12 +44,6 @@ export const MENTION_EACH = { type: 3, require: false, }, - { - name: "dev", - description: "want to tag them individually?", - type: 5, - require: false, - }, ], }; diff --git a/src/controllers/mentionEachUser.ts b/src/controllers/mentionEachUser.ts index ebe63602..c02812b6 100644 --- a/src/controllers/mentionEachUser.ts +++ b/src/controllers/mentionEachUser.ts @@ -6,7 +6,6 @@ import { env } from "../typeDefinitions/default.types"; import { UserArray, MentionEachUserOptions, - DevFlag, } from "../typeDefinitions/filterUsersByRole"; import { mentionEachUserInMessage } from "../utils/guildRole"; import { checkDisplayType } from "../utils/checkDisplayType"; @@ -16,7 +15,6 @@ export async function mentionEachUser( roleToBeTaggedObj: MentionEachUserOptions; displayMessageObj?: MentionEachUserOptions; channelId: number; - dev?: DevFlag; }, env: env, ctx: ExecutionContext @@ -24,19 +22,20 @@ export async function mentionEachUser( const getMembersInServerResponse = await getMembersInServer(env); const roleId = transformedArgument.roleToBeTaggedObj.value; const msgToBeSent = transformedArgument?.displayMessageObj?.value; - const dev = transformedArgument?.dev?.value || false; - // optional chaining here only because display message obj is optional argument + const usersWithMatchingRole = filterUserByRoles( getMembersInServerResponse as UserArray[], roleId ); + const payload = { channelId: transformedArgument.channelId, roleId: roleId, message: msgToBeSent, usersWithMatchingRole, }; - if (!dev || usersWithMatchingRole.length === 0) { + + if (usersWithMatchingRole.length === 0) { const responseData = checkDisplayType({ usersWithMatchingRole, msgToBeSent, diff --git a/src/typeDefinitions/filterUsersByRole.d.ts b/src/typeDefinitions/filterUsersByRole.d.ts index a54fd748..4d42fd2a 100644 --- a/src/typeDefinitions/filterUsersByRole.d.ts +++ b/src/typeDefinitions/filterUsersByRole.d.ts @@ -10,8 +10,3 @@ export type MentionEachUserOptions = { type: number; value: string; }; -export type DevFlag = { - name: string; - type: number; - value: boolean; -}; diff --git a/tests/unit/handlers/mentionEachUser.test.ts b/tests/unit/handlers/mentionEachUser.test.ts index dc23bc22..5224f904 100644 --- a/tests/unit/handlers/mentionEachUser.test.ts +++ b/tests/unit/handlers/mentionEachUser.test.ts @@ -19,7 +19,7 @@ describe("Test mention each function", () => { expect(response).toBeInstanceOf(Promise); }); - it("should run without displayMessageObj argument in dev mode", async () => { + it("should run without displayMessageObj argument", async () => { const env = { BOT_PUBLIC_KEY: "xyz", DISCORD_GUILD_ID: "123", @@ -28,11 +28,6 @@ describe("Test mention each function", () => { const response = mentionEachUser( { ...onlyRoleToBeTagged, - dev: { - name: "dev", - type: 4, - value: true, - }, }, env, ctx