lots of changes

This commit is contained in:
ry 2019-11-10 09:42:09 +01:00
parent 304d0ccb96
commit f7fd3b99a4
60 changed files with 3029 additions and 878 deletions

View file

@ -1,90 +1,80 @@
const Command = require("../../src/structures/Command");
const { table } = require("quick.db");
const Servers = new table("servers");
const Users = new table("users");
const Command = require('../../src/structures/Command');
const { table } = require('quick.db');
const Servers = new table('servers');
const Users = new table('users');
const Bot = new table('bot');
const clean = text => {
if (typeof text == "string")
return text
.replace(/`/g, "`" + String.fromCharCode(8203))
.replace(/@/g, "@" + String.fromCharCode(8203));
else return text;
const clean = (text) => {
if (typeof text == 'string')
return text.replace(/`/g, '`' + String.fromCharCode(8203)).replace(/@/g, '@' + String.fromCharCode(8203));
else return text;
};
module.exports = class Eval extends Command {
constructor() {
super({
name: "eval",
description: "Run JavaScript code directly from the process.",
aliases: ["ev", "e"],
module: "Developers",
cooldown: 0,
guildOnly: false,
developerOnly: true
});
}
constructor() {
super({
name: 'eval',
description: 'Run JavaScript code directly from the process.',
aliases: [ 'ev', 'e' ],
module: 'Developers',
cooldown: 0,
guildOnly: false,
developerOnly: true
});
}
async command(ctx) {
if (!ctx.args.length) return;
async command(ctx) {
if (!ctx.args.length) return;
const client = ctx.client;
const client = ctx.client;
let code = ctx.args.join(" ");
let silent = false;
let code = ctx.args.join(' ');
let silent = false;
if (code.endsWith("-s")) (code = code.split("-s")[0]), (silent = true);
if (code.endsWith("--silent"))
(code = code.split("--silent")[0]), (silent = true);
if (code.endsWith('-s')) (code = code.split('-s')[0]), (silent = true);
if (code.endsWith('--silent')) (code = code.split('--silent')[0]), (silent = true);
try {
let evaled = await eval(code);
try {
let evaled = await eval(code);
if (typeof evaled != "string") evaled = require("util").inspect(evaled);
if (typeof evaled != 'string')
evaled = require('util').inspect(evaled, false, await ctx.db.backend.get('eval'));
evaled.replace(
new RegExp(client.token.replace(/\./g, "\\.", "g")),
"uwu"
);
evaled.replace(new RegExp(client.token.replace(/\./g, '\\.', 'g')), 'uwu');
if (!silent) {
ctx
.send(`\`\`\`js\n${clean(evaled)}\n\`\`\``)
.then(async m => {
await m.react("📥");
await m.react("🗑");
})
.catch(err => {
ctx
.send(
`\`Content is over 2,000 characters: react to upload to Hastebin\``
)
.then(async m => {
client.lastEval = clean(evaled);
if (!silent) {
ctx
.send(`\`\`\`js\n${clean(evaled)}\n\`\`\``)
.then(async (m) => {
await m.react('📥');
await m.react('🗑');
})
.catch((err) => {
ctx
.send(`\`Content is over 2,000 characters: react to upload to Hastebin\``)
.then(async (m) => {
client.lastEval = clean(evaled);
await m.react("📥");
await m.react("🗑");
});
});
}
} catch (error) {
ctx
.send(`\`\`\`js\n${clean(error)}\n\`\`\``)
.then(async m => {
await m.react("📥");
await m.react("🗑");
})
.catch(err => {
ctx
.send(
`\`Content is over 2,000 characters: react to upload to Hastebin\``
)
.then(async m => {
client.lastEval = clean(error);
await m.react('📥');
await m.react('🗑');
});
});
}
} catch (error) {
ctx
.send(`\`\`\`js\n${clean(error)}\n\`\`\``)
.then(async (m) => {
await m.react('📥');
await m.react('🗑');
})
.catch((err) => {
ctx.send(`\`Content is over 2,000 characters: react to upload to Hastebin\``).then(async (m) => {
client.lastEval = clean(error);
await m.react("📥");
await m.react("🗑");
});
});
}
}
await m.react('📥');
await m.react('🗑');
});
});
}
}
};

View file

@ -1,39 +1,38 @@
const Command = require('../../src/structures/Command');
module.exports = class Reload extends Command {
constructor() {
super({
name: 'reload',
description: 'Reload a command without restarting the process.',
aliases: ['re'],
module: 'Developers',
cooldown: 0,
guildOnly: false,
developerOnly: true
});
}
constructor() {
super({
name: 'reload',
description: 'Reload a command without restarting the process.',
aliases: [ 're' ],
module: 'Developers',
cooldown: 0,
guildOnly: false,
developerOnly: true
});
}
async command(ctx) {
if (!ctx.args.length) return;
const date = Date.now();
async command(ctx) {
if (!ctx.args.length) return;
const date = Date.now();
const data = ctx.args[0];
const [module,command] = data.split('/');
const data = ctx.args[0];
const [ module, command ] = data.split('/');
if (!module || !command) return;
if (!module || !command) return;
try {
delete require.cache[require.resolve(`../${module}/${command}`)];
delete ctx.client.commands.get(command);
try {
delete require.cache[require.resolve(`../${module}/${command}`)];
delete ctx.client.commands.get(command);
const cmd = require(`../${module}/${command}`);
const Command = new cmd();
ctx.client.commands.set(Command.name, Command);
const cmd = require(`../${module}/${command}`);
const Command = new cmd();
ctx.client.commands.set(Command.name, Command);
console.log(`Reloaded \`${Command.name}\` in ${(Date.now() - date) / 1000}s.`)
return ctx.send(`Reloaded \`${Command.name}\` in ${(Date.now() - date) / 1000}s.`);
} catch(err) {
return ctx.send(`Failed to reload the command.\n\`${err}\``);
}
}
}
return ctx.send(`Reloaded \`${Command.name}\` in ${(Date.now() - date) / 1000}s.`);
} catch (err) {
return ctx.send(`Failed to reload the command.\n\`${err}\``);
}
}
};

View file

@ -1,21 +0,0 @@
const Command = require("../../src/structures/Command");
module.exports = class Setup extends Command {
constructor() {
super({
name: "setup",
description: "x",
aliases: ["s"],
module: "Developers",
cooldown: 0,
guildOnly: false,
developerOnly: true
});
}
async command(ctx) {
let x = await ctx.utils.db.prefix
.remove(ctx)
.catch(err => console.error(err));
//' console.log(x);
}
};

View file

@ -1,18 +1,19 @@
const Command = require("../../src/structures/Command");
const Command = require('../../src/structures/Command');
module.exports = class Stop extends Command {
constructor() {
super({
name: "stop",
description: "Stops the bot",
aliases: [],
module: "Developers",
cooldown: 0,
guildOnly: false,
developerOnly: true
});
}
constructor() {
super({
name: 'stop',
description: 'Stops the bot',
aliases: [],
module: 'Developers',
cooldown: 0,
guildOnly: false,
developerOnly: true
});
}
async command(ctx) {
process.exit();
}
async command(ctx) {
await ctx.send('Restarting.');
process.exit();
}
};