Changed some variable names to prevent collision

Done some changes to fix registration issues
This commit is contained in:
aiden@zuchtbude.de
2022-10-08 16:49:56 +02:00
parent 549d617528
commit 8cf68ac0ca
7 changed files with 26 additions and 30 deletions
+12 -17
View File
@@ -1,5 +1,3 @@
const { config } = require('process');
const wait = require('util').promisify(setTimeout);
module.exports = {
@@ -16,7 +14,7 @@ module.exports = {
.setName("client_key")
.setDescription("If you already have an account, create a client key, and add that one here to link your account")
),
slashcommandGlobal:false,
slashcommandGlobal:true,
async function(interactionObject) {
var username = interactionObject.options.getString("username")
@@ -32,12 +30,6 @@ module.exports = {
}
await interactionObject.deferReply({ephemeral:ephemeral})
if(!config.panel.allowRegistration){
return;
}
// This part triggers only when the client key is present, and is the only part that will trigger in that case
// It will request the user's data based on the presented key, and then append that data to the account in the database or create one if none should be found
if(client_key != null){
@@ -45,13 +37,13 @@ module.exports = {
interactionObject.editReply("Incorrect Client Key size")
return
}
fetch(`${config.panel.url}/api/client/account`,{
fetch(`${mainconfig.panel.url}/api/client/account`,{
"method": "GET",
"headers": {
"Accept": "application/json",
"Content-Type": "application/json",
"Authorization": `Bearer ${client_key}`,
'User-Agent': `${config.panel.useragent}`,
'User-Agent': `${mainconfig.panel.useragent}`,
}
})
.then(async response => {
@@ -61,6 +53,9 @@ module.exports = {
case "500":
interactionObject.editReply("Server Error")
break;
default:
interactionObject.editReply(`Your key is likely incorrect, please make sure that you are using the right key\n${mainconfig.panel.url}/account/api`)
break
}
return
}
@@ -83,18 +78,18 @@ module.exports = {
interactionObject.editReply("You need to supply a valid username or a client key if you already have an account")
return}
if(!config.panel.allowRegistration){
if(!mainconfig.panel.allowRegistration){
interactionObject.editReply("Registering new account has been disabled by the administrator")
return
}
fetch(`${config.panel.url}/api/application/users`,{
fetch(`${mainconfig.panel.url}/api/application/users`,{
"method": "POST",
"headers": {
"Accept": "application/json",
"Content-Type": "application/json",
"Authorization": `Bearer ${config.panel.applicationKey}`,
'User-Agent': `${config.panel.useragent}`,
"Authorization": `Bearer ${mainconfig.panel.applicationKey}`,
'User-Agent': `${mainconfig.panel.useragent}`,
},
"body":JSON.stringify({
"email": `${interactionObject.user.id}@goodanimemes.com`,
@@ -129,12 +124,12 @@ module.exports = {
interactionObject.user.send(
`${config.panel.url}\n
`${mainconfig.panel.url}\n
The password for your account __${username}__ is __${password}__\n\n
Now you can log into your account and go to your profile settings\n
Go to \`API Credentials\` and create a new key\n
Then go back to the server and use the register command again, this time using the \`client_key\` parameter with the key you just created
This message will get deleted in 2 minutes`
This message will get deleted <t:${Math.floor((new Date().getTime() + 120000)/1000)}:R>`
).then(dm => {
setTimeout(() => {
dm.delete()