Skip to content
This repository was archived by the owner on Jan 24, 2022. It is now read-only.

Commit f2157a3

Browse files
authored
fix(API): Use Array#find since its array not an object (#104)
* fix(API): Use Array#find since its array not an object * fix(ci): Solve eslint error
1 parent 962af8d commit f2157a3

File tree

3 files changed

+4
-39
lines changed

3 files changed

+4
-39
lines changed

dist/src/Zhycorp.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ class ZhycorpWrapper {
1717
if (!USER_PATTERN.test(id))
1818
throw Error("Invalid user id");
1919
const { body: result } = await superagent_1.get(this.baseURL);
20-
if (!result[id])
20+
if (!result.find((b) => b.botID === id))
2121
throw new ZhycorpError_1.default("Not Found");
22-
const bot = result[id];
22+
const bot = result.find((b) => b.botID === id);
2323
const user = await Bot_1.getOwner(id);
2424
return {
2525
approved: bot.approved,

src/Zhycorp.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ export class ZhycorpWrapper {
1111
if (!USER_PATTERN.test(id)) throw Error("Invalid user id");
1212

1313
const { body: result } = await get(this.baseURL);
14-
if (!result[id]) throw new ZhycorpError("Not Found");
15-
const bot = result[id];
14+
if (!result.find((b: Bot) => b.botID === id)) throw new ZhycorpError("Not Found");
15+
const bot = result.find((b: Bot) => b.botID === id);
1616
const user = await getOwner(id);
1717
return {
1818
approved: bot.approved,

yarn.lock

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,6 @@
145145
"@typescript-eslint/typescript-estree" "4.11.0"
146146
debug "^4.1.1"
147147

148-
"@typescript-eslint/[email protected]":
149-
version "4.10.0"
150-
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.10.0.tgz#dbd7e1fc63d7363e3aaff742a6f2b8afdbac9d27"
151-
integrity sha512-WAPVw35P+fcnOa8DEic0tQUhoJJsgt+g6DEcz257G7vHFMwmag58EfowdVbiNcdfcV27EFR0tUBVXkDoIvfisQ==
152-
dependencies:
153-
"@typescript-eslint/types" "4.10.0"
154-
"@typescript-eslint/visitor-keys" "4.10.0"
155-
156148
"@typescript-eslint/[email protected]":
157149
version "4.11.0"
158150
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.11.0.tgz#2d906537db8a3a946721699e4fc0833810490254"
@@ -161,30 +153,11 @@
161153
"@typescript-eslint/types" "4.11.0"
162154
"@typescript-eslint/visitor-keys" "4.11.0"
163155

164-
"@typescript-eslint/[email protected]":
165-
version "4.10.0"
166-
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.10.0.tgz#12f983750ebad867f0c806e705c1953cd6415789"
167-
integrity sha512-+dt5w1+Lqyd7wIPMa4XhJxUuE8+YF+vxQ6zxHyhLGHJjHiunPf0wSV8LtQwkpmAsRi1lEOoOIR30FG5S2HS33g==
168-
169156
"@typescript-eslint/[email protected]":
170157
version "4.11.0"
171158
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.11.0.tgz#86cf95e7eac4ccfd183f9fcf1480cece7caf4ca4"
172159
integrity sha512-XXOdt/NPX++txOQHM1kUMgJUS43KSlXGdR/aDyEwuAEETwuPt02Nc7v+s57PzuSqMbNLclblQdv3YcWOdXhQ7g==
173160

174-
"@typescript-eslint/[email protected]":
175-
version "4.10.0"
176-
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.10.0.tgz#1e62e45fd57866afd42daf5e9fb6bd4e8dbcfa75"
177-
integrity sha512-mGK0YRp9TOk6ZqZ98F++bW6X5kMTzCRROJkGXH62d2azhghmq+1LNLylkGe6uGUOQzD452NOAEth5VAF6PDo5g==
178-
dependencies:
179-
"@typescript-eslint/types" "4.10.0"
180-
"@typescript-eslint/visitor-keys" "4.10.0"
181-
debug "^4.1.1"
182-
globby "^11.0.1"
183-
is-glob "^4.0.1"
184-
lodash "^4.17.15"
185-
semver "^7.3.2"
186-
tsutils "^3.17.1"
187-
188161
"@typescript-eslint/[email protected]":
189162
version "4.11.0"
190163
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.11.0.tgz#1144d145841e5987d61c4c845442a24b24165a4b"
@@ -199,14 +172,6 @@
199172
semver "^7.3.2"
200173
tsutils "^3.17.1"
201174

202-
"@typescript-eslint/[email protected]":
203-
version "4.10.0"
204-
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.10.0.tgz#9478822329a9bc8ebcc80623d7f79a01da5ee451"
205-
integrity sha512-hPyz5qmDMuZWFtHZkjcCpkAKHX8vdu1G3YsCLEd25ryZgnJfj6FQuJ5/O7R+dB1ueszilJmAFMtlU4CA6se3Jg==
206-
dependencies:
207-
"@typescript-eslint/types" "4.10.0"
208-
eslint-visitor-keys "^2.0.0"
209-
210175
"@typescript-eslint/[email protected]":
211176
version "4.11.0"
212177
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.11.0.tgz#906669a50f06aa744378bb84c7d5c4fdbc5b7d51"

0 commit comments

Comments
 (0)