diff --git a/src/commandExecutor.js b/src/commandExecutor.js index 26ca6a6d75cb59abc8e38ac5af5bcf80a687d4e5..d15ea4956070c30273c421f1d8087378b5329a8f 100644 --- a/src/commandExecutor.js +++ b/src/commandExecutor.js @@ -44,6 +44,12 @@ async function VerifyAndExecuteGetAllMembers(data, userMediaID) const templateOptions = commandHelper.getGroupIDsWithCondition(userDatabase.connectedGroups, groups, true); + if(templateOptions.length === 0) + { + data.text = "You are not connected to any groups yet. please use the !connecttogroup command first."; + return data; + } + return await commandHelper.executeCommandOnGroup(data.message, getAllMembers, { "type":"talkToGroup", @@ -70,6 +76,12 @@ async function VerifyAndExecuteDisconnectFromGroup(data, userMediaID) const templateOptions = commandHelper.getGroupIDsWithCondition(userDatabase.connectedGroups, groups, true); + if(templateOptions.length === 0) + { + data.text = "You are not connected to any groups."; + return data; + } + return await commandHelper.executeCommandOnGroup(data.message, ExecuteDisconnectFromGroup,{ "type":"talkToGroup", "command":"DI", @@ -198,6 +210,12 @@ async function VerifyAndExecuteOpenSessionToMember(data, userDatabase, userMedia } } + if(templateOptions.length === 0) + { + data.text = "No other user is currently connected to the group " + targetGroup.groupName + "."; + return data; + } + return await commandHelper.executeCommandOnGroupMember(data.message, ExecuteOpenSessionToMember, { "type":"talkToGroup", @@ -212,6 +230,12 @@ async function VerifyAndExecuteOpenSessionToGroup(data, userDatabase, userMediaI const templateOptions = commandHelper.getGroupIDsWithCondition(userDatabase.connectedGroups, groups, true); + if(templateOptions.length === 0) + { + data.text = "You are currently not connected to a group. Please connect to a group with the command !connectToGroup first."; + return data; + } + return await commandHelper.executeCommandOnGroup(data.message, ExecuteOpenSessionToGroup, { "type":"talkToGroup", "command":"SE", @@ -312,6 +336,11 @@ async function VerifyAndExecuteGetConnectedMembers(data, userMediaID) const templateOptions = commandHelper.getGroupIDsWithCondition(userDatabase.connectedGroups, groups, true); + if(templateOptions.length === 0) + { + data.text = "You are not connected to any groups yet. please use the !connecttogroup command first"; + return data; + } return await commandHelper.executeCommandOnGroup(data.message,ExecuteGetConnectedMembers, { "type":"talkToGroup",