Skip to content
This repository has been archived by the owner on Aug 13, 2021. It is now read-only.

Fixed register command #143

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@
"dependencies": {
"@babel/cli": "^7.14.5",
"@babel/core": "^7.14.6",
"axios": "^0.21.1",
"chalk": "^4.0.0",
"discord.js": "^12.4.1",
"dotenv": "^10.0.0",
"format-duration": "^1.3.1",
"fsevents": "^2.3.2",
"moment": "^2.24.0",
"mongoose": "^5.13.2",
"node-fetch": "^2.6.0"
"mongoose": "^5.13.2"
},
"devDependencies": {
"@babel/node": "^7.14.7",
Expand All @@ -42,4 +41,4 @@
"jest": "^27.0.6",
"nodemon": "^2.0.12"
}
}
}
8 changes: 4 additions & 4 deletions src/commands/register.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { User } from '../models/user.model';
const fetch = require(`node-fetch`);
const cloudscraper = require(`cloudscraper`);

const urlExists = async url => await fetch(url)
.then((res) => res.text())
.then((res) => res.includes(`RACER_INFO`));
const urlExists = async url => await cloudscraper.get(url)
.then((res) => res.includes(`RACER_INFO`))
.catch((err) => false); // apparently it returns a captcha error if the racer doens't exist

const registerUser = (msg, ntLink) => {
const user = new User({
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4253,7 +4253,7 @@ node-environment-flags@^1.0.5:
object.getownpropertydescriptors "^2.0.3"
semver "^5.7.0"

node-fetch@^2.6.0, node-fetch@^2.6.1:
node-fetch@^2.6.1:
version "2.6.1"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052"
integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==
Expand Down