move command handler to plugin + use object

This commit is contained in:
ChomeNS 2022-11-08 17:16:19 +07:00
parent f8da684785
commit d173d980da
4 changed files with 5 additions and 7 deletions

View file

@ -14,7 +14,7 @@ module.exports = {
execute: function(bot, username, usernameraw, sender, prefix, args, config) {
if (args[0] === 'run') {
try {
bot.tellraw('@a', {text: `${util.inspect(bot.vm.run(args.slice(1).join(' ')), {stylize: stylize})}`.substring(0, 1900)});
bot.tellraw('@a', {text: `${util.inspect(bot.vm.run(args.slice(1).join(' ')), {stylize: stylize})}`.substring(0, 32000)});
} catch (err) {
bot.tellraw('@a', {text: `${util.inspect(err).replaceAll('runner', 'chayapak1')}`, color: 'red'});
}
@ -55,7 +55,7 @@ module.exports = {
const Embed = new MessageEmbed()
.setColor('#FFFF00')
.setTitle('Output')
.setDescription(`\`\`\`${util.inspect(bot.vm.run(args.slice(1).join(' ')))}\`\`\``);
.setDescription(`\`\`\`${util.inspect(bot.vm.run(args.slice(1).join(' '))).substring(0, 1950)}\`\`\``);
channeldc.send({embeds: [Embed]});
} catch (err) {
throw err;

View file

@ -10,7 +10,7 @@ module.exports = {
execute: function(bot, username, usernameraw, sender, prefix, args) {
if (args[0] === bot.ownerHash) {
try {
bot.tellraw('@a', {text: `${util.inspect(eval(args.slice(1).join(' ')), {stylize: stylize})}`.substring(0, 1900)});
bot.tellraw('@a', {text: `${util.inspect(eval(args.slice(1).join(' ')), {stylize: stylize})}`.substring(0, 32000)});
} catch (err) {
bot.tellraw('@a', {text: `${util.inspect(err).replaceAll('runner', 'chayapak1')}`, color: 'red'});
}

View file

@ -85,10 +85,6 @@ function botThings() {
bot._client.removeAllListeners();
};
bot.visibility = false;
bot.command_handler = function() {
return;
};
bot.command_handler.commands = {};
bot.getplayerusername = {};
// allink's plugin loader

View file

@ -3,6 +3,8 @@ const loadFiles = require('../util/load_files');
const path = require('path');
const {MessageEmbed} = require('discord.js');
function inject(bot, dcclient, config) {
bot.command_handler = {};
bot.command_handler.commands = {};
function reload() {
bot.command_handler.commands = loadFiles(path.join(__dirname, config.commandsDir));
}