Changed some variable names to prevent collision
Done some changes to fix registration issues
This commit is contained in:
@@ -31,7 +31,7 @@ module.exports = {
|
|||||||
)
|
)
|
||||||
|
|
||||||
,
|
,
|
||||||
slashcommandGlobal:false,
|
slashcommandGlobal:true,
|
||||||
async function(interactionObject) {
|
async function(interactionObject) {
|
||||||
let ephemeral = interactionObject.options.getString("visibility")
|
let ephemeral = interactionObject.options.getString("visibility")
|
||||||
let serverid = interactionObject.options.getString("server_identifier")
|
let serverid = interactionObject.options.getString("server_identifier")
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ module.exports = {
|
|||||||
)
|
)
|
||||||
|
|
||||||
,
|
,
|
||||||
slashcommandGlobal:false,
|
slashcommandGlobal:true,
|
||||||
async function(interactionObject) {
|
async function(interactionObject) {
|
||||||
let ephemeral = interactionObject.options.getString("visibility")
|
let ephemeral = interactionObject.options.getString("visibility")
|
||||||
let action = interactionObject.options.getString("action")
|
let action = interactionObject.options.getString("action")
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
const { config } = require('process');
|
|
||||||
|
|
||||||
const wait = require('util').promisify(setTimeout);
|
const wait = require('util').promisify(setTimeout);
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
@@ -16,7 +14,7 @@ module.exports = {
|
|||||||
.setName("client_key")
|
.setName("client_key")
|
||||||
.setDescription("If you already have an account, create a client key, and add that one here to link your account")
|
.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) {
|
async function(interactionObject) {
|
||||||
|
|
||||||
var username = interactionObject.options.getString("username")
|
var username = interactionObject.options.getString("username")
|
||||||
@@ -32,12 +30,6 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
await interactionObject.deferReply({ephemeral:ephemeral})
|
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
|
// 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
|
// 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){
|
if(client_key != null){
|
||||||
@@ -45,13 +37,13 @@ module.exports = {
|
|||||||
interactionObject.editReply("Incorrect Client Key size")
|
interactionObject.editReply("Incorrect Client Key size")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fetch(`${config.panel.url}/api/client/account`,{
|
fetch(`${mainconfig.panel.url}/api/client/account`,{
|
||||||
"method": "GET",
|
"method": "GET",
|
||||||
"headers": {
|
"headers": {
|
||||||
"Accept": "application/json",
|
"Accept": "application/json",
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
"Authorization": `Bearer ${client_key}`,
|
"Authorization": `Bearer ${client_key}`,
|
||||||
'User-Agent': `${config.panel.useragent}`,
|
'User-Agent': `${mainconfig.panel.useragent}`,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then(async response => {
|
.then(async response => {
|
||||||
@@ -61,6 +53,9 @@ module.exports = {
|
|||||||
case "500":
|
case "500":
|
||||||
interactionObject.editReply("Server Error")
|
interactionObject.editReply("Server Error")
|
||||||
break;
|
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
|
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")
|
interactionObject.editReply("You need to supply a valid username or a client key if you already have an account")
|
||||||
return}
|
return}
|
||||||
|
|
||||||
if(!config.panel.allowRegistration){
|
if(!mainconfig.panel.allowRegistration){
|
||||||
interactionObject.editReply("Registering new account has been disabled by the administrator")
|
interactionObject.editReply("Registering new account has been disabled by the administrator")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
fetch(`${config.panel.url}/api/application/users`,{
|
fetch(`${mainconfig.panel.url}/api/application/users`,{
|
||||||
"method": "POST",
|
"method": "POST",
|
||||||
"headers": {
|
"headers": {
|
||||||
"Accept": "application/json",
|
"Accept": "application/json",
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
"Authorization": `Bearer ${config.panel.applicationKey}`,
|
"Authorization": `Bearer ${mainconfig.panel.applicationKey}`,
|
||||||
'User-Agent': `${config.panel.useragent}`,
|
'User-Agent': `${mainconfig.panel.useragent}`,
|
||||||
},
|
},
|
||||||
"body":JSON.stringify({
|
"body":JSON.stringify({
|
||||||
"email": `${interactionObject.user.id}@goodanimemes.com`,
|
"email": `${interactionObject.user.id}@goodanimemes.com`,
|
||||||
@@ -129,12 +124,12 @@ module.exports = {
|
|||||||
|
|
||||||
|
|
||||||
interactionObject.user.send(
|
interactionObject.user.send(
|
||||||
`${config.panel.url}\n
|
`${mainconfig.panel.url}\n
|
||||||
The password for your account __${username}__ is __${password}__\n\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
|
Now you can log into your account and go to your profile settings\n
|
||||||
Go to \`API Credentials\` and create a new key\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
|
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 => {
|
).then(dm => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
dm.delete()
|
dm.delete()
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ module.exports = {
|
|||||||
)
|
)
|
||||||
|
|
||||||
,
|
,
|
||||||
slashcommandGlobal:false,
|
slashcommandGlobal:true,
|
||||||
async function(interactionObject) {
|
async function(interactionObject) {
|
||||||
let ephemeral = interactionObject.options.getString("visibility")
|
let ephemeral = interactionObject.options.getString("visibility")
|
||||||
let serverid = interactionObject.options.getString("server_identifier")
|
let serverid = interactionObject.options.getString("server_identifier")
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
var pool = mysql.createPool({
|
var pool = mysql.createPool({
|
||||||
connectionLimit : 10,
|
connectionLimit : 10,
|
||||||
host: config.database.host,
|
host: mainconfig.database.host,
|
||||||
port: config.database.port,
|
port: mainconfig.database.port,
|
||||||
user: config.database.username,
|
user: mainconfig.database.username,
|
||||||
password: config.database.password,
|
password: mainconfig.database.password,
|
||||||
database: config.database.dbname,
|
database: mainconfig.database.dbname,
|
||||||
charset : 'utf8mb4'
|
charset : 'utf8mb4'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -90,12 +90,11 @@ folders.forEach(element => {
|
|||||||
|
|
||||||
// console.log(commands)
|
// console.log(commands)
|
||||||
|
|
||||||
client.login(config.token);
|
client.login(mainconfig.token);
|
||||||
|
|
||||||
var ignorelist = config.ignorelist
|
var ignorelist = mainconfig.ignorelist
|
||||||
var prefix = config.prefix;
|
var prefix = mainconfig.prefix;
|
||||||
var platform = process.platform;
|
var platform = process.platform;
|
||||||
// var main_config = client.commands.get("redis").function("getValJSON", "main_config");
|
|
||||||
|
|
||||||
client.on("ready", () => {
|
client.on("ready", () => {
|
||||||
commands.get("Startup_function").function()
|
commands.get("Startup_function").function()
|
||||||
|
|||||||
+3
-1
@@ -7,11 +7,13 @@ client = new Discord.Client({
|
|||||||
})
|
})
|
||||||
|
|
||||||
fs = require("fs")
|
fs = require("fs")
|
||||||
config = require("./config/main.json")
|
mainconfig = require("./config/main.json")
|
||||||
readline = require("readline")
|
readline = require("readline")
|
||||||
MessageAttachment = { XXXXXXXXXXXXXXXX, MessageAttachment } = require('discord.js')
|
MessageAttachment = { XXXXXXXXXXXXXXXX, MessageAttachment } = require('discord.js')
|
||||||
mysql = require("mysql")
|
mysql = require("mysql")
|
||||||
fetch = require("node-fetch")
|
fetch = require("node-fetch")
|
||||||
|
Hashids = require("hashids/cjs")
|
||||||
|
hashids = new Hashids("", 6)
|
||||||
|
|
||||||
MessageActionRow = Discord.MessageActionRow;
|
MessageActionRow = Discord.MessageActionRow;
|
||||||
MessageButton = Discord.MessageButton;
|
MessageButton = Discord.MessageButton;
|
||||||
|
|||||||
Reference in New Issue
Block a user