mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-14 10:44:55 -05:00
use standard and not google cuz BAD
This commit is contained in:
parent
37f88488f6
commit
1a7e5af054
66 changed files with 1622 additions and 1615 deletions
|
@ -4,7 +4,7 @@
|
||||||
"es2021": true
|
"es2021": true
|
||||||
},
|
},
|
||||||
"extends": [
|
"extends": [
|
||||||
"google"
|
"standard"
|
||||||
],
|
],
|
||||||
"parserOptions": {
|
"parserOptions": {
|
||||||
"ecmaVersion": "latest",
|
"ecmaVersion": "latest",
|
||||||
|
|
178
bot.js
178
bot.js
|
@ -1,20 +1,20 @@
|
||||||
/* eslint-disable max-len */
|
/* eslint-disable max-len */
|
||||||
|
|
||||||
const mc = require('minecraft-protocol');
|
const mc = require('minecraft-protocol')
|
||||||
const crypto = require('crypto');
|
const crypto = require('crypto')
|
||||||
const colorConvert = require('color-convert');
|
const colorConvert = require('color-convert')
|
||||||
const sleep = require('sleep-promise');
|
const sleep = require('sleep-promise')
|
||||||
const generateEaglerUsername = require('./util/generateEaglerUsername');
|
const generateEaglerUsername = require('./util/generateEaglerUsername')
|
||||||
const {EventEmitter} = require('events');
|
const { EventEmitter } = require('events')
|
||||||
const {loadPlugins} = require('./util/loadPlugins');
|
const { loadPlugins } = require('./util/loadPlugins')
|
||||||
const uuid = require('uuid-by-string');
|
const uuid = require('uuid-by-string')
|
||||||
const moment = require('moment-timezone');
|
const moment = require('moment-timezone')
|
||||||
const cowsay = require('cowsay2');
|
const cowsay = require('cowsay2')
|
||||||
const cows = require('cowsay2/cows');
|
const cows = require('cowsay2/cows')
|
||||||
const util = require('node:util');
|
const util = require('node:util')
|
||||||
const {VM} = require('vm2');
|
const { VM } = require('vm2')
|
||||||
const randomstring = require('randomstring');
|
const randomstring = require('randomstring')
|
||||||
const mineflayer = require('mineflayer');
|
const mineflayer = require('mineflayer')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* makes the bot
|
* makes the bot
|
||||||
|
@ -26,63 +26,63 @@ const mineflayer = require('mineflayer');
|
||||||
* @param {object} rl readline.
|
* @param {object} rl readline.
|
||||||
* @return {object} the bot object
|
* @return {object} the bot object
|
||||||
*/
|
*/
|
||||||
async function createBot(server, config, getBots, setNewBot, dcclient, rl) {
|
async function createBot (server, config, getBots, setNewBot, dcclient, rl) {
|
||||||
const bot = new EventEmitter();
|
const bot = new EventEmitter()
|
||||||
bot.options = {
|
bot.options = {
|
||||||
username: !server.kaboom ?
|
username: !server.kaboom
|
||||||
'ChomeNS_Bot' :
|
? 'ChomeNS_Bot'
|
||||||
randomstring.generate(8),
|
: randomstring.generate(8),
|
||||||
host: server.host,
|
host: server.host,
|
||||||
port: server.port,
|
port: server.port,
|
||||||
version: config.version,
|
version: config.version,
|
||||||
kaboom: server.kaboom,
|
kaboom: server.kaboom,
|
||||||
checkTimeoutInterval: '30000',
|
checkTimeoutInterval: '30000',
|
||||||
keepAlive: false,
|
keepAlive: false,
|
||||||
hideErrors: true,
|
hideErrors: true
|
||||||
};
|
}
|
||||||
bot._client = mc.createClient(bot.options);
|
bot._client = mc.createClient(bot.options)
|
||||||
bot.version = bot._client.version;
|
bot.version = bot._client.version
|
||||||
bot.write = (name, data) => bot._client.write(name, data);
|
bot.write = (name, data) => bot._client.write(name, data)
|
||||||
bot.end = (reason = 'end', event) => {
|
bot.end = (reason = 'end', event) => {
|
||||||
bot.emit('end', reason, event);
|
bot.emit('end', reason, event)
|
||||||
bot.removeAllListeners();
|
bot.removeAllListeners()
|
||||||
bot._client.end();
|
bot._client.end()
|
||||||
bot._client.removeAllListeners();
|
bot._client.removeAllListeners()
|
||||||
};
|
}
|
||||||
bot.visibility = false;
|
bot.visibility = false
|
||||||
bot.getBots = getBots;
|
bot.getBots = getBots
|
||||||
bot.getplayerusername = {};
|
bot.getplayerusername = {}
|
||||||
|
|
||||||
await sleep(200);
|
await sleep(200)
|
||||||
|
|
||||||
setNewBot(bot.options.host, bot);
|
setNewBot(bot.options.host, bot)
|
||||||
|
|
||||||
await loadPlugins(bot, dcclient, config, rl);
|
await loadPlugins(bot, dcclient, config, rl)
|
||||||
|
|
||||||
const channel = dcclient.channels.cache.get(config.discord.servers[bot.options.host]);
|
const channel = dcclient.channels.cache.get(config.discord.servers[bot.options.host])
|
||||||
|
|
||||||
bot.playersAddedPlayers = {};
|
bot.playersAddedPlayers = {}
|
||||||
bot.getplayerusername = {};
|
bot.getplayerusername = {}
|
||||||
|
|
||||||
bot._client.on('login', async function(data) {
|
bot._client.on('login', async function (data) {
|
||||||
bot.entityId = data.entityId;
|
bot.entityId = data.entityId
|
||||||
bot.uuid = bot._client.uuid;
|
bot.uuid = bot._client.uuid
|
||||||
bot.username = bot._client.username;
|
bot.username = bot._client.username
|
||||||
chatMessage = require('prismarine-chat')(bot.version);
|
const chatMessage = require('prismarine-chat')(bot.version)
|
||||||
const mcData = require('minecraft-data')(bot.version);
|
const mcData = require('minecraft-data')(bot.version)
|
||||||
bot.console.info(
|
bot.console.info(
|
||||||
`Successfully logged in to: ${bot.options.host}:${bot.options.port}`,
|
`Successfully logged in to: ${bot.options.host}:${bot.options.port}`
|
||||||
);
|
)
|
||||||
channel.send(
|
channel.send(
|
||||||
`Successfully logged in to: \`${bot.options.host}:${bot.options.port}\``,
|
`Successfully logged in to: \`${bot.options.host}:${bot.options.port}\``
|
||||||
);
|
)
|
||||||
bot.eaglercrashstarted = false;
|
bot.eaglercrashstarted = false
|
||||||
|
|
||||||
bot.vmoptions = {
|
bot.vmoptions = {
|
||||||
timeout: 2000,
|
timeout: 2000,
|
||||||
sandbox: {
|
sandbox: {
|
||||||
run(cmd) {
|
run (cmd) {
|
||||||
bot.core.run(cmd);
|
bot.core.run(cmd)
|
||||||
},
|
},
|
||||||
mc,
|
mc,
|
||||||
mineflayer,
|
mineflayer,
|
||||||
|
@ -93,19 +93,19 @@ async function createBot(server, config, getBots, setNewBot, dcclient, rl) {
|
||||||
chatMessage,
|
chatMessage,
|
||||||
crypto,
|
crypto,
|
||||||
colorConvert,
|
colorConvert,
|
||||||
bruhifyText(message) {
|
bruhifyText (message) {
|
||||||
if (
|
if (
|
||||||
typeof message !== 'string'
|
typeof message !== 'string'
|
||||||
) throw new SyntaxError('message must be a string');
|
) throw new SyntaxError('message must be a string')
|
||||||
bot.bruhifyText = message.substring(0, 1000);
|
bot.bruhifyText = message.substring(0, 1000)
|
||||||
},
|
},
|
||||||
generateEaglerUsername,
|
generateEaglerUsername,
|
||||||
cowsay,
|
cowsay,
|
||||||
cows,
|
cows,
|
||||||
mcData,
|
mcData
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
bot.vm = new VM(bot.vmoptions);
|
bot.vm = new VM(bot.vmoptions)
|
||||||
|
|
||||||
// await sleep(1400);
|
// await sleep(1400);
|
||||||
// bot.tellraw('@a', [
|
// bot.tellraw('@a', [
|
||||||
|
@ -126,24 +126,24 @@ async function createBot(server, config, getBots, setNewBot, dcclient, rl) {
|
||||||
// color: 'gold',
|
// color: 'gold',
|
||||||
// },
|
// },
|
||||||
// ]);
|
// ]);
|
||||||
});
|
})
|
||||||
|
|
||||||
bot.on('player_added', (player) => {
|
bot.on('player_added', (player) => {
|
||||||
bot.playersAddedPlayers[player.name] = player.UUID;
|
bot.playersAddedPlayers[player.name] = player.UUID
|
||||||
bot.getplayerusername[player.UUID] = player.name;
|
bot.getplayerusername[player.UUID] = player.name
|
||||||
});
|
})
|
||||||
|
|
||||||
bot._client.on('end', function(reason) {
|
bot._client.on('end', function (reason) {
|
||||||
bot.end(reason, 'end');
|
bot.end(reason, 'end')
|
||||||
});
|
})
|
||||||
|
|
||||||
bot.once('end', (reason, event) => {
|
bot.once('end', (reason, event) => {
|
||||||
bot.console.info(
|
bot.console.info(
|
||||||
`Disconnected from ${bot.options.host} (${event} event): ${util.inspect(reason)}`,
|
`Disconnected from ${bot.options.host} (${event} event): ${util.inspect(reason)}`
|
||||||
);
|
)
|
||||||
channel.send(`Disconnected: \`${util.inspect(reason)}\``);
|
channel.send(`Disconnected: \`${util.inspect(reason)}\``)
|
||||||
|
|
||||||
let timeout = config.reconnectTimeout;
|
let timeout = config.reconnectTimeout
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (reason.text) {
|
if (reason.text) {
|
||||||
|
@ -151,35 +151,35 @@ async function createBot(server, config, getBots, setNewBot, dcclient, rl) {
|
||||||
'Wait 5 seconds before connecting, thanks! :)' ||
|
'Wait 5 seconds before connecting, thanks! :)' ||
|
||||||
reason.text ===
|
reason.text ===
|
||||||
'You are logging in too fast, try again later.'
|
'You are logging in too fast, try again later.'
|
||||||
) timeout = 1000 * 7;
|
) timeout = 1000 * 7
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
bot.console.error(e);
|
bot.console.error(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
bot.end();
|
bot.end()
|
||||||
createBot(server, config, getBots, setNewBot, dcclient, rl);
|
createBot(server, config, getBots, setNewBot, dcclient, rl)
|
||||||
}, timeout);
|
}, timeout)
|
||||||
});
|
})
|
||||||
|
|
||||||
bot._client.on('keep_alive', (packet) => {
|
bot._client.on('keep_alive', (packet) => {
|
||||||
bot.write('keep_alive', {keepAliveId: packet.keepAliveId});
|
bot.write('keep_alive', { keepAliveId: packet.keepAliveId })
|
||||||
});
|
})
|
||||||
|
|
||||||
bot._client.on('kick_disconnect', function(data) {
|
bot._client.on('kick_disconnect', function (data) {
|
||||||
const parsed = JSON.parse(data.reason);
|
const parsed = JSON.parse(data.reason)
|
||||||
bot.end(parsed, 'kick_disconnect');
|
bot.end(parsed, 'kick_disconnect')
|
||||||
});
|
})
|
||||||
|
|
||||||
bot._client.on('disconnect', function(data) {
|
bot._client.on('disconnect', function (data) {
|
||||||
const parsed = JSON.parse(data.reason);
|
const parsed = JSON.parse(data.reason)
|
||||||
bot.end(parsed, 'disconnect');
|
bot.end(parsed, 'disconnect')
|
||||||
});
|
})
|
||||||
|
|
||||||
bot._client.on('error', function() {});
|
bot._client.on('error', function () {})
|
||||||
|
|
||||||
return bot;
|
return bot
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {createBot};
|
module.exports = { createBot }
|
||||||
|
|
|
@ -5,10 +5,10 @@ module.exports = {
|
||||||
description: 'Sudos everyone on Ayunboom!',
|
description: 'Sudos everyone on Ayunboom!',
|
||||||
trusted: 1,
|
trusted: 1,
|
||||||
usage: '<hash> <c:|command>',
|
usage: '<hash> <c:|command>',
|
||||||
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
execute: function (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||||
bot.core.run(`essentials:sudo * ${args.slice(1).join(' ')}`);
|
bot.core.run(`essentials:sudo * ${args.slice(1).join(' ')}`)
|
||||||
},
|
},
|
||||||
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) {
|
discordExecute: function (bot, username, usernameraw, sender, prefix, args, channeldc, message) {
|
||||||
bot.core.run(`essentials:sudo * ${args.join(' ')}`);
|
bot.core.run(`essentials:sudo * ${args.join(' ')}`)
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
/* eslint-disable max-len */
|
/* eslint-disable max-len */
|
||||||
const {MessageEmbed} = require('discord.js');
|
const { MessageEmbed } = require('discord.js')
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'botuser',
|
name: 'botuser',
|
||||||
alias: [],
|
alias: [],
|
||||||
description: 'Shows the bot\'s username and UUID',
|
description: 'Shows the bot\'s username and UUID',
|
||||||
usage: '',
|
usage: '',
|
||||||
trusted: 0,
|
trusted: 0,
|
||||||
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
execute: function (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||||
bot.tellraw(selector, [{text: 'The bot\'s username is: ', color: 'white'}, {text: `${bot.username}`, color: 'gold', clickEvent: {action: 'copy_to_clipboard', value: `${bot.username}`}, hoverEvent: {action: 'show_text', contents: [{text: 'Click here to copy the username to your clipboard', color: 'green'}]}}, {text: ' and the UUID is: '}, {text: `${bot.uuid}`, color: 'aqua', clickEvent: {action: 'copy_to_clipboard', value: `${bot.uuid}`}, hoverEvent: {action: 'show_text', contents: [{text: 'Click here to copy the UUID to your clipboard', color: 'green'}]}}]);
|
bot.tellraw(selector, [{ text: 'The bot\'s username is: ', color: 'white' }, { text: `${bot.username}`, color: 'gold', clickEvent: { action: 'copy_to_clipboard', value: `${bot.username}` }, hoverEvent: { action: 'show_text', contents: [{ text: 'Click here to copy the username to your clipboard', color: 'green' }] } }, { text: ' and the UUID is: ' }, { text: `${bot.uuid}`, color: 'aqua', clickEvent: { action: 'copy_to_clipboard', value: `${bot.uuid}` }, hoverEvent: { action: 'show_text', contents: [{ text: 'Click here to copy the UUID to your clipboard', color: 'green' }] } }])
|
||||||
},
|
},
|
||||||
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) {
|
discordExecute: function (bot, username, usernameraw, sender, prefix, args, channeldc, message) {
|
||||||
const Embed = new MessageEmbed()
|
const Embed = new MessageEmbed()
|
||||||
.setColor('#FFFF00')
|
.setColor('#FFFF00')
|
||||||
.setTitle('Bot\'s User')
|
.setTitle('Bot\'s User')
|
||||||
.setDescription(`The bot's username is: \`${bot.username}\` and the UUID is: \`${bot.uuid}\``);
|
.setDescription(`The bot's username is: \`${bot.username}\` and the UUID is: \`${bot.uuid}\``)
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({ embeds: [Embed] })
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* eslint-disable max-len */
|
/* eslint-disable max-len */
|
||||||
const {MessageEmbed} = require('discord.js');
|
const { MessageEmbed } = require('discord.js')
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'botvisibility',
|
name: 'botvisibility',
|
||||||
alias: ['botvis', 'togglevis', 'togglevisibility'],
|
alias: ['botvis', 'togglevis', 'togglevisibility'],
|
||||||
|
@ -7,58 +7,58 @@ module.exports = {
|
||||||
usage: [
|
usage: [
|
||||||
'<hash> <true|false>',
|
'<hash> <true|false>',
|
||||||
'<hash> <on|off>',
|
'<hash> <on|off>',
|
||||||
'<hash>',
|
'<hash>'
|
||||||
],
|
],
|
||||||
trusted: 1,
|
trusted: 1,
|
||||||
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
execute: function (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||||
if (args[1] === 'true' || args[1] === 'on') {
|
if (args[1] === 'true' || args[1] === 'on') {
|
||||||
bot.visibility = true;
|
bot.visibility = true
|
||||||
bot.chat('/essentials:vanish disable');
|
bot.chat('/essentials:vanish disable')
|
||||||
bot.tellraw(selector, [{text: 'The bot\'s visibility is now ', color: 'white'}, {text: 'visible', color: 'green'}]);
|
bot.tellraw(selector, [{ text: 'The bot\'s visibility is now ', color: 'white' }, { text: 'visible', color: 'green' }])
|
||||||
} else if (args[1] === 'false' || args[1] === 'off') {
|
} else if (args[1] === 'false' || args[1] === 'off') {
|
||||||
bot.visibility = false;
|
bot.visibility = false
|
||||||
bot.chat('/essentials:vanish enable');
|
bot.chat('/essentials:vanish enable')
|
||||||
bot.tellraw(selector, [{text: 'The bot\'s visibility is now ', color: 'white'}, {text: 'invisible', color: 'gold'}]);
|
bot.tellraw(selector, [{ text: 'The bot\'s visibility is now ', color: 'white' }, { text: 'invisible', color: 'gold' }])
|
||||||
} else if (!args[1]) {
|
} else if (!args[1]) {
|
||||||
bot.visibility = !bot.visibility;
|
bot.visibility = !bot.visibility
|
||||||
const greenOrGold = bot.visibility ? 'green' : 'gold';
|
const greenOrGold = bot.visibility ? 'green' : 'gold'
|
||||||
const visibleOrInvisible = bot.visibility ? 'visible' : 'invisible';
|
const visibleOrInvisible = bot.visibility ? 'visible' : 'invisible'
|
||||||
const enableOrDisable = bot.visibility ? 'disable' : 'enable';
|
const enableOrDisable = bot.visibility ? 'disable' : 'enable'
|
||||||
bot.chat(`/essentials:vanish ${enableOrDisable}`);
|
bot.chat(`/essentials:vanish ${enableOrDisable}`)
|
||||||
bot.tellraw(selector, [{text: 'The bot\'s visibility is now ', color: 'white'}, {text: visibleOrInvisible, color: greenOrGold}]);
|
bot.tellraw(selector, [{ text: 'The bot\'s visibility is now ', color: 'white' }, { text: visibleOrInvisible, color: greenOrGold }])
|
||||||
} else {
|
} else {
|
||||||
throw new SyntaxError('Invalid argument');
|
throw new SyntaxError('Invalid argument')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) {
|
discordExecute: function (bot, username, usernameraw, sender, prefix, args, channeldc, message) {
|
||||||
if (args[0] === 'true' || args[0] === 'on') {
|
if (args[0] === 'true' || args[0] === 'on') {
|
||||||
bot.visibility = true;
|
bot.visibility = true
|
||||||
bot.chat('/essentials:vanish disable');
|
bot.chat('/essentials:vanish disable')
|
||||||
const Embed = new MessageEmbed()
|
const Embed = new MessageEmbed()
|
||||||
.setColor('#FFFF00')
|
.setColor('#FFFF00')
|
||||||
.setTitle('Bot\'s Visibility')
|
.setTitle('Bot\'s Visibility')
|
||||||
.setDescription('The bot\'s visibility is now visible');
|
.setDescription('The bot\'s visibility is now visible')
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({ embeds: [Embed] })
|
||||||
} else if (args[0] === 'false' || args[0] === 'off') {
|
} else if (args[0] === 'false' || args[0] === 'off') {
|
||||||
bot.visibility = false;
|
bot.visibility = false
|
||||||
bot.chat('/essentials:vanish enable');
|
bot.chat('/essentials:vanish enable')
|
||||||
const Embed = new MessageEmbed()
|
const Embed = new MessageEmbed()
|
||||||
.setColor('#FFFF00')
|
.setColor('#FFFF00')
|
||||||
.setTitle('Bot\'s Visibility')
|
.setTitle('Bot\'s Visibility')
|
||||||
.setDescription('The bot\'s visibility is now invisible');
|
.setDescription('The bot\'s visibility is now invisible')
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({ embeds: [Embed] })
|
||||||
} else if (!args[0]) {
|
} else if (!args[0]) {
|
||||||
bot.visibility = !bot.visibility;
|
bot.visibility = !bot.visibility
|
||||||
const visibleOrInvisible = bot.visibility ? 'visible' : 'invisible';
|
const visibleOrInvisible = bot.visibility ? 'visible' : 'invisible'
|
||||||
const enableOrDisable = bot.visibility ? 'disable' : 'enable';
|
const enableOrDisable = bot.visibility ? 'disable' : 'enable'
|
||||||
bot.chat(`/essentials:vanish ${enableOrDisable}`);
|
bot.chat(`/essentials:vanish ${enableOrDisable}`)
|
||||||
const Embed = new MessageEmbed()
|
const Embed = new MessageEmbed()
|
||||||
.setColor('#FFFF00')
|
.setColor('#FFFF00')
|
||||||
.setTitle('Bot\'s Visibility')
|
.setTitle('Bot\'s Visibility')
|
||||||
.setDescription(`The bot\'s visibility is now ${visibleOrInvisible}`);
|
.setDescription(`The bot's visibility is now ${visibleOrInvisible}`)
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({ embeds: [Embed] })
|
||||||
} else {
|
} else {
|
||||||
throw new SyntaxError('Invalid argument');
|
throw new SyntaxError('Invalid argument')
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
/* eslint-disable max-len */
|
/* eslint-disable max-len */
|
||||||
const {MessageEmbed} = require('discord.js');
|
const { MessageEmbed } = require('discord.js')
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'bruhify',
|
name: 'bruhify',
|
||||||
alias: [],
|
alias: [],
|
||||||
description: 'RecycleBot bruhify but actionbar',
|
description: 'RecycleBot bruhify but actionbar',
|
||||||
usage: '<message>',
|
usage: '<message>',
|
||||||
trusted: 0,
|
trusted: 0,
|
||||||
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
execute: function (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||||
bot.bruhifyText = args.join(' ');
|
bot.bruhifyText = args.join(' ')
|
||||||
},
|
},
|
||||||
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc) {
|
discordExecute: function (bot, username, usernameraw, sender, prefix, args, channeldc) {
|
||||||
bot.bruhifyText = args.join(' ');
|
bot.bruhifyText = args.join(' ')
|
||||||
const Embed = new MessageEmbed()
|
const Embed = new MessageEmbed()
|
||||||
.setColor('#FFFF00')
|
.setColor('#FFFF00')
|
||||||
.setTitle('Bruhify')
|
.setTitle('Bruhify')
|
||||||
.setDescription(`Bruhify set to: ${bot.bruhifyText}`);
|
.setDescription(`Bruhify set to: ${bot.bruhifyText}`)
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({ embeds: [Embed] })
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
|
|
@ -5,10 +5,10 @@ module.exports = {
|
||||||
description: 'Executes a command in the command core',
|
description: 'Executes a command in the command core',
|
||||||
usage: '<command>',
|
usage: '<command>',
|
||||||
trusted: 0,
|
trusted: 0,
|
||||||
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
execute: function (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||||
bot.core.run(args.join(' '));
|
bot.core.run(args.join(' '))
|
||||||
},
|
},
|
||||||
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc) {
|
discordExecute: function (bot, username, usernameraw, sender, prefix, args, channeldc) {
|
||||||
bot.core.run(args.join(' '));
|
bot.core.run(args.join(' '))
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
|
|
@ -1,42 +1,42 @@
|
||||||
/* eslint-disable max-len */
|
/* eslint-disable max-len */
|
||||||
const changelog = require('../changelog.json');
|
const changelog = require('../changelog.json')
|
||||||
const {MessageEmbed} = require('discord.js');
|
const { MessageEmbed } = require('discord.js')
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'changelog',
|
name: 'changelog',
|
||||||
alias: ['changelogs'],
|
alias: ['changelogs'],
|
||||||
description: 'Shows the bot\'s changelog',
|
description: 'Shows the bot\'s changelog',
|
||||||
usage: '',
|
usage: '',
|
||||||
trusted: 0,
|
trusted: 0,
|
||||||
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
execute: function (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||||
const component = [];
|
const component = []
|
||||||
|
|
||||||
component.push({text: 'Changelogs ', color: 'green'});
|
component.push({ text: 'Changelogs ', color: 'green' })
|
||||||
component.push({text: '(', color: 'dark_gray'});
|
component.push({ text: '(', color: 'dark_gray' })
|
||||||
component.push({text: changelog.length, color: 'gray'});
|
component.push({ text: changelog.length, color: 'gray' })
|
||||||
component.push({text: ')', color: 'dark_gray'});
|
component.push({ text: ')', color: 'dark_gray' })
|
||||||
component.push({text: ':', color: 'gray'});
|
component.push({ text: ':', color: 'gray' })
|
||||||
component.push('\n');
|
component.push('\n')
|
||||||
changelog.forEach((message, number) => {
|
changelog.forEach((message, number) => {
|
||||||
number += 1;
|
number += 1
|
||||||
component.push({text: number, color: 'gray'});
|
component.push({ text: number, color: 'gray' })
|
||||||
component.push({text: ' - ', color: 'dark_gray'});
|
component.push({ text: ' - ', color: 'dark_gray' })
|
||||||
component.push({text: message, color: 'gray'});
|
component.push({ text: message, color: 'gray' })
|
||||||
component.push('\n');
|
component.push('\n')
|
||||||
});
|
})
|
||||||
component.pop();
|
component.pop()
|
||||||
|
|
||||||
bot.tellraw(selector, component);
|
bot.tellraw(selector, component)
|
||||||
},
|
},
|
||||||
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc) {
|
discordExecute: function (bot, username, usernameraw, sender, prefix, args, channeldc) {
|
||||||
let changelogs = '';
|
let changelogs = ''
|
||||||
changelog.forEach((message, number) => {
|
changelog.forEach((message, number) => {
|
||||||
number += 1;
|
number += 1
|
||||||
changelogs += `\`${number}\` - \`${message}\`` + '\n';
|
changelogs += `\`${number}\` - \`${message}\`` + '\n'
|
||||||
});
|
})
|
||||||
const Embed = new MessageEmbed()
|
const Embed = new MessageEmbed()
|
||||||
.setColor('#FFFF00')
|
.setColor('#FFFF00')
|
||||||
.setTitle(`Changelogs (${changelog.length})`)
|
.setTitle(`Changelogs (${changelog.length})`)
|
||||||
.setDescription(changelogs);
|
.setDescription(changelogs)
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({ embeds: [Embed] })
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
|
|
@ -6,20 +6,18 @@ module.exports = {
|
||||||
description: 'Clears the chat',
|
description: 'Clears the chat',
|
||||||
usage: '[specific] <player>',
|
usage: '[specific] <player>',
|
||||||
trusted: 0,
|
trusted: 0,
|
||||||
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
execute: function (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||||
if (args[0] === 'specific') {
|
if (args[0] === 'specific') {
|
||||||
bot.tellraw(args[1], [{text: `${'\n'.repeat(100)}`, color: 'white'}, {text: `Your chat has been cleared by ${username}.`, color: 'dark_green'}]);
|
bot.tellraw(args[1], [{ text: `${'\n'.repeat(100)}`, color: 'white' }, { text: `Your chat has been cleared by ${username}.`, color: 'dark_green' }])
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
bot.tellraw(selector, [{text: `${'\n'.repeat(100)}`, color: 'white'}, {text: 'The chat has been cleared.', color: 'dark_green'}]);
|
bot.tellraw('@a', [{ text: `${'\n'.repeat(100)}`, color: 'white' }, { text: 'The chat has been cleared.', color: 'dark_green' }])
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) {
|
discordExecute: function (bot, username, usernameraw, sender, prefix, args, channeldc, message) {
|
||||||
if (args[0] === 'specific') {
|
if (args[0] === 'specific') {
|
||||||
bot.tellraw(args[1], [{text: `${'\n'.repeat(100)}`, color: 'white'}, {text: `Your chat has been cleared by ${username} (on Discord).`, color: 'dark_green'}]);
|
bot.tellraw(args[1], [{ text: `${'\n'.repeat(100)}`, color: 'white' }, { text: `Your chat has been cleared by ${username} (on Discord).`, color: 'dark_green' }])
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
bot.tellraw(selector, [{text: `${'\n'.repeat(100)}`, color: 'white'}, {text: 'The chat has been cleared.', color: 'dark_green'}]);
|
bot.tellraw('@a', [{ text: `${'\n'.repeat(100)}`, color: 'white' }, { text: 'The chat has been cleared.', color: 'dark_green' }])
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
|
|
@ -5,14 +5,14 @@ module.exports = {
|
||||||
alias: ['ccq'],
|
alias: ['ccq'],
|
||||||
usage: '',
|
usage: '',
|
||||||
trusted: 0,
|
trusted: 0,
|
||||||
execute: function(bot) {
|
execute: function (bot) {
|
||||||
if (bot.queue[0]) {
|
if (bot.queue[0]) {
|
||||||
bot.chatQueue = [];
|
bot.chatQueue = []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
discordExecute: function(bot) {
|
discordExecute: function (bot) {
|
||||||
if (bot.queue[0]) {
|
if (bot.queue[0]) {
|
||||||
bot.chatQueue = [];
|
bot.chatQueue = []
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
|
|
@ -1,59 +1,59 @@
|
||||||
/* eslint-disable require-jsdoc */
|
/* eslint-disable require-jsdoc */
|
||||||
/* eslint-disable max-len */
|
/* eslint-disable max-len */
|
||||||
const {MessageEmbed} = require('discord.js');
|
const { MessageEmbed } = require('discord.js')
|
||||||
function add(command, interval, bot) {
|
function add (command, interval, bot) {
|
||||||
const id = setInterval(() => bot.core.run(command), interval);
|
const id = setInterval(() => bot.core.run(command), interval)
|
||||||
|
|
||||||
bot.cloops.push({id, interval, command});
|
bot.cloops.push({ id, interval, command })
|
||||||
}
|
}
|
||||||
function remove(item, bot) {
|
function remove (item, bot) {
|
||||||
clearInterval(bot.cloops[item].id);
|
clearInterval(bot.cloops[item].id)
|
||||||
|
|
||||||
bot.cloops.splice(item, 1);
|
bot.cloops.splice(item, 1)
|
||||||
}
|
}
|
||||||
function clear(bot) {
|
function clear (bot) {
|
||||||
for (const interval of bot.cloops) clearInterval(interval.id);
|
for (const interval of bot.cloops) clearInterval(interval.id)
|
||||||
|
|
||||||
bot.cloops = [];
|
bot.cloops = []
|
||||||
}
|
}
|
||||||
function list(bot, discord, channeldc, selector) {
|
function list (bot, discord, channeldc, selector) {
|
||||||
const message = [];
|
const message = []
|
||||||
|
|
||||||
if (discord) {
|
if (discord) {
|
||||||
for (const [id, cloop] of Object.entries(bot.cloops)) {
|
for (const [id, cloop] of Object.entries(bot.cloops)) {
|
||||||
message.push(id);
|
message.push(id)
|
||||||
message.push(' > ');
|
message.push(' > ')
|
||||||
message.push(`\`${cloop.command}\``);
|
message.push(`\`${cloop.command}\``)
|
||||||
message.push(' - ');
|
message.push(' - ')
|
||||||
message.push(cloop.interval);
|
message.push(cloop.interval)
|
||||||
message.push('\n');
|
message.push('\n')
|
||||||
}
|
}
|
||||||
|
|
||||||
message.pop();
|
message.pop()
|
||||||
|
|
||||||
const Embed = new MessageEmbed()
|
const Embed = new MessageEmbed()
|
||||||
.setColor('#FFFF00')
|
.setColor('#FFFF00')
|
||||||
.setTitle('Cloops')
|
.setTitle('Cloops')
|
||||||
.setDescription(message.join(''));
|
.setDescription(message.join(''))
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({ embeds: [Embed] })
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
message.push({text: 'Cloops:', color: 'green'});
|
message.push({ text: 'Cloops:', color: 'green' })
|
||||||
message.push('\n');
|
message.push('\n')
|
||||||
|
|
||||||
for (const [id, cloop] of Object.entries(bot.cloops)) {
|
for (const [id, cloop] of Object.entries(bot.cloops)) {
|
||||||
message.push({text: id, color: 'aqua'});
|
message.push({ text: id, color: 'aqua' })
|
||||||
message.push({text: ' > ', color: 'gold'});
|
message.push({ text: ' > ', color: 'gold' })
|
||||||
message.push({text: cloop.command, color: 'green'});
|
message.push({ text: cloop.command, color: 'green' })
|
||||||
message.push({text: ' - ', color: 'gold'});
|
message.push({ text: ' - ', color: 'gold' })
|
||||||
message.push({text: cloop.interval, color: 'green'});
|
message.push({ text: cloop.interval, color: 'green' })
|
||||||
message.push('\n');
|
message.push('\n')
|
||||||
}
|
}
|
||||||
|
|
||||||
message.pop();
|
message.pop()
|
||||||
|
|
||||||
bot.tellraw(selector, message);
|
bot.tellraw(selector, message)
|
||||||
}
|
}
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'cloop',
|
name: 'cloop',
|
||||||
|
@ -63,55 +63,55 @@ module.exports = {
|
||||||
'<hash> <add> <interval> <command>',
|
'<hash> <add> <interval> <command>',
|
||||||
'<hash> <remove> <index>',
|
'<hash> <remove> <index>',
|
||||||
'<hash> <removeall>',
|
'<hash> <removeall>',
|
||||||
'<hash> <list>',
|
'<hash> <list>'
|
||||||
],
|
],
|
||||||
trusted: 1,
|
trusted: 1,
|
||||||
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
execute: function (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||||
if (!bot.cloops) bot.cloops = [];
|
if (!bot.cloops) bot.cloops = []
|
||||||
if (args[1] === 'add' && args[3]) {
|
if (args[1] === 'add' && args[3]) {
|
||||||
if (!Number(args[2]) && Number(args[2]) !== 0) throw new SyntaxError('Invalid interval');
|
if (!Number(args[2]) && Number(args[2]) !== 0) throw new SyntaxError('Invalid interval')
|
||||||
add(args.slice(3).join(' '), args[2], bot);
|
add(args.slice(3).join(' '), args[2], bot)
|
||||||
bot.tellraw(selector, [{text: 'Added command ', color: 'white'}, {text: `${args.slice(3).join(' ')}`, color: 'aqua'}, {text: ' with interval ', color: 'white'}, {text: `${args[2]}`, color: 'green'}, {text: ' to the cloops', color: 'white'}]);
|
bot.tellraw(selector, [{ text: 'Added command ', color: 'white' }, { text: `${args.slice(3).join(' ')}`, color: 'aqua' }, { text: ' with interval ', color: 'white' }, { text: `${args[2]}`, color: 'green' }, { text: ' to the cloops', color: 'white' }])
|
||||||
} else if (args[1] === 'list') {
|
} else if (args[1] === 'list') {
|
||||||
list(bot, false, null, selector);
|
list(bot, false, null, selector)
|
||||||
} else if (args[1] === 'remove') {
|
} else if (args[1] === 'remove') {
|
||||||
remove(args[2], bot);
|
remove(args[2], bot)
|
||||||
bot.tellraw(selector, [{text: 'Removed cloop '}, {text: args[2], color: 'aqua'}]);
|
bot.tellraw(selector, [{ text: 'Removed cloop ' }, { text: args[2], color: 'aqua' }])
|
||||||
} else if (args[1] === 'removeall') {
|
} else if (args[1] === 'removeall') {
|
||||||
clear(bot);
|
clear(bot)
|
||||||
bot.tellraw(selector, [{text: 'Removed all looped commands', color: 'white'}]);
|
bot.tellraw(selector, [{ text: 'Removed all looped commands', color: 'white' }])
|
||||||
} else {
|
} else {
|
||||||
throw new SyntaxError('Invalid argument');
|
throw new SyntaxError('Invalid argument')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) {
|
discordExecute: function (bot, username, usernameraw, sender, prefix, args, channeldc, message) {
|
||||||
if (!bot.cloops) bot.cloops = [];
|
if (!bot.cloops) bot.cloops = []
|
||||||
if (args[0] === 'add' && args[2]) {
|
if (args[0] === 'add' && args[2]) {
|
||||||
if (!Number(args[1]) && Number(args[1]) !== 0) throw new SyntaxError('Invalid interval');
|
if (!Number(args[1]) && Number(args[1]) !== 0) throw new SyntaxError('Invalid interval')
|
||||||
add(args.slice(2).join(' '), args[1], bot);
|
add(args.slice(2).join(' '), args[1], bot)
|
||||||
const Embed = new MessageEmbed()
|
const Embed = new MessageEmbed()
|
||||||
.setColor('#FFFF00')
|
.setColor('#FFFF00')
|
||||||
.setTitle('Cloop')
|
.setTitle('Cloop')
|
||||||
.setDescription(`Added cloop \`${args.slice(2).join(' ')}\` with interval ${args[1]} to the cloops`);
|
.setDescription(`Added cloop \`${args.slice(2).join(' ')}\` with interval ${args[1]} to the cloops`)
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({ embeds: [Embed] })
|
||||||
} else if (args[0] === 'list') {
|
} else if (args[0] === 'list') {
|
||||||
list(bot, true, channeldc);
|
list(bot, true, channeldc)
|
||||||
} else if (args[0] === 'remove') {
|
} else if (args[0] === 'remove') {
|
||||||
remove(args[1], bot);
|
remove(args[1], bot)
|
||||||
const Embed = new MessageEmbed()
|
const Embed = new MessageEmbed()
|
||||||
.setColor('#FFFF00')
|
.setColor('#FFFF00')
|
||||||
.setTitle('Cloop')
|
.setTitle('Cloop')
|
||||||
.setDescription(`Removed cloop \`${args[1]}\``);
|
.setDescription(`Removed cloop \`${args[1]}\``)
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({ embeds: [Embed] })
|
||||||
} else if (args[0] === 'removeall') {
|
} else if (args[0] === 'removeall') {
|
||||||
clear(bot);
|
clear(bot)
|
||||||
const Embed = new MessageEmbed()
|
const Embed = new MessageEmbed()
|
||||||
.setColor('#FFFF00')
|
.setColor('#FFFF00')
|
||||||
.setTitle('Cloop')
|
.setTitle('Cloop')
|
||||||
.setDescription('Removed all looped commands');
|
.setDescription('Removed all looped commands')
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({ embeds: [Embed] })
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Invalid argument');
|
throw new Error('Invalid argument')
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
|
|
@ -1,22 +1,22 @@
|
||||||
/* eslint-disable max-len */
|
/* eslint-disable max-len */
|
||||||
const cowsay = require('cowsay2');
|
const cowsay = require('cowsay2')
|
||||||
const cows = require('cowsay2/cows');
|
const cows = require('cowsay2/cows')
|
||||||
const {MessageEmbed} = require('discord.js');
|
const { MessageEmbed } = require('discord.js')
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'cowsay',
|
name: 'cowsay',
|
||||||
alias: [],
|
alias: [],
|
||||||
description: 'Moo',
|
description: 'Moo',
|
||||||
usage: [
|
usage: [
|
||||||
'<cow> <message>',
|
'<cow> <message>',
|
||||||
'<list (not support on Discord)>',
|
'<list (not support on Discord)>'
|
||||||
],
|
],
|
||||||
trusted: 0,
|
trusted: 0,
|
||||||
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
execute: function (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||||
if (args[0]==='list') {
|
if (args[0] === 'list') {
|
||||||
const listed = Object.keys(cows);
|
const listed = Object.keys(cows)
|
||||||
|
|
||||||
let primary = true;
|
let primary = true
|
||||||
const message = [];
|
const message = []
|
||||||
|
|
||||||
listed.forEach((value) => {
|
listed.forEach((value) => {
|
||||||
message.push({
|
message.push({
|
||||||
|
@ -24,21 +24,21 @@ module.exports = {
|
||||||
color: (!((primary = !primary)) ? 'gold' : 'yellow'),
|
color: (!((primary = !primary)) ? 'gold' : 'yellow'),
|
||||||
clickEvent: {
|
clickEvent: {
|
||||||
action: 'suggest_command',
|
action: 'suggest_command',
|
||||||
value: `${prefix}cowsay ${value} `,
|
value: `${prefix}cowsay ${value} `
|
||||||
},
|
}
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
|
|
||||||
bot.tellraw(selector, message);
|
bot.tellraw(selector, message)
|
||||||
} else {
|
} else {
|
||||||
bot.tellraw(selector, {text: cowsay.say(args.slice(1).join(' '), {cow: cows[args[0]]})});
|
bot.tellraw(selector, { text: cowsay.say(args.slice(1).join(' '), { cow: cows[args[0]] }) })
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message, config) {
|
discordExecute: function (bot, username, usernameraw, sender, prefix, args, channeldc, message, config) {
|
||||||
const Embed = new MessageEmbed()
|
const Embed = new MessageEmbed()
|
||||||
.setColor('#FFFF00')
|
.setColor('#FFFF00')
|
||||||
.setTitle('Cowsay')
|
.setTitle('Cowsay')
|
||||||
.setDescription(cowsay.say(args.slice(1).join(' '), {cow: cows[args[0]]}));
|
.setDescription(cowsay.say(args.slice(1).join(' '), { cow: cows[args[0]] }))
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({ embeds: [Embed] })
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
/* eslint-disable max-len */
|
/* eslint-disable max-len */
|
||||||
const sleep = require('sleep-promise');
|
const sleep = require('sleep-promise')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* crash server
|
* crash server
|
||||||
* @param {object} bot bot object
|
* @param {object} bot bot object
|
||||||
*/
|
*/
|
||||||
async function crash(bot) {
|
async function crash (bot) {
|
||||||
bot.core.run('data merge storage crash {data:[0]}');
|
bot.core.run('data merge storage crash {data:[0]}')
|
||||||
|
|
||||||
await sleep(1000);
|
await sleep(1000)
|
||||||
|
|
||||||
for (let i = 0; i < 256; i++) bot.core.run('data modify storage crash data append from storage crash data[]');
|
for (let i = 0; i < 256; i++) bot.core.run('data modify storage crash data append from storage crash data[]')
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
@ -19,10 +19,10 @@ module.exports = {
|
||||||
description: 'Crashes the server',
|
description: 'Crashes the server',
|
||||||
usage: '<hash>',
|
usage: '<hash>',
|
||||||
trusted: 1,
|
trusted: 1,
|
||||||
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
execute: function (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||||
crash(bot);
|
crash(bot)
|
||||||
},
|
},
|
||||||
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) {
|
discordExecute: function (bot, username, usernameraw, sender, prefix, args, channeldc, message) {
|
||||||
crash(bot);
|
crash(bot)
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
/* eslint-disable max-len */
|
/* eslint-disable max-len */
|
||||||
const {MessageEmbed} = require('discord.js');
|
const { MessageEmbed } = require('discord.js')
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'creator',
|
name: 'creator',
|
||||||
alias: [],
|
alias: [],
|
||||||
description: 'Shows the bot\'s creator',
|
description: 'Shows the bot\'s creator',
|
||||||
usage: '',
|
usage: '',
|
||||||
trusted: 0,
|
trusted: 0,
|
||||||
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
execute: function (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||||
bot.tellraw(selector, [{text: 'ChomeNS Bot ', color: 'yellow'}, {text: 'was created by ', color: 'white'}, {text: 'chayapak', color: 'gold'}]);
|
bot.tellraw(selector, [{ text: 'ChomeNS Bot ', color: 'yellow' }, { text: 'was created by ', color: 'white' }, { text: 'chayapak', color: 'gold' }])
|
||||||
},
|
},
|
||||||
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) {
|
discordExecute: function (bot, username, usernameraw, sender, prefix, args, channeldc, message) {
|
||||||
const Embed = new MessageEmbed()
|
const Embed = new MessageEmbed()
|
||||||
.setColor('#FFFF00')
|
.setColor('#FFFF00')
|
||||||
.setTitle('Creator')
|
.setTitle('Creator')
|
||||||
.setDescription('ChomeNS Bot was created by chayapak');
|
.setDescription('ChomeNS Bot was created by chayapak')
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({ embeds: [Embed] })
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
|
|
@ -5,20 +5,20 @@ module.exports = {
|
||||||
description: 'Shows the discord invite',
|
description: 'Shows the discord invite',
|
||||||
usage: '',
|
usage: '',
|
||||||
trusted: 0,
|
trusted: 0,
|
||||||
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
execute: function (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||||
bot.tellraw(selector, [
|
bot.tellraw(selector, [
|
||||||
{
|
{
|
||||||
text: 'The Discord invite is ',
|
text: 'The Discord invite is ',
|
||||||
color: 'white',
|
color: 'white'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: 'https://discord.gg/xdgCkUyaA4',
|
text: 'https://discord.gg/xdgCkUyaA4',
|
||||||
color: 'blue',
|
color: 'blue',
|
||||||
clickEvent: {
|
clickEvent: {
|
||||||
action: 'open_url',
|
action: 'open_url',
|
||||||
value: 'https://discord.gg/xdgCkUyaA4',
|
value: 'https://discord.gg/xdgCkUyaA4'
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
]);
|
])
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* eslint-disable max-len */
|
/* eslint-disable max-len */
|
||||||
const {resize} = require('../util/image');
|
const { resize } = require('../util/image')
|
||||||
const axios = require('axios');
|
const axios = require('axios')
|
||||||
const sharp = require('sharp');
|
const sharp = require('sharp')
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'draw',
|
name: 'draw',
|
||||||
|
@ -9,32 +9,32 @@ module.exports = {
|
||||||
alias: [],
|
alias: [],
|
||||||
trusted: 0,
|
trusted: 0,
|
||||||
usage: '<image url (JPEG, PNG, WebP, AVIF, GIF, SVG, TIFF)>',
|
usage: '<image url (JPEG, PNG, WebP, AVIF, GIF, SVG, TIFF)>',
|
||||||
execute: async function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
execute: async function (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||||
try {
|
try {
|
||||||
const url = args.join(' ');
|
const url = args.join(' ')
|
||||||
|
|
||||||
const image = await axios.get('https://http-proxy.nongsonchome.repl.co', {
|
const image = await axios.get('https://http-proxy.nongsonchome.repl.co', {
|
||||||
params: {
|
params: {
|
||||||
uri: url,
|
uri: url
|
||||||
},
|
},
|
||||||
responseType: 'arraybuffer',
|
responseType: 'arraybuffer'
|
||||||
});
|
})
|
||||||
|
|
||||||
const loaded = sharp(image.data);
|
const loaded = sharp(image.data)
|
||||||
|
|
||||||
const metadata = await loaded
|
const metadata = await loaded
|
||||||
.metadata();
|
.metadata()
|
||||||
|
|
||||||
const {width, height} = resize(metadata.width, metadata.height);
|
const { width, height } = resize(metadata.width, metadata.height)
|
||||||
|
|
||||||
const {data, info} = await loaded
|
const { data, info } = await loaded
|
||||||
.resize({fit: 'fill', kernel: 'nearest', width, height})
|
.resize({ fit: 'fill', kernel: 'nearest', width, height })
|
||||||
.raw()
|
.raw()
|
||||||
.toBuffer({resolveWithObject: true});
|
.toBuffer({ resolveWithObject: true })
|
||||||
|
|
||||||
bot.draw(data, info);
|
bot.draw(data, info)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
bot.tellraw(selector, {text: 'SyntaxError: Invalid URL', color: 'red'});
|
bot.tellraw(selector, { text: 'SyntaxError: Invalid URL', color: 'red' })
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
|
|
@ -5,18 +5,18 @@ module.exports = {
|
||||||
description: 'Lags Eaglercraft and crashes it',
|
description: 'Lags Eaglercraft and crashes it',
|
||||||
usage: '<on|off> <hash>',
|
usage: '<on|off> <hash>',
|
||||||
trusted: 1,
|
trusted: 1,
|
||||||
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
execute: function (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||||
if (args[1] === 'on') {
|
if (args[1] === 'on') {
|
||||||
bot.eaglercrashstarted = true;
|
bot.eaglercrashstarted = true
|
||||||
bot.eaglercrash = setInterval(async function() {
|
bot.eaglercrash = setInterval(async function () {
|
||||||
if (bot.eaglercrashstarted === true) return bot.core.run('minecraft:playsound block.note_block.harp record @a ~ ~ ~ 100000000000000000000000000000000000000 1 0');
|
if (bot.eaglercrashstarted === true) return bot.core.run('minecraft:playsound block.note_block.harp record @a ~ ~ ~ 100000000000000000000000000000000000000 1 0')
|
||||||
}, 0);
|
}, 0)
|
||||||
bot.core.run('minecraft:tellraw @a ["",{"text":"Eaglercrash started","color":"white"}]');
|
bot.core.run('minecraft:tellraw @a ["",{"text":"Eaglercrash started","color":"white"}]')
|
||||||
}
|
}
|
||||||
if (args[1] === 'off') {
|
if (args[1] === 'off') {
|
||||||
clearInterval(bot.eaglercrash);
|
clearInterval(bot.eaglercrash)
|
||||||
bot.eaglercrashstarted = false;
|
bot.eaglercrashstarted = false
|
||||||
bot.core.run('minecraft:tellraw @a ["",{"text":"Eaglercrash stopped","color":"white"}]');
|
bot.core.run('minecraft:tellraw @a ["",{"text":"Eaglercrash stopped","color":"white"}]')
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
|
|
@ -5,10 +5,10 @@ module.exports = {
|
||||||
description: 'Says a message',
|
description: 'Says a message',
|
||||||
usage: '<message>',
|
usage: '<message>',
|
||||||
trusted: 0,
|
trusted: 0,
|
||||||
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
execute: function (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||||
bot.chat(args.join(' '));
|
bot.chat(args.join(' '))
|
||||||
},
|
},
|
||||||
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc) {
|
discordExecute: function (bot, username, usernameraw, sender, prefix, args, channeldc) {
|
||||||
bot.chat(args.join(' '));
|
bot.chat(args.join(' '))
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
|
|
@ -5,10 +5,10 @@ module.exports = {
|
||||||
description: 'Ends the bot\'s client',
|
description: 'Ends the bot\'s client',
|
||||||
usage: '<hash>',
|
usage: '<hash>',
|
||||||
trusted: 1,
|
trusted: 1,
|
||||||
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
execute: function (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||||
bot.end('end command');
|
bot.end('end command')
|
||||||
},
|
},
|
||||||
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) {
|
discordExecute: function (bot, username, usernameraw, sender, prefix, args, channeldc, message) {
|
||||||
bot.end('end command');
|
bot.end('end command')
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
|
|
@ -5,11 +5,11 @@ module.exports = {
|
||||||
description: 'Summon any entity!',
|
description: 'Summon any entity!',
|
||||||
usage: '[specific] <player>',
|
usage: '[specific] <player>',
|
||||||
trusted: 0,
|
trusted: 0,
|
||||||
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
execute: function (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
const mcData = require('minecraft-data')(bot.version);
|
const mcData = require('minecraft-data')(bot.version)
|
||||||
|
|
||||||
throw new Error('Execute Bypass is patched so this command will be broken for now!');
|
throw new Error('Execute Bypass is patched so this command will be broken for now!')
|
||||||
// if (!args[0]) return;
|
// if (!args[0]) return;
|
||||||
// const entity = mcData.entitiesByName[args[0]];
|
// const entity = mcData.entitiesByName[args[0]];
|
||||||
// if (!entity) throw new SyntaxError('Invalid entity');
|
// if (!entity) throw new SyntaxError('Invalid entity');
|
||||||
|
@ -20,5 +20,5 @@ module.exports = {
|
||||||
// bot.core.run('minecraft:execute unless entity @s[name= run ] run execute as @a at ' + args[2] + ' run summon minecraft:' + entity.name);
|
// bot.core.run('minecraft:execute unless entity @s[name= run ] run execute as @a at ' + args[2] + ' run summon minecraft:' + entity.name);
|
||||||
// bot.tellraw(selector, [{text: `Entity `, color: 'white'}, {text: entity.displayName, color: 'green'}, {text: ' spawning at ', color: 'white'}, {text: `${args[2]}`, color: 'aqua'}]);
|
// bot.tellraw(selector, [{text: `Entity `, color: 'white'}, {text: entity.displayName, color: 'green'}, {text: ' spawning at ', color: 'white'}, {text: `${args[2]}`, color: 'aqua'}]);
|
||||||
// }
|
// }
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
/* eslint-disable max-len */
|
/* eslint-disable max-len */
|
||||||
const {MessageEmbed} = require('discord.js');
|
const { MessageEmbed } = require('discord.js')
|
||||||
const {VM} = require('vm2');
|
const { VM } = require('vm2')
|
||||||
const axios = require('axios');
|
const axios = require('axios')
|
||||||
const util = require('util');
|
const util = require('util')
|
||||||
const querystring = require('querystring');
|
const querystring = require('querystring')
|
||||||
const {stylize} = require('../util/colors/minecraft');
|
const { stylize } = require('../util/colors/minecraft')
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'eval',
|
name: 'eval',
|
||||||
alias: [],
|
alias: [],
|
||||||
|
@ -13,18 +13,18 @@ module.exports = {
|
||||||
usage: [
|
usage: [
|
||||||
'<run> <code>',
|
'<run> <code>',
|
||||||
'<reset>',
|
'<reset>',
|
||||||
'<server (eval server)> <code>',
|
'<server (eval server)> <code>'
|
||||||
],
|
],
|
||||||
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
execute: function (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||||
if (args[0] === 'run') {
|
if (args[0] === 'run') {
|
||||||
try {
|
try {
|
||||||
bot.tellraw(selector, {text: `${util.inspect(bot.vm.run(args.slice(1).join(' ')), {stylize: stylize})}`.substring(0, 32000)});
|
bot.tellraw(selector, { text: `${util.inspect(bot.vm.run(args.slice(1).join(' ')), { stylize })}`.substring(0, 32000) })
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
bot.tellraw(selector, {text: `${util.inspect(err).replaceAll('runner', 'chayapak1')}`, color: 'red'});
|
bot.tellraw(selector, { text: `${util.inspect(err).replaceAll('runner', 'chayapak1')}`, color: 'red' })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (args[0] === 'reset') {
|
if (args[0] === 'reset') {
|
||||||
bot.vm = new VM(bot.vmoptions);
|
bot.vm = new VM(bot.vmoptions)
|
||||||
}
|
}
|
||||||
if (args[0] === 'server') {
|
if (args[0] === 'server') {
|
||||||
axios
|
axios
|
||||||
|
@ -32,44 +32,40 @@ module.exports = {
|
||||||
html: false,
|
html: false,
|
||||||
showErrorMsg: false,
|
showErrorMsg: false,
|
||||||
colors: 'minecraft',
|
colors: 'minecraft',
|
||||||
code: args[1],
|
code: args[1]
|
||||||
})).then((res) => {
|
})).then((res) => {
|
||||||
bot.tellraw(selector, {text: `${res.data}`});
|
bot.tellraw(selector, { text: `${res.data}` })
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
bot.tellraw(selector, {text: `${err}`, color: 'red'});
|
bot.tellraw(selector, { text: `${err}`, color: 'red' })
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message, config) {
|
discordExecute: function (bot, username, usernameraw, sender, prefix, args, channeldc, message, config) {
|
||||||
if (args[0] === 'run') {
|
if (args[0] === 'run') {
|
||||||
try {
|
|
||||||
const Embed = new MessageEmbed()
|
const Embed = new MessageEmbed()
|
||||||
.setColor('#FFFF00')
|
.setColor('#FFFF00')
|
||||||
.setTitle('Output')
|
.setTitle('Output')
|
||||||
.setDescription(`\`\`\`${util.inspect(bot.vm.run(args.slice(1).join(' '))).substring(0, 1950)}\`\`\``);
|
.setDescription(`\`\`\`${util.inspect(bot.vm.run(args.slice(1).join(' '))).substring(0, 1950)}\`\`\``)
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({ embeds: [Embed] })
|
||||||
} catch (err) {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
} else if (args[0] === 'reset') {
|
} else if (args[0] === 'reset') {
|
||||||
bot.vm = new VM(bot.vmoptions);
|
bot.vm = new VM(bot.vmoptions)
|
||||||
} else if (args[0] === 'server') {
|
} else if (args[0] === 'server') {
|
||||||
axios
|
axios
|
||||||
.post(config.eval.serverUrl, querystring.stringify({
|
.post(config.eval.serverUrl, querystring.stringify({
|
||||||
html: false,
|
html: false,
|
||||||
showErrorMsg: false,
|
showErrorMsg: false,
|
||||||
code: args[1],
|
code: args[1]
|
||||||
})).then((res) => {
|
})).then((res) => {
|
||||||
const Embed = new MessageEmbed()
|
const Embed = new MessageEmbed()
|
||||||
.setColor('#FFFF00')
|
.setColor('#FFFF00')
|
||||||
.setTitle('Output')
|
.setTitle('Output')
|
||||||
.setDescription(`\`\`\`${res.data}\`\`\``);
|
.setDescription(`\`\`\`${res.data}\`\`\``)
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({ embeds: [Embed] })
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
throw err;
|
throw err
|
||||||
});
|
})
|
||||||
} else {
|
} else {
|
||||||
throw new SyntaxError('Invalid argument');
|
throw new SyntaxError('Invalid argument')
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ module.exports = {
|
||||||
description: 'Execute command bypassed',
|
description: 'Execute command bypassed',
|
||||||
usage: '<hash> <command>',
|
usage: '<hash> <command>',
|
||||||
trusted: 1,
|
trusted: 1,
|
||||||
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
execute: function (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||||
bot.core.run('minecraft:execute unless entity @s[name= run ] run ' + args.slice(1).join(' '));
|
bot.core.run('minecraft:execute unless entity @s[name= run ] run ' + args.slice(1).join(' '))
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ module.exports = {
|
||||||
description: 'Gamemode everyone',
|
description: 'Gamemode everyone',
|
||||||
usage: '<hash> <gamemode>',
|
usage: '<hash> <gamemode>',
|
||||||
trusted: 1,
|
trusted: 1,
|
||||||
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
execute: function (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||||
bot.core.run(`minecraft:execute unless entity @s[name= run ] run gamemode ${args[1]} @a[name=!${bot.username}]`);
|
bot.core.run(`minecraft:execute unless entity @s[name= run ] run gamemode ${args[1]} @a[name=!${bot.username}]`)
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
|
130
commands/help.js
130
commands/help.js
|
@ -1,69 +1,69 @@
|
||||||
/* eslint-disable require-jsdoc */
|
/* eslint-disable require-jsdoc */
|
||||||
/* eslint-disable no-var */
|
/* eslint-disable no-var */
|
||||||
/* eslint-disable max-len */
|
/* eslint-disable max-len */
|
||||||
const {MessageEmbed} = require('discord.js');
|
const { MessageEmbed } = require('discord.js')
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'help',
|
name: 'help',
|
||||||
alias: ['heko', 'cmds', 'commands'],
|
alias: ['heko', 'cmds', 'commands'],
|
||||||
description: 'Shows the help',
|
description: 'Shows the help',
|
||||||
usage: '[command]',
|
usage: '[command]',
|
||||||
trusted: 0,
|
trusted: 0,
|
||||||
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
execute: function (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||||
if (args[0]) {
|
if (args[0]) {
|
||||||
for (const command of bot.command_handler.commands) {
|
for (const command of bot.command_handler.commands) {
|
||||||
function run() {
|
function run () {
|
||||||
let alias = command.name;
|
let alias = command.name
|
||||||
|
|
||||||
if (command.alias.toString() !== '') {
|
if (command.alias.toString() !== '') {
|
||||||
alias = command.alias.join(', ');
|
alias = command.alias.join(', ')
|
||||||
}
|
}
|
||||||
|
|
||||||
const usage = [];
|
const usage = []
|
||||||
if (typeof command.usage === 'string') {
|
if (typeof command.usage === 'string') {
|
||||||
usage.push({text: `${prefix}${command.name} `, color: 'gold'});
|
usage.push({ text: `${prefix}${command.name} `, color: 'gold' })
|
||||||
usage.push({text: command.usage, color: 'aqua'});
|
usage.push({ text: command.usage, color: 'aqua' })
|
||||||
} else {
|
} else {
|
||||||
command.usage.forEach((value) => {
|
command.usage.forEach((value) => {
|
||||||
usage.push({text: `${prefix}${command.name} `, color: 'gold'});
|
usage.push({ text: `${prefix}${command.name} `, color: 'gold' })
|
||||||
usage.push({text: value, color: 'aqua'});
|
usage.push({ text: value, color: 'aqua' })
|
||||||
usage.push('\n');
|
usage.push('\n')
|
||||||
});
|
})
|
||||||
usage.pop();
|
usage.pop()
|
||||||
}
|
}
|
||||||
|
|
||||||
const component = [];
|
const component = []
|
||||||
component.push({text: prefix + command.name, color: 'gold'});
|
component.push({ text: prefix + command.name, color: 'gold' })
|
||||||
component.push({text: ` (${alias})`, color: 'white'});
|
component.push({ text: ` (${alias})`, color: 'white' })
|
||||||
component.push({text: ' - ', color: 'gray'});
|
component.push({ text: ' - ', color: 'gray' })
|
||||||
component.push({text: command.description, color: 'gray'});
|
component.push({ text: command.description, color: 'gray' })
|
||||||
|
|
||||||
component.push('\n');
|
component.push('\n')
|
||||||
|
|
||||||
component.push({text: 'Trust level: ', color: 'green'});
|
component.push({ text: 'Trust level: ', color: 'green' })
|
||||||
component.push({text: command.trusted, color: 'yellow'});
|
component.push({ text: command.trusted, color: 'yellow' })
|
||||||
|
|
||||||
component.push('\n');
|
component.push('\n')
|
||||||
|
|
||||||
component.push({text: 'Supported on Discord: ', color: 'green'});
|
component.push({ text: 'Supported on Discord: ', color: 'green' })
|
||||||
component.push({text: command.discordExecute ? 'true' : 'false', color: 'gold'});
|
component.push({ text: command.discordExecute ? 'true' : 'false', color: 'gold' })
|
||||||
|
|
||||||
component.push('\n');
|
component.push('\n')
|
||||||
|
|
||||||
component.push(usage);
|
component.push(usage)
|
||||||
|
|
||||||
bot.tellraw(selector, component);
|
bot.tellraw(selector, component)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command.name === args[0]) run();
|
if (command.name === args[0]) run()
|
||||||
for (const alias of command.alias) {
|
for (const alias of command.alias) {
|
||||||
if (alias === args[0]) run();
|
if (alias === args[0]) run()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
const generalCommands = [];
|
const generalCommands = []
|
||||||
const trustedCommands = [];
|
const trustedCommands = []
|
||||||
const ownerCommands = [];
|
const ownerCommands = []
|
||||||
function component(command, color) {
|
function component (command, color) {
|
||||||
return {
|
return {
|
||||||
text: command.name + ' ',
|
text: command.name + ' ',
|
||||||
color,
|
color,
|
||||||
|
@ -71,72 +71,72 @@ module.exports = {
|
||||||
action: 'show_text',
|
action: 'show_text',
|
||||||
contents: [{
|
contents: [{
|
||||||
text: 'Click here to see the information for this command',
|
text: 'Click here to see the information for this command',
|
||||||
color: 'green',
|
color: 'green'
|
||||||
}],
|
}]
|
||||||
},
|
},
|
||||||
clickEvent: {
|
clickEvent: {
|
||||||
action: 'run_command',
|
action: 'run_command',
|
||||||
value: `${prefix}help ${command.name}`,
|
value: `${prefix}help ${command.name}`
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
};
|
};
|
||||||
for (const command of bot.command_handler.commands) {
|
for (const command of bot.command_handler.commands) {
|
||||||
if (command.trusted !== 0) continue;
|
if (command.trusted !== 0) continue
|
||||||
generalCommands.push(component(command, 'green'));
|
generalCommands.push(component(command, 'green'))
|
||||||
}
|
}
|
||||||
for (const command of bot.command_handler.commands) {
|
for (const command of bot.command_handler.commands) {
|
||||||
if (command.trusted !== 1) continue;
|
if (command.trusted !== 1) continue
|
||||||
trustedCommands.push(component(command, 'red'));
|
trustedCommands.push(component(command, 'red'))
|
||||||
}
|
}
|
||||||
for (const command of bot.command_handler.commands) {
|
for (const command of bot.command_handler.commands) {
|
||||||
if (command.trusted !== 2) continue;
|
if (command.trusted !== 2) continue
|
||||||
ownerCommands.push(component(command, 'dark_red'));
|
ownerCommands.push(component(command, 'dark_red'))
|
||||||
}
|
}
|
||||||
|
|
||||||
const pre = [{text: 'Commands ', color: 'gray'}, {text: '(', color: 'dark_gray'}, {text: 'Length: ', color: 'gray'}, {text: bot.command_handler.commands.length, color: 'green'}, {text: ') ', color: 'dark_gray'}, {text: '(', color: 'dark_gray'}, {text: '⬤ Public', color: 'green'}, {text: ' ⬤ Trusted', color: 'red'}, {text: ' ⬤ Owner', color: 'dark_red'}, {text: ') - ', color: 'dark_gray'}];
|
const pre = [{ text: 'Commands ', color: 'gray' }, { text: '(', color: 'dark_gray' }, { text: 'Length: ', color: 'gray' }, { text: bot.command_handler.commands.length, color: 'green' }, { text: ') ', color: 'dark_gray' }, { text: '(', color: 'dark_gray' }, { text: '⬤ Public', color: 'green' }, { text: ' ⬤ Trusted', color: 'red' }, { text: ' ⬤ Owner', color: 'dark_red' }, { text: ') - ', color: 'dark_gray' }]
|
||||||
bot.tellraw(selector, [pre, generalCommands, trustedCommands, ownerCommands]);
|
bot.tellraw(selector, [pre, generalCommands, trustedCommands, ownerCommands])
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
discordExecute: async function(bot, username, usernameraw, sender, prefix, args, channeldc) {
|
discordExecute: async function (bot, username, usernameraw, sender, prefix, args, channeldc) {
|
||||||
if (args[0]) {
|
if (args[0]) {
|
||||||
for (const command of bot.command_handler.commands) {
|
for (const command of bot.command_handler.commands) {
|
||||||
function run() {
|
function run () {
|
||||||
let alias = command.name;
|
let alias = command.name
|
||||||
|
|
||||||
if (command.alias.toString() !== '') {
|
if (command.alias.toString() !== '') {
|
||||||
alias = command.alias.join(', ');
|
alias = command.alias.join(', ')
|
||||||
}
|
}
|
||||||
const Embed = new MessageEmbed()
|
const Embed = new MessageEmbed()
|
||||||
.setColor('#FFFF00')
|
.setColor('#FFFF00')
|
||||||
.setTitle(`${prefix + command.name} (${alias}) - ${command.description}`)
|
.setTitle(`${prefix + command.name} (${alias}) - ${command.description}`)
|
||||||
.setDescription(`Trust level: ${command.trusted}
|
.setDescription(`Trust level: ${command.trusted}
|
||||||
Supported: ${command.discordExecute ? 'true' : 'false'}
|
Supported: ${command.discordExecute ? 'true' : 'false'}
|
||||||
${prefix + command.name} ${command.usage}`,
|
${prefix + command.name} ${command.usage}`
|
||||||
);
|
)
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({ embeds: [Embed] })
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command.name === args[0]) run();
|
if (command.name === args[0]) run()
|
||||||
for (const alias of command.alias) {
|
for (const alias of command.alias) {
|
||||||
if (alias === args[0]) run();
|
if (alias === args[0]) run()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
let supportedCommands = '';
|
let supportedCommands = ''
|
||||||
let unsupportedCommands = '';
|
let unsupportedCommands = ''
|
||||||
for (const command of bot.command_handler.commands) {
|
for (const command of bot.command_handler.commands) {
|
||||||
if (!command.discordExecute) continue;
|
if (!command.discordExecute) continue
|
||||||
supportedCommands += command.name + ' ';
|
supportedCommands += command.name + ' '
|
||||||
}
|
}
|
||||||
for (const command of bot.command_handler.commands) {
|
for (const command of bot.command_handler.commands) {
|
||||||
if (command.discordExecute) continue;
|
if (command.discordExecute) continue
|
||||||
unsupportedCommands += command.name + ' ';
|
unsupportedCommands += command.name + ' '
|
||||||
}
|
}
|
||||||
const Embed = new MessageEmbed()
|
const Embed = new MessageEmbed()
|
||||||
.setColor('#FFFF00')
|
.setColor('#FFFF00')
|
||||||
.setTitle(`Commands (Length: ${bot.command_handler.commands.length})`)
|
.setTitle(`Commands (Length: ${bot.command_handler.commands.length})`)
|
||||||
.setDescription('**Supported Commands**\n' + supportedCommands + '\n**Unsupported Commands**\n' + unsupportedCommands);
|
.setDescription('**Supported Commands**\n' + supportedCommands + '\n**Unsupported Commands**\n' + unsupportedCommands)
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({ embeds: [Embed] })
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
/* eslint-disable max-len */
|
/* eslint-disable max-len */
|
||||||
const {MessageEmbed} = require('discord.js');
|
const { MessageEmbed } = require('discord.js')
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'list',
|
name: 'list',
|
||||||
alias: [],
|
alias: [],
|
||||||
description: 'List players',
|
description: 'List players',
|
||||||
usage: '',
|
usage: '',
|
||||||
trusted: 0,
|
trusted: 0,
|
||||||
execute: async function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
execute: async function (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||||
try {
|
try {
|
||||||
const component = [];
|
const component = []
|
||||||
component.push({text: 'Players ', color: 'green'});
|
component.push({ text: 'Players ', color: 'green' })
|
||||||
component.push({text: '(', color: 'dark_gray'});
|
component.push({ text: '(', color: 'dark_gray' })
|
||||||
component.push({text: bot.players.list.length, color: 'gray'});
|
component.push({ text: bot.players.list.length, color: 'gray' })
|
||||||
component.push({text: ')', color: 'dark_gray'});
|
component.push({ text: ')', color: 'dark_gray' })
|
||||||
component.push('\n');
|
component.push('\n')
|
||||||
for (const property of bot.players.list) {
|
for (const property of bot.players.list) {
|
||||||
// if (property.match.startsWith('@')) continue;
|
// if (property.match.startsWith('@')) continue;
|
||||||
component.push({
|
component.push({
|
||||||
|
@ -21,57 +21,57 @@ module.exports = {
|
||||||
color: 'yellow',
|
color: 'yellow',
|
||||||
clickEvent: {
|
clickEvent: {
|
||||||
action: 'copy_to_clipboard',
|
action: 'copy_to_clipboard',
|
||||||
value: property.name,
|
value: property.name
|
||||||
},
|
},
|
||||||
hoverEvent: {
|
hoverEvent: {
|
||||||
action: 'show_text',
|
action: 'show_text',
|
||||||
contents: [{
|
contents: [{
|
||||||
text: 'Click here to copy the username to your clipboard',
|
text: 'Click here to copy the username to your clipboard',
|
||||||
color: 'green',
|
color: 'green'
|
||||||
}],
|
}]
|
||||||
},
|
}
|
||||||
});
|
})
|
||||||
component.push({
|
component.push({
|
||||||
text: ' › ',
|
text: ' › ',
|
||||||
color: 'dark_gray',
|
color: 'dark_gray'
|
||||||
});
|
})
|
||||||
component.push({
|
component.push({
|
||||||
text: property.UUID,
|
text: property.UUID,
|
||||||
color: 'aqua',
|
color: 'aqua',
|
||||||
clickEvent: {
|
clickEvent: {
|
||||||
action: 'copy_to_clipboard',
|
action: 'copy_to_clipboard',
|
||||||
value: property.UUID,
|
value: property.UUID
|
||||||
},
|
},
|
||||||
hoverEvent: {
|
hoverEvent: {
|
||||||
action: 'show_text',
|
action: 'show_text',
|
||||||
contents: [{
|
contents: [{
|
||||||
text: 'Click here to copy the UUID to your clipboard',
|
text: 'Click here to copy the UUID to your clipboard',
|
||||||
color: 'green',
|
color: 'green'
|
||||||
}],
|
}]
|
||||||
},
|
|
||||||
});
|
|
||||||
component.push('\n');
|
|
||||||
}
|
}
|
||||||
component.pop();
|
})
|
||||||
bot.tellraw(selector, component);
|
component.push('\n')
|
||||||
|
}
|
||||||
|
component.pop()
|
||||||
|
bot.tellraw(selector, component)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc) {
|
discordExecute: function (bot, username, usernameraw, sender, prefix, args, channeldc) {
|
||||||
try {
|
try {
|
||||||
let players = '';
|
let players = ''
|
||||||
for (const property of bot.players.list) {
|
for (const property of bot.players.list) {
|
||||||
// if (property.match.startsWith('@')) continue;
|
// if (property.match.startsWith('@')) continue;
|
||||||
players += `\`${property.name}\` › \`${property.UUID}\`` + '\n';
|
players += `\`${property.name}\` › \`${property.UUID}\`` + '\n'
|
||||||
}
|
}
|
||||||
const Embed = new MessageEmbed()
|
const Embed = new MessageEmbed()
|
||||||
.setColor('#FFFF00')
|
.setColor('#FFFF00')
|
||||||
.setTitle(`Players (${bot.players.list.length})`)
|
.setTitle(`Players (${bot.players.list.length})`)
|
||||||
.setDescription(players.substring(0, 4096));
|
.setDescription(players.substring(0, 4096))
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({ embeds: [Embed] })
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
|
|
@ -1,144 +1,147 @@
|
||||||
|
/* eslint-disable no-case-declarations */
|
||||||
/* eslint-disable require-jsdoc */
|
/* eslint-disable require-jsdoc */
|
||||||
/* eslint-disable max-len */
|
/* eslint-disable max-len */
|
||||||
const fs = require('fs/promises');
|
const fs = require('fs/promises')
|
||||||
const {MessageEmbed} = require('discord.js');
|
const { MessageEmbed } = require('discord.js')
|
||||||
const path = require('path');
|
const path = require('path')
|
||||||
const fileExists = require('../util/file-exists');
|
const fileExists = require('../util/file-exists')
|
||||||
const fileList = require('../util/file-list');
|
const fileList = require('../util/file-list')
|
||||||
const axios = require('axios');
|
const axios = require('axios')
|
||||||
const os = require('os');
|
const os = require('os')
|
||||||
|
|
||||||
let SONGS_PATH;
|
let SONGS_PATH
|
||||||
|
|
||||||
if (os.hostname() === 'chomens-kubuntu') {
|
if (os.hostname() === 'chomens-kubuntu') {
|
||||||
SONGS_PATH = path.join(__dirname, '..', '..', 'nginx-html', 'midis');
|
SONGS_PATH = path.join(__dirname, '..', '..', 'nginx-html', 'midis')
|
||||||
} else {
|
} else {
|
||||||
SONGS_PATH = path.join(__dirname, '..', 'midis');
|
SONGS_PATH = path.join(__dirname, '..', 'midis')
|
||||||
}
|
}
|
||||||
|
|
||||||
async function play(bot, values, discord, channeldc, selector) {
|
let song
|
||||||
|
|
||||||
|
async function play (bot, values, discord, channeldc, selector) {
|
||||||
try {
|
try {
|
||||||
const filepath = values.join(' ');
|
const filepath = values.join(' ')
|
||||||
const absolutePath = await resolve(filepath);
|
const absolutePath = await resolve(filepath)
|
||||||
song = bot.music.load(await fs.readFile(absolutePath), path.basename(absolutePath));
|
song = bot.music.load(await fs.readFile(absolutePath), path.basename(absolutePath))
|
||||||
bot.music.queue.push(song);
|
bot.music.queue.push(song)
|
||||||
bot.music.play(song);
|
bot.music.play(song)
|
||||||
if (discord) {
|
if (discord) {
|
||||||
const Embed = new MessageEmbed()
|
const Embed = new MessageEmbed()
|
||||||
.setColor('#FFFF00')
|
.setColor('#FFFF00')
|
||||||
.setTitle('Music')
|
.setTitle('Music')
|
||||||
.setDescription(`Added ${song.name} to the song queue`);
|
.setDescription(`Added ${song.name} to the song queue`)
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({ embeds: [Embed] })
|
||||||
} else {
|
} else {
|
||||||
bot.tellraw(selector, [{text: 'Added ', color: 'white'}, {text: song.name, color: 'gold'}, {text: ' to the song queue', color: 'white'}]);
|
bot.tellraw(selector, [{ text: 'Added ', color: 'white' }, { text: song.name, color: 'gold' }, { text: ' to the song queue', color: 'white' }])
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (discord) {
|
if (discord) {
|
||||||
const Embed = new MessageEmbed()
|
const Embed = new MessageEmbed()
|
||||||
.setColor('#FF0000')
|
.setColor('#FF0000')
|
||||||
.setTitle('Error')
|
.setTitle('Error')
|
||||||
.setDescription(`\`\`\`SyntaxError: Invalid file\`\`\``);
|
.setDescription('```SyntaxError: Invalid file```')
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({ embeds: [Embed] })
|
||||||
} else {
|
} else {
|
||||||
bot.tellraw(selector, {text: 'SyntaxError: Invalid file', color: 'red'});
|
bot.tellraw(selector, { text: 'SyntaxError: Invalid file', color: 'red' })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function playUrl(bot, values, discord, channeldc, selector) {
|
async function playUrl (bot, values, discord, channeldc, selector) {
|
||||||
try {
|
try {
|
||||||
const url = values.join(' ');
|
const url = values.join(' ')
|
||||||
const response = await axios.get('https://http-proxy.nongsonchome.repl.co', {
|
const response = await axios.get('https://http-proxy.nongsonchome.repl.co', {
|
||||||
params: {
|
params: {
|
||||||
uri: url,
|
uri: url
|
||||||
},
|
},
|
||||||
responseType: 'arraybuffer',
|
responseType: 'arraybuffer'
|
||||||
});
|
})
|
||||||
song = bot.music.load(response.data, url);
|
song = bot.music.load(response.data, url)
|
||||||
bot.music.queue.push(song);
|
bot.music.queue.push(song)
|
||||||
bot.music.play(song);
|
bot.music.play(song)
|
||||||
if (discord) {
|
if (discord) {
|
||||||
const Embed = new MessageEmbed()
|
const Embed = new MessageEmbed()
|
||||||
.setColor('#FFFF00')
|
.setColor('#FFFF00')
|
||||||
.setTitle('Music')
|
.setTitle('Music')
|
||||||
.setDescription(`Added ${song.name} to the song queue`);
|
.setDescription(`Added ${song.name} to the song queue`)
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({ embeds: [Embed] })
|
||||||
} else {
|
} else {
|
||||||
bot.tellraw(selector, [{text: 'Added ', color: 'white'}, {text: song.name, color: 'gold'}, {text: ' to the song queue', color: 'white'}]);
|
bot.tellraw(selector, [{ text: 'Added ', color: 'white' }, { text: song.name, color: 'gold' }, { text: ' to the song queue', color: 'white' }])
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (discord) {
|
if (discord) {
|
||||||
const Embed = new MessageEmbed()
|
const Embed = new MessageEmbed()
|
||||||
.setColor('#FF0000')
|
.setColor('#FF0000')
|
||||||
.setTitle('Error')
|
.setTitle('Error')
|
||||||
.setDescription(`\`\`\`SyntaxError: Invalid URL\`\`\``);
|
.setDescription('```SyntaxError: Invalid URL```')
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({ embeds: [Embed] })
|
||||||
} else {
|
} else {
|
||||||
bot.tellraw(selector, {text: 'SyntaxError: Invalid URL', color: 'red'});
|
bot.tellraw(selector, { text: 'SyntaxError: Invalid URL', color: 'red' })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function resolve(filepath) {
|
async function resolve (filepath) {
|
||||||
if (!path.isAbsolute(filepath) && await fileExists(SONGS_PATH)) {
|
if (!path.isAbsolute(filepath) && await fileExists(SONGS_PATH)) {
|
||||||
return path.join(SONGS_PATH, filepath);
|
return path.join(SONGS_PATH, filepath)
|
||||||
}
|
}
|
||||||
return filepath;
|
return filepath
|
||||||
}
|
}
|
||||||
|
|
||||||
async function list(bot, discord, channeldc, prefix, selector, args) {
|
async function list (bot, discord, channeldc, prefix, selector, args) {
|
||||||
try {
|
try {
|
||||||
let absolutePath;
|
let absolutePath
|
||||||
if (args[1]) absolutePath = await resolve(path.join(SONGS_PATH, args.slice(1).join(' ')));
|
if (args[1]) absolutePath = await resolve(path.join(SONGS_PATH, args.slice(1).join(' ')))
|
||||||
else absolutePath = await resolve(SONGS_PATH);
|
else absolutePath = await resolve(SONGS_PATH)
|
||||||
|
|
||||||
if (!absolutePath.includes('midis')) throw new Error('bro trying to hack my server?!/1?!');
|
if (!absolutePath.includes('midis')) throw new Error('bro trying to hack my server?!/1?!')
|
||||||
|
|
||||||
const listed = await fileList(absolutePath);
|
const listed = await fileList(absolutePath)
|
||||||
|
|
||||||
if (discord) {
|
if (discord) {
|
||||||
const Embed = new MessageEmbed()
|
const Embed = new MessageEmbed()
|
||||||
.setColor('#FFFF00')
|
.setColor('#FFFF00')
|
||||||
.setTitle('Songs')
|
.setTitle('Songs')
|
||||||
.setDescription(listed.join(', '));
|
.setDescription(listed.join(', '))
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({ embeds: [Embed] })
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let primary = true;
|
let primary = true
|
||||||
const message = [];
|
const message = []
|
||||||
|
|
||||||
for (const value of listed) {
|
for (const value of listed) {
|
||||||
const isFile = (await fs.lstat(path.join(absolutePath, value))).isFile();
|
const isFile = (await fs.lstat(path.join(absolutePath, value))).isFile()
|
||||||
message.push({
|
message.push({
|
||||||
text: value + ' ',
|
text: value + ' ',
|
||||||
color: (!((primary = !primary)) ? 'gold' : 'yellow'),
|
color: (!((primary = !primary)) ? 'gold' : 'yellow'),
|
||||||
clickEvent: {
|
clickEvent: {
|
||||||
action: 'suggest_command',
|
action: 'suggest_command',
|
||||||
value: `${prefix}music ${isFile ? 'play' : 'list'} ${path.join(args.slice(1).join(' '), value)}`,
|
value: `${prefix}music ${isFile ? 'play' : 'list'} ${path.join(args.slice(1).join(' '), value)}`
|
||||||
},
|
},
|
||||||
hoverEvent: {
|
hoverEvent: {
|
||||||
action: 'show_text',
|
action: 'show_text',
|
||||||
contents: [
|
contents: [
|
||||||
{text: 'Name: ', color: 'white'},
|
{ text: 'Name: ', color: 'white' },
|
||||||
{text: value, color: 'gold'},
|
{ text: value, color: 'gold' },
|
||||||
'\n',
|
'\n',
|
||||||
{text: 'Click here to suggest the command!', color: 'green'},
|
{ text: 'Click here to suggest the command!', color: 'green' }
|
||||||
],
|
]
|
||||||
},
|
}
|
||||||
});
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
bot.tellraw(selector, message);
|
bot.tellraw(selector, message)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (discord) {
|
if (discord) {
|
||||||
const Embed = new MessageEmbed()
|
const Embed = new MessageEmbed()
|
||||||
.setColor('#FF0000')
|
.setColor('#FF0000')
|
||||||
.setTitle('Error')
|
.setTitle('Error')
|
||||||
.setDescription(`\`\`\`${e.toString()}\`\`\``);
|
.setDescription(`\`\`\`${e.toString()}\`\`\``)
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({ embeds: [Embed] })
|
||||||
} else {
|
} else {
|
||||||
bot.tellraw(selector, {text: e.toString(), color: 'red'});
|
bot.tellraw(selector, { text: e.toString(), color: 'red' })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -156,182 +159,182 @@ module.exports = {
|
||||||
'<list> [directory]',
|
'<list> [directory]',
|
||||||
'<skip>',
|
'<skip>',
|
||||||
'<nowplaying>',
|
'<nowplaying>',
|
||||||
'<queue>',
|
'<queue>'
|
||||||
],
|
],
|
||||||
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
execute: function (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||||
switch (args[0]) {
|
switch (args[0]) {
|
||||||
case 'play':
|
case 'play':
|
||||||
play(bot, args.slice(1), false, null, selector);
|
play(bot, args.slice(1), false, null, selector)
|
||||||
break;
|
break
|
||||||
case 'playurl':
|
case 'playurl':
|
||||||
playUrl(bot, args.slice(1), false, null, selector);
|
playUrl(bot, args.slice(1), false, null, selector)
|
||||||
break;
|
break
|
||||||
case 'stop':
|
case 'stop':
|
||||||
try {
|
try {
|
||||||
bot.tellraw(selector, {text: 'Cleared the song queue'});
|
bot.tellraw(selector, { text: 'Cleared the song queue' })
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
bot.music.stop();
|
bot.music.stop()
|
||||||
break;
|
break
|
||||||
case 'skip':
|
case 'skip':
|
||||||
try {
|
try {
|
||||||
bot.tellraw(selector, [{text: 'Skipping '}, {text: bot.music.song.name, color: 'gold'}]);
|
bot.tellraw(selector, [{ text: 'Skipping ' }, { text: bot.music.song.name, color: 'gold' }])
|
||||||
bot.music.skip();
|
bot.music.skip()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error('No music is currently playing!');
|
throw new Error('No music is currently playing!')
|
||||||
}
|
}
|
||||||
break;
|
break
|
||||||
case 'loop':
|
case 'loop':
|
||||||
switch (args[1]) {
|
switch (args[1]) {
|
||||||
case 'off':
|
case 'off':
|
||||||
bot.music.loop = 0;
|
bot.music.loop = 0
|
||||||
bot.tellraw(selector, [
|
bot.tellraw(selector, [
|
||||||
{
|
{
|
||||||
text: 'Looping is now ',
|
text: 'Looping is now '
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: 'disabled',
|
text: 'disabled',
|
||||||
color: 'red',
|
color: 'red'
|
||||||
},
|
}
|
||||||
]);
|
])
|
||||||
break;
|
break
|
||||||
case 'current':
|
case 'current':
|
||||||
bot.music.loop = 1;
|
bot.music.loop = 1
|
||||||
bot.tellraw(selector, [
|
bot.tellraw(selector, [
|
||||||
{
|
{
|
||||||
text: 'Now Looping ',
|
text: 'Now Looping '
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: song.name,
|
text: song.name,
|
||||||
color: 'gold',
|
color: 'gold'
|
||||||
},
|
|
||||||
]);
|
|
||||||
break;
|
|
||||||
case 'all':
|
|
||||||
bot.music.loop = 2;
|
|
||||||
bot.tellraw(selector, {
|
|
||||||
text: 'Now looping every song in the queue',
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new SyntaxError('Invalid argument');
|
|
||||||
}
|
}
|
||||||
break;
|
])
|
||||||
|
break
|
||||||
|
case 'all':
|
||||||
|
bot.music.loop = 2
|
||||||
|
bot.tellraw(selector, {
|
||||||
|
text: 'Now looping every song in the queue'
|
||||||
|
})
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
throw new SyntaxError('Invalid argument')
|
||||||
|
}
|
||||||
|
break
|
||||||
case 'list':
|
case 'list':
|
||||||
list(bot, false, null, prefix, selector, args);
|
list(bot, false, null, prefix, selector, args)
|
||||||
break;
|
break
|
||||||
case 'nowplaying':
|
case 'nowplaying':
|
||||||
bot.tellraw(selector, [
|
bot.tellraw(selector, [
|
||||||
{
|
{
|
||||||
text: 'Now playing ',
|
text: 'Now playing '
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: bot.music.song.name,
|
text: bot.music.song.name,
|
||||||
color: 'gold',
|
color: 'gold'
|
||||||
},
|
}
|
||||||
]);
|
])
|
||||||
break;
|
break
|
||||||
case 'queue':
|
case 'queue':
|
||||||
const queueWithName = [];
|
const queueWithName = []
|
||||||
bot.music.queue.forEach((song) => queueWithName.push(song.name));
|
bot.music.queue.forEach((song) => queueWithName.push(song.name))
|
||||||
bot.tellraw(selector, [
|
bot.tellraw(selector, [
|
||||||
{
|
{
|
||||||
text: 'Queue: ',
|
text: 'Queue: ',
|
||||||
color: 'green',
|
color: 'green'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: queueWithName.join(', '),
|
text: queueWithName.join(', '),
|
||||||
color: 'aqua',
|
color: 'aqua'
|
||||||
},
|
}
|
||||||
]);
|
])
|
||||||
break;
|
break
|
||||||
default:
|
default:
|
||||||
throw new SyntaxError('Invalid argument');
|
throw new SyntaxError('Invalid argument')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) {
|
discordExecute: function (bot, username, usernameraw, sender, prefix, args, channeldc, message) {
|
||||||
let Embed;
|
let Embed
|
||||||
switch (args[0]) {
|
switch (args[0]) {
|
||||||
case 'play':
|
case 'play':
|
||||||
play(bot, args.slice(1), true, channeldc);
|
play(bot, args.slice(1), true, channeldc)
|
||||||
break;
|
break
|
||||||
case 'playurl':
|
case 'playurl':
|
||||||
playUrl(bot, args.slice(1), true, channeldc);
|
playUrl(bot, args.slice(1), true, channeldc)
|
||||||
break;
|
break
|
||||||
case 'stop':
|
case 'stop':
|
||||||
try {
|
try {
|
||||||
const Embed = new MessageEmbed()
|
const Embed = new MessageEmbed()
|
||||||
.setColor('#FFFF00')
|
.setColor('#FFFF00')
|
||||||
.setTitle('Stop')
|
.setTitle('Stop')
|
||||||
.setDescription('Cleared the song queue');
|
.setDescription('Cleared the song queue')
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({ embeds: [Embed] })
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
bot.music.stop();
|
bot.music.stop()
|
||||||
break;
|
break
|
||||||
case 'skip':
|
case 'skip':
|
||||||
try {
|
try {
|
||||||
const Embed = new MessageEmbed()
|
const Embed = new MessageEmbed()
|
||||||
.setColor('#FFFF00')
|
.setColor('#FFFF00')
|
||||||
.setTitle('Skip')
|
.setTitle('Skip')
|
||||||
.setDescription(`Skipping ${bot.music.song.name}`);
|
.setDescription(`Skipping ${bot.music.song.name}`)
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({ embeds: [Embed] })
|
||||||
bot.music.skip();
|
bot.music.skip()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error('No music is currently playing!');
|
throw new Error('No music is currently playing!')
|
||||||
}
|
}
|
||||||
break;
|
break
|
||||||
case 'loop':
|
case 'loop':
|
||||||
switch (args[1]) {
|
switch (args[1]) {
|
||||||
case 'off':
|
case 'off':
|
||||||
bot.music.loop = 0;
|
bot.music.loop = 0
|
||||||
Embed = new MessageEmbed()
|
Embed = new MessageEmbed()
|
||||||
.setColor('#FFFF00')
|
.setColor('#FFFF00')
|
||||||
.setTitle('Loop')
|
.setTitle('Loop')
|
||||||
.setDescription('Looping is now disabled');
|
.setDescription('Looping is now disabled')
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({ embeds: [Embed] })
|
||||||
break;
|
break
|
||||||
case 'current':
|
case 'current':
|
||||||
bot.music.loop = 1;
|
bot.music.loop = 1
|
||||||
Embed = new MessageEmbed()
|
Embed = new MessageEmbed()
|
||||||
.setColor('#FFFF00')
|
.setColor('#FFFF00')
|
||||||
.setTitle('Loop')
|
.setTitle('Loop')
|
||||||
.setDescription(`Now looping ${song.name}`);
|
.setDescription(`Now looping ${song.name}`)
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({ embeds: [Embed] })
|
||||||
break;
|
break
|
||||||
case 'all':
|
case 'all':
|
||||||
bot.music.loop = 2;
|
bot.music.loop = 2
|
||||||
Embed = new MessageEmbed()
|
Embed = new MessageEmbed()
|
||||||
.setColor('#FFFF00')
|
.setColor('#FFFF00')
|
||||||
.setTitle('Loop')
|
.setTitle('Loop')
|
||||||
.setDescription('Now looping every song in the queue');
|
.setDescription('Now looping every song in the queue')
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({ embeds: [Embed] })
|
||||||
break;
|
break
|
||||||
}
|
}
|
||||||
break;
|
break
|
||||||
case 'list':
|
case 'list':
|
||||||
list(bot, true, channeldc, prefix, '@a', args);
|
list(bot, true, channeldc, prefix, '@a', args)
|
||||||
break;
|
break
|
||||||
case 'nowplaying':
|
case 'nowplaying':
|
||||||
Embed = new MessageEmbed()
|
Embed = new MessageEmbed()
|
||||||
.setColor('#FFFF00')
|
.setColor('#FFFF00')
|
||||||
.setTitle('Now playing')
|
.setTitle('Now playing')
|
||||||
.setDescription(`Now playing ${bot.music.song.name}`);
|
.setDescription(`Now playing ${bot.music.song.name}`)
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({ embeds: [Embed] })
|
||||||
break;
|
break
|
||||||
case 'queue':
|
case 'queue':
|
||||||
const queueWithName = [];
|
const queueWithName = []
|
||||||
bot.music.queue.forEach((song) => queueWithName.push(song.name));
|
bot.music.queue.forEach((song) => queueWithName.push(song.name))
|
||||||
Embed = new MessageEmbed()
|
Embed = new MessageEmbed()
|
||||||
.setColor('#FFFF00')
|
.setColor('#FFFF00')
|
||||||
.setTitle('Queue')
|
.setTitle('Queue')
|
||||||
.setDescription(queueWithName.join(', '));
|
.setDescription(queueWithName.join(', '))
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({ embeds: [Embed] })
|
||||||
break;
|
break
|
||||||
default:
|
default:
|
||||||
throw new SyntaxError('Invalid argument');
|
throw new SyntaxError('Invalid argument')
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
|
|
@ -5,41 +5,43 @@ module.exports = {
|
||||||
description: 'Broadcasts a message to all of the servers that the bot is connected',
|
description: 'Broadcasts a message to all of the servers that the bot is connected',
|
||||||
usage: '<message>',
|
usage: '<message>',
|
||||||
trusted: 0,
|
trusted: 0,
|
||||||
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
execute: function (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||||
const component = [
|
const component = [
|
||||||
{
|
{
|
||||||
text: '[',
|
text: '[',
|
||||||
color: 'dark_gray',
|
color: 'dark_gray'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: bot.options.host === 'kitsune.icu' ? 'kit' : bot.options.host,
|
text: bot.options.host === 'kitsune.icu' ? 'kit' : bot.options.host,
|
||||||
color: 'gray',
|
color: 'gray'
|
||||||
},
|
},
|
||||||
bot.options.host === 'kitsune.icu' ? {
|
bot.options.host === 'kitsune.icu'
|
||||||
|
? {
|
||||||
text: 'sune.icu',
|
text: 'sune.icu',
|
||||||
color: 'gray',
|
color: 'gray'
|
||||||
} : '',
|
}
|
||||||
|
: '',
|
||||||
{
|
{
|
||||||
text: '] ',
|
text: '] ',
|
||||||
color: 'dark_gray',
|
color: 'dark_gray'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: username,
|
text: username,
|
||||||
color: 'gray',
|
color: 'gray'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: ' \u203a ',
|
text: ' \u203a ',
|
||||||
color: 'dark_gray',
|
color: 'dark_gray'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: args.join(' '),
|
text: args.join(' '),
|
||||||
color: 'gray',
|
color: 'gray'
|
||||||
},
|
}
|
||||||
];
|
]
|
||||||
|
|
||||||
const bots = bot.getBots();
|
const bots = bot.getBots()
|
||||||
bots.forEach((bot) => {
|
bots.forEach((bot) => {
|
||||||
bot.tellraw(selector, component);
|
bot.tellraw(selector, component)
|
||||||
});
|
})
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
|
|
@ -4,10 +4,10 @@ module.exports = {
|
||||||
description: 'Resets the bot\'s command core',
|
description: 'Resets the bot\'s command core',
|
||||||
usage: '',
|
usage: '',
|
||||||
trusted: 0,
|
trusted: 0,
|
||||||
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
execute: function (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||||
bot.core.loopPlace();
|
bot.core.loopPlace()
|
||||||
},
|
},
|
||||||
discordExecute: function(bot) {
|
discordExecute: function (bot) {
|
||||||
bot.core.loopPlace();
|
bot.core.loopPlace()
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
/* eslint-disable max-len */
|
/* eslint-disable max-len */
|
||||||
const {between} = require('../util/between');
|
const { between } = require('../util/between')
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'rtp',
|
name: 'rtp',
|
||||||
alias: [],
|
alias: [],
|
||||||
description: 'Randomly teleports the player',
|
description: 'Randomly teleports the player',
|
||||||
usage: '',
|
usage: '',
|
||||||
trusted: 0,
|
trusted: 0,
|
||||||
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
execute: function (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||||
const rtppos = `${between(20000000, 500000)} 100 ${between(20000000, 500000)}`;
|
const rtppos = `${between(20000000, 500000)} 100 ${between(20000000, 500000)}`
|
||||||
bot.tellraw(selector, [{text: 'Teleporting ', color: 'white'}, {text: username, color: 'aqua'}, {text: ' to ', color: 'white'}, {text: rtppos, color: 'green'}, {text: '...', color: 'white'}]);
|
bot.tellraw(selector, [{ text: 'Teleporting ', color: 'white' }, { text: username, color: 'aqua' }, { text: ' to ', color: 'white' }, { text: rtppos, color: 'green' }, { text: '...', color: 'white' }])
|
||||||
bot.core.run(`essentials:teleport ${sender} ${rtppos}`);
|
bot.core.run(`essentials:teleport ${sender} ${rtppos}`)
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
|
|
@ -1,33 +1,34 @@
|
||||||
|
/* eslint-disable no-eval */
|
||||||
/* eslint-disable max-len */
|
/* eslint-disable max-len */
|
||||||
const util = require('util');
|
const util = require('util')
|
||||||
const {stylize} = require('../util/colors/minecraft');
|
const { stylize } = require('../util/colors/minecraft')
|
||||||
const {MessageEmbed} = require('discord.js');
|
const { MessageEmbed } = require('discord.js')
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'servereval',
|
name: 'servereval',
|
||||||
alias: [],
|
alias: [],
|
||||||
description: 'Basically eval command but without vm2',
|
description: 'Basically eval command but without vm2',
|
||||||
trusted: 2,
|
trusted: 2,
|
||||||
usage: '<ownerhash> <code>',
|
usage: '<ownerhash> <code>',
|
||||||
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
execute: function (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||||
try {
|
try {
|
||||||
bot.tellraw(selector, {text: util.inspect(eval(args.slice(1).join(' ')), {stylize}).substring(0, 32766)});
|
bot.tellraw(selector, { text: util.inspect(eval(args.slice(1).join(' ')), { stylize }).substring(0, 32766) })
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
bot.tellraw(selector, {text: util.inspect(err).replaceAll('runner', 'chayapak1'), color: 'red'});
|
bot.tellraw(selector, { text: util.inspect(err).replaceAll('runner', 'chayapak1'), color: 'red' })
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message, config) {
|
discordExecute: function (bot, username, usernameraw, sender, prefix, args, channeldc, message, config) {
|
||||||
try {
|
try {
|
||||||
const Embed = new MessageEmbed()
|
const Embed = new MessageEmbed()
|
||||||
.setColor('#FFFF00')
|
.setColor('#FFFF00')
|
||||||
.setTitle('Output')
|
.setTitle('Output')
|
||||||
.setDescription(util.inspect(eval(args.join(' ')), {stylize}));
|
.setDescription(util.inspect(eval(args.join(' ')), { stylize }))
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({ embeds: [Embed] })
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
const Embed = new MessageEmbed()
|
const Embed = new MessageEmbed()
|
||||||
.setColor('#FF0000')
|
.setColor('#FF0000')
|
||||||
.setTitle('Error')
|
.setTitle('Error')
|
||||||
.setDescription(`\`\`\`${util.inspect(err).replaceAll('runner', 'chayapak1')}\`\`\``);
|
.setDescription(`\`\`\`${util.inspect(err).replaceAll('runner', 'chayapak1')}\`\`\``)
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({ embeds: [Embed] })
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
|
|
@ -1,40 +1,40 @@
|
||||||
/* eslint-disable max-len */
|
/* eslint-disable max-len */
|
||||||
const {MessageEmbed} = require('discord.js');
|
const { MessageEmbed } = require('discord.js')
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'test',
|
name: 'test',
|
||||||
alias: [],
|
alias: [],
|
||||||
description: 'Tests if the bot is working',
|
description: 'Tests if the bot is working',
|
||||||
usage: '',
|
usage: '',
|
||||||
trusted: 0,
|
trusted: 0,
|
||||||
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
execute: function (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||||
bot.tellraw(selector, [
|
bot.tellraw(selector, [
|
||||||
{
|
{
|
||||||
text: `Username: ${username},`,
|
text: `Username: ${username},`,
|
||||||
color: 'green',
|
color: 'green'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: ` Raw username: ${usernameraw},`,
|
text: ` Raw username: ${usernameraw},`,
|
||||||
color: 'green',
|
color: 'green'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: ` Sender UUID: ${sender},`,
|
text: ` Sender UUID: ${sender},`,
|
||||||
color: 'green',
|
color: 'green'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: ` Prefix: ${prefix},`,
|
text: ` Prefix: ${prefix},`,
|
||||||
color: 'green',
|
color: 'green'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: ` Args: ${args.join(', ').toString()}`,
|
text: ` Args: ${args.join(', ').toString()}`,
|
||||||
color: 'green',
|
color: 'green'
|
||||||
|
}
|
||||||
|
])
|
||||||
},
|
},
|
||||||
]);
|
discordExecute: function (bot, username, usernameraw, sender, prefix, args, channeldc) {
|
||||||
},
|
|
||||||
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc) {
|
|
||||||
const Embed = new MessageEmbed()
|
const Embed = new MessageEmbed()
|
||||||
.setColor('#FFFF00')
|
.setColor('#FFFF00')
|
||||||
.setTitle('Hello!')
|
.setTitle('Hello!')
|
||||||
.setDescription('This is the first ever command to be discordified!' + '\n' + `More info: Username: ${username}, Prefix: ${prefix}, Args: ${args.join(' ')}`);
|
.setDescription('This is the first ever command to be discordified!' + '\n' + `More info: Username: ${username}, Prefix: ${prefix}, Args: ${args.join(' ')}`)
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({ embeds: [Embed] })
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
|
|
@ -1,44 +1,42 @@
|
||||||
/* eslint-disable max-len */
|
/* eslint-disable max-len */
|
||||||
const {MessageEmbed} = require('discord.js');
|
const { MessageEmbed } = require('discord.js')
|
||||||
const moment = require('moment-timezone');
|
const moment = require('moment-timezone')
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'time',
|
name: 'time',
|
||||||
alias: [],
|
alias: [],
|
||||||
description: 'Shows the time',
|
description: 'Shows the time',
|
||||||
usage: '<timezone>',
|
usage: '<timezone>',
|
||||||
trusted: 0,
|
trusted: 0,
|
||||||
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
execute: function (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||||
const timezone = args.join(' ');
|
const timezone = args.join(' ')
|
||||||
const momented = moment().tz(timezone).format('dddd, MMMM Do, YYYY, hh:mm:ss A');
|
const momented = moment().tz(timezone).format('dddd, MMMM Do, YYYY, hh:mm:ss A')
|
||||||
const component = [{text: 'The current date and time for the timezone ', color: 'white'}, {text: timezone, color: 'aqua'}, {text: ' is: ', color: 'white'}, {text: `${momented}`, color: 'green'}];
|
const component = [{ text: 'The current date and time for the timezone ', color: 'white' }, { text: timezone, color: 'aqua' }, { text: ' is: ', color: 'white' }, { text: `${momented}`, color: 'green' }]
|
||||||
if (timezone.toLowerCase() === 'asia/bangkok' || timezone.toLowerCase() === 'utc') {
|
if (timezone.toLowerCase() === 'asia/bangkok' || timezone.toLowerCase() === 'utc') {
|
||||||
bot.tellraw(selector, component);
|
bot.tellraw(selector, component)
|
||||||
return;
|
|
||||||
} else if (momented === moment().format('dddd, MMMM Do, YYYY, hh:mm:ss A')) {
|
} else if (momented === moment().format('dddd, MMMM Do, YYYY, hh:mm:ss A')) {
|
||||||
throw new SyntaxError('Invalid timezone');
|
throw new SyntaxError('Invalid timezone')
|
||||||
} else {
|
} else {
|
||||||
bot.tellraw(selector, component);
|
bot.tellraw(selector, component)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc) {
|
discordExecute: function (bot, username, usernameraw, sender, prefix, args, channeldc) {
|
||||||
const timezone = args.join(' ');
|
const timezone = args.join(' ')
|
||||||
const momented = moment().tz(timezone).format('dddd, MMMM Do, YYYY, hh:mm:ss A');
|
const momented = moment().tz(timezone).format('dddd, MMMM Do, YYYY, hh:mm:ss A')
|
||||||
const description = `The current date and time for the timezone ${timezone} is: ${momented}`;
|
const description = `The current date and time for the timezone ${timezone} is: ${momented}`
|
||||||
if (timezone.toLowerCase() === 'asia/bangkok' || timezone.toLowerCase() === 'utc') {
|
if (timezone.toLowerCase() === 'asia/bangkok' || timezone.toLowerCase() === 'utc') {
|
||||||
const Embed = new MessageEmbed()
|
const Embed = new MessageEmbed()
|
||||||
.setColor('#FFFF00')
|
.setColor('#FFFF00')
|
||||||
.setTitle('Time')
|
.setTitle('Time')
|
||||||
.setDescription(description);
|
.setDescription(description)
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({ embeds: [Embed] })
|
||||||
return;
|
|
||||||
} else if (momented === moment().format('dddd, MMMM Do, YYYY, hh:mm:ss A')) {
|
} else if (momented === moment().format('dddd, MMMM Do, YYYY, hh:mm:ss A')) {
|
||||||
throw new SyntaxError('Invalid timezone');
|
throw new SyntaxError('Invalid timezone')
|
||||||
} else {
|
} else {
|
||||||
const Embed = new MessageEmbed()
|
const Embed = new MessageEmbed()
|
||||||
.setColor('#FFFF00')
|
.setColor('#FFFF00')
|
||||||
.setTitle('Time')
|
.setTitle('Time')
|
||||||
.setDescription(description);
|
.setDescription(description)
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({ embeds: [Embed] })
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ module.exports = {
|
||||||
description: 'Teleport everyone',
|
description: 'Teleport everyone',
|
||||||
usage: '<hash> <player>',
|
usage: '<hash> <player>',
|
||||||
trusted: 1,
|
trusted: 1,
|
||||||
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
execute: function (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||||
bot.core.run(`minecraft:execute unless entity @s[name= run ] run tp @a ${args.slice(1).join(' ')}`);
|
bot.core.run(`minecraft:execute unless entity @s[name= run ] run tp @a ${args.slice(1).join(' ')}`)
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
|
|
@ -1,34 +1,34 @@
|
||||||
/* eslint-disable max-len */
|
/* eslint-disable max-len */
|
||||||
const {MessageEmbed} = require('discord.js');
|
const { MessageEmbed } = require('discord.js')
|
||||||
const translate = require('@vitalets/google-translate-api');
|
const translate = require('@vitalets/google-translate-api')
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'translate',
|
name: 'translate',
|
||||||
alias: [],
|
alias: [],
|
||||||
description: 'Translate a message from any language to any language using Google Translate',
|
description: 'Translate a message from any language to any language using Google Translate',
|
||||||
usage: '<language 1> <language 2> <message>',
|
usage: '<language 1> <language 2> <message>',
|
||||||
trusted: 0,
|
trusted: 0,
|
||||||
execute: async function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
execute: async function (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||||
try {
|
try {
|
||||||
const res = await translate(args.slice(2).join(' '), {from: args[0], to: args[1]});
|
const res = await translate(args.slice(2).join(' '), { from: args[0], to: args[1] })
|
||||||
bot.tellraw(selector, [{text: 'Result: ', color: 'gold'}, {text: res.text, color: 'green'}]);
|
bot.tellraw(selector, [{ text: 'Result: ', color: 'gold' }, { text: res.text, color: 'green' }])
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
bot.tellraw(selector, {text: String(e), color: 'red'});
|
bot.tellraw(selector, { text: String(e), color: 'red' })
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
discordExecute: async function(bot, username, usernameraw, sender, prefix, args, channeldc, message) {
|
discordExecute: async function (bot, username, usernameraw, sender, prefix, args, channeldc, message) {
|
||||||
try {
|
try {
|
||||||
const res = await translate(args.slice(2).join(' '), {from: args[0], to: args[1]});
|
const res = await translate(args.slice(2).join(' '), { from: args[0], to: args[1] })
|
||||||
const Embed = new MessageEmbed()
|
const Embed = new MessageEmbed()
|
||||||
.setColor('#FFFF00')
|
.setColor('#FFFF00')
|
||||||
.setTitle('Result')
|
.setTitle('Result')
|
||||||
.setDescription(res.text);
|
.setDescription(res.text)
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({ embeds: [Embed] })
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const Embed = new MessageEmbed()
|
const Embed = new MessageEmbed()
|
||||||
.setColor('#FF0000')
|
.setColor('#FF0000')
|
||||||
.setTitle('Error')
|
.setTitle('Error')
|
||||||
.setDescription(`\`\`\`${e}\`\`\``);
|
.setDescription(`\`\`\`${e}\`\`\``)
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({ embeds: [Embed] })
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
/* eslint-disable max-len */
|
/* eslint-disable max-len */
|
||||||
const {MessageEmbed} = require('discord.js');
|
const { MessageEmbed } = require('discord.js')
|
||||||
const {secondsToHms} = require('../util/secondToHms');
|
const { secondsToHms } = require('../util/secondToHms')
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'uptime',
|
name: 'uptime',
|
||||||
alias: [],
|
alias: [],
|
||||||
description: 'Shows the bot\'s uptime',
|
description: 'Shows the bot\'s uptime',
|
||||||
usage: '',
|
usage: '',
|
||||||
trusted: 0,
|
trusted: 0,
|
||||||
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
execute: function (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||||
bot.tellraw(selector, [{text: 'The bot\'s uptime is ', color: 'white'}, {text: `${secondsToHms(Math.floor(performance.now() / 1000))}`, color: 'green'}]);
|
bot.tellraw(selector, [{ text: 'The bot\'s uptime is ', color: 'white' }, { text: `${secondsToHms(Math.floor(performance.now() / 1000))}`, color: 'green' }])
|
||||||
},
|
},
|
||||||
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) {
|
discordExecute: function (bot, username, usernameraw, sender, prefix, args, channeldc, message) {
|
||||||
const Embed = new MessageEmbed()
|
const Embed = new MessageEmbed()
|
||||||
.setColor('#FFFF00')
|
.setColor('#FFFF00')
|
||||||
.setTitle('Bot\'s Uptime')
|
.setTitle('Bot\'s Uptime')
|
||||||
.setDescription(`The bot\'s uptime is ${secondsToHms(Math.floor(performance.now() / 1000))}`);
|
.setDescription(`The bot's uptime is ${secondsToHms(Math.floor(performance.now() / 1000))}`)
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({ embeds: [Embed] })
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
/* eslint-disable max-len */
|
/* eslint-disable max-len */
|
||||||
const urban = require('urban-dictionary');
|
const urban = require('urban-dictionary')
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'urban',
|
name: 'urban',
|
||||||
alias: [],
|
alias: [],
|
||||||
description: 'Working Urban Dictionary',
|
description: 'Working Urban Dictionary',
|
||||||
usage: '<word>',
|
usage: '<word>',
|
||||||
trusted: 0,
|
trusted: 0,
|
||||||
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
execute: function (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||||
urban.autocompleteExtra(args[0], (error, results) => {
|
urban.autocompleteExtra(args[0], (error, results) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
bot.tellraw(selector, [{text: '[', color: 'dark_red'}, {text: 'Urban', color: 'red'}, {text: '] ', color: 'dark_red'}, {text: error.message, color: 'red'}]);
|
bot.tellraw(selector, [{ text: '[', color: 'dark_red' }, { text: 'Urban', color: 'red' }, { text: '] ', color: 'dark_red' }, { text: error.message, color: 'red' }])
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
results.forEach(({preview, term}) => {
|
results.forEach(({ preview, term }) => {
|
||||||
bot.tellraw(selector, [{text: '[', color: 'dark_red'}, {text: 'Urban', color: 'red'}, {text: '] ', color: 'dark_red'}, {text: term, color: 'white'}, {text: ' - ', color: 'white'}, {text: preview, color: 'white'}]);
|
bot.tellraw(selector, [{ text: '[', color: 'dark_red' }, { text: 'Urban', color: 'red' }, { text: '] ', color: 'dark_red' }, { text: term, color: 'white' }, { text: ' - ', color: 'white' }, { text: preview, color: 'white' }])
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
|
|
@ -1,83 +1,83 @@
|
||||||
/* eslint-disable max-len */
|
/* eslint-disable max-len */
|
||||||
const {MessageEmbed} = require('discord.js');
|
const { MessageEmbed } = require('discord.js')
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'uuid',
|
name: 'uuid',
|
||||||
alias: [],
|
alias: [],
|
||||||
description: 'Gets the UUID of a player. If no player specified it will show your UUID instead',
|
description: 'Gets the UUID of a player. If no player specified it will show your UUID instead',
|
||||||
usage: '',
|
usage: '',
|
||||||
trusted: 0,
|
trusted: 0,
|
||||||
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
execute: function (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||||
if (args[0]) {
|
if (args[0]) {
|
||||||
const playername = args.join(' ');
|
const playername = args.join(' ')
|
||||||
const player = bot.playersAddedPlayers[playername];
|
const player = bot.playersAddedPlayers[playername]
|
||||||
if (player === undefined) throw new SyntaxError('Invalid Username');
|
if (player === undefined) throw new SyntaxError('Invalid Username')
|
||||||
bot.tellraw(selector,
|
bot.tellraw(selector,
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
text: `${playername}'s UUID: `,
|
text: `${playername}'s UUID: `,
|
||||||
color: 'green',
|
color: 'green'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: player,
|
text: player,
|
||||||
color: 'aqua',
|
color: 'aqua',
|
||||||
clickEvent: {
|
clickEvent: {
|
||||||
action: 'copy_to_clipboard',
|
action: 'copy_to_clipboard',
|
||||||
value: player,
|
value: player
|
||||||
},
|
},
|
||||||
hoverEvent: {
|
hoverEvent: {
|
||||||
action: 'show_text',
|
action: 'show_text',
|
||||||
contents: [
|
contents: [
|
||||||
{
|
{
|
||||||
text: 'Click here to copy the UUID to your clipboard',
|
text: 'Click here to copy the UUID to your clipboard',
|
||||||
color: 'green',
|
color: 'green'
|
||||||
},
|
}
|
||||||
],
|
]
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
]);
|
])
|
||||||
} else {
|
} else {
|
||||||
bot.tellraw(selector,
|
bot.tellraw(selector,
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
text: `Your UUID: `,
|
text: 'Your UUID: ',
|
||||||
color: 'green',
|
color: 'green'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: sender,
|
text: sender,
|
||||||
color: 'aqua',
|
color: 'aqua',
|
||||||
clickEvent: {
|
clickEvent: {
|
||||||
action: 'copy_to_clipboard',
|
action: 'copy_to_clipboard',
|
||||||
value: sender,
|
value: sender
|
||||||
},
|
},
|
||||||
hoverEvent: {
|
hoverEvent: {
|
||||||
action: 'show_text',
|
action: 'show_text',
|
||||||
contents: [
|
contents: [
|
||||||
{
|
{
|
||||||
text: 'Click here to copy the uuid to your clipboard',
|
text: 'Click here to copy the uuid to your clipboard',
|
||||||
color: 'green',
|
color: 'green'
|
||||||
},
|
}
|
||||||
],
|
]
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
]);
|
])
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) {
|
discordExecute: function (bot, username, usernameraw, sender, prefix, args, channeldc, message) {
|
||||||
if (args[0]) {
|
if (args[0]) {
|
||||||
const playername = args.join(' ');
|
const playername = args.join(' ')
|
||||||
const player = bot.playersAddedPlayers[playername];
|
const player = bot.playersAddedPlayers[playername]
|
||||||
if (player === undefined) throw new SyntaxError('Invalid UUID');
|
if (player === undefined) throw new SyntaxError('Invalid UUID')
|
||||||
const Embed = new MessageEmbed()
|
const Embed = new MessageEmbed()
|
||||||
.setColor('#FFFF00')
|
.setColor('#FFFF00')
|
||||||
.setTitle('UUID')
|
.setTitle('UUID')
|
||||||
.setDescription(`${playername}'s UUID: ${player}`);
|
.setDescription(`${playername}'s UUID: ${player}`)
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({ embeds: [Embed] })
|
||||||
} else {
|
} else {
|
||||||
const Embed = new MessageEmbed()
|
const Embed = new MessageEmbed()
|
||||||
.setColor('#FF0000')
|
.setColor('#FF0000')
|
||||||
.setTitle('Error')
|
.setTitle('Error')
|
||||||
.setDescription('Invalid player name');
|
.setDescription('Invalid player name')
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({ embeds: [Embed] })
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
|
|
@ -5,13 +5,13 @@ module.exports = {
|
||||||
alias: [],
|
alias: [],
|
||||||
usage: '<hash>',
|
usage: '<hash>',
|
||||||
trusted: 1,
|
trusted: 1,
|
||||||
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
execute: function (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||||
if (args[0] === hash) {
|
if (args[0] === hash) {
|
||||||
bot.tellraw(selector, {text: 'Valid hash', color: 'green'});
|
bot.tellraw(selector, { text: 'Valid hash', color: 'green' })
|
||||||
} else if (args[0] === ownerhash) {
|
} else if (args[0] === ownerhash) {
|
||||||
bot.tellraw(selector, {text: 'Valid OwnerHash', color: 'green'});
|
bot.tellraw(selector, { text: 'Valid OwnerHash', color: 'green' })
|
||||||
} else {
|
} else {
|
||||||
bot.tellraw(selector, {text: 'Invalid hash', color: 'red'});
|
bot.tellraw(selector, { text: 'Invalid hash', color: 'red' })
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
|
|
@ -1,37 +1,37 @@
|
||||||
/* eslint-disable max-len */
|
/* eslint-disable max-len */
|
||||||
const wiki = require('wikipedia');
|
const wiki = require('wikipedia')
|
||||||
const util = require('util');
|
const util = require('util')
|
||||||
const {MessageEmbed} = require('discord.js');
|
const { MessageEmbed } = require('discord.js')
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'wikipedia',
|
name: 'wikipedia',
|
||||||
alias: ['wiki'],
|
alias: ['wiki'],
|
||||||
description: 'Working Wikipedia!',
|
description: 'Working Wikipedia!',
|
||||||
usage: '<page>',
|
usage: '<page>',
|
||||||
trusted: 0,
|
trusted: 0,
|
||||||
execute: async function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
execute: async function (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||||
try {
|
try {
|
||||||
const page = await wiki.page(args.join(' '));
|
const page = await wiki.page(args.join(' '))
|
||||||
const summary = await page.summary();
|
const summary = await page.summary()
|
||||||
bot.tellraw(selector, {text: summary.extract, color: 'green'});
|
bot.tellraw(selector, { text: summary.extract, color: 'green' })
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
bot.tellraw(selector, {text: e.toString(), color: 'red'});
|
bot.tellraw(selector, { text: e.toString(), color: 'red' })
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
discordExecute: async function(bot, username, usernameraw, sender, prefix, args, channeldc) {
|
discordExecute: async function (bot, username, usernameraw, sender, prefix, args, channeldc) {
|
||||||
try {
|
try {
|
||||||
const page = await wiki.page(args.join(' '));
|
const page = await wiki.page(args.join(' '))
|
||||||
const summary = await page.summary();
|
const summary = await page.summary()
|
||||||
const Embed = new MessageEmbed()
|
const Embed = new MessageEmbed()
|
||||||
.setColor('#FFFF00')
|
.setColor('#FFFF00')
|
||||||
.setTitle('Output')
|
.setTitle('Output')
|
||||||
.setDescription(summary.extract);
|
.setDescription(summary.extract)
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({ embeds: [Embed] })
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const Embed = new MessageEmbed()
|
const Embed = new MessageEmbed()
|
||||||
.setColor('#FF0000')
|
.setColor('#FF0000')
|
||||||
.setTitle('Error')
|
.setTitle('Error')
|
||||||
.setDescription(`\`\`\`${util.inspect(e)}\`\`\``);
|
.setDescription(`\`\`\`${util.inspect(e)}\`\`\``)
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({ embeds: [Embed] })
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
|
36
config.js
36
config.js
|
@ -4,12 +4,12 @@ module.exports = {
|
||||||
prefixes: [
|
prefixes: [
|
||||||
'*',
|
'*',
|
||||||
'cbot ',
|
'cbot ',
|
||||||
'/cbot ',
|
'/cbot '
|
||||||
],
|
],
|
||||||
commandsDir: '../commands', // this will be used by the commands.js in the plugins folder so it needs ../
|
commandsDir: '../commands', // this will be used by the commands.js in the plugins folder so it needs ../
|
||||||
keys: {
|
keys: {
|
||||||
normalKey: '<27>iB_D<5F><44><EFBFBD>k<EFBFBD><6B>j8H<38>{?[/ڭ<>f<EFBFBD>}Ѣ<>^-=<3D>Ț<EFBFBD><C89A>v]<5D><>g><3E><>=c',
|
normalKey: '<27>iB_D<5F><44><EFBFBD>k<EFBFBD><6B>j8H<38>{?[/ڭ<>f<EFBFBD>}Ѣ<>^-=<3D>Ț<EFBFBD><C89A>v]<5D><>g><3E><>=c',
|
||||||
ownerHashKey: 'b)R<><52>nF<6E>CW<43><57><EFBFBD>#<23>\\[<5B>S*8"t^eia<69>Z<EFBFBD><5A>k<EFBFBD><6B><EFBFBD><EFBFBD>K1<4B>8zȢ<7A>',
|
ownerHashKey: 'b)R<><52>nF<6E>CW<43><57><EFBFBD>#<23>\\[<5B>S*8"t^eia<69>Z<EFBFBD><5A>k<EFBFBD><6B><EFBFBD><EFBFBD>K1<4B>8zȢ<7A>'
|
||||||
},
|
},
|
||||||
console: true,
|
console: true,
|
||||||
useChat: false,
|
useChat: false,
|
||||||
|
@ -19,13 +19,13 @@ module.exports = {
|
||||||
customName: [
|
customName: [
|
||||||
{
|
{
|
||||||
text: 'ChomeNS Bot ',
|
text: 'ChomeNS Bot ',
|
||||||
color: 'yellow',
|
color: 'yellow'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: 'Core',
|
text: 'Core',
|
||||||
color: 'green',
|
color: 'green'
|
||||||
},
|
}
|
||||||
],
|
]
|
||||||
},
|
},
|
||||||
self_care: {
|
self_care: {
|
||||||
prefix: true,
|
prefix: true,
|
||||||
|
@ -34,10 +34,10 @@ module.exports = {
|
||||||
vanish: true,
|
vanish: true,
|
||||||
gamemode: true,
|
gamemode: true,
|
||||||
mute: true,
|
mute: true,
|
||||||
endCredits: true,
|
endCredits: true
|
||||||
},
|
},
|
||||||
eval: {
|
eval: {
|
||||||
serverUrl: 'http://192.168.1.105:4445/',
|
serverUrl: 'http://192.168.1.105:4445/'
|
||||||
},
|
},
|
||||||
reconnectTimeout: 1000 * 2,
|
reconnectTimeout: 1000 * 2,
|
||||||
self_care_check_interval: 2000,
|
self_care_check_interval: 2000,
|
||||||
|
@ -50,35 +50,35 @@ module.exports = {
|
||||||
'192.168.1.103': '1002806756885413978',
|
'192.168.1.103': '1002806756885413978',
|
||||||
'kitsune.icu': '1004006678460637315',
|
'kitsune.icu': '1004006678460637315',
|
||||||
'mc.chomens41793.ga': '1010734897796763758',
|
'mc.chomens41793.ga': '1010734897796763758',
|
||||||
'real.chipmunk.land': '1042590315464364032',
|
'real.chipmunk.land': '1042590315464364032'
|
||||||
},
|
},
|
||||||
prefix: '!',
|
prefix: '!'
|
||||||
},
|
},
|
||||||
servers: [
|
servers: [
|
||||||
{
|
{
|
||||||
host: 'play.kaboom.pw',
|
host: 'play.kaboom.pw',
|
||||||
port: 25565,
|
port: 25565,
|
||||||
kaboom: true,
|
kaboom: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
host: 'sus.shhnowisnottheti.me',
|
host: 'sus.shhnowisnottheti.me',
|
||||||
port: 25565,
|
port: 25565,
|
||||||
kaboom: true,
|
kaboom: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
host: 'kitsune.icu',
|
host: 'kitsune.icu',
|
||||||
port: 25565,
|
port: 25565,
|
||||||
kaboom: true,
|
kaboom: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
host: 'real.chipmunk.land',
|
host: 'real.chipmunk.land',
|
||||||
port: 25565,
|
port: 25565,
|
||||||
kaboom: true,
|
kaboom: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
host: 'mc.chomens41793.ga',
|
host: 'mc.chomens41793.ga',
|
||||||
port: 25565,
|
port: 25565,
|
||||||
kaboom: true,
|
kaboom: true
|
||||||
},
|
}
|
||||||
],
|
]
|
||||||
};
|
}
|
||||||
|
|
44
index.js
44
index.js
|
@ -1,36 +1,36 @@
|
||||||
/* eslint-disable max-len */
|
/* eslint-disable max-len */
|
||||||
const readline = require('node:readline');
|
const readline = require('node:readline')
|
||||||
const {stdin: input, stdout: output} = require('node:process');
|
const { stdin: input, stdout: output } = require('node:process')
|
||||||
const rl = readline.createInterface({input, output});
|
const rl = readline.createInterface({ input, output })
|
||||||
const config = require('./config');
|
const config = require('./config')
|
||||||
const {createBot} = require('./bot');
|
const { createBot } = require('./bot')
|
||||||
const {
|
const {
|
||||||
Client,
|
Client,
|
||||||
Intents,
|
Intents
|
||||||
} = require('discord.js');
|
} = require('discord.js')
|
||||||
const intents = new Intents(['GUILDS', 'GUILD_MESSAGES']);
|
const intents = new Intents(['GUILDS', 'GUILD_MESSAGES'])
|
||||||
const dcclient = new Client({
|
const dcclient = new Client({
|
||||||
intents,
|
intents
|
||||||
});
|
})
|
||||||
|
|
||||||
let bots = [];
|
let bots = []
|
||||||
|
|
||||||
dcclient.on('ready', () => {
|
dcclient.on('ready', () => {
|
||||||
config.servers.forEach(async (server) => {
|
config.servers.forEach(async (server) => {
|
||||||
const getBots = () => bots;
|
const getBots = () => bots
|
||||||
const setNewBot = (server, bot) => {
|
const setNewBot = (server, bot) => {
|
||||||
bots = bots.filter((eachBot) => eachBot !== server);
|
bots = bots.filter((eachBot) => eachBot !== server)
|
||||||
bots.push(bot);
|
bots.push(bot)
|
||||||
};
|
}
|
||||||
// await is important cuz the function is async
|
// await is important cuz the function is async
|
||||||
// VVVVV
|
// VVVVV
|
||||||
const bot = await createBot(server, config, getBots, setNewBot, dcclient, rl);
|
const bot = await createBot(server, config, getBots, setNewBot, dcclient, rl)
|
||||||
bots.push(bot);
|
bots.push(bot)
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
|
|
||||||
dcclient.login(config.discord.token);
|
dcclient.login(config.discord.token)
|
||||||
|
|
||||||
process.on('uncaughtException', (e) => {
|
process.on('uncaughtException', (e) => {
|
||||||
console.log('uncaught ' + e);
|
console.log('uncaught ' + e)
|
||||||
});
|
})
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
"moment": "^2.29.3",
|
"moment": "^2.29.3",
|
||||||
"moment-timezone": "^0.5.34",
|
"moment-timezone": "^0.5.34",
|
||||||
"prismarine-block": "^1.16.3",
|
"prismarine-block": "^1.16.3",
|
||||||
|
"prismarine-chat": "^1.7.2",
|
||||||
"prismarine-chunk": "^1.32.0",
|
"prismarine-chunk": "^1.32.0",
|
||||||
"prismarine-item": "^1.11.5",
|
"prismarine-item": "^1.11.5",
|
||||||
"prismarine-registry": "^1.3.0",
|
"prismarine-registry": "^1.3.0",
|
||||||
|
@ -39,6 +40,6 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"eslint": "^8.20.0",
|
"eslint": "^8.20.0",
|
||||||
"eslint-config-google": "^0.14.0"
|
"eslint-config-standard": "^17.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,40 +2,40 @@
|
||||||
/* eslint-disable require-jsdoc */
|
/* eslint-disable require-jsdoc */
|
||||||
// eslint-disable-next-line no-undef
|
// eslint-disable-next-line no-undef
|
||||||
// const parse = require('../util/text_parser');
|
// const parse = require('../util/text_parser');
|
||||||
const {containsIllegalCharacters} = require('../util/containsIllegalCharacters');
|
const { containsIllegalCharacters } = require('../util/containsIllegalCharacters')
|
||||||
const {chatPacketListener, parsePlayerMessages} = require('../util/chat');
|
const { chatPacketListener, parsePlayerMessages } = require('../util/chat')
|
||||||
|
|
||||||
function inject(bot) {
|
function inject (bot) {
|
||||||
bot.chatQueue = [];
|
bot.chatQueue = []
|
||||||
|
|
||||||
const chatQueue = setInterval(function() {
|
const chatQueue = setInterval(function () {
|
||||||
if (bot.chatQueue[0] || bot.chatQueue[0] === '') {
|
if (bot.chatQueue[0] || bot.chatQueue[0] === '') {
|
||||||
try {
|
try {
|
||||||
if (containsIllegalCharacters(bot.chatQueue[0])) {
|
if (containsIllegalCharacters(bot.chatQueue[0])) {
|
||||||
bot.chatQueue.shift();
|
bot.chatQueue.shift()
|
||||||
return;
|
return
|
||||||
};
|
};
|
||||||
bot.write('chat', {message: bot.chatQueue[0]});
|
bot.write('chat', { message: bot.chatQueue[0] })
|
||||||
bot.chatQueue.shift();
|
bot.chatQueue.shift()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
bot.console.error(e);
|
bot.console.error(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 450);
|
}, 450)
|
||||||
|
|
||||||
bot.chat = (message) => {
|
bot.chat = (message) => {
|
||||||
bot.chatQueue.push(String(message));
|
bot.chatQueue.push(String(message))
|
||||||
};
|
}
|
||||||
|
|
||||||
bot.once('end', () => {
|
bot.once('end', () => {
|
||||||
clearInterval(chatQueue);
|
clearInterval(chatQueue)
|
||||||
});
|
})
|
||||||
|
|
||||||
const ChatMessage = require('prismarine-chat')(bot.version);
|
const ChatMessage = require('prismarine-chat')(bot.version)
|
||||||
|
|
||||||
bot._client.on('chat', (packet) => chatPacketListener(packet, ChatMessage, bot));
|
bot._client.on('chat', (packet) => chatPacketListener(packet, ChatMessage, bot))
|
||||||
|
|
||||||
bot.on('parsed_chat', (message, packet) => parsePlayerMessages(message, packet, bot));
|
bot.on('parsed_chat', (message, packet) => parsePlayerMessages(message, packet, bot))
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {inject};
|
module.exports = { inject }
|
||||||
|
|
|
@ -1,101 +1,102 @@
|
||||||
/* eslint-disable require-jsdoc */
|
/* eslint-disable require-jsdoc */
|
||||||
/* eslint-disable max-len */
|
/* eslint-disable max-len */
|
||||||
const path = require('path');
|
const path = require('path')
|
||||||
const {MessageEmbed} = require('discord.js');
|
const { MessageEmbed } = require('discord.js')
|
||||||
function inject(bot, dcclient, config) {
|
function inject (bot, dcclient, config) {
|
||||||
const loadFiles = require('../util/load_files');
|
const loadFiles = require('../util/load_files')
|
||||||
const channeldc = dcclient.channels.cache.get(config.discord.servers[bot.options.host]);
|
const channeldc = dcclient.channels.cache.get(config.discord.servers[bot.options.host])
|
||||||
bot.command_handler = {};
|
bot.command_handler = {}
|
||||||
bot.command_handler.commands = {};
|
bot.command_handler.commands = {}
|
||||||
bot.command_handler.reload = async function() {
|
bot.command_handler.reload = async function () {
|
||||||
bot.command_handler.commands = await loadFiles(path.join(__dirname, config.commandsDir));
|
bot.command_handler.commands = await loadFiles(path.join(__dirname, config.commandsDir))
|
||||||
};
|
}
|
||||||
bot.command_handler.reload();
|
bot.command_handler.reload()
|
||||||
bot.command_handler.main = function(prefix, username, usernameraw, message, sender, channeldc, hash, ownerhash, selector) {
|
bot.command_handler.main = function (prefix, username, usernameraw, message, sender, channeldc, hash, ownerhash, selector) {
|
||||||
bot.command_handler.reload();
|
bot.command_handler.reload()
|
||||||
let raw;
|
let raw
|
||||||
let command;
|
let command
|
||||||
const discord = message.content ? true : false;
|
const discord = !!message.content
|
||||||
|
|
||||||
discord ? raw = message.content.substring(prefix.length) :
|
discord
|
||||||
raw = message.substring(prefix.length);
|
? raw = message.content.substring(prefix.length)
|
||||||
|
: raw = message.substring(prefix.length)
|
||||||
|
|
||||||
const [commandName, ...args] = raw.split(' ');
|
const [commandName, ...args] = raw.split(' ')
|
||||||
command = bot.command_handler.commands.find((command) => command.name === commandName.toLowerCase());
|
command = bot.command_handler.commands.find((command) => command.name === commandName.toLowerCase())
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const alias = bot.command_handler.commands.find((command) => command.alias.includes(commandName.toLowerCase()));
|
const alias = bot.command_handler.commands.find((command) => command.alias.includes(commandName.toLowerCase()))
|
||||||
if (alias) command = bot.command_handler.commands.find((command) => command.alias.includes(commandName.toLowerCase()));
|
if (alias) command = bot.command_handler.commands.find((command) => command.alias.includes(commandName.toLowerCase()))
|
||||||
if (prefix === '*' && message.endsWith('*') && message !== '*') return;
|
if (prefix === '*' && message.endsWith('*') && message !== '*') return
|
||||||
if (!command) throw new Error(`Unknown command: "${commandName}"`);
|
if (!command) throw new Error(`Unknown command: "${commandName}"`)
|
||||||
|
|
||||||
if (command.name !== 'validate' && command.trusted === 1) {
|
if (command.name !== 'validate' && command.trusted === 1) {
|
||||||
if (discord && !message.member?.roles?.cache?.some((role) => role.name === 'Trusted')) throw new Error('You\'re not in the trusted role!');
|
if (discord && !message.member?.roles?.cache?.some((role) => role.name === 'Trusted')) throw new Error('You\'re not in the trusted role!')
|
||||||
else if (!discord && args[0] !== hash) throw new Error(`Invalid hash`);
|
else if (!discord && args[0] !== hash) throw new Error('Invalid hash')
|
||||||
} else if (command.name !== 'validate' && command.trusted === 2) {
|
} else if (command.name !== 'validate' && command.trusted === 2) {
|
||||||
if (discord && !message.member?.roles?.cache?.some((role) => role.name === 'Trusted')) throw new Error('You\'re not in the trusted role!');
|
if (discord && !message.member?.roles?.cache?.some((role) => role.name === 'Trusted')) throw new Error('You\'re not in the trusted role!')
|
||||||
else if (!discord && args[0] !== ownerhash) throw new Error(`Invalid OwnerHash`);
|
else if (!discord && args[0] !== ownerhash) throw new Error('Invalid OwnerHash')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prefix === config.discord.prefix) {
|
if (prefix === config.discord.prefix) {
|
||||||
if (!command.discordExecute) throw new Error('This command is not yet supported on discord!');
|
if (!command.discordExecute) throw new Error('This command is not yet supported on discord!')
|
||||||
command.discordExecute(bot, username, usernameraw, sender, prefix, args, channeldc, message, config);
|
command.discordExecute(bot, username, usernameraw, sender, prefix, args, channeldc, message, config)
|
||||||
} else {
|
} else {
|
||||||
command.execute(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector);
|
command.execute(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector)
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (prefix === config.discord.prefix) {
|
if (prefix === config.discord.prefix) {
|
||||||
const Embed = new MessageEmbed()
|
const Embed = new MessageEmbed()
|
||||||
.setColor('#FF0000')
|
.setColor('#FF0000')
|
||||||
.setTitle('Error')
|
.setTitle('Error')
|
||||||
.setDescription(`\`\`\`${e}\`\`\``);
|
.setDescription(`\`\`\`${e}\`\`\``)
|
||||||
channeldc.send({embeds: [Embed]});
|
channeldc.send({ embeds: [Embed] })
|
||||||
} else {
|
} else {
|
||||||
bot.tellraw(selector, {text: String(e), color: 'red'});
|
bot.tellraw(selector, { text: String(e), color: 'red' })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
bot.command_handler.run = function(username, usernameraw, message, sender, channeldc, hash, ownerhash, selector = '@a') {
|
bot.command_handler.run = function (username, usernameraw, message, sender, channeldc, hash, ownerhash, selector = '@a') {
|
||||||
for (const prefix of config.prefixes) {
|
for (const prefix of config.prefixes) {
|
||||||
if (!message.startsWith(prefix)) continue;
|
if (!message.startsWith(prefix)) continue
|
||||||
bot.command_handler.main(prefix, username, usernameraw, message, sender, channeldc, hash, ownerhash, selector);
|
bot.command_handler.main(prefix, username, usernameraw, message, sender, channeldc, hash, ownerhash, selector)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
bot.on('message', async (_username, _message, _sender) => {
|
bot.on('message', async (_username, _message, _sender) => {
|
||||||
// try catch cuz TypeError: Cannot read properties of undefined (reading 'replace')
|
// try catch cuz TypeError: Cannot read properties of undefined (reading 'replace')
|
||||||
try {
|
try {
|
||||||
const usernameraw = _username.replace(/§.?/g, '');
|
const usernameraw = _username.replace(/§.?/g, '')
|
||||||
const sender = _sender !== '00000000-0000-0000-0000-000000000000' ? _sender : bot.playersAddedPlayers[usernameraw];
|
const sender = _sender !== '00000000-0000-0000-0000-000000000000' ? _sender : bot.playersAddedPlayers[usernameraw]
|
||||||
let username;
|
let username
|
||||||
if (!bot.getplayerusername[sender]) username = usernameraw;
|
if (!bot.getplayerusername[sender]) username = usernameraw
|
||||||
else username = bot.getplayerusername[sender];
|
else username = bot.getplayerusername[sender]
|
||||||
const message = _message.replace(/* /§r/g */ /§.?/g, '')/* .replace(/§/g, '')*/;
|
const message = _message.replace(/* /§r/g */ /§.?/g, '')/* .replace(/§/g, '') */
|
||||||
bot.command_handler.run(username, usernameraw, message, sender, channeldc, bot.hash, bot.ownerHash);
|
bot.command_handler.run(username, usernameraw, message, sender, channeldc, bot.hash, bot.ownerHash)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
bot.console.error(e);
|
bot.console.error(e)
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
bot.on('cspy', async function(_username, _message) {
|
bot.on('cspy', async function (_username, _message) {
|
||||||
const username = _username.replace(/§.?/g, '');
|
const username = _username.replace(/§.?/g, '')
|
||||||
const message = _message.replace(/§.?/g, '');
|
const message = _message.replace(/§.?/g, '')
|
||||||
const sender = bot.playersAddedPlayers[username];
|
const sender = bot.playersAddedPlayers[username]
|
||||||
bot.command_handler.run(username, username, message, sender, channeldc, bot.hash, bot.ownerHash, username);
|
bot.command_handler.run(username, username, message, sender, channeldc, bot.hash, bot.ownerHash, username)
|
||||||
});
|
})
|
||||||
function handleDiscordMessages(message) {
|
function handleDiscordMessages (message) {
|
||||||
try {
|
try {
|
||||||
// ignores the message that comes from the bot itself
|
// ignores the message that comes from the bot itself
|
||||||
if (message.author.id === dcclient.user.id) return;
|
if (message.author.id === dcclient.user.id) return
|
||||||
// only receive messages in SPECIFIC channel
|
// only receive messages in SPECIFIC channel
|
||||||
if (message.channel.id !== channeldc.id) return;
|
if (message.channel.id !== channeldc.id) return
|
||||||
if (!message.content.startsWith(config.discord.prefix)) return;
|
if (!message.content.startsWith(config.discord.prefix)) return
|
||||||
bot.command_handler.main(config.discord.prefix, message.member.displayName, message.member.displayName, message, 'no sender for discord', channeldc);
|
bot.command_handler.main(config.discord.prefix, message.member.displayName, message.member.displayName, message, 'no sender for discord', channeldc)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return;
|
return
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
bot.once('end', () => {
|
bot.once('end', () => {
|
||||||
dcclient.off('messageCreate', handleDiscordMessages);
|
dcclient.off('messageCreate', handleDiscordMessages)
|
||||||
});
|
})
|
||||||
dcclient.on('messageCreate', handleDiscordMessages);
|
dcclient.on('messageCreate', handleDiscordMessages)
|
||||||
};
|
};
|
||||||
module.exports = {inject};
|
module.exports = { inject }
|
||||||
|
|
|
@ -1,72 +1,73 @@
|
||||||
|
/* eslint-disable no-eval */
|
||||||
/* eslint-disable require-jsdoc */
|
/* eslint-disable require-jsdoc */
|
||||||
/* eslint-disable max-len */
|
/* eslint-disable max-len */
|
||||||
const moment = require('moment-timezone');
|
const moment = require('moment-timezone')
|
||||||
const util = require('util');
|
const util = require('util')
|
||||||
|
|
||||||
function inject(bot, _dcclient, config, rl) {
|
function inject (bot, _dcclient, config, rl) {
|
||||||
if (!config.console) return;
|
if (!config.console) return
|
||||||
|
|
||||||
// readline > fix on log
|
// readline > fix on log
|
||||||
function log(...args) {
|
function log (...args) {
|
||||||
rl.output.write('\x1b[2K\r');
|
rl.output.write('\x1b[2K\r')
|
||||||
console.log(args.toString());
|
console.log(args.toString())
|
||||||
rl._refreshLine();
|
rl._refreshLine()
|
||||||
};
|
};
|
||||||
|
|
||||||
const chatMessage = require('prismarine-chat')(bot.version);
|
const chatMessage = require('prismarine-chat')(bot.version)
|
||||||
|
|
||||||
function prefix(prefix, _message) {
|
function prefix (prefix, _message) {
|
||||||
const message = `[${moment().format('HH:mm:ss')} ${prefix}§r] [${bot.options.host}] `;
|
const message = `[${moment().format('HH:mm:ss')} ${prefix}§r] [${bot.options.host}] `
|
||||||
const component = chatMessage.MessageBuilder.fromString(message).toJSON();
|
const component = chatMessage.MessageBuilder.fromString(message).toJSON()
|
||||||
return chatMessage.fromNotch(component).toAnsi() + _message;
|
return chatMessage.fromNotch(component).toAnsi() + _message
|
||||||
}
|
}
|
||||||
|
|
||||||
bot.console = {};
|
bot.console = {}
|
||||||
bot.console.host = 'all';
|
bot.console.host = 'all'
|
||||||
bot.console.log = function(message) {
|
bot.console.log = function (message) {
|
||||||
log(prefix('&6LOG', message));
|
log(prefix('&6LOG', message))
|
||||||
};
|
}
|
||||||
bot.console.info = function(message) {
|
bot.console.info = function (message) {
|
||||||
log(prefix('&aINFO', message));
|
log(prefix('&aINFO', message))
|
||||||
};
|
}
|
||||||
bot.console.error = function(error) {
|
bot.console.error = function (error) {
|
||||||
log(prefix('&cERROR', typeof error === 'string' ? error : error.stack));
|
log(prefix('&cERROR', typeof error === 'string' ? error : error.stack))
|
||||||
};
|
}
|
||||||
|
|
||||||
bot.on('parsed_chat', (message) => {
|
bot.on('parsed_chat', (message) => {
|
||||||
bot.console.log(message.toAnsi());
|
bot.console.log(message.toAnsi())
|
||||||
});
|
})
|
||||||
|
|
||||||
function handleLine(line) {
|
function handleLine (line) {
|
||||||
try {
|
try {
|
||||||
if (line.toLowerCase() === '' ||
|
if (line.toLowerCase() === '' ||
|
||||||
line.toLowerCase().startsWith(' ')) return;
|
line.toLowerCase().startsWith(' ')) return
|
||||||
|
|
||||||
if (line.startsWith('.csvr ')) {
|
if (line.startsWith('.csvr ')) {
|
||||||
const host = line.substring(6);
|
const host = line.substring(6)
|
||||||
bot.getBots().forEach((eachBot) => eachBot.console.host = host);
|
bot.getBots().forEach((eachBot) => { eachBot.console.host = host })
|
||||||
bot.console.info(`Host set to: ${host}`);
|
bot.console.info(`Host set to: ${host}`)
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bot.options.host !== bot.console.host && bot.console.host !== 'all') return;
|
if (bot.options.host !== bot.console.host && bot.console.host !== 'all') return
|
||||||
if (line.toLowerCase() === '.exit' || line.toLowerCase() === '.end') {
|
if (line.toLowerCase() === '.exit' || line.toLowerCase() === '.end') {
|
||||||
bot.end('end command');
|
bot.end('end command')
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
if (line.toLowerCase().startsWith('.servereval ')) {
|
if (line.toLowerCase().startsWith('.servereval ')) {
|
||||||
try {
|
try {
|
||||||
bot.tellraw('@a', {
|
bot.tellraw('@a', {
|
||||||
text: `${util.inspect(eval(`${line.substring(12)}`))}`,
|
text: `${util.inspect(eval(`${line.substring(12)}`))}`,
|
||||||
color: 'green',
|
color: 'green'
|
||||||
});
|
})
|
||||||
return;
|
return
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
bot.tellraw('@a', {text: `${util.inspect(err)}`, color: 'red'});
|
bot.tellraw('@a', { text: `${util.inspect(err)}`, color: 'red' })
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (line === '.kill') process.exit();
|
if (line === '.kill') process.exit()
|
||||||
|
|
||||||
if (line.startsWith('.')) {
|
if (line.startsWith('.')) {
|
||||||
return bot.command_handler.run(
|
return bot.command_handler.run(
|
||||||
|
@ -76,42 +77,42 @@ function inject(bot, _dcclient, config, rl) {
|
||||||
bot.uuid,
|
bot.uuid,
|
||||||
null,
|
null,
|
||||||
'h',
|
'h',
|
||||||
'o',
|
'o'
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
bot.tellraw('@a', [
|
bot.tellraw('@a', [
|
||||||
{
|
{
|
||||||
text: '[',
|
text: '[',
|
||||||
color: 'dark_gray',
|
color: 'dark_gray'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: `${bot.username} Console`,
|
text: `${bot.username} Console`,
|
||||||
color: 'gray',
|
color: 'gray'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: '] ',
|
text: '] ',
|
||||||
color: 'dark_gray',
|
color: 'dark_gray'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: 'chayapak ',
|
text: 'chayapak ',
|
||||||
color: 'green',
|
color: 'green'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: '\u203a ',
|
text: '\u203a ',
|
||||||
color: 'dark_gray',
|
color: 'dark_gray'
|
||||||
},
|
},
|
||||||
chatMessage.MessageBuilder.fromString('&7' + line),
|
chatMessage.MessageBuilder.fromString('&7' + line)
|
||||||
]);
|
])
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
bot.console.error(e);
|
bot.console.error(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rl.on('line', handleLine);
|
rl.on('line', handleLine)
|
||||||
|
|
||||||
bot.once('end', () => {
|
bot.once('end', () => {
|
||||||
rl.off('line', handleLine);
|
rl.off('line', handleLine)
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {inject};
|
module.exports = { inject }
|
||||||
|
|
100
plugins/core.js
100
plugins/core.js
|
@ -1,84 +1,84 @@
|
||||||
/* eslint-disable max-len */
|
/* eslint-disable max-len */
|
||||||
/* eslint-disable require-jsdoc */
|
/* eslint-disable require-jsdoc */
|
||||||
const nbt = require('prismarine-nbt');
|
const nbt = require('prismarine-nbt')
|
||||||
const Vec3 = require('vec3');
|
const Vec3 = require('vec3')
|
||||||
|
|
||||||
const relativePosition = new Vec3(0, 0, 0);
|
const relativePosition = new Vec3(0, 0, 0)
|
||||||
|
|
||||||
function inject(bot, dcclient, config) {
|
function inject (bot, dcclient, config) {
|
||||||
const mcData = require('minecraft-data')(bot.version);
|
const mcData = require('minecraft-data')(bot.version)
|
||||||
const chatMessage = require('prismarine-chat')(bot.version);
|
const chatMessage = require('prismarine-chat')(bot.version)
|
||||||
const core = {
|
const core = {
|
||||||
isCore(position) {
|
isCore (position) {
|
||||||
return position.x >= core.start.x && position.x <= core.end.x && position.y >= core.start.y && position.y <= core.end.y && position.z >= core.start.z && position.z <= core.end.z;
|
return position.x >= core.start.x && position.x <= core.end.x && position.y >= core.start.y && position.y <= core.end.y && position.z >= core.start.z && position.z <= core.end.z
|
||||||
},
|
},
|
||||||
run(command) {
|
run (command) {
|
||||||
try {
|
try {
|
||||||
if (config.useChat &&
|
if (config.useChat &&
|
||||||
command.startsWith('minecraft:tellraw @a ') &&
|
command.startsWith('minecraft:tellraw @a ') &&
|
||||||
!command.includes('Console') &&
|
!command.includes('Console') &&
|
||||||
!command.includes('Discord')
|
!command.includes('Discord')
|
||||||
) {
|
) {
|
||||||
bot.chat(chatMessage.fromNotch(command.replace('minecraft:tellraw @a ', '')).toMotd().replaceAll('\xa7', '&'));
|
bot.chat(chatMessage.fromNotch(command.replace('minecraft:tellraw @a ', '')).toMotd().replaceAll('\xa7', '&'))
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
relativePosition.x++;
|
relativePosition.x++
|
||||||
|
|
||||||
if (relativePosition.x >= 16) {
|
if (relativePosition.x >= 16) {
|
||||||
relativePosition.x = 0;
|
relativePosition.x = 0
|
||||||
relativePosition.y++;
|
relativePosition.y++
|
||||||
}
|
}
|
||||||
|
|
||||||
if (relativePosition.y >= config.core.layers) {
|
if (relativePosition.y >= config.core.layers) {
|
||||||
relativePosition.y = 0;
|
relativePosition.y = 0
|
||||||
relativePosition.z++;
|
relativePosition.z++
|
||||||
}
|
}
|
||||||
|
|
||||||
if (relativePosition.z >= 16) {
|
if (relativePosition.z >= 16) {
|
||||||
relativePosition.z = 0;
|
relativePosition.z = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
const impulseMode = !bot.options.kaboom;
|
const impulseMode = !bot.options.kaboom
|
||||||
|
|
||||||
const location = {
|
const location = {
|
||||||
x: core.start.x + relativePosition.x,
|
x: core.start.x + relativePosition.x,
|
||||||
y: core.start.y + relativePosition.y,
|
y: core.start.y + relativePosition.y,
|
||||||
z: core.start.z + relativePosition.z,
|
z: core.start.z + relativePosition.z
|
||||||
};
|
}
|
||||||
|
|
||||||
if (impulseMode) bot.write('update_command_block', {location, command: '', mode: 0, flags: 0});
|
if (impulseMode) bot.write('update_command_block', { location, command: '', mode: 0, flags: 0 })
|
||||||
bot.write('update_command_block', {location, command: String(command).substring(0, 32767), mode: impulseMode ? 2 : 1, flags: 0b100});
|
bot.write('update_command_block', { location, command: String(command).substring(0, 32767), mode: impulseMode ? 2 : 1, flags: 0b100 })
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
bot.console.error(e);
|
bot.console.error(e)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async loopPlace() {
|
async loopPlace () {
|
||||||
try {
|
try {
|
||||||
const fillCommand = `/minecraft:fill ${core.start.x} ${core.start.y} ${core.start.z} ${core.end.x} ${core.end.y} ${core.end.z} command_block{CustomName:'${JSON.stringify(config.core.customName)}'}`;
|
const fillCommand = `/minecraft:fill ${core.start.x} ${core.start.y} ${core.start.z} ${core.end.x} ${core.end.y} ${core.end.z} command_block{CustomName:'${JSON.stringify(config.core.customName)}'}`
|
||||||
const location = {x: Math.floor(bot.position.x), y: Math.floor(bot.position.y) - 1, z: Math.floor(bot.position.z)};
|
const location = { x: Math.floor(bot.position.x), y: Math.floor(bot.position.y) - 1, z: Math.floor(bot.position.z) }
|
||||||
|
|
||||||
bot.write('set_creative_slot', {
|
bot.write('set_creative_slot', {
|
||||||
slot: 36,
|
slot: 36,
|
||||||
item: {
|
item: {
|
||||||
present: true,
|
present: true,
|
||||||
itemId: mcData.itemsByName['repeating_command_block'].id,
|
itemId: mcData.itemsByName.repeating_command_block.id,
|
||||||
itemCount: 64,
|
itemCount: 64,
|
||||||
nbtData: nbt.comp({
|
nbtData: nbt.comp({
|
||||||
BlockEntityTag: nbt.comp({
|
BlockEntityTag: nbt.comp({
|
||||||
Command: nbt.string(fillCommand),
|
Command: nbt.string(fillCommand),
|
||||||
auto: nbt.byte(1),
|
auto: nbt.byte(1),
|
||||||
TrackOutput: nbt.byte(0),
|
TrackOutput: nbt.byte(0)
|
||||||
}),
|
})
|
||||||
}),
|
})
|
||||||
},
|
}
|
||||||
});
|
})
|
||||||
|
|
||||||
bot.write('block_dig', {
|
bot.write('block_dig', {
|
||||||
status: 0,
|
status: 0,
|
||||||
location,
|
location,
|
||||||
face: 1,
|
face: 1
|
||||||
});
|
})
|
||||||
|
|
||||||
bot.write('block_place', {
|
bot.write('block_place', {
|
||||||
location,
|
location,
|
||||||
|
@ -87,34 +87,34 @@ function inject(bot, dcclient, config) {
|
||||||
cursorX: 0.5,
|
cursorX: 0.5,
|
||||||
cursorY: 0.5,
|
cursorY: 0.5,
|
||||||
cursorZ: 0.5,
|
cursorZ: 0.5,
|
||||||
insideBlock: false,
|
insideBlock: false
|
||||||
});
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
bot.console.error(e);
|
bot.console.error(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
function fillCore() {
|
function fillCore () {
|
||||||
core.start = new Vec3(
|
core.start = new Vec3(
|
||||||
Math.floor(bot.position.x / 16) * 16,
|
Math.floor(bot.position.x / 16) * 16,
|
||||||
0 /* bot.position.y */,
|
0 /* bot.position.y */,
|
||||||
Math.floor(bot.position.z / 16) * 16,
|
Math.floor(bot.position.z / 16) * 16
|
||||||
).floor();
|
).floor()
|
||||||
core.end = core.start.clone().translate(16, config.core.layers, 16).subtract(new Vec3(1, 1, 1));
|
core.end = core.start.clone().translate(16, config.core.layers, 16).subtract(new Vec3(1, 1, 1))
|
||||||
|
|
||||||
bot.core.loopPlace();
|
bot.core.loopPlace()
|
||||||
}
|
}
|
||||||
|
|
||||||
bot.on('position', fillCore);
|
bot.on('position', fillCore)
|
||||||
|
|
||||||
const interval = setInterval(() => fillCore(), config.core.refillInterval);
|
const interval = setInterval(() => fillCore(), config.core.refillInterval)
|
||||||
|
|
||||||
bot.once('end', () => {
|
bot.once('end', () => {
|
||||||
clearInterval(interval);
|
clearInterval(interval)
|
||||||
});
|
})
|
||||||
|
|
||||||
bot.core = core;
|
bot.core = core
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {inject};
|
module.exports = { inject }
|
||||||
|
|
|
@ -1,43 +1,44 @@
|
||||||
/* eslint-disable require-jsdoc */
|
/* eslint-disable require-jsdoc */
|
||||||
/* eslint-disable max-len */
|
/* eslint-disable max-len */
|
||||||
const {escapeMarkdown} = require('../util/escapeMarkdown');
|
const { escapeMarkdown } = require('../util/escapeMarkdown')
|
||||||
async function inject(bot, dcclient, config) {
|
async function inject (bot, dcclient, config) {
|
||||||
const channel = dcclient.channels.cache.get(config.discord.servers[bot.options.host]);
|
const chatMessage = require('prismarine-chat')(bot.version)
|
||||||
|
const channel = dcclient.channels.cache.get(config.discord.servers[bot.options.host])
|
||||||
|
|
||||||
let queue = '';
|
let queue = ''
|
||||||
const queueInterval = setInterval(() => {
|
const queueInterval = setInterval(() => {
|
||||||
if (queue === '') return;
|
if (queue === '') return
|
||||||
|
|
||||||
channel.send({
|
channel.send({
|
||||||
content: '```ansi\n' + queue.substring(0, 1986) + '\n```',
|
content: '```ansi\n' + queue.substring(0, 1986) + '\n```',
|
||||||
allowedMentions: {
|
allowedMentions: {
|
||||||
parse: [],
|
parse: []
|
||||||
},
|
}
|
||||||
});
|
})
|
||||||
queue = '';
|
queue = ''
|
||||||
}, 1000);
|
}, 1000)
|
||||||
|
|
||||||
bot.on('parsed_chat', (message) => {
|
bot.on('parsed_chat', (message) => {
|
||||||
const cleanMessage = escapeMarkdown(message.toAnsi(), true);
|
const cleanMessage = escapeMarkdown(message.toAnsi(), true)
|
||||||
const discordMsg = cleanMessage
|
const discordMsg = cleanMessage
|
||||||
.replaceAll('@', '@\u200b')
|
.replaceAll('@', '@\u200b')
|
||||||
.replaceAll('http', 'http\u200b')
|
.replaceAll('http', 'http\u200b')
|
||||||
.replaceAll('\u001b[9', '\u001b[3');
|
.replaceAll('\u001b[9', '\u001b[3')
|
||||||
if (message.toMotd().startsWith('§8[§eChomeNS §9Discord§8] §c')) return;
|
if (message.toMotd().startsWith('§8[§eChomeNS §9Discord§8] §c')) return
|
||||||
queue += '\n' + discordMsg;
|
queue += '\n' + discordMsg
|
||||||
});
|
})
|
||||||
|
|
||||||
// handle discord messages!!!
|
// handle discord messages!!!
|
||||||
async function handleDiscordMessages(message) {
|
async function handleDiscordMessages (message) {
|
||||||
// Ignore messages from the bot itself
|
// Ignore messages from the bot itself
|
||||||
if (message.author.id === dcclient.user.id) return;
|
if (message.author.id === dcclient.user.id) return
|
||||||
|
|
||||||
// Only handle messages in specified channel
|
// Only handle messages in specified channel
|
||||||
if (message.channel.id !== channel.id) return;
|
if (message.channel.id !== channel.id) return
|
||||||
if (message.content.startsWith(config.discord.prefix)) return;
|
if (message.content.startsWith(config.discord.prefix)) return
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const attachmentsComponent = [];
|
const attachmentsComponent = []
|
||||||
if (message.attachments) {
|
if (message.attachments) {
|
||||||
message.attachments.forEach((value) => {
|
message.attachments.forEach((value) => {
|
||||||
attachmentsComponent.push({
|
attachmentsComponent.push({
|
||||||
|
@ -45,70 +46,76 @@ async function inject(bot, dcclient, config) {
|
||||||
color: 'green',
|
color: 'green',
|
||||||
clickEvent: {
|
clickEvent: {
|
||||||
action: 'open_url',
|
action: 'open_url',
|
||||||
value: value.proxyURL,
|
value: value.proxyURL
|
||||||
},
|
}
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
const component = [
|
const component = [
|
||||||
{text: '[', color: 'dark_gray'},
|
{ text: '[', color: 'dark_gray' },
|
||||||
{text: 'ChomeNS ', color: 'yellow',
|
{
|
||||||
|
text: 'ChomeNS ',
|
||||||
|
color: 'yellow',
|
||||||
clickEvent: {
|
clickEvent: {
|
||||||
action: 'open_url',
|
action: 'open_url',
|
||||||
value: 'https://discord.gg/xdgCkUyaA4',
|
value: 'https://discord.gg/xdgCkUyaA4'
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
{
|
||||||
{text: 'Discord', color: 'blue',
|
text: 'Discord',
|
||||||
|
color: 'blue',
|
||||||
clickEvent: {
|
clickEvent: {
|
||||||
action: 'open_url',
|
action: 'open_url',
|
||||||
value: 'https://discord.gg/xdgCkUyaA4',
|
value: 'https://discord.gg/xdgCkUyaA4'
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
{ text: '] ', color: 'dark_gray' },
|
||||||
{text: '] ', color: 'dark_gray'},
|
{
|
||||||
{text: `${message.member.displayName}`, color: 'red',
|
text: `${message.member.displayName}`,
|
||||||
|
color: 'red',
|
||||||
clickEvent: {
|
clickEvent: {
|
||||||
action: 'copy_to_clipboard',
|
action: 'copy_to_clipboard',
|
||||||
value: `${message.author.username}#${message.author.discriminator}`,
|
value: `${message.author.username}#${message.author.discriminator}`
|
||||||
},
|
},
|
||||||
hoverEvent: {
|
hoverEvent: {
|
||||||
action: 'show_text',
|
action: 'show_text',
|
||||||
value: [
|
value: [
|
||||||
{
|
{
|
||||||
text: message.author.username,
|
text: message.author.username,
|
||||||
color: 'white',
|
color: 'white'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: '#',
|
text: '#',
|
||||||
color: 'dark_gray',
|
color: 'dark_gray'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: message.author.discriminator,
|
text: message.author.discriminator,
|
||||||
color: 'gray',
|
color: 'gray'
|
||||||
},
|
},
|
||||||
'\n',
|
'\n',
|
||||||
{
|
{
|
||||||
text: 'Click here to copy the tag to your clipboard',
|
text: 'Click here to copy the tag to your clipboard',
|
||||||
color: 'green',
|
color: 'green'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
],
|
{ text: ' › ', color: 'dark_gray' },
|
||||||
},
|
|
||||||
},
|
|
||||||
{text: ' › ', color: 'dark_gray'},
|
|
||||||
chatMessage.MessageBuilder.fromString('&7' + message.content),
|
chatMessage.MessageBuilder.fromString('&7' + message.content),
|
||||||
attachmentsComponent.length === 0 ? '' : attachmentsComponent,
|
attachmentsComponent.length === 0 ? '' : attachmentsComponent
|
||||||
];
|
]
|
||||||
bot.tellraw('@a', component);
|
bot.tellraw('@a', component)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bot.once('end', () => {
|
bot.once('end', () => {
|
||||||
clearInterval(queueInterval);
|
clearInterval(queueInterval)
|
||||||
dcclient.off('messageCreate', handleDiscordMessages);
|
dcclient.off('messageCreate', handleDiscordMessages)
|
||||||
});
|
})
|
||||||
|
|
||||||
dcclient.on('messageCreate', handleDiscordMessages);
|
dcclient.on('messageCreate', handleDiscordMessages)
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {inject};
|
module.exports = { inject }
|
||||||
|
|
|
@ -1,54 +1,54 @@
|
||||||
/* eslint-disable max-len */
|
/* eslint-disable max-len */
|
||||||
const convert = require('color-convert');
|
const convert = require('color-convert')
|
||||||
|
|
||||||
// eslint-disable-next-line require-jsdoc
|
// eslint-disable-next-line require-jsdoc
|
||||||
function inject(bot) {
|
function inject (bot) {
|
||||||
/**
|
/**
|
||||||
* draw which is totallynotskidded from ybot
|
* draw which is totallynotskidded from ybot
|
||||||
* @param {buffer} data data buffer
|
* @param {buffer} data data buffer
|
||||||
* @param {*} info idk bout this
|
* @param {*} info idk bout this
|
||||||
* @param {object} prefix prefix in the output compoenent
|
* @param {object} prefix prefix in the output compoenent
|
||||||
*/
|
*/
|
||||||
function draw(data, info, prefix = {}) {
|
function draw (data, info, prefix = {}) {
|
||||||
const pixels = [];
|
const pixels = []
|
||||||
|
|
||||||
// Data Buffer -> RGB Array
|
// Data Buffer -> RGB Array
|
||||||
for (let i = 0; i < data.length; i += info.channels) {
|
for (let i = 0; i < data.length; i += info.channels) {
|
||||||
pixels.push([
|
pixels.push([
|
||||||
data[i + 0],
|
data[i + 0],
|
||||||
data[i + 1],
|
data[i + 1],
|
||||||
data[i + 2],
|
data[i + 2]
|
||||||
]);
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
const rows = [];
|
const rows = []
|
||||||
|
|
||||||
// RGB Array -> Rows Array
|
// RGB Array -> Rows Array
|
||||||
for (let i = 0; i < pixels.length; i += info.width) {
|
for (let i = 0; i < pixels.length; i += info.width) {
|
||||||
const row = pixels.slice(i, i + info.width);
|
const row = pixels.slice(i, i + info.width)
|
||||||
|
|
||||||
rows.push(row);
|
rows.push(row)
|
||||||
}
|
}
|
||||||
|
|
||||||
const messages = [];
|
const messages = []
|
||||||
|
|
||||||
for (const row of rows) {
|
for (const row of rows) {
|
||||||
const message = [{...prefix, text: ''}];
|
const message = [{ ...prefix, text: '' }]
|
||||||
|
|
||||||
for (const rgb of row) {
|
for (const rgb of row) {
|
||||||
message.push({
|
message.push({
|
||||||
text: '⎮',
|
text: '⎮',
|
||||||
color: `#${convert.rgb.hex(rgb)}`,
|
color: `#${convert.rgb.hex(rgb)}`
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
messages.push(message);
|
messages.push(message)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const message of messages) bot.tellraw('@a', message);
|
for (const message of messages) bot.tellraw('@a', message)
|
||||||
}
|
}
|
||||||
|
|
||||||
bot.draw = draw;
|
bot.draw = draw
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {inject};
|
module.exports = { inject }
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
/* eslint-disable max-len */
|
/* eslint-disable max-len */
|
||||||
const crypto = require('crypto');
|
const crypto = require('crypto')
|
||||||
module.exports = {
|
module.exports = {
|
||||||
inject: function(bot, dcclient, config) {
|
inject: function (bot, dcclient, config) {
|
||||||
bot.hash = '';
|
bot.hash = ''
|
||||||
|
|
||||||
const interval = setInterval(() => {
|
const interval = setInterval(() => {
|
||||||
bot.hash = crypto.createHash('sha256').update(Math.floor(Date.now() / 10000) + config.keys.normalKey).digest('hex').substring(0, 16);
|
bot.hash = crypto.createHash('sha256').update(Math.floor(Date.now() / 10000) + config.keys.normalKey).digest('hex').substring(0, 16)
|
||||||
bot.ownerHash = crypto.createHash('sha256').update(Math.floor(Date.now() / 10000) + config.keys.ownerHashKey).digest('hex').substring(0, 16);
|
bot.ownerHash = crypto.createHash('sha256').update(Math.floor(Date.now() / 10000) + config.keys.ownerHashKey).digest('hex').substring(0, 16)
|
||||||
}, 2000);
|
}, 2000)
|
||||||
bot.once('end', () => {
|
bot.once('end', () => {
|
||||||
clearInterval(interval);
|
clearInterval(interval)
|
||||||
});
|
})
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
|
181
plugins/music.js
181
plugins/music.js
|
@ -1,7 +1,7 @@
|
||||||
/* eslint-disable require-jsdoc */
|
/* eslint-disable require-jsdoc */
|
||||||
/* eslint-disable max-len */
|
/* eslint-disable max-len */
|
||||||
const {Midi} = require('@tonejs/midi');
|
const { Midi } = require('@tonejs/midi')
|
||||||
const {convertMidi} = require('../util/midi_converter');
|
const { convertMidi } = require('../util/midi_converter')
|
||||||
|
|
||||||
const soundNames = {
|
const soundNames = {
|
||||||
harp: 'minecraft:block.note_block.harp',
|
harp: 'minecraft:block.note_block.harp',
|
||||||
|
@ -19,130 +19,129 @@ const soundNames = {
|
||||||
didgeridoo: 'minecraft:block.note_block.didgeridoo',
|
didgeridoo: 'minecraft:block.note_block.didgeridoo',
|
||||||
bit: 'minecraft:block.note_block.bit',
|
bit: 'minecraft:block.note_block.bit',
|
||||||
banjo: 'minecraft:block.note_block.banjo',
|
banjo: 'minecraft:block.note_block.banjo',
|
||||||
pling: 'minecraft:block.note_block.pling',
|
pling: 'minecraft:block.note_block.pling'
|
||||||
};
|
}
|
||||||
|
|
||||||
function inject(bot) {
|
function inject (bot) {
|
||||||
bot.music = function() {};
|
bot.music = function () {}
|
||||||
bot.music.song = null;
|
bot.music.song = null
|
||||||
bot.music.loop = 0;
|
bot.music.loop = 0
|
||||||
bot.music.queue = [];
|
bot.music.queue = []
|
||||||
let time = 0;
|
let time = 0
|
||||||
let startTime = 0;
|
let startTime = 0
|
||||||
let noteIndex = 0;
|
let noteIndex = 0
|
||||||
bot.music.skip = function() {
|
bot.music.skip = function () {
|
||||||
if (bot.music.loop === 2) {
|
if (bot.music.loop === 2) {
|
||||||
bot.music.queue.push(bot.music.queue.shift());
|
bot.music.queue.push(bot.music.queue.shift())
|
||||||
bot.music.play(bot.music.queue[0]);
|
bot.music.play(bot.music.queue[0])
|
||||||
} else {
|
} else {
|
||||||
bot.music.queue.shift();
|
bot.music.queue.shift()
|
||||||
|
}
|
||||||
|
resetTime()
|
||||||
}
|
}
|
||||||
resetTime();
|
|
||||||
};
|
|
||||||
|
|
||||||
const interval = setInterval(async () => {
|
const interval = setInterval(async () => {
|
||||||
try {
|
try {
|
||||||
if (!bot.music.queue.length) return;
|
if (!bot.music.queue.length) return
|
||||||
bot.music.song = bot.music.queue[0];
|
bot.music.song = bot.music.queue[0]
|
||||||
time = Date.now() - startTime;
|
time = Date.now() - startTime
|
||||||
while (bot.music.song.notes[noteIndex]?.time <= time) {
|
while (bot.music.song.notes[noteIndex]?.time <= time) {
|
||||||
const note = bot.music.song.notes[noteIndex];
|
const note = bot.music.song.notes[noteIndex]
|
||||||
const floatingPitch = 2 ** ((note.pitch - 12) / 12.0);
|
const floatingPitch = 2 ** ((note.pitch - 12) / 12.0)
|
||||||
bot.core.run(`minecraft:execute as @a[tag=!nomusic] at @s run playsound ${soundNames[note.instrument]} record @s ~ ~ ~ ${note.volume} ${floatingPitch}`);
|
bot.core.run(`minecraft:execute as @a[tag=!nomusic] at @s run playsound ${soundNames[note.instrument]} record @s ~ ~ ~ ${note.volume} ${floatingPitch}`)
|
||||||
noteIndex++;
|
noteIndex++
|
||||||
bot.core.run('minecraft:title @a[tag=!nomusic] actionbar ' + JSON.stringify(toComponent()));
|
bot.core.run('minecraft:title @a[tag=!nomusic] actionbar ' + JSON.stringify(toComponent()))
|
||||||
if (noteIndex >= bot.music.song.notes.length) {
|
if (noteIndex >= bot.music.song.notes.length) {
|
||||||
if (bot.music.loop === 1) {
|
if (bot.music.loop === 1) {
|
||||||
resetTime();
|
resetTime()
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
if (bot.music.loop === 2) {
|
if (bot.music.loop === 2) {
|
||||||
resetTime();
|
resetTime()
|
||||||
bot.music.queue.push(bot.music.queue.shift());
|
bot.music.queue.push(bot.music.queue.shift())
|
||||||
bot.music.play(bot.music.queue[0]);
|
bot.music.play(bot.music.queue[0])
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
bot.music.queue.shift();
|
bot.music.queue.shift()
|
||||||
if (!bot.music.queue[0]) {
|
if (!bot.music.queue[0]) {
|
||||||
bot.tellraw('@a', {text: 'Finished playing every song in the queue'});
|
bot.tellraw('@a', { text: 'Finished playing every song in the queue' })
|
||||||
bot.music.stop();
|
bot.music.stop()
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
if (bot.music.queue[0].notes.length > 0) {
|
if (bot.music.queue[0].notes.length > 0) {
|
||||||
if (bot.music.queue.length !== 1) resetTime();
|
if (bot.music.queue.length !== 1) resetTime()
|
||||||
bot.music.play(bot.music.queue[0]);
|
bot.music.play(bot.music.queue[0])
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}, 50);
|
}, 50)
|
||||||
|
|
||||||
bot.once('end', () => {
|
bot.once('end', () => {
|
||||||
clearInterval(interval);
|
clearInterval(interval)
|
||||||
});
|
})
|
||||||
|
|
||||||
bot.music.load = function(buffer, fallbackName = '[unknown]') {
|
bot.music.load = function (buffer, fallbackName = '[unknown]') {
|
||||||
// TODO: NBS Support
|
// TODO: NBS Support
|
||||||
const midi = new Midi(buffer);
|
const midi = new Midi(buffer)
|
||||||
const song = convertMidi(midi);
|
const song = convertMidi(midi)
|
||||||
if (song.name === '') song.name = fallbackName;
|
if (song.name === '') song.name = fallbackName
|
||||||
return song;
|
return song
|
||||||
};
|
|
||||||
|
|
||||||
bot.music.play = function(song) {
|
|
||||||
loop = song.loop;
|
|
||||||
if (bot.music.queue.length === 1) resetTime();
|
|
||||||
};
|
|
||||||
|
|
||||||
bot.music.stop = function() {
|
|
||||||
bot.music.song = null;
|
|
||||||
bot.music.loop = 0;
|
|
||||||
bot.music.queue = [];
|
|
||||||
resetTime();
|
|
||||||
};
|
|
||||||
|
|
||||||
function resetTime() {
|
|
||||||
time = 0;
|
|
||||||
startTime = Date.now();
|
|
||||||
noteIndex = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatTime(time) {
|
bot.music.play = function () {
|
||||||
const seconds = Math.floor(time / 1000);
|
if (bot.music.queue.length === 1) resetTime()
|
||||||
|
|
||||||
return `${Math.floor(seconds / 60)}:${(seconds % 60).toString().padStart(2, '0')}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function toComponent() {
|
bot.music.stop = function () {
|
||||||
|
bot.music.song = null
|
||||||
|
bot.music.loop = 0
|
||||||
|
bot.music.queue = []
|
||||||
|
resetTime()
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetTime () {
|
||||||
|
time = 0
|
||||||
|
startTime = Date.now()
|
||||||
|
noteIndex = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatTime (time) {
|
||||||
|
const seconds = Math.floor(time / 1000)
|
||||||
|
|
||||||
|
return `${Math.floor(seconds / 60)}:${(seconds % 60).toString().padStart(2, '0')}`
|
||||||
|
}
|
||||||
|
|
||||||
|
function toComponent () {
|
||||||
const component = [
|
const component = [
|
||||||
{text: '[', color: 'dark_gray'},
|
{ text: '[', color: 'dark_gray' },
|
||||||
{text: 'ChomeNS Bot', color: 'yellow'},
|
{ text: 'ChomeNS Bot', color: 'yellow' },
|
||||||
{text: '] ', color: 'dark_gray'},
|
{ text: '] ', color: 'dark_gray' },
|
||||||
{text: 'Now Playing', color: 'gold'},
|
{ text: 'Now Playing', color: 'gold' },
|
||||||
{text: ' | ', color: 'dark_gray'},
|
{ text: ' | ', color: 'dark_gray' },
|
||||||
{text: bot.music.song.name, color: 'green'},
|
{ text: bot.music.song.name, color: 'green' },
|
||||||
{text: ' | ', color: 'dark_gray'},
|
{ text: ' | ', color: 'dark_gray' },
|
||||||
{text: formatTime(time), color: 'gray'},
|
{ text: formatTime(time), color: 'gray' },
|
||||||
{text: ' / ', color: 'dark_gray'},
|
{ text: ' / ', color: 'dark_gray' },
|
||||||
{text: formatTime(bot.music.song.length), color: 'gray'},
|
{ text: formatTime(bot.music.song.length), color: 'gray' },
|
||||||
{text: ' | ', color: 'dark_gray'},
|
{ text: ' | ', color: 'dark_gray' },
|
||||||
{text: noteIndex, color: 'gray'},
|
{ text: noteIndex, color: 'gray' },
|
||||||
{text: ' / ', color: 'dark_gray'},
|
{ text: ' / ', color: 'dark_gray' },
|
||||||
{text: bot.music.song.notes.length, color: 'gray'},
|
{ text: bot.music.song.notes.length, color: 'gray' }
|
||||||
];
|
]
|
||||||
|
|
||||||
if (bot.music.loop === 1) {
|
if (bot.music.loop === 1) {
|
||||||
component.push({text: ' | ', color: 'dark_gray'});
|
component.push({ text: ' | ', color: 'dark_gray' })
|
||||||
component.push({text: 'Looping Current', color: 'green'});
|
component.push({ text: 'Looping Current', color: 'green' })
|
||||||
}
|
}
|
||||||
if (bot.music.loop === 2) {
|
if (bot.music.loop === 2) {
|
||||||
component.push({text: ' | ', color: 'dark_gray'});
|
component.push({ text: ' | ', color: 'dark_gray' })
|
||||||
component.push({text: 'Looping All', color: 'green'});
|
component.push({ text: 'Looping All', color: 'green' })
|
||||||
}
|
}
|
||||||
|
|
||||||
return component;
|
return component
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {inject};
|
module.exports = { inject }
|
||||||
|
|
|
@ -1,157 +1,157 @@
|
||||||
/* eslint-disable max-len */
|
/* eslint-disable max-len */
|
||||||
/* eslint-disable require-jsdoc */
|
/* eslint-disable require-jsdoc */
|
||||||
class PlayerList {
|
class PlayerList {
|
||||||
list = [];
|
list = []
|
||||||
|
|
||||||
addPlayer(player) {
|
addPlayer (player) {
|
||||||
this.removePlayer(player);
|
this.removePlayer(player)
|
||||||
|
|
||||||
this.list.push(player);
|
this.list.push(player)
|
||||||
}
|
}
|
||||||
|
|
||||||
hasPlayer(player) {
|
hasPlayer (player) {
|
||||||
return this.getPlayer(player) !== undefined;
|
return this.getPlayer(player) !== undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
getPlayer(player) {
|
getPlayer (player) {
|
||||||
let identifier;
|
let identifier
|
||||||
|
|
||||||
switch (typeof player) {
|
switch (typeof player) {
|
||||||
case 'object':
|
case 'object':
|
||||||
identifier = player.UUID;
|
identifier = player.UUID
|
||||||
break;
|
break
|
||||||
case 'string':
|
case 'string':
|
||||||
identifier = player;
|
identifier = player
|
||||||
break;
|
break
|
||||||
default:
|
default:
|
||||||
throw new Error(`Get player called with ${player}`);
|
throw new Error(`Get player called with ${player}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.list.find((player) => [player.UUID, player.name].some((item) => item === identifier));
|
return this.list.find((player) => [player.UUID, player.name].some((item) => item === identifier))
|
||||||
}
|
}
|
||||||
|
|
||||||
getPlayers() {
|
getPlayers () {
|
||||||
return Array.from(this.list);
|
return Array.from(this.list)
|
||||||
}
|
}
|
||||||
|
|
||||||
removePlayer(player) {
|
removePlayer (player) {
|
||||||
this.list = this.list.filter(({UUID}) => UUID !== player.UUID);
|
this.list = this.list.filter(({ UUID }) => UUID !== player.UUID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class TabCompletePlayerRequester {
|
class TabCompletePlayerRequester {
|
||||||
id = 0;
|
id = 0
|
||||||
queue = {};
|
queue = {}
|
||||||
bot;
|
bot
|
||||||
|
|
||||||
constructor(bot) {
|
constructor (bot) {
|
||||||
this.bot = bot;
|
this.bot = bot
|
||||||
|
|
||||||
bot._client.on('target_packet', (name, data) => {
|
bot._client.on('target_packet', (name, data) => {
|
||||||
if (name !== 'tab_complete') return;
|
if (name !== 'tab_complete') return
|
||||||
|
|
||||||
const players = data.matches
|
const players = data.matches
|
||||||
.filter((match) => !match.tooltip)
|
.filter((match) => !match.tooltip)
|
||||||
.map((match) => match.match);
|
.map((match) => match.match)
|
||||||
|
|
||||||
this.returnPlayerList(data.transactionId, players);
|
this.returnPlayerList(data.transactionId, players)
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
getPlayerList() {
|
getPlayerList () {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
this.id++;
|
this.id++
|
||||||
this.id %= 256;
|
this.id %= 256
|
||||||
|
|
||||||
this.queue[this.id] = resolve;
|
this.queue[this.id] = resolve
|
||||||
|
|
||||||
setTimeout(() => this.returnPlayerList(this.id, this.getPlayerList()), 1000 * 5);
|
setTimeout(() => this.returnPlayerList(this.id, this.getPlayerList()), 1000 * 5)
|
||||||
|
|
||||||
this.bot.write('tab_complete', {transactionId: this.id, text: '/scoreboard players add '});
|
this.bot.write('tab_complete', { transactionId: this.id, text: '/scoreboard players add ' })
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
returnPlayerList(id, players) {
|
returnPlayerList (id, players) {
|
||||||
if (!this.queue[id]) return;
|
if (!this.queue[id]) return
|
||||||
|
|
||||||
this.queue[id](players);
|
this.queue[id](players)
|
||||||
|
|
||||||
delete this.queue[id];
|
delete this.queue[id]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function inject(bot, dcclient, config) {
|
function inject (bot, dcclient, config) {
|
||||||
bot.players = new PlayerList();
|
bot.players = new PlayerList()
|
||||||
bot.requester = new TabCompletePlayerRequester(bot);
|
bot.requester = new TabCompletePlayerRequester(bot)
|
||||||
|
|
||||||
bot._client.on('player_info', (packet) => {
|
bot._client.on('player_info', (packet) => {
|
||||||
for (const player of packet.data) {
|
for (const player of packet.data) {
|
||||||
switch (packet.action) {
|
switch (packet.action) {
|
||||||
case 0:
|
case 0:
|
||||||
addPlayer(player, packet);
|
addPlayer(player, packet)
|
||||||
break;
|
break
|
||||||
case 1:
|
case 1:
|
||||||
updateGamemode(player, packet);
|
updateGamemode(player, packet)
|
||||||
break;
|
break
|
||||||
case 2:
|
case 2:
|
||||||
updatePing(player, packet);
|
updatePing(player, packet)
|
||||||
break;
|
break
|
||||||
case 3:
|
case 3:
|
||||||
updateDisplayName(player, packet);
|
updateDisplayName(player, packet)
|
||||||
break;
|
break
|
||||||
case 4:
|
case 4:
|
||||||
removePlayer(player, packet);
|
removePlayer(player, packet)
|
||||||
break;
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
|
||||||
function addPlayer(player, packet) {
|
function addPlayer (player, packet) {
|
||||||
// if (bot.players.getPlayer(player)) bot.emit('player_unvanished', player, packet);
|
// if (bot.players.getPlayer(player)) bot.emit('player_unvanished', player, packet);
|
||||||
/* else */bot.emit('player_added', player, packet);
|
/* else */bot.emit('player_added', player, packet)
|
||||||
|
|
||||||
bot.players.addPlayer(player);
|
bot.players.addPlayer(player)
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateGamemode(player, packet) {
|
function updateGamemode (player, packet) {
|
||||||
const fullPlayer = bot.players.getPlayer(player);
|
const fullPlayer = bot.players.getPlayer(player)
|
||||||
|
|
||||||
bot.emit('onPlayerGamemodeUpdate', player, packet);
|
bot.emit('onPlayerGamemodeUpdate', player, packet)
|
||||||
|
|
||||||
if (fullPlayer === undefined) return;
|
if (fullPlayer === undefined) return
|
||||||
|
|
||||||
fullPlayer.gamemode = player.gamemode;
|
fullPlayer.gamemode = player.gamemode
|
||||||
}
|
}
|
||||||
|
|
||||||
function updatePing(player, packet) {
|
function updatePing (player, packet) {
|
||||||
const fullPlayer = bot.players.getPlayer(player);
|
const fullPlayer = bot.players.getPlayer(player)
|
||||||
|
|
||||||
bot.emit('player_ping_updated', player, packet);
|
bot.emit('player_ping_updated', player, packet)
|
||||||
|
|
||||||
if (fullPlayer === undefined) return;
|
if (fullPlayer === undefined) return
|
||||||
|
|
||||||
fullPlayer.ping = player.ping;
|
fullPlayer.ping = player.ping
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateDisplayName(player, packet) {
|
function updateDisplayName (player, packet) {
|
||||||
const fullPlayer = bot.players.getPlayer(player);
|
const fullPlayer = bot.players.getPlayer(player)
|
||||||
|
|
||||||
bot.emit('player_display_name_updated', player, packet);
|
bot.emit('player_display_name_updated', player, packet)
|
||||||
|
|
||||||
if (fullPlayer === undefined) return;
|
if (fullPlayer === undefined) return
|
||||||
|
|
||||||
fullPlayer.displayName = player.displayName;
|
fullPlayer.displayName = player.displayName
|
||||||
}
|
}
|
||||||
|
|
||||||
async function removePlayer(player, packet) {
|
async function removePlayer (player, packet) {
|
||||||
// const fullPlayer = bot.players.getPlayer(player);
|
// const fullPlayer = bot.players.getPlayer(player);
|
||||||
// const players = await bot.requester.getPlayerList();
|
// const players = await bot.requester.getPlayerList();
|
||||||
//
|
//
|
||||||
// if (fullPlayer && players.some((name) => name === fullPlayer.name)) bot.emit('player_vanished', player);
|
// if (fullPlayer && players.some((name) => name === fullPlayer.name)) bot.emit('player_vanished', player);
|
||||||
/* else */bot.emit('player_removed', player, packet);
|
/* else */bot.emit('player_removed', player, packet)
|
||||||
|
|
||||||
bot.players.removePlayer(player);
|
bot.players.removePlayer(player)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {inject};
|
module.exports = { inject }
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
/* eslint-disable require-jsdoc */
|
/* eslint-disable require-jsdoc */
|
||||||
function inject(bot) {
|
function inject (bot) {
|
||||||
bot._client.on('position', (position) => {
|
bot._client.on('position', (position) => {
|
||||||
bot.position = position;
|
bot.position = position
|
||||||
bot.write('teleport_confirm', {teleportId: position.teleportId});
|
bot.write('teleport_confirm', { teleportId: position.teleportId })
|
||||||
bot.emit('position', position);
|
bot.emit('position', position)
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {inject};
|
module.exports = { inject }
|
||||||
|
|
|
@ -1,78 +1,78 @@
|
||||||
/* eslint-disable require-jsdoc */
|
/* eslint-disable require-jsdoc */
|
||||||
/* eslint-disable max-len */
|
/* eslint-disable max-len */
|
||||||
function inject(bot, dcclient, config) {
|
function inject (bot, dcclient, config) {
|
||||||
let vanish = false;
|
let vanish = false
|
||||||
let cspy = false;
|
let cspy = false
|
||||||
let op = true;
|
let op = true
|
||||||
let gameMode = 1;
|
let gameMode = 1
|
||||||
let prefix = false;
|
let prefix = false
|
||||||
let muted = false;
|
let muted = false
|
||||||
let endCredits = false;
|
let endCredits = false
|
||||||
|
|
||||||
bot.on('parsed_chat', (data) => {
|
bot.on('parsed_chat', (data) => {
|
||||||
if (data.toString() === 'You are now completely invisible to normal users, and hidden from in-game commands.') vanish = true;
|
if (data.toString() === 'You are now completely invisible to normal users, and hidden from in-game commands.') vanish = true
|
||||||
if (!bot.visibility &&
|
if (!bot.visibility &&
|
||||||
data.toString().startsWith('Vanish for ') &&
|
data.toString().startsWith('Vanish for ') &&
|
||||||
data.toString().endsWith('disabled')
|
data.toString().endsWith('disabled')
|
||||||
) vanish = false;
|
) vanish = false
|
||||||
if (data.toString() === 'Successfully enabled CommandSpy' || data.toString() === ' Enabled your command spy.' || data.toString() === ' Your command spy is already enabled.') cspy = true;
|
if (data.toString() === 'Successfully enabled CommandSpy' || data.toString() === ' Enabled your command spy.' || data.toString() === ' Your command spy is already enabled.') cspy = true
|
||||||
if (data.toString() === 'Successfully disabled CommandSpy' || data.toString() === ' Disabled your command spy.') cspy = false;
|
if (data.toString() === 'Successfully disabled CommandSpy' || data.toString() === ' Disabled your command spy.') cspy = false
|
||||||
if (data.toString() === 'You now have the tag: [ChomeNS Bot]') {
|
if (data.toString() === 'You now have the tag: [ChomeNS Bot]') {
|
||||||
prefix = true;
|
prefix = true
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
if (data.toString().startsWith('You no longer have a tag')) prefix = false;
|
if (data.toString().startsWith('You no longer have a tag')) prefix = false
|
||||||
if (data.toString().startsWith('You now have the tag: ')) prefix = false;
|
if (data.toString().startsWith('You now have the tag: ')) prefix = false
|
||||||
if (data.toString().startsWith('You have been muted')) muted = true;
|
if (data.toString().startsWith('You have been muted')) muted = true
|
||||||
if (data.toString() === 'You have been unmuted.') muted = false;
|
if (data.toString() === 'You have been unmuted.') muted = false
|
||||||
});
|
})
|
||||||
|
|
||||||
bot._client.on('entity_status', (data) => {
|
bot._client.on('entity_status', (data) => {
|
||||||
if (data.entityId !== bot.entityId) return;
|
if (data.entityId !== bot.entityId) return
|
||||||
|
|
||||||
switch (data.entityStatus) {
|
switch (data.entityStatus) {
|
||||||
case 24:
|
case 24:
|
||||||
op = false;
|
op = false
|
||||||
|
|
||||||
bot.emit('deop');
|
bot.emit('deop')
|
||||||
break;
|
break
|
||||||
case 28:
|
case 28:
|
||||||
op = true;
|
op = true
|
||||||
|
|
||||||
bot.emit('op');
|
bot.emit('op')
|
||||||
break;
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
bot.emit('entity_status', data);
|
bot.emit('entity_status', data)
|
||||||
});
|
})
|
||||||
|
|
||||||
bot._client.on('game_state_change', (data) => {
|
bot._client.on('game_state_change', (data) => {
|
||||||
if (data.reason === 4) endCredits = true;
|
if (data.reason === 4) endCredits = true
|
||||||
|
|
||||||
if (data.reason !== 3) return;
|
if (data.reason !== 3) return
|
||||||
|
|
||||||
gameMode = data.gameMode;
|
gameMode = data.gameMode
|
||||||
});
|
})
|
||||||
|
|
||||||
bot._client.once('login', (data) => {
|
bot._client.once('login', (data) => {
|
||||||
gameMode = data.gameMode;
|
gameMode = data.gameMode
|
||||||
});
|
})
|
||||||
|
|
||||||
const interval = setInterval(() => {
|
const interval = setInterval(() => {
|
||||||
if (bot.options.kaboom) {
|
if (bot.options.kaboom) {
|
||||||
if (!prefix && config.self_care.prefix) bot.chat('/extras:prefix &8[&eChomeNS Bot&8]');
|
if (!prefix && config.self_care.prefix) bot.chat('/extras:prefix &8[&eChomeNS Bot&8]')
|
||||||
if (!op && config.self_care.op) bot.chat('/minecraft:op @s[type=player]');
|
if (!op && config.self_care.op) bot.chat('/minecraft:op @s[type=player]')
|
||||||
if (!cspy && config.self_care.cspy) bot.chat('/commandspy:commandspy on');
|
if (!cspy && config.self_care.cspy) bot.chat('/commandspy:commandspy on')
|
||||||
}
|
}
|
||||||
if (!vanish && config.self_care.vanish) bot.chat('/essentials:vanish enable');
|
if (!vanish && config.self_care.vanish) bot.chat('/essentials:vanish enable')
|
||||||
if (gameMode !== 1 && config.self_care.gamemode) bot.chat('/minecraft:gamemode creative @s[type=player]');
|
if (gameMode !== 1 && config.self_care.gamemode) bot.chat('/minecraft:gamemode creative @s[type=player]')
|
||||||
if (muted && config.self_care.mute) bot.chat('/essentials:mute ' + bot.uuid);
|
if (muted && config.self_care.mute) bot.chat('/essentials:mute ' + bot.uuid)
|
||||||
if (endCredits && config.self_care.endCredits) bot.write('client_command', {payload: 0});
|
if (endCredits && config.self_care.endCredits) bot.write('client_command', { payload: 0 })
|
||||||
}, config.self_care_check_interval);
|
}, config.self_care_check_interval)
|
||||||
|
|
||||||
bot.once('end', () => {
|
bot.once('end', () => {
|
||||||
clearInterval(interval);
|
clearInterval(interval)
|
||||||
});
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {inject};
|
module.exports = { inject }
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
/* eslint-disable require-jsdoc */
|
/* eslint-disable require-jsdoc */
|
||||||
/* eslint-disable max-len */
|
/* eslint-disable max-len */
|
||||||
function inject(bot) {
|
function inject (bot) {
|
||||||
bot.tellraw = function(selector, message) {
|
bot.tellraw = function (selector, message) {
|
||||||
bot.core.run(`minecraft:tellraw ${selector} ${typeof message === 'string' ? message : JSON.stringify(message)}`);
|
bot.core.run(`minecraft:tellraw ${selector} ${typeof message === 'string' ? message : JSON.stringify(message)}`)
|
||||||
};
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {inject};
|
module.exports = { inject }
|
||||||
|
|
|
@ -5,9 +5,9 @@ module.exports = {
|
||||||
* @param {Number} max
|
* @param {Number} max
|
||||||
* @return {Number}
|
* @return {Number}
|
||||||
*/
|
*/
|
||||||
between: function(min, max) {
|
between: function (min, max) {
|
||||||
return Math.floor(
|
return Math.floor(
|
||||||
Math.random() * (max - min) + min,
|
Math.random() * (max - min) + min
|
||||||
);
|
)
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
|
74
util/chat.js
74
util/chat.js
|
@ -5,30 +5,30 @@
|
||||||
* @param {object} ChatMessage basically just require prismarine-chat
|
* @param {object} ChatMessage basically just require prismarine-chat
|
||||||
* @param {object} bot bot
|
* @param {object} bot bot
|
||||||
*/
|
*/
|
||||||
function chatPacketListener(packet, ChatMessage, bot) {
|
function chatPacketListener (packet, ChatMessage, bot) {
|
||||||
// try catch prevents hi % exploit (it uses prismarine-chat)
|
// try catch prevents hi % exploit (it uses prismarine-chat)
|
||||||
// and try catch also prevents json parse error
|
// and try catch also prevents json parse error
|
||||||
try {
|
try {
|
||||||
const parsedMessage = JSON.parse(packet.message);
|
const parsedMessage = JSON.parse(packet.message)
|
||||||
if (parsedMessage.translate === 'translation.test.invalid' ||
|
if (parsedMessage.translate === 'translation.test.invalid' ||
|
||||||
parsedMessage.translate === 'translation.test.invalid2') return;
|
parsedMessage.translate === 'translation.test.invalid2') return
|
||||||
|
|
||||||
// down here it prevents command set message
|
// down here it prevents command set message
|
||||||
|
|
||||||
// for ayunboom cuz its 1.17.1
|
// for ayunboom cuz its 1.17.1
|
||||||
// VVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
// VVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
||||||
if (parsedMessage.extra) {
|
if (parsedMessage.extra) {
|
||||||
if (parsedMessage.extra[0].text === 'Command set: ') return;
|
if (parsedMessage.extra[0].text === 'Command set: ') return
|
||||||
}
|
}
|
||||||
// for 1.18 or newer(?)
|
// for 1.18 or newer(?)
|
||||||
// VVVVVVVVVVVVVVVVVVVVV
|
// VVVVVVVVVVVVVVVVVVVVV
|
||||||
if (parsedMessage.translate === 'advMode.setCommand.success') return;
|
if (parsedMessage.translate === 'advMode.setCommand.success') return
|
||||||
|
|
||||||
const message = ChatMessage.fromNotch(packet.message);
|
const message = ChatMessage.fromNotch(packet.message)
|
||||||
|
|
||||||
bot.emit('parsed_chat', message, packet);
|
bot.emit('parsed_chat', message, packet)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -38,53 +38,53 @@ function chatPacketListener(packet, ChatMessage, bot) {
|
||||||
* @param {object} packet chat packet
|
* @param {object} packet chat packet
|
||||||
* @param {object} bot bot
|
* @param {object} bot bot
|
||||||
*/
|
*/
|
||||||
function parsePlayerMessages(message, packet, bot) {
|
function parsePlayerMessages (message, packet, bot) {
|
||||||
try {
|
try {
|
||||||
// prevent braille cuz it CRASHES THE ENTIRE LAPTOP
|
// prevent braille cuz it CRASHES THE ENTIRE LAPTOP
|
||||||
// but sometimes this may not work
|
// but sometimes this may not work
|
||||||
if (message.toString().includes('⣿')) return;
|
if (message.toString().includes('⣿')) return
|
||||||
|
|
||||||
// then here is all the player message parsing thing
|
// then here is all the player message parsing thing
|
||||||
const raw = message.toMotd().substring(0, 32767);
|
const raw = message.toMotd().substring(0, 32767)
|
||||||
if (raw.match(/.* .*: .*/g)) {
|
if (raw.match(/.* .*: .*/g)) {
|
||||||
const username = raw.replace(/.*?\[.*?\] /g, '').replace(/:.*/g, '').replace(/§#....../gm, '');
|
const username = raw.replace(/.*?\[.*?\] /g, '').replace(/:.*/g, '').replace(/§#....../gm, '')
|
||||||
const message = raw.split(': ')[1];
|
const message = raw.split(': ')[1]
|
||||||
bot.emit('message', username, message, packet.sender);
|
bot.emit('message', username, message, packet.sender)
|
||||||
} else if (raw.match(/.* .*\u203a .*/g)) {
|
} else if (raw.match(/.* .*\u203a .*/g)) {
|
||||||
const username = raw.replace(/.*?\[.*?\] /g, '').replace(/\u203a.*/g, '').replace(/§#....../gm, '').split(' ')[0];
|
const username = raw.replace(/.*?\[.*?\] /g, '').replace(/\u203a.*/g, '').replace(/§#....../gm, '').split(' ')[0]
|
||||||
const message = raw.split('\u203a ')[1].substring(2);
|
const message = raw.split('\u203a ')[1].substring(2)
|
||||||
bot.emit('message', username, message, packet.sender);
|
bot.emit('message', username, message, packet.sender)
|
||||||
} else if (raw.match(/.* .*\u00BB .*/g)) {
|
} else if (raw.match(/.* .*\u00BB .*/g)) {
|
||||||
const username = raw.replace(/.*?\[.*?\] /g, '').replace(/\u00BB.*/g, '').replace(/§#....../gm, '').split(' ')[0];
|
const username = raw.replace(/.*?\[.*?\] /g, '').replace(/\u00BB.*/g, '').replace(/§#....../gm, '').split(' ')[0]
|
||||||
const message = raw.split('\u00BB ')[1].substring(2);
|
const message = raw.split('\u00BB ')[1].substring(2)
|
||||||
bot.emit('message', username, message, packet.sender);
|
bot.emit('message', username, message, packet.sender)
|
||||||
} else if (raw.match(/<.*> .*/g)) {
|
} else if (raw.match(/<.*> .*/g)) {
|
||||||
const username = raw.substring(1).split('>')[0];
|
const username = raw.substring(1).split('>')[0]
|
||||||
const message = raw.split('> ')[1];
|
const message = raw.split('> ')[1]
|
||||||
|
|
||||||
bot.emit('message', username, message, packet.sender);
|
bot.emit('message', username, message, packet.sender)
|
||||||
} else if (raw.match(/§.*§b: §b\/.*/g)) {
|
} else if (raw.match(/§.*§b: §b\/.*/g)) {
|
||||||
const username = raw.split('§b: §b')[0];
|
const username = raw.split('§b: §b')[0]
|
||||||
const command = raw.split('§b: §b')[1];
|
const command = raw.split('§b: §b')[1]
|
||||||
|
|
||||||
bot.emit('cspy', username, command);
|
bot.emit('cspy', username, command)
|
||||||
} else if (raw.match(/§.*§e: §e\/.*/g)) {
|
} else if (raw.match(/§.*§e: §e\/.*/g)) {
|
||||||
const username = raw.split('§e: §e')[0];
|
const username = raw.split('§e: §e')[0]
|
||||||
const command = raw.split('§e: §e')[1];
|
const command = raw.split('§e: §e')[1]
|
||||||
bot.emit('cspy', username, command);
|
bot.emit('cspy', username, command)
|
||||||
} else if (raw.match(/§.*§b: \/.*/g)) {
|
} else if (raw.match(/§.*§b: \/.*/g)) {
|
||||||
const username = raw.split('§b: ')[0];
|
const username = raw.split('§b: ')[0]
|
||||||
const command = raw.split('§b: ')[1];
|
const command = raw.split('§b: ')[1]
|
||||||
|
|
||||||
bot.emit('cspy', username, command);
|
bot.emit('cspy', username, command)
|
||||||
} else if (raw.match(/§.*§e: \/.*/g)) {
|
} else if (raw.match(/§.*§e: \/.*/g)) {
|
||||||
const username = raw.split('§e: ')[0];
|
const username = raw.split('§e: ')[0]
|
||||||
const command = raw.split('§e: ')[1];
|
const command = raw.split('§e: ')[1]
|
||||||
bot.emit('cspy', username, command);
|
bot.emit('cspy', username, command)
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {chatPacketListener, parsePlayerMessages};
|
module.exports = { chatPacketListener, parsePlayerMessages }
|
||||||
|
|
|
@ -11,13 +11,13 @@ const styles = {
|
||||||
special: '\xa73',
|
special: '\xa73',
|
||||||
string: '\xa72',
|
string: '\xa72',
|
||||||
symbol: '\xa72',
|
symbol: '\xa72',
|
||||||
undefined: '\xa78',
|
undefined: '\xa78'
|
||||||
};
|
|
||||||
|
|
||||||
function stylize(str, styleType) {
|
|
||||||
const style = styles[styleType];
|
|
||||||
if (style !== undefined) return `${style}${str}\xa7r`;
|
|
||||||
return str;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {stylize, styles};
|
function stylize (str, styleType) {
|
||||||
|
const style = styles[styleType]
|
||||||
|
if (style !== undefined) return `${style}${str}\xa7r`
|
||||||
|
return str
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { stylize, styles }
|
||||||
|
|
|
@ -4,16 +4,16 @@
|
||||||
* @param {String} character the character
|
* @param {String} character the character
|
||||||
* @return {boolean} allowed
|
* @return {boolean} allowed
|
||||||
*/
|
*/
|
||||||
function isAllowedCharacter(character) {
|
function isAllowedCharacter (character) {
|
||||||
return character !== '\xa7' && character >= ' ' && character !== '\x7f';
|
return character !== '\xa7' && character >= ' ' && character !== '\x7f'
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* mc chat check if contains illegal chars.
|
* mc chat check if contains illegal chars.
|
||||||
* @param {String} string the string
|
* @param {String} string the string
|
||||||
* @return {boolean} if contains then true else false
|
* @return {boolean} if contains then true else false
|
||||||
*/
|
*/
|
||||||
function containsIllegalCharacters(string) {
|
function containsIllegalCharacters (string) {
|
||||||
for (let i = 0; i < string.length; i++) if (!isAllowedCharacter(string[i])) return true;
|
for (let i = 0; i < string.length; i++) if (!isAllowedCharacter(string[i])) return true
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {containsIllegalCharacters};
|
module.exports = { containsIllegalCharacters }
|
||||||
|
|
|
@ -4,19 +4,19 @@
|
||||||
* @param {Boolean} zwsp
|
* @param {Boolean} zwsp
|
||||||
* @return {String}
|
* @return {String}
|
||||||
*/
|
*/
|
||||||
function escapeMarkdown(text, zwsp) {
|
function escapeMarkdown (text, zwsp) {
|
||||||
let unescaped;
|
let unescaped
|
||||||
let escaped;
|
let escaped
|
||||||
try {
|
try {
|
||||||
unescaped = text.replace(/\\(\*|@|_|`|~|\\)/g, '$1');
|
unescaped = text.replace(/\\(\*|@|_|`|~|\\)/g, '$1')
|
||||||
escaped = unescaped.replace(/(\*|@|_|`|~|\\)/g, zwsp ?
|
escaped = unescaped.replace(/(\*|@|_|`|~|\\)/g, zwsp
|
||||||
'\u200b\u200b$1' :
|
? '\u200b\u200b$1'
|
||||||
'\\$1',
|
: '\\$1'
|
||||||
);
|
)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return unescaped;
|
return unescaped
|
||||||
}
|
}
|
||||||
return escaped;
|
return escaped
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {escapeMarkdown};
|
module.exports = { escapeMarkdown }
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
const fs = require('fs/promises');
|
const fs = require('fs/promises')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* check if file exists
|
* check if file exists
|
||||||
* @param {String} filepath the file path
|
* @param {String} filepath the file path
|
||||||
* @return {boolean} if file exists true else false
|
* @return {boolean} if file exists true else false
|
||||||
*/
|
*/
|
||||||
async function fileExists(filepath) {
|
async function fileExists (filepath) {
|
||||||
try {
|
try {
|
||||||
await fs.access(filepath);
|
await fs.access(filepath)
|
||||||
return true;
|
return true
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.code !== 'ENOENT') throw error;
|
if (error.code !== 'ENOENT') throw error
|
||||||
|
|
||||||
return false;
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = fileExists;
|
module.exports = fileExists
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
const fs = require('fs/promises');
|
const fs = require('fs/promises')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* just list the files
|
* just list the files
|
||||||
* @param {String} filepath file path
|
* @param {String} filepath file path
|
||||||
* @return {Array} component.
|
* @return {Array} component.
|
||||||
*/
|
*/
|
||||||
async function list(filepath = '.') {
|
async function list (filepath = '.') {
|
||||||
const files = await fs.readdir(filepath);
|
const files = await fs.readdir(filepath)
|
||||||
|
|
||||||
const component = [];
|
const component = []
|
||||||
files.forEach((filename, index) => {
|
files.forEach((filename, index) => {
|
||||||
component.push(filename);
|
component.push(filename)
|
||||||
});
|
})
|
||||||
return component;
|
return component
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = list;
|
module.exports = list
|
||||||
|
|
|
@ -3,21 +3,21 @@ const profanityNames = ['Eagler', 'Eagler', 'Bitch', 'Cock', 'Milf', 'Milf', 'Ye
|
||||||
'Eag', 'Deevis', 'Chode', 'Deev', 'Deev', 'Fucker', 'Fucking',
|
'Eag', 'Deevis', 'Chode', 'Deev', 'Deev', 'Fucker', 'Fucking',
|
||||||
'Dumpster', 'Dumpster', 'Cum', 'Chad', 'Egg', 'Fudgler', 'Fudgli',
|
'Dumpster', 'Dumpster', 'Cum', 'Chad', 'Egg', 'Fudgler', 'Fudgli',
|
||||||
'Yee', 'Yee', 'Yee', 'Yeet', 'Flumpter', 'Darvy', 'Darver', 'Darver',
|
'Yee', 'Yee', 'Yee', 'Yeet', 'Flumpter', 'Darvy', 'Darver', 'Darver',
|
||||||
'Fuck', 'Fuck', 'Frick', 'Eagler', 'Vigg', 'Vigg', 'Cunt', 'Darvig',
|
'Fuck', 'Fuck', 'Frick', 'Eagler', 'Vigg', 'Vigg', 'Cunt', 'Darvig'
|
||||||
];
|
]
|
||||||
const names = ['Yeeish', 'Yeeish', 'Yee', 'Yee', 'Yeer', 'Yeeler', 'Eagler', 'Eagl',
|
const names = ['Yeeish', 'Yeeish', 'Yee', 'Yee', 'Yeer', 'Yeeler', 'Eagler', 'Eagl',
|
||||||
'Darver', 'Darvler', 'Vool', 'Vigg', 'Vigg', 'Deev', 'Yigg', 'Yeeg'];
|
'Darver', 'Darvler', 'Vool', 'Vigg', 'Vigg', 'Deev', 'Yigg', 'Yeeg']
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gets a random item in an array
|
* gets a random item in an array
|
||||||
* @param {Array} arr the array
|
* @param {Array} arr the array
|
||||||
* @return {*} the item in the array
|
* @return {*} the item in the array
|
||||||
*/
|
*/
|
||||||
function getRandomItem(arr) {
|
function getRandomItem (arr) {
|
||||||
const randomIndex = Math.floor(Math.random() * arr.length);
|
const randomIndex = Math.floor(Math.random() * arr.length)
|
||||||
const item = arr[randomIndex];
|
const item = arr[randomIndex]
|
||||||
|
|
||||||
return item;
|
return item
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,15 +25,15 @@ function getRandomItem(arr) {
|
||||||
* @param {boolean} profanity bad words.
|
* @param {boolean} profanity bad words.
|
||||||
* @return {String} the output of the generated eagler username
|
* @return {String} the output of the generated eagler username
|
||||||
*/
|
*/
|
||||||
function genUsername(profanity) {
|
function genUsername (profanity) {
|
||||||
let username;
|
let username
|
||||||
if (profanity) {
|
if (profanity) {
|
||||||
username = getRandomItem(profanityNames) + getRandomItem(profanityNames) + (10 + Math.floor(Math.random() * 90));
|
username = getRandomItem(profanityNames) + getRandomItem(profanityNames) + (10 + Math.floor(Math.random() * 90))
|
||||||
} else {
|
} else {
|
||||||
username = getRandomItem(names) + getRandomItem(names) + (10 + Math.floor(Math.random() * 90));
|
username = getRandomItem(names) + getRandomItem(names) + (10 + Math.floor(Math.random() * 90))
|
||||||
}
|
}
|
||||||
|
|
||||||
return username;
|
return username
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = genUsername;
|
module.exports = genUsername
|
||||||
|
|
|
@ -4,24 +4,24 @@
|
||||||
* @param {number} height height
|
* @param {number} height height
|
||||||
* @return {object} width and height
|
* @return {object} width and height
|
||||||
*/
|
*/
|
||||||
function resize(width, height) {
|
function resize (width, height) {
|
||||||
const aspectRatio = width / height;
|
const aspectRatio = width / height
|
||||||
|
|
||||||
let optimalWidth = Math.round(aspectRatio * 20 * (27 / 3));
|
let optimalWidth = Math.round(aspectRatio * 20 * (27 / 3))
|
||||||
let optimalHeight = 20;
|
let optimalHeight = 20
|
||||||
|
|
||||||
if (optimalWidth > 320) {
|
if (optimalWidth > 320) {
|
||||||
const reduction = optimalWidth / 320;
|
const reduction = optimalWidth / 320
|
||||||
|
|
||||||
optimalWidth = 320;
|
optimalWidth = 320
|
||||||
|
|
||||||
optimalHeight *= reduction;
|
optimalHeight *= reduction
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
width: Math.floor(optimalWidth),
|
width: Math.floor(optimalWidth),
|
||||||
height: Math.floor(optimalHeight),
|
height: Math.floor(optimalHeight)
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {resize};
|
module.exports = { resize }
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* eslint-disable max-len */
|
/* eslint-disable max-len */
|
||||||
const fs = require('fs/promises');
|
const fs = require('fs/promises')
|
||||||
const util = require('util');
|
const util = require('util')
|
||||||
const path = require('path');
|
const path = require('path')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* load plugins
|
* load plugins
|
||||||
|
@ -10,19 +10,19 @@ const path = require('path');
|
||||||
* @param {object} config the config
|
* @param {object} config the config
|
||||||
* @param {object} rl readline.
|
* @param {object} rl readline.
|
||||||
*/
|
*/
|
||||||
async function loadPlugins(bot, dcclient, config, rl) {
|
async function loadPlugins (bot, dcclient, config, rl) {
|
||||||
const dir = path.join(__dirname, '..', 'plugins');
|
const dir = path.join(__dirname, '..', 'plugins')
|
||||||
const plugins = await fs.readdir(dir);
|
const plugins = await fs.readdir(dir)
|
||||||
plugins.forEach((plugin) => {
|
plugins.forEach((plugin) => {
|
||||||
if (!plugin.endsWith('.js')) return;
|
if (!plugin.endsWith('.js')) return
|
||||||
try {
|
try {
|
||||||
const plug = require(path.join(dir, plugin));
|
const plug = require(path.join(dir, plugin))
|
||||||
plug.inject(bot, dcclient, config, rl);
|
plug.inject(bot, dcclient, config, rl)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(`Plugin ${plugin} is having exception loading the plugin:`);
|
console.log(`Plugin ${plugin} is having exception loading the plugin:`)
|
||||||
console.log(util.inspect(e));
|
console.log(util.inspect(e))
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {loadPlugins};
|
module.exports = { loadPlugins }
|
||||||
|
|
|
@ -1,25 +1,25 @@
|
||||||
const fs = require('fs/promises');
|
const fs = require('fs/promises')
|
||||||
const path = require('path');
|
const path = require('path')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* loads js files
|
* loads js files
|
||||||
* @param {string} directory the directory that contains the js files
|
* @param {string} directory the directory that contains the js files
|
||||||
* @return {Array} an array of require()ed js files
|
* @return {Array} an array of require()ed js files
|
||||||
*/
|
*/
|
||||||
async function loadPlugins(directory) {
|
async function loadPlugins (directory) {
|
||||||
const plugins = [];
|
const plugins = []
|
||||||
|
|
||||||
for (const filename of await fs.readdir(directory)) {
|
for (const filename of await fs.readdir(directory)) {
|
||||||
if (!filename.endsWith('.js')) continue;
|
if (!filename.endsWith('.js')) continue
|
||||||
|
|
||||||
const filepath = path.join(directory, filename);
|
const filepath = path.join(directory, filename)
|
||||||
|
|
||||||
const plugin = require(filepath);
|
const plugin = require(filepath)
|
||||||
|
|
||||||
plugins.push(plugin);
|
plugins.push(plugin)
|
||||||
}
|
}
|
||||||
|
|
||||||
return plugins;
|
return plugins
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = loadPlugins;
|
module.exports = loadPlugins
|
||||||
|
|
|
@ -3,15 +3,15 @@
|
||||||
* @param {Number} d seconds
|
* @param {Number} d seconds
|
||||||
* @return {String} X hour, X minute, X second
|
* @return {String} X hour, X minute, X second
|
||||||
*/
|
*/
|
||||||
function secondsToHms(d) {
|
function secondsToHms (d) {
|
||||||
d = Number(d);
|
d = Number(d)
|
||||||
const h = Math.floor(d / 3600);
|
const h = Math.floor(d / 3600)
|
||||||
const m = Math.floor(d % 3600 / 60);
|
const m = Math.floor(d % 3600 / 60)
|
||||||
const s = Math.floor(d % 3600 % 60);
|
const s = Math.floor(d % 3600 % 60)
|
||||||
const hDisplay = h > 0 ? h + (h == 1 ? ' hour, ' : ' hours, ') : '';
|
const hDisplay = h > 0 ? h + (h === 1 ? ' hour, ' : ' hours, ') : ''
|
||||||
const mDisplay = m > 0 ? m + (m == 1 ? ' minute, ' : ' minutes, ') : '';
|
const mDisplay = m > 0 ? m + (m === 1 ? ' minute, ' : ' minutes, ') : ''
|
||||||
const sDisplay = s > 0 ? s + (s == 1 ? ' second' : ' seconds') : '';
|
const sDisplay = s > 0 ? s + (s === 1 ? ' second' : ' seconds') : ''
|
||||||
return hDisplay + mDisplay + sDisplay;
|
return hDisplay + mDisplay + sDisplay
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {secondsToHms};
|
module.exports = { secondsToHms }
|
||||||
|
|
Loading…
Reference in a new issue