 
         if parameters[0] == "#profile"
         {
-            let apiResponse = try drop.client.get("\(baseUrl)\(parameters[1])/profile")
-
-            guard let username = apiResponse.json?["data", "username"]?.string,
-                let avatar = apiResponse.json?["data", "avatar"]?.string else
-            {
-                throw Abort.custom(status: .notFound, message: "No response from API")
-            }
-
-            let fields = try JSON(
-                [
-                    AttachmentsField(title: "Title", value: "Value", isShort: true).makeNode(),
-                    AttachmentsField(title: "Title 2", value: "Value 2", isShort: true).makeNode()
-                ])
-
-            let attachments = try JSON(node:
-                [
-                    "pretext" : "Profile for \(parameters[1])",
-                    "color" : "#00ff00",
-                    "title" : username,
-                    "thumb_url" : avatar,
-                    "fields" : fields
-                ])
-
-            payload = try JSON(node:
-                [
-                    "response_type" : "in_channel",
-                    "attachments" : JSON([attachments])
-                ])
+            do
+            {
+                let apiResponse = try drop.client.get("\(baseUrl)\(parameters[1])/profile")
+
+                guard let username = apiResponse.json?["data", "username"]?.string,
+                    let avatar = apiResponse.json?["data", "avatar"]?.string else
+                {
+                    throw Abort.custom(status: .notFound, message: "No response from API")
+                }
+
+                let fields = try JSON(
+                    [
+                        AttachmentsField(title: "Title", value: "Value", isShort: true).makeNode(),
+                        AttachmentsField(title: "Title 2", value: "Value 2", isShort: true).makeNode()
+                    ])
+
+                let attachments = try JSON(node:
+                    [
+                        "pretext" : "Profile for \(parameters[1])",
+                        "color" : "#00ff00",
+                        "title" : username,
+                        "thumb_url" : avatar,
+                        "fields" : fields
+                    ])
+
+                payload = try JSON(node:
+                    [
+                        "response_type" : "in_channel",
+                        "attachments" : JSON([attachments])
+                    ])
+            }
+            catch
+            {
+                return "\(error)"
+            }
         }
         else
         {

        {
            return "\(error)"
        }
//        guard let apiResponse = try? self.drop.client.get(uri, headers: ["X-APIKEY" : apikey], query: [:], body: "") else
//        {
//            return "Something bad happened"
//        }
//
//        return apiResponse
    }

    ////////////////////////////////////////////////////////////

            return "Please enter the name of a World of Warcraft realm."
        }

        do
        {
            let apiResponse = try self.drop.client.get(uri, query: ["locale" : "en_US", "apikey" : apiKey])
            guard let realms = apiResponse.json?["realms"]?.pathIndexableArray else
            {
                return "No realms"
            }

            guard let selectedRealm = realms.filter(
                { (realm) -> Bool in
                    realm["name"]?.string?.lowercased() == text.lowercased()
            }).first
                else
            {
                return "\(text) is not a valid realm"
            }

            let realmName = selectedRealm["name"]?.string ?? "Invalid name"
            let status = selectedRealm["status"]?.bool ?? false

            let message = "\(realmName) \(status ? "is" : "is not") online."
            let payload = try JSON(node:
                [
                    "response_type" : "ephemeral",
                    "text" : message
                ])
            
            return payload
        }
        catch
        {
            return "\(error)"
        }

    }

    ////////////////////////////////////////////////////////////
