Adding user registration and user cache - (Pulling user from API)

This commit is contained in:
Raven Scott 2022-01-24 19:59:38 +00:00
parent 840f172d4c
commit 6d200b53cb
5 changed files with 106 additions and 88 deletions

2
.gitignore vendored
View File

@ -8,7 +8,7 @@ config.json
config.js
data/
test.js
cache/
# Runtime data
pids
*.pid

52
commands/register.js Normal file
View File

@ -0,0 +1,52 @@
const { version } = require("discord.js");
const { codeBlock } = require("@discordjs/builders");
const { DurationFormatter } = require("@sapphire/time-utilities");
const durationFormatter = new DurationFormatter();
const fs = require("fs");
require("dotenv").config();
var http = require('unirest');
exports.run = (client, message, args, level) => { // eslint-disable-line no-unused-vars
let username = args
const path = 'cache/' + message.author.id + ".user"
console.log(username[0])
var Request = http.get('https://board.grwh.work/jsonrpc.php').headers({ Accept: 'application/json', 'Content-Type': 'application/json' }).send({ "jsonrpc": "2.0", "method": "getUserByName", "id": 0, "params": { "username": username[0] } });
Request.auth({
user: 'jsonrpc',
pass: process.env.KANBOARD_API_KEY,
sendImmediately: false
}).then(function (response) {
let data = response.body.result
if (fs.existsSync(path)) {
console.log("User already exists")
message.channel.send("That user is already in our system and cannot be registered again.")
}
else {
console.log("No Channel PWD Found! Generating!")
fs.writeFile('./cache/' + message.author.id + ".user", "{\"userid\":\"" + data.id + "\"}", function (err) {
message.channel.send("You have registered your DiscordID successfully!")
})
}
})
};
exports.conf = {
enabled: true,
guildOnly: false,
aliases: [],
permLevel: "User"
};
exports.help = {
name: "register",
category: "Main",
description: "Bind your discordID to your board username.",
usage: "register $BOARDUSERNAME"
};

99
package-lock.json generated
View File

@ -10,17 +10,14 @@
"license": "MIT",
"dependencies": {
"@aahlw/peji": "^1.0.0",
"@acegoal07/discordjs-pagination": "^1.2.0",
"@discordjs/builders": "^0.2.0",
"@psibean/discord.js-pagination": "^4.0.5",
"@ryukobot/paginationembed": "^1.0.5",
"@sapphire/time-utilities": "^1.3.8",
"axios": "^0.25.0",
"colorette": "^1.3.0",
"discord.js": "^13.0.1",
"djs-interaction-util": "^0.2.8",
"dotenv": "^10.0.0",
"enmap": "^5.8.5",
"jsonfile": "^6.1.0",
"pagination.djs": "^3.1.1",
"unirest": "^0.6.0"
},
@ -44,14 +41,6 @@
"discord.js": "^13.3.1"
}
},
"node_modules/@acegoal07/discordjs-pagination": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@acegoal07/discordjs-pagination/-/discordjs-pagination-1.2.0.tgz",
"integrity": "sha512-Z6d86UJU3qSIYiyPBUD95naYMIOT7/LG2ETmnggKPN5MIm66wSKiyOJoM605gRbuV7XR0d6QTNeQvGLmsHj5Ag==",
"dependencies": {
"discord.js": "^13.5.0"
}
},
"node_modules/@babel/code-frame": {
"version": "7.12.11",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.11.tgz",
@ -217,22 +206,6 @@
"integrity": "sha512-wdppn25U8z/2yiaT6YGquE6X8sSv7hNMWSXYSSU1jGv/yd6XqjXgTDJ8KP4NgjTXfJ3GbRjeeb8RTV7a/VpM+w==",
"dev": true
},
"node_modules/@psibean/discord.js-pagination": {
"version": "4.0.5",
"resolved": "https://registry.npmjs.org/@psibean/discord.js-pagination/-/discord.js-pagination-4.0.5.tgz",
"integrity": "sha512-RkPSigdSY/Y5lSXVw+0E+Ed3NctCWEsw0AuzueGts7Vc9TobpRgx760foL2lnzE4HiFJiJ3dpVY2tktvxKVrtQ=="
},
"node_modules/@ryukobot/paginationembed": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/@ryukobot/paginationembed/-/paginationembed-1.0.5.tgz",
"integrity": "sha512-zcbva1mKbCDiGJHeK4oNnUHSgUws79TxltiGB0SLQtx3wLkdCItj6trI9XfgXxzhq6d1huInhLdPvxaZRLXCjw==",
"engines": {
"node": ">=16.6.0"
},
"peerDependencies": {
"discord.js": "^13.2.0"
}
},
"node_modules/@sapphire/async-queue": {
"version": "1.1.9",
"resolved": "https://registry.npmjs.org/@sapphire/async-queue/-/async-queue-1.1.9.tgz",
@ -891,14 +864,6 @@
"node": ">= 6"
}
},
"node_modules/djs-interaction-util": {
"version": "0.2.8",
"resolved": "https://registry.npmjs.org/djs-interaction-util/-/djs-interaction-util-0.2.8.tgz",
"integrity": "sha512-GmQkdrO2tzYxbksc30/KLEQqlpaItCoENh3dl/7RVyGHjg7omrBidW4DXGZgIB2OF75TcDqYfzxKvD1otDcvig==",
"peerDependencies": {
"discord.js": "^13"
}
},
"node_modules/doctrine": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz",
@ -1769,7 +1734,7 @@
"version": "4.2.8",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.8.tgz",
"integrity": "sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg==",
"dev": true
"devOptional": true
},
"node_modules/har-schema": {
"version": "2.0.0",
@ -2223,6 +2188,17 @@
"json5": "lib/cli.js"
}
},
"node_modules/jsonfile": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz",
"integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==",
"dependencies": {
"universalify": "^2.0.0"
},
"optionalDependencies": {
"graceful-fs": "^4.1.6"
}
},
"node_modules/jsprim": {
"version": "1.4.2",
"resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.2.tgz",
@ -3560,6 +3536,14 @@
"request": "^2.88.0"
}
},
"node_modules/universalify": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz",
"integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==",
"engines": {
"node": ">= 10.0.0"
}
},
"node_modules/uri-js": {
"version": "4.4.1",
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
@ -3726,14 +3710,6 @@
"discord.js": "^13.3.1"
}
},
"@acegoal07/discordjs-pagination": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@acegoal07/discordjs-pagination/-/discordjs-pagination-1.2.0.tgz",
"integrity": "sha512-Z6d86UJU3qSIYiyPBUD95naYMIOT7/LG2ETmnggKPN5MIm66wSKiyOJoM605gRbuV7XR0d6QTNeQvGLmsHj5Ag==",
"requires": {
"discord.js": "^13.5.0"
}
},
"@babel/code-frame": {
"version": "7.12.11",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.11.tgz",
@ -3866,17 +3842,6 @@
"integrity": "sha512-wdppn25U8z/2yiaT6YGquE6X8sSv7hNMWSXYSSU1jGv/yd6XqjXgTDJ8KP4NgjTXfJ3GbRjeeb8RTV7a/VpM+w==",
"dev": true
},
"@psibean/discord.js-pagination": {
"version": "4.0.5",
"resolved": "https://registry.npmjs.org/@psibean/discord.js-pagination/-/discord.js-pagination-4.0.5.tgz",
"integrity": "sha512-RkPSigdSY/Y5lSXVw+0E+Ed3NctCWEsw0AuzueGts7Vc9TobpRgx760foL2lnzE4HiFJiJ3dpVY2tktvxKVrtQ=="
},
"@ryukobot/paginationembed": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/@ryukobot/paginationembed/-/paginationembed-1.0.5.tgz",
"integrity": "sha512-zcbva1mKbCDiGJHeK4oNnUHSgUws79TxltiGB0SLQtx3wLkdCItj6trI9XfgXxzhq6d1huInhLdPvxaZRLXCjw==",
"requires": {}
},
"@sapphire/async-queue": {
"version": "1.1.9",
"resolved": "https://registry.npmjs.org/@sapphire/async-queue/-/async-queue-1.1.9.tgz",
@ -4369,12 +4334,6 @@
}
}
},
"djs-interaction-util": {
"version": "0.2.8",
"resolved": "https://registry.npmjs.org/djs-interaction-util/-/djs-interaction-util-0.2.8.tgz",
"integrity": "sha512-GmQkdrO2tzYxbksc30/KLEQqlpaItCoENh3dl/7RVyGHjg7omrBidW4DXGZgIB2OF75TcDqYfzxKvD1otDcvig==",
"requires": {}
},
"doctrine": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz",
@ -5039,7 +4998,7 @@
"version": "4.2.8",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.8.tgz",
"integrity": "sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg==",
"dev": true
"devOptional": true
},
"har-schema": {
"version": "2.0.0",
@ -5363,6 +5322,15 @@
"minimist": "^1.2.0"
}
},
"jsonfile": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz",
"integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==",
"requires": {
"graceful-fs": "^4.1.6",
"universalify": "^2.0.0"
}
},
"jsprim": {
"version": "1.4.2",
"resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.2.tgz",
@ -6402,6 +6370,11 @@
"request": "^2.88.0"
}
},
"universalify": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz",
"integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ=="
},
"uri-js": {
"version": "4.4.1",
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",

View File

@ -31,6 +31,7 @@
"discord.js": "^13.0.1",
"dotenv": "^10.0.0",
"enmap": "^5.8.5",
"jsonfile": "^6.1.0",
"pagination.djs": "^3.1.1",
"unirest": "^0.6.0"
},

View File

@ -9,13 +9,6 @@
dependencies:
"discord.js" "^13.3.1"
"@acegoal07/discordjs-pagination@^1.2.0":
"integrity" "sha512-Z6d86UJU3qSIYiyPBUD95naYMIOT7/LG2ETmnggKPN5MIm66wSKiyOJoM605gRbuV7XR0d6QTNeQvGLmsHj5Ag=="
"resolved" "https://registry.npmjs.org/@acegoal07/discordjs-pagination/-/discordjs-pagination-1.2.0.tgz"
"version" "1.2.0"
dependencies:
"discord.js" "^13.5.0"
"@babel/code-frame@7.12.11":
"integrity" "sha512-Zt1yodBx1UcyiePMSkWnU4hPqhwq7hGi2nFL1LeA3EUl+q2LQx16MISgJ0+z7dnmgvP9QtIleuETGOiOH1RcIw=="
"resolved" "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.11.tgz"
@ -90,16 +83,6 @@
"resolved" "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.0.tgz"
"version" "1.2.0"
"@psibean/discord.js-pagination@^4.0.5":
"integrity" "sha512-RkPSigdSY/Y5lSXVw+0E+Ed3NctCWEsw0AuzueGts7Vc9TobpRgx760foL2lnzE4HiFJiJ3dpVY2tktvxKVrtQ=="
"resolved" "https://registry.npmjs.org/@psibean/discord.js-pagination/-/discord.js-pagination-4.0.5.tgz"
"version" "4.0.5"
"@ryukobot/paginationembed@^1.0.5":
"integrity" "sha512-zcbva1mKbCDiGJHeK4oNnUHSgUws79TxltiGB0SLQtx3wLkdCItj6trI9XfgXxzhq6d1huInhLdPvxaZRLXCjw=="
"resolved" "https://registry.npmjs.org/@ryukobot/paginationembed/-/paginationembed-1.0.5.tgz"
"version" "1.0.5"
"@sapphire/async-queue@^1.1.9":
"integrity" "sha512-CbXaGwwlEMq+l1TRu01FJCvySJ1CEFKFclHT48nIfNeZXaAAmmwwy7scUKmYHPUa3GhoMp6Qr1B3eAJux6XgOQ=="
"resolved" "https://registry.npmjs.org/@sapphire/async-queue/-/async-queue-1.1.9.tgz"
@ -557,7 +540,7 @@
"resolved" "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.26.1.tgz"
"version" "0.26.1"
"discord.js@^13", "discord.js@^13.0.1", "discord.js@^13.2.0", "discord.js@^13.3.1", "discord.js@^13.5.0", "discord.js@>=13.5.0":
"discord.js@^13.0.1", "discord.js@^13.3.1", "discord.js@>=13.5.0":
"integrity" "sha512-tXNR8zgsEPxPBvGk3AQjJ9ljIIC6/LOPjzKwpwz8Y1Q2X66Vi3ZqFgRHYwnHKC0jC0F+l4LzxlhmOJsBZDNg9g=="
"resolved" "https://registry.npmjs.org/discord.js/-/discord.js-13.6.0.tgz"
"version" "13.6.0"
@ -572,11 +555,6 @@
"node-fetch" "^2.6.1"
"ws" "^8.4.0"
"djs-interaction-util@^0.2.8":
"integrity" "sha512-GmQkdrO2tzYxbksc30/KLEQqlpaItCoENh3dl/7RVyGHjg7omrBidW4DXGZgIB2OF75TcDqYfzxKvD1otDcvig=="
"resolved" "https://registry.npmjs.org/djs-interaction-util/-/djs-interaction-util-0.2.8.tgz"
"version" "0.2.8"
"doctrine@^2.1.0":
"integrity" "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw=="
"resolved" "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz"
@ -1087,7 +1065,7 @@
dependencies:
"type-fest" "^0.20.2"
"graceful-fs@^4.1.2":
"graceful-fs@^4.1.2", "graceful-fs@^4.1.6":
"integrity" "sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg=="
"resolved" "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.8.tgz"
"version" "4.2.8"
@ -1385,6 +1363,15 @@
dependencies:
"minimist" "^1.2.0"
"jsonfile@^6.1.0":
"integrity" "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ=="
"resolved" "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz"
"version" "6.1.0"
dependencies:
"universalify" "^2.0.0"
optionalDependencies:
"graceful-fs" "^4.1.6"
"jsprim@^1.2.2":
"integrity" "sha512-P2bSOMAc/ciLz6DzgjVlGJP9+BrJWu5UDGK70C2iweC5QBIeFf0ZXRvGjEj2uYgrY2MkAAhsSWHDWlFtEroZWw=="
"resolved" "https://registry.npmjs.org/jsprim/-/jsprim-1.4.2.tgz"
@ -2274,6 +2261,11 @@
"mime" "^2.4.0"
"request" "^2.88.0"
"universalify@^2.0.0":
"integrity" "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ=="
"resolved" "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz"
"version" "2.0.0"
"uri-js@^4.2.2":
"integrity" "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg=="
"resolved" "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz"