Browse Source

add dev commands back

master
ry 1 month ago
parent
commit
7576968a06
7 changed files with 269 additions and 0 deletions
  1. +25
    -0
      DiscordModules/Developers/blacklist.js
  2. +45
    -0
      DiscordModules/Developers/dig.js
  3. +80
    -0
      DiscordModules/Developers/eval.js
  4. +28
    -0
      DiscordModules/Developers/exec.js
  5. +38
    -0
      DiscordModules/Developers/reload.js
  6. +19
    -0
      DiscordModules/Developers/stop.js
  7. +34
    -0
      DiscordModules/Developers/update.js

+ 25
- 0
DiscordModules/Developers/blacklist.js View File

@@ -0,0 +1,25 @@
const Command = require('../../src/structures/Command');
module.exports = class Blacklist extends Command {
constructor() {
super({
name: 'blacklist',
description: 'Master the Blacklist',
aliases: ['bl'],
module: 'Developers',
cooldown: 0,
guildOnly: false,
developerOnly: true
});
}

async command(ctx) {
console.log(ctx.args)
let ACTION = ctx.args[0]
let ID = ctx.args[1]
let REASON = ctx.args.shift().shift().join(' ')
// let REASON = ctx.args[2]

let X = await ctx.utils.db.blacklist(ID, ACTION, REASON)
console.log(X)
}
};

+ 45
- 0
DiscordModules/Developers/dig.js View File

@@ -0,0 +1,45 @@
const Command = require("../../src/structures/Command");
const exec = require("shell-exec");
const dig = require("node-dig-dns");
const {
MessageEmbed
} = require("discord.js");
let DomainReg = new RegExp(
`(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]`
);
module.exports = class Dig extends Command {
constructor() {
super({
name: "dig",
description: "dig website dns information stuff",
aliases: [],
module: "Developers",
cooldown: 10,
guildOnly: false,
developerOnly: true,
nsfw: false
});
}

async command(ctx) {
let count = 0;
let domain = ctx.args[0];
let type = ctx.args[1];
const DIG = new MessageEmbed().setTitle(`${domain} (${type})`);
if (domain.match(DomainReg)) {
try {
let result = await dig([domain, type]);

result.answer.forEach(r => {
count++;
DIG.addField(`Answer ${count}`, r.value);
});
} catch (error) {
DIG.setDescription(
`Either the Domain you are trying to dig for doesn't exist or the record you are requesting does not exist.`
);
}
}
ctx.send(DIG);
}
};

+ 80
- 0
DiscordModules/Developers/eval.js View File

@@ -0,0 +1,80 @@
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;
};

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
});
}

async command(ctx) {
if (!ctx.args.length) return;

const client = ctx.client;

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);

try {
let evaled = await eval(code);

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');

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('🗑');
});
});
}
}
};

+ 28
- 0
DiscordModules/Developers/exec.js View File

@@ -0,0 +1,28 @@
const Command = require('../../src/structures/Command');
const exec = require('shell-exec');
module.exports = class Exec extends Command {
constructor() {
super({
name: 'exec',
description: 'Execute shell commands',
aliases: [ 'ex' ],
module: 'Developers',
cooldown: 1,
guildOnly: false,
developerOnly: true,
nsfw: false
});
}

async command(ctx) {
const trying = await ctx.send('Attempting to execute ' + ctx.utils.format.bold(ctx.args.join(' ')));

await exec(ctx.args.join(' '))
.then((r) => {
trying.edit('```bash\n' + r.stdout + '```');
})
.catch((error) => {
trying.edit('Failed to execute ' + ctx.utils.format.bold(ctx.args.join(' ')));
});
}
};

+ 38
- 0
DiscordModules/Developers/reload.js View File

@@ -0,0 +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
});
}

async command(ctx) {
if (!ctx.args.length) return;
const date = Date.now();

const data = ctx.args[0];
const [ module, command ] = data.split('/');

if (!module || !command) return;

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);

return ctx.send(`Reloaded \`${Command.name}\` in ${(Date.now() - date) / 1000}s.`);
} catch (err) {
return ctx.send(`Failed to reload the command.\n\`${err}\``);
}
}
};

+ 19
- 0
DiscordModules/Developers/stop.js View File

@@ -0,0 +1,19 @@
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
});
}

async command(ctx) {
await ctx.send('Restarting.');
process.exit();
}
};

+ 34
- 0
DiscordModules/Developers/update.js View File

@@ -0,0 +1,34 @@
const Command = require('../../src/structures/Command');
const exec = require('shell-exec');
module.exports = class Update extends Command {
constructor() {
super({
name: 'update',
description: 'Execute shell commands',
aliases: [ 'up', 'pull' ],
module: 'Developers',
cooldown: 1,
guildOnly: false,
developerOnly: true,
nsfw: false
});
}

async command(ctx) {
const trying = await ctx.send(
`${ctx.utils.emotes.random.loading} Getting the latest updates from ${ctx.config.source.replace(
'https://',
''
)} ${ctx.utils.emotes.random.loading}`
);

await exec('git pull')
.then((r) => {
trying.edit('```fix\n' + r.stdout + '```');
})
.catch((error) => {
trying.edit(`Failed to get the latest updates.`);
console.error(error);
});
}
};

Loading…
Cancel
Save