From 631a348717a176554c60468f0a71d1ef8ea55e4d Mon Sep 17 00:00:00 2001 From: Braeden Sowinski Date: Mon, 25 Jul 2022 21:58:13 -0700 Subject: [PATCH] debug management --- commands/add-money.js | 3 ++- commands/bal.js | 1 + commands/deposit.js | 1 + commands/give.js | 1 + commands/help.js | 5 +++- commands/id-set.js | 1 + commands/inventory-add.js | 1 + commands/inventory.js | 1 + commands/me.js | 1 + commands/ping.js | 1 + commands/remove-channel.js | 1 + commands/remove-income.js | 1 + commands/search.js | 1 + commands/set-channel.js | 1 + commands/set-income.js | 1 + commands/set-starting-balance.js | 1 + commands/stats.js | 44 ++++++++++++++++++++++++++++++++ commands/tweet.js | 1 + commands/withdraw.js | 1 + commands/work.js | 30 ++++++++++++++++++++++ events/messageCreate.js | 24 ++--------------- structures/QuarksBot.js | 2 ++ 22 files changed, 100 insertions(+), 24 deletions(-) create mode 100644 commands/stats.js create mode 100644 commands/work.js diff --git a/commands/add-money.js b/commands/add-money.js index deac31a..c3156f8 100644 --- a/commands/add-money.js +++ b/commands/add-money.js @@ -1,7 +1,8 @@ const { MessageEmbed } = require('discord.js'); module.exports = { - name: "add-monet", + name: "add-money", + debug: false, description: "change the starting balance for the server", usage: "[user] [amount]", permissions: { diff --git a/commands/bal.js b/commands/bal.js index 1f37730..37fcc55 100644 --- a/commands/bal.js +++ b/commands/bal.js @@ -2,6 +2,7 @@ const { MessageEmbed, Guild } = require('discord.js'); module.exports = { name: "bal", + debug: false, description: "View balance", usage: "[user]", permissions: { diff --git a/commands/deposit.js b/commands/deposit.js index c52e82c..2693141 100644 --- a/commands/deposit.js +++ b/commands/deposit.js @@ -2,6 +2,7 @@ const { MessageEmbed } = require('discord.js'); module.exports = { name: "deposit", + debug: false, description: "deposit cash to your balance", usage: "[amount]", permissions: { diff --git a/commands/give.js b/commands/give.js index db300dd..28df9b6 100644 --- a/commands/give.js +++ b/commands/give.js @@ -3,6 +3,7 @@ const Inventory = require('../structures/inventory'); module.exports = { name: "give", + debug: false, description: "give user an amount of cash", usage: "[amount]", permissions: { diff --git a/commands/help.js b/commands/help.js index d45e077..7403e53 100644 --- a/commands/help.js +++ b/commands/help.js @@ -2,6 +2,7 @@ const { MessageEmbed } = require("discord.js"); module.exports = { name: "help", + debug: false, description: "Get information on a specific command", usage: "[command]", permissions: { @@ -30,7 +31,9 @@ module.exports = { if (GuildDB.customChannelStatus==true&&!GuildDB.allowedChannels.includes(interaction.channel_id)) { return interaction.send(`You are not allowed to use the bot in this channel.`); } - let Commands = client.commands.map((cmd) => + let Commands = client.commands.filter((cmd) => { + return !cmd.debug + }).map((cmd) => `\`/${cmd.name}${cmd.usage ? " " + cmd.usage : ""}\` - ${cmd.description}` ); diff --git a/commands/id-set.js b/commands/id-set.js index 2ce2780..bd9de08 100644 --- a/commands/id-set.js +++ b/commands/id-set.js @@ -2,6 +2,7 @@ const { MessageEmbed } = require('discord.js'); module.exports = { name: "id-set", + debug: false, description: "set a value on your wallet ID", usage: "[firstname/lastname/dob] [value]", permissions: { diff --git a/commands/inventory-add.js b/commands/inventory-add.js index f401af0..48362ed 100644 --- a/commands/inventory-add.js +++ b/commands/inventory-add.js @@ -4,6 +4,7 @@ const action = ['pick up', 'grab', 'get', 'aquire', 'obtain', 'gain', 'take poss module.exports = { name: "inventory-add", + debug: false, description: "add item to inventory", usage: "[item]", permissions: { diff --git a/commands/inventory.js b/commands/inventory.js index 1fd28dc..3e7784f 100644 --- a/commands/inventory.js +++ b/commands/inventory.js @@ -5,6 +5,7 @@ const action = ['ditch', 'drop', 'forget', 'throw out', 'leave', 'set down', 'le module.exports = { name: "inventory", + debug: false, description: "Manage your inventory", usage: "[command]", permissions: { diff --git a/commands/me.js b/commands/me.js index 6911bda..38c27cc 100644 --- a/commands/me.js +++ b/commands/me.js @@ -2,6 +2,7 @@ const { MessageEmbed } = require('discord.js'); module.exports = { name: "me", + debug: false, description: "Send a message stating your characters action", usage: "[action]", permissions: { diff --git a/commands/ping.js b/commands/ping.js index 9491686..3bcf4c9 100644 --- a/commands/ping.js +++ b/commands/ping.js @@ -2,6 +2,7 @@ const { MessageEmbed } = require('discord.js'); module.exports = { name: "ping", + debug: true, description: "Test bot activity", usage: "", permissions: { diff --git a/commands/remove-channel.js b/commands/remove-channel.js index 5622e27..5f14b74 100644 --- a/commands/remove-channel.js +++ b/commands/remove-channel.js @@ -2,6 +2,7 @@ const { MessageEmbed, MessageActionRow, MessageButton } = require('discord.js'); module.exports = { name: "remove-channel", + debug: false, description: "Remove channel", usage: "[channel type]", permissions: { diff --git a/commands/remove-income.js b/commands/remove-income.js index ff1857b..9079011 100644 --- a/commands/remove-income.js +++ b/commands/remove-income.js @@ -2,6 +2,7 @@ const { MessageEmbed, Guild } = require('discord.js'); module.exports = { name: "remove-income", + debug: false, description: "remove an income role", usage: "[role] [amount daily]", permissions: { diff --git a/commands/search.js b/commands/search.js index 32d95cb..d8ccc91 100644 --- a/commands/search.js +++ b/commands/search.js @@ -3,6 +3,7 @@ const Inventory = require('../structures/inventory'); module.exports = { name: "search", + debug: false, description: "Search a users inventory", usage: "[user]", permissions: { diff --git a/commands/set-channel.js b/commands/set-channel.js index 1929cd7..f8e8393 100644 --- a/commands/set-channel.js +++ b/commands/set-channel.js @@ -2,6 +2,7 @@ const { MessageEmbed } = require('discord.js'); module.exports = { name: "set-channel", + debug: false, description: "set a channel", usage: "[channel type] [channel]", permissions: { diff --git a/commands/set-income.js b/commands/set-income.js index a3c2b71..43935f5 100644 --- a/commands/set-income.js +++ b/commands/set-income.js @@ -2,6 +2,7 @@ const { MessageEmbed, Guild } = require('discord.js'); module.exports = { name: "set-income", + debug: false, description: "set a role to recieve income when working", usage: "[role] [amount daily]", permissions: { diff --git a/commands/set-starting-balance.js b/commands/set-starting-balance.js index 410d94d..ccfa324 100644 --- a/commands/set-starting-balance.js +++ b/commands/set-starting-balance.js @@ -2,6 +2,7 @@ const { MessageEmbed } = require('discord.js'); module.exports = { name: "set-starting-balance", + debug: false, description: "change the starting balance for the server", usage: "[amount]", permissions: { diff --git a/commands/stats.js b/commands/stats.js new file mode 100644 index 0000000..abf2b37 --- /dev/null +++ b/commands/stats.js @@ -0,0 +1,44 @@ +const { MessageEmbed } = require('discord.js'); + +module.exports = { + name: "stats", + debug: true, + description: "check bot statistics", + usage: "", + permissions: { + channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"], + member: [], + }, + SlashCommand: { + options: [], + /** + * + * @param {require("../structures/QuarksBot")} client + * @param {import("discord.js").MessageCreate} message + * @param {string[]} args + * @param {*} param3 + */ + run: async (client, interaction, args, { GuildDB }) => { + if (GuildDB.customChannelStatus==true&&!GuildDB.allowedChannels.includes(interaction.channel_id)) { + return interaction.send(`You are not allowed to use the bot in this channel.`); + } + + const data = ` + \`\`\` + ******************************* + * Channels *${client.padding(client.channels.cache.size)}* + ******************************* + * Servers *${client.padding(client.guilds.cache.size)}* + ******************************* + * Users *${client.padding(client.users.cache.size)} + * ***************************** + \`\`\` + ` + + const stats = new MessageEmbed() + .setColor(client.config.EmbedColor) + .setTitle('Statistics') + .setDescription(data) + }, + }, +} \ No newline at end of file diff --git a/commands/tweet.js b/commands/tweet.js index 5156971..1c73e52 100644 --- a/commands/tweet.js +++ b/commands/tweet.js @@ -2,6 +2,7 @@ const { MessageEmbed } = require('discord.js'); module.exports = { name: "tweet", + debug: false, description: "Tweet your thoughts to the local twitter page", usage: "[message]", permissions: { diff --git a/commands/withdraw.js b/commands/withdraw.js index 9c04987..b73f5e3 100644 --- a/commands/withdraw.js +++ b/commands/withdraw.js @@ -3,6 +3,7 @@ const inventory = require('./inventory'); module.exports = { name: "withdraw", + debug: false, description: "withdraw cash from balance", usage: "[amount]", permissions: { diff --git a/commands/work.js b/commands/work.js new file mode 100644 index 0000000..0eba3c5 --- /dev/null +++ b/commands/work.js @@ -0,0 +1,30 @@ +const { MessageEmbed } = require('discord.js'); + +module.exports = { + name: "work", + debug: false, + description: "work to earn your income", + usage: "", + permissions: { + channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"], + member: [], + }, + SlashCommand: { + options: [], + /** + * + * @param {require("../structures/QuarksBot")} client + * @param {import("discord.js").MessageCreate} message + * @param {string[]} args + * @param {*} param3 + */ + run: async (client, interaction, args, { GuildDB }) => { + if (GuildDB.customChannelStatus==true&&!GuildDB.allowedChannels.includes(interaction.channel_id)) { + return interaction.send(`You are not allowed to use the bot in this channel.`); + } + + console.log(interaction.member) + return interaction.send('Debugging...') + }, + }, +} \ No newline at end of file diff --git a/events/messageCreate.js b/events/messageCreate.js index 1b1d478..b105a36 100644 --- a/events/messageCreate.js +++ b/events/messageCreate.js @@ -31,26 +31,6 @@ module.exports = async (client, message) => { client.commands.find((x) => x.aliases && x.aliases.includes(command)); //Executing the codes when we get the command or aliases - if (cmd) { - if ( - (cmd.permissions && - cmd.permissions.channel && - !message.channel - .permissionsFor(client.user) - .has(cmd.permissions.channel)) || - (cmd.permissions && - cmd.permissions.member && - !message.channel - .permissionsFor(message.member) - .has(cmd.permissions.member)) - ) - return client.sendError( - message.channel, - "Missing Permissions!" + GuildDB.DJ - ? " You need the correct role to access this command." - : "" - ); - cmd.run(client, message, args, { GuildDB }); - client.CommandsRan++; - } else return; + if (cmd) cmd.run(client, message, args, { GuildDB }); + else return; }; \ No newline at end of file diff --git a/structures/QuarksBot.js b/structures/QuarksBot.js index 35961d0..a26c7cc 100644 --- a/structures/QuarksBot.js +++ b/structures/QuarksBot.js @@ -72,6 +72,8 @@ class QuarksBot extends Client { exists(n) {return null != n && undefined != n && "" != n} + padding(data) {return (` ${data}` + " ".repeat((9-data.toString().length)))} + LoadCommands() { let CommandsDir = path.join(__dirname, '..', 'commands'); fs.readdir(CommandsDir, (err, files) => {