@@ -16,6 +16,7 @@ export async function mentionEachUser(
1616 roleToBeTaggedObj : MentionEachUserOptions ;
1717 displayMessageObj ?: MentionEachUserOptions ;
1818 channelId : number ;
19+ showroles ?: DevFlag ;
1920 dev ?: DevFlag ;
2021 } ,
2122 env : env ,
@@ -25,7 +26,7 @@ export async function mentionEachUser(
2526 const roleId = transformedArgument . roleToBeTaggedObj . value ;
2627 const msgToBeSent = transformedArgument ?. displayMessageObj ?. value ;
2728 const dev = transformedArgument ?. dev ?. value || false ;
28-
29+ const showroles = transformedArgument ?. showroles ?. value || false ;
2930 const usersWithMatchingRole = filterUserByRoles (
3031 getMembersInServerResponse as UserArray [ ] ,
3132 roleId
@@ -36,21 +37,37 @@ export async function mentionEachUser(
3637 message : msgToBeSent ,
3738 usersWithMatchingRole,
3839 } ;
39-
40- if ( ! dev || usersWithMatchingRole . length === 0 ) {
40+ if ( transformedArgument . showroles ?. value === true ) {
41+ let responseMessage = "" ;
42+ if ( usersWithMatchingRole . length === 0 ) {
43+ responseMessage = `Sorry, no user found with <@&${ roleId } > role.` ;
44+ } else if ( usersWithMatchingRole . length === 1 ) {
45+ // Mention the single user by ID
46+ responseMessage = `The user with <@&${ roleId } > role is ${ payload . usersWithMatchingRole } .` ;
47+ } else {
48+ // Mention multiple users by their IDs
49+ responseMessage = `The users with <@&${ roleId } > role are ${ payload . usersWithMatchingRole } .` ;
50+ }
51+ return discordTextResponse ( responseMessage ) ;
52+ } else if ( ! dev || usersWithMatchingRole . length === 0 ) {
4153 const responseData = checkDisplayType ( {
4254 usersWithMatchingRole,
4355 msgToBeSent,
4456 roleId,
4557 } ) ;
4658 return discordTextResponse ( responseData ) ;
4759 } else {
48- let responseMessage = "" ;
49- if ( usersWithMatchingRole . length === 1 ) {
50- responseMessage = `The user with <@&${ roleId } > role is: ${ payload . usersWithMatchingRole } ` ;
51- } else {
52- responseMessage = `The users with <@&${ roleId } > role are: ${ payload . usersWithMatchingRole } ` ;
53- }
54- return discordTextResponse ( responseMessage ) ;
60+ // Regular dev flow to mention users
61+ ctx . waitUntil (
62+ mentionEachUserInMessage ( {
63+ message : payload . message ,
64+ userIds : payload . usersWithMatchingRole ,
65+ channelId : payload . channelId ,
66+ env,
67+ } )
68+ ) ;
69+ return discordTextResponse (
70+ `Found ${ usersWithMatchingRole . length } users with matched role, mentioning them shortly...`
71+ ) ;
5572 }
5673}
0 commit comments