use vars more + help command rewrite
This commit is contained in:
parent
c1c2a6b86b
commit
e130dbec7c
4 changed files with 154 additions and 130 deletions
|
@ -10,11 +10,11 @@ const Users = new table('users');
|
||||||
const Backend = new table('backend');
|
const Backend = new table('backend');
|
||||||
const Trello = require('trello');
|
const Trello = require('trello');
|
||||||
const config = require('../config');
|
const config = require('../config');
|
||||||
|
const vars = require('../vars');
|
||||||
const {
|
const {
|
||||||
db,
|
db,
|
||||||
topic
|
topic
|
||||||
} = require('../utils')
|
} = require('../utils')
|
||||||
const vars = require('../vars');
|
|
||||||
const trello = new Trello(config.trello.key, config.trello.token);
|
const trello = new Trello(config.trello.key, config.trello.token);
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'message',
|
name: 'message',
|
||||||
|
@ -69,7 +69,7 @@ module.exports = {
|
||||||
utils: require('../utils'),
|
utils: require('../utils'),
|
||||||
config: require('../config'),
|
config: require('../config'),
|
||||||
vars: require('../vars'),
|
vars: require('../vars'),
|
||||||
isDeveloper: client.config.developers.find((dev) => msg.author.id == dev.id)
|
isDeveloper: vars.developers.find((dev) => msg.author.id == dev.id)
|
||||||
};
|
};
|
||||||
if (!cmd) return;
|
if (!cmd) return;
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ module.exports = {
|
||||||
if (cmd.guildOnly && !msg.guild) return;
|
if (cmd.guildOnly && !msg.guild) return;
|
||||||
if (cmd.nsfw && !ctx.channel.nsfw)
|
if (cmd.nsfw && !ctx.channel.nsfw)
|
||||||
return ctx.send('This channel is not set to NSFW, please mark it as such and rerun this command.');
|
return ctx.send('This channel is not set to NSFW, please mark it as such and rerun this command.');
|
||||||
if (cmd.developerOnly && !client.config.developers.find((dev) => msg.author.id == dev.id)) return;
|
if (cmd.developerOnly && !vars.developers.find((dev) => msg.author.id == dev.id)) return;
|
||||||
if (cmd.AuthorPermissions !== 'NONE' && !ctx.member.permissions.has(cmd.AuthorPermissions)) {
|
if (cmd.AuthorPermissions !== 'NONE' && !ctx.member.permissions.has(cmd.AuthorPermissions)) {
|
||||||
return ctx.send(`You need the \`${cmd.AuthorPermissions}\` Permission(s) to run this Command`);
|
return ctx.send(`You need the \`${cmd.AuthorPermissions}\` Permission(s) to run this Command`);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,21 @@
|
||||||
const Command = require('../../src/structures/Command');
|
const Command = require("../../src/structures/Command");
|
||||||
const {
|
const {
|
||||||
MessageEmbed
|
MessageEmbed
|
||||||
} = require('discord.js');
|
} = require("discord.js");
|
||||||
|
|
||||||
module.exports = class Help extends Command {
|
function CapFirstLetter(string) {
|
||||||
|
if (typeof string == undefined) return;
|
||||||
|
var firstLetter = string[0] || string.charAt(0);
|
||||||
|
return firstLetter ? firstLetter.toUpperCase() + string.slice(1) : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = class nHelp extends Command {
|
||||||
constructor() {
|
constructor() {
|
||||||
super({
|
super({
|
||||||
name: 'help',
|
name: "nhelp",
|
||||||
description: 'View a list of available commands or information on a specific command.',
|
description: "View a list of available commands or information on a specific command.",
|
||||||
aliases: ['h'],
|
aliases: ['h', '?'],
|
||||||
module: 'General',
|
module: "General",
|
||||||
cooldown: 0,
|
cooldown: 0,
|
||||||
guildOnly: false,
|
guildOnly: false,
|
||||||
developerOnly: false
|
developerOnly: false
|
||||||
|
@ -17,119 +23,137 @@ module.exports = class Help extends Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
async command(ctx) {
|
async command(ctx) {
|
||||||
//console.log(ctx.args);
|
let Help = new MessageEmbed();
|
||||||
let silent = ['--nd', '--no-dev'];
|
const commands = {
|
||||||
if (ctx.args.includes(silent)) {
|
General: {
|
||||||
console.log('is silent');
|
cs: ctx.client.commands
|
||||||
|
.filter(command => command.module == "General")
|
||||||
|
.map(c => c),
|
||||||
|
name: "General"
|
||||||
|
},
|
||||||
|
Settings: {
|
||||||
|
cs: ctx.client.commands
|
||||||
|
.filter(command => command.module == "Settings")
|
||||||
|
.map(c => c),
|
||||||
|
name: "Settings"
|
||||||
|
},
|
||||||
|
Images: {
|
||||||
|
cs: ctx.client.commands
|
||||||
|
.filter(command => command.module == "Images")
|
||||||
|
.map(c => c),
|
||||||
|
name: "Images"
|
||||||
|
},
|
||||||
|
Roleplay: {
|
||||||
|
cs: ctx.client.commands
|
||||||
|
.filter(command => command.module == "Roleplay")
|
||||||
|
.map(c => c),
|
||||||
|
name: "Roleplay"
|
||||||
}
|
}
|
||||||
if (!ctx.args.length) {
|
};
|
||||||
const commands = [
|
let lengths = [];
|
||||||
[
|
let names = ["General", "Settings", "Images", "Roleplay"];
|
||||||
'General',
|
|
||||||
ctx.client.commands
|
|
||||||
.filter((command) => command.module == 'General')
|
|
||||||
.map((command) => `${command.name}`)
|
|
||||||
.join(' | ')
|
|
||||||
],
|
|
||||||
/* [
|
|
||||||
'Images',
|
|
||||||
ctx.client.commands
|
|
||||||
.filter((command) => command.module == 'Images')
|
|
||||||
.map((command) => `${command.name}`)
|
|
||||||
.join(' | ')
|
|
||||||
], */
|
|
||||||
[
|
|
||||||
'Images',
|
|
||||||
ctx.client.commands
|
|
||||||
.filter((command) => command.module == 'Images')
|
|
||||||
.map((command) => `${command.name}`)
|
|
||||||
.join(' | ')
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'Roleplay',
|
|
||||||
ctx.client.commands
|
|
||||||
.filter((command) => command.module == 'Roleplay')
|
|
||||||
.map((command) => `${command.name}`)
|
|
||||||
.join(' | ')
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'Settings',
|
|
||||||
ctx.client.commands
|
|
||||||
.filter((command) => command.module == 'Settings')
|
|
||||||
.map((command) => `${command.name}`)
|
|
||||||
.join(' | ')
|
|
||||||
]
|
|
||||||
];
|
|
||||||
|
|
||||||
if (ctx.isDeveloper)
|
for (const i in commands) {
|
||||||
commands.push([
|
if (commands.hasOwnProperty(i)) {
|
||||||
'Developers',
|
const c = commands[i];
|
||||||
ctx.client.commands
|
lengths.push(c.cs.length);
|
||||||
.filter((command) => command.module == 'Developers')
|
|
||||||
.map((command) => `${command.name}`)
|
|
||||||
.join(' | ')
|
|
||||||
]);
|
|
||||||
|
|
||||||
return ctx.send({
|
|
||||||
embed: {
|
|
||||||
description: `Use \`'help <command>\` to get help on a specific command`,
|
|
||||||
fields: commands.map((group) => {
|
|
||||||
return new Object({
|
|
||||||
name: group[0],
|
|
||||||
value: group[1]
|
|
||||||
});
|
|
||||||
}),
|
|
||||||
color: 0xff873f
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
} else {
|
let start = 0;
|
||||||
const command = ctx.client.commands.find(
|
|
||||||
(c) =>
|
Help.setAuthor(ctx.author.tag, ctx.author.avatarURL())
|
||||||
c.name == ctx.args[0].toLowerCase() || (c.aliases && c.aliases.includes(ctx.args[0].toLowerCase()))
|
.setTitle("Command Help")
|
||||||
|
.setTimestamp(new Date())
|
||||||
|
.setColor(ctx.vars.color)
|
||||||
|
.setFooter(`${ctx.client.user.username}`, ctx.client.user.avatarURL());
|
||||||
|
|
||||||
|
if (ctx.args.length === 0) {
|
||||||
|
lengths.forEach(c => {
|
||||||
|
Help.addField(
|
||||||
|
`${names[start]} (${c})`,
|
||||||
|
`${ctx.utils.format.code(`'help --${names[start].toLowerCase()}`)}`,
|
||||||
|
true
|
||||||
);
|
);
|
||||||
if (!command) return ctx.send(`That command couldn't be found. Use \`'help\` to see all commands.`);
|
start++;
|
||||||
|
});
|
||||||
|
return ctx.send(Help);
|
||||||
|
}
|
||||||
|
|
||||||
|
let category, cmd;
|
||||||
|
if (ctx.args.length > 0) {
|
||||||
|
category = ctx.args[0].slice(2);
|
||||||
|
cmd = ctx.args[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (commands.hasOwnProperty(CapFirstLetter(category))) {
|
||||||
|
let short = [];
|
||||||
|
let long = [];
|
||||||
|
commands[`${CapFirstLetter(category)}`].cs.forEach(c => {
|
||||||
|
short.push(`${ctx.utils.format.code(c.name)} - ${c.description}`);
|
||||||
|
long.push(c);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (ctx.args.length === 2) {
|
||||||
|
let c = long.filter(
|
||||||
|
c =>
|
||||||
|
c.name === cmd.toLowerCase() ||
|
||||||
|
(c.aliases && c.aliases.includes(cmd.toLowerCase()))
|
||||||
|
);
|
||||||
|
let Text;
|
||||||
|
if (c.length === 0) {
|
||||||
|
Text = "There is no command with that name in this category.";
|
||||||
|
Help.setDescription(Text);
|
||||||
|
return ctx.send(Help);
|
||||||
|
} else {
|
||||||
let fields = [{
|
let fields = [{
|
||||||
name: 'Module',
|
name: "Module",
|
||||||
value: command.module,
|
value: c[0].module,
|
||||||
inline: true
|
inline: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Aliases',
|
name: "Aliases",
|
||||||
value: command.aliases.length == 0 ? 'No aliases' : command.aliases.join(', '),
|
value: c[0].aliases.length == 0 ?
|
||||||
|
"No aliases" : c[0].aliases.join(", "),
|
||||||
inline: true
|
inline: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Cooldown',
|
name: "Cooldown",
|
||||||
value: command.cooldown == 0 ? 'No cooldown' : `${command.cooldown}s`,
|
value: c[0].cooldown == 0 ? "No cooldown" : `${c[0].cooldown}s`,
|
||||||
inline: true
|
inline: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Server only?',
|
name: "Server only?",
|
||||||
value: command.guildOnly ? 'Yes' : 'No',
|
value: c[0].guildOnly ? "Yes" : "No",
|
||||||
inline: true
|
inline: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Permissions needed',
|
name: "Permissions needed",
|
||||||
value: command.AuthorPermissions ? command.AuthorPermissions : 'None',
|
value: c[0].AuthorPermissions ? c[0].AuthorPermissions : "None",
|
||||||
inline: true
|
inline: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Developers only?',
|
name: "Developers only?",
|
||||||
value: command.developerOnly ? 'Yes' : 'No',
|
value: c[0].developerOnly ? "Yes" : "No",
|
||||||
inline: true
|
inline: true
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
fields.forEach(i => {
|
||||||
let embed = new MessageEmbed()
|
Help.addField(i.name, i.value, i.inline);
|
||||||
.setTitle(command.name)
|
|
||||||
.setDescription(command.description)
|
|
||||||
.setColor(0xff873f);
|
|
||||||
fields.forEach((i) => {
|
|
||||||
embed.addField(i.name, i.value, i.inline);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return ctx.send(embed);
|
return ctx.send(Help);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Help.setDescription(
|
||||||
|
`Use ${ctx.utils.format.code(
|
||||||
|
`'help --<cagegory> <command> to get help on a specific command`
|
||||||
|
)}\n\n${short.join("\n")}`
|
||||||
|
);
|
||||||
|
return ctx.send(Help);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Help.setDescription("This Category does not exist");
|
||||||
|
return ctx.send(Help);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
|
@ -1,5 +1,5 @@
|
||||||
const ora = require("ora");
|
const ora = require("ora");
|
||||||
const config = require("../../config");
|
const config = require("../../vars");
|
||||||
const chalk = require("chalk");
|
const chalk = require("chalk");
|
||||||
const BotSpinner = new ora({
|
const BotSpinner = new ora({
|
||||||
discardStdin: false
|
discardStdin: false
|
||||||
|
@ -12,35 +12,35 @@ const ServerSpinner = new ora({
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = async = {
|
module.exports = async = {
|
||||||
starting: async function() {
|
starting: async function () {
|
||||||
BotSpinner.text = `${config.name} v${config.version} is starting`;
|
BotSpinner.text = `${config.name} - v${config.version} is starting`;
|
||||||
BotSpinner.spinner = "moon";
|
BotSpinner.spinner = "moon";
|
||||||
BotSpinner.start();
|
BotSpinner.start();
|
||||||
return BotSpinner;
|
return BotSpinner;
|
||||||
},
|
},
|
||||||
stopSpinner: function() {
|
stopSpinner: function () {
|
||||||
return BotSpinner.stop();
|
return BotSpinner.stop();
|
||||||
},
|
},
|
||||||
hasStarted: async function() {
|
hasStarted: async function () {
|
||||||
BotSpinner.succeed(`${config.name} v${config.version} has started`);
|
BotSpinner.succeed(`${config.name} - v${config.version} has started`);
|
||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
shardReady: async function(text) {
|
shardReady: async function (text) {
|
||||||
shardSpinner.text = text;
|
shardSpinner.text = text;
|
||||||
shardSpinner.spinner = "moon";
|
shardSpinner.spinner = "moon";
|
||||||
return shardSpinner.start();
|
return shardSpinner.start();
|
||||||
},
|
},
|
||||||
shardSpinnerStarted: function() {
|
shardSpinnerStarted: function () {
|
||||||
return shardSpinner.succeed();
|
return shardSpinner.succeed();
|
||||||
},
|
},
|
||||||
servers: {
|
servers: {
|
||||||
setup: async function(server) {
|
setup: async function (server) {
|
||||||
ServerSpinner.text = `Setting up ${chalk.red(server.name)} | ${chalk.red(
|
ServerSpinner.text = `Setting up ${chalk.red(server.name)} | ${chalk.red(
|
||||||
server.id
|
server.id
|
||||||
)}...`;
|
)}...`;
|
||||||
ServerSpinner.start();
|
ServerSpinner.start();
|
||||||
},
|
},
|
||||||
fin: async function(server) {
|
fin: async function (server) {
|
||||||
ServerSpinner.succeed(
|
ServerSpinner.succeed(
|
||||||
`${chalk.red(server.name)} | ${chalk.red(server.id)} has been set up.`
|
`${chalk.red(server.name)} | ${chalk.red(server.id)} has been set up.`
|
||||||
);
|
);
|
||||||
|
|
2
vars.js
2
vars.js
|
@ -1,7 +1,7 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
name: 'Thaldrin',
|
||||||
version: '3.6.2',
|
version: '3.6.2',
|
||||||
color: '#ff995d',
|
color: '#ff995d',
|
||||||
name: 'thaldr.in',
|
|
||||||
hostname: '127.2.11.1',
|
hostname: '127.2.11.1',
|
||||||
//hostname: 'localhost',
|
//hostname: 'localhost',
|
||||||
port: '8080',
|
port: '8080',
|
||||||
|
|
Loading…
Reference in a new issue