diff --git a/functions/functionality/command.js b/functions/functionality/command.js index 2af23ed..eac97d7 100644 --- a/functions/functionality/command.js +++ b/functions/functionality/command.js @@ -31,7 +31,7 @@ module.exports = { ) , - slashcommandGlobal:false, + slashcommandGlobal:true, async function(interactionObject) { let ephemeral = interactionObject.options.getString("visibility") let serverid = interactionObject.options.getString("server_identifier") diff --git a/functions/functionality/power.js b/functions/functionality/power.js index 38676ed..d5b052e 100644 --- a/functions/functionality/power.js +++ b/functions/functionality/power.js @@ -37,7 +37,7 @@ module.exports = { ) , - slashcommandGlobal:false, + slashcommandGlobal:true, async function(interactionObject) { let ephemeral = interactionObject.options.getString("visibility") let action = interactionObject.options.getString("action") diff --git a/functions/functionality/register.js b/functions/functionality/register.js index a1c607e..17ab73e 100644 --- a/functions/functionality/register.js +++ b/functions/functionality/register.js @@ -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 ` ).then(dm => { setTimeout(() => { dm.delete() diff --git a/functions/functionality/servers.js b/functions/functionality/servers.js index e98dd09..4abda7a 100644 --- a/functions/functionality/servers.js +++ b/functions/functionality/servers.js @@ -25,7 +25,7 @@ module.exports = { ) , - slashcommandGlobal:false, + slashcommandGlobal:true, async function(interactionObject) { let ephemeral = interactionObject.options.getString("visibility") let serverid = interactionObject.options.getString("server_identifier") diff --git a/functions/utilities/query.js b/functions/utilities/query.js index 888699f..3a3afd1 100644 --- a/functions/utilities/query.js +++ b/functions/utilities/query.js @@ -2,11 +2,11 @@ var pool = mysql.createPool({ connectionLimit : 10, - host: config.database.host, - port: config.database.port, - user: config.database.username, - password: config.database.password, - database: config.database.dbname, + host: mainconfig.database.host, + port: mainconfig.database.port, + user: mainconfig.database.username, + password: mainconfig.database.password, + database: mainconfig.database.dbname, charset : 'utf8mb4' }); diff --git a/main.js b/main.js index ea83c01..385f8be 100644 --- a/main.js +++ b/main.js @@ -90,12 +90,11 @@ folders.forEach(element => { // console.log(commands) -client.login(config.token); +client.login(mainconfig.token); -var ignorelist = config.ignorelist -var prefix = config.prefix; +var ignorelist = mainconfig.ignorelist +var prefix = mainconfig.prefix; var platform = process.platform; -// var main_config = client.commands.get("redis").function("getValJSON", "main_config"); client.on("ready", () => { commands.get("Startup_function").function() diff --git a/requires.js b/requires.js index bfd5351..d6e483f 100644 --- a/requires.js +++ b/requires.js @@ -7,11 +7,13 @@ client = new Discord.Client({ }) fs = require("fs") -config = require("./config/main.json") +mainconfig = require("./config/main.json") readline = require("readline") MessageAttachment = { XXXXXXXXXXXXXXXX, MessageAttachment } = require('discord.js') mysql = require("mysql") fetch = require("node-fetch") +Hashids = require("hashids/cjs") +hashids = new Hashids("", 6) MessageActionRow = Discord.MessageActionRow; MessageButton = Discord.MessageButton;