lib/slack/smart-bot/commands/general/use_rules.rb in slack-smart-bot-1.9.1 vs lib/slack/smart-bot/commands/general/use_rules.rb in slack-smart-bot-1.9.2

- old
+ new

@@ -14,15 +14,16 @@ (!user.key?(:enterprise_user) or ( user.key?(:enterprise_user) and !config[:allow_access][__method__].include?(user[:enterprise_user].id))) respond "You don't have access to use this command, please contact an Admin to be able to use it: <@#{config.admins.join(">, <@")}>" else #todo: add pagination for case more than 1000 channels on the workspace channels = get_channels() - + channel.gsub!('#','') # for the case the channel name is in plain text including # channel_found = channels.detect { |c| c.name == channel } - members = get_channel_members(@channels_id[channel]) unless channel_found.nil? + get_channels_name_and_id() unless @channels_id.key?(channel) + members = get_channel_members(@channels_id[channel]) unless channel_found.nil? or !@channels_id.key?(channel) - if channel_found.nil? - respond "The channel you are trying to use doesn't exist", dest + if channel_found.nil? or !@channels_id.key?(channel) + respond "The channel you are trying to use doesn't exist or cannot be found.", dest elsif channel_found.name == config.master_channel respond "You cannot use the rules from Master Channel on any other channel.", dest elsif !@bots_created.key?(@channels_id[channel]) respond "There is no bot running on that channel.", dest elsif @bots_created.key?(@channels_id[channel]) and @bots_created[@channels_id[channel]][:status] != :on