forked from afspiegeling/NitoriBot
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5f2c073767 | ||
|
|
5000abf90d | ||
|
|
afff6aea83 | ||
|
|
2e753c583b |
+5
-5
@@ -1,6 +1,6 @@
|
||||
.env
|
||||
node_modules
|
||||
.upm
|
||||
.replit
|
||||
replit.nix
|
||||
new file
|
||||
logs
|
||||
midis
|
||||
config.js
|
||||
.env
|
||||
amog
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
# chomens-bot-js
|
||||
***(originally named chomens-bot-mc)***\
|
||||
\
|
||||
Archive of ChomeNS Bot Javascript source code.\
|
||||
\
|
||||
Some of the code are messy and hardcoded so you might wanna change some of it.\
|
||||
\
|
||||
Explore the code and see how it works!\
|
||||
Also note that the core is broken sometimes.
|
||||
|
||||
R.I.P ChomeNS Bot Javascript
|
||||
@@ -1,128 +0,0 @@
|
||||
const mc = require('minecraft-protocol')
|
||||
const { EventEmitter } = require('events')
|
||||
const { loadPlugins } = require('./util/loadPlugins')
|
||||
const util = require('node:util')
|
||||
const randomstring = require('randomstring')
|
||||
|
||||
/**
|
||||
* makes the bot
|
||||
* @param {object} server the server object used in the config
|
||||
* @param {object} config the config file
|
||||
* @param {Function} getBots get bots function in index.js
|
||||
* @param {Function} setNewBot ig real
|
||||
* @param {Class} dcclient discord client
|
||||
* @param {object} rl readline.
|
||||
* @return {object} the bot object
|
||||
*/
|
||||
async function createBot (server, config, getBots, setNewBot, dcclient, rl) {
|
||||
const bot = new EventEmitter()
|
||||
bot.options = {
|
||||
username: server.username ?? randomstring.generate(8),
|
||||
host: server.host ?? 'localhost',
|
||||
port: server.port ?? 25565,
|
||||
version: config.version,
|
||||
kaboom: server.kaboom ?? true,
|
||||
logging: server.logging ?? true,
|
||||
useChat: server.useChat ?? false,
|
||||
checkTimeoutInterval: config.timeoutInterval,
|
||||
hideErrors: true
|
||||
}
|
||||
|
||||
// among us fix for bot.options.host and bot.options.port
|
||||
bot.server = {
|
||||
host: server.host,
|
||||
port: server.port
|
||||
}
|
||||
|
||||
bot.visibility = false
|
||||
bot.getBots = getBots
|
||||
|
||||
bot.end = (reason = 'end', event) => {
|
||||
bot.emit('end', reason, event)
|
||||
bot.removeAllListeners()
|
||||
bot._client.end()
|
||||
bot._client.removeAllListeners()
|
||||
}
|
||||
|
||||
bot._client = mc.createClient(bot.options)
|
||||
|
||||
bot.setMaxListeners(Infinity)
|
||||
bot._client.setMaxListeners(Infinity)
|
||||
|
||||
bot.version = bot._client.version
|
||||
bot.write = (name, data) => bot._client.write(name, data)
|
||||
|
||||
setNewBot(bot.server.host, bot)
|
||||
|
||||
const channel = dcclient.channels.cache.get(config.discord.servers[`${bot.server.host}:${bot.server.port}`])
|
||||
|
||||
channel.send(
|
||||
`Connecting to: \`${bot.server.host}:${bot.server.port}\``
|
||||
)
|
||||
|
||||
bot._client.on('login', (data) => bot.emit('login', data))
|
||||
|
||||
bot.on('login', async function (data) {
|
||||
bot.entityId = data.entityId
|
||||
bot.uuid = bot._client.uuid
|
||||
bot.username = bot._client.username
|
||||
|
||||
channel.send(
|
||||
`Successfully logged in to: \`${bot.server.host}:${bot.server.port}\``
|
||||
)
|
||||
})
|
||||
|
||||
await loadPlugins(bot, dcclient, config, rl)
|
||||
|
||||
bot._client.on('end', (reason) => {
|
||||
bot.end(reason, 'end')
|
||||
})
|
||||
|
||||
bot.on('end', (reason, event) => {
|
||||
bot.console.info(
|
||||
`Disconnected from ${bot.server.host} (${event} event): ${util.inspect(reason)}`
|
||||
)
|
||||
channel.send(`Disconnected: \`${util.inspect(reason)}\``)
|
||||
|
||||
let timeout = config.reconnectTimeout
|
||||
|
||||
try {
|
||||
if (reason.text) {
|
||||
if (reason.text ===
|
||||
'Wait 5 seconds before connecting, thanks! :)' ||
|
||||
reason.text ===
|
||||
'You are logging in too fast, try again later.'
|
||||
) timeout = 1000 * 7
|
||||
}
|
||||
} catch (e) {
|
||||
bot.console.error(e)
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
bot.end()
|
||||
createBot(server, config, getBots, setNewBot, dcclient, rl)
|
||||
}, timeout)
|
||||
})
|
||||
|
||||
bot._client.on('keep_alive', ({ keepAliveId }) => {
|
||||
bot.write('keep_alive', { keepAliveId })
|
||||
})
|
||||
|
||||
bot._client.on('kick_disconnect', (data) => {
|
||||
const parsed = JSON.parse(data.reason)
|
||||
bot.end(parsed, 'kick_disconnect')
|
||||
})
|
||||
|
||||
bot._client.on('disconnect', (data) => {
|
||||
const parsed = JSON.parse(data.reason)
|
||||
bot.end(parsed, 'disconnect')
|
||||
})
|
||||
|
||||
bot._client.on('error', (data) => {
|
||||
bot.end(data, 'error')
|
||||
})
|
||||
|
||||
return bot
|
||||
};
|
||||
|
||||
module.exports = { createBot }
|
||||
@@ -1,18 +0,0 @@
|
||||
const { EmbedBuilder } = require('discord.js')
|
||||
module.exports = {
|
||||
name: 'botuser',
|
||||
alias: [],
|
||||
description: 'Shows the bot\'s username and UUID',
|
||||
usage: '',
|
||||
trusted: 0,
|
||||
execute (bot, username, 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' }] } }])
|
||||
},
|
||||
discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Bot\'s User')
|
||||
.setDescription(`The bot's username is: \`${bot.username}\` and the UUID is: \`${bot.uuid}\``)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
const { EmbedBuilder } = require('discord.js')
|
||||
module.exports = {
|
||||
name: 'botvisibility',
|
||||
alias: ['botvis', 'togglevis', 'togglevisibility'],
|
||||
description: 'Changes the bot\'s visibility',
|
||||
usage: [
|
||||
'<hash> <true|false>',
|
||||
'<hash> <on|off>',
|
||||
'<hash>'
|
||||
],
|
||||
trusted: 1,
|
||||
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
if (args[1] === 'true' || args[1] === 'on') {
|
||||
bot.visibility = true
|
||||
bot.chat('/essentials:vanish disable')
|
||||
bot.tellraw(selector, [{ text: 'The bot\'s visibility is now ', color: 'white' }, { text: 'visible', color: 'green' }])
|
||||
} else if (args[1] === 'false' || args[1] === 'off') {
|
||||
bot.visibility = false
|
||||
bot.chat('/essentials:vanish enable')
|
||||
bot.tellraw(selector, [{ text: 'The bot\'s visibility is now ', color: 'white' }, { text: 'invisible', color: 'gold' }])
|
||||
} else if (!args[1]) {
|
||||
bot.visibility = !bot.visibility
|
||||
const greenOrGold = bot.visibility ? 'green' : 'gold'
|
||||
const visibleOrInvisible = bot.visibility ? 'visible' : 'invisible'
|
||||
const enableOrDisable = bot.visibility ? 'disable' : 'enable'
|
||||
bot.chat(`/essentials:vanish ${enableOrDisable}`)
|
||||
bot.tellraw(selector, [{ text: 'The bot\'s visibility is now ', color: 'white' }, { text: visibleOrInvisible, color: greenOrGold }])
|
||||
} else {
|
||||
throw new SyntaxError('Invalid argument')
|
||||
}
|
||||
},
|
||||
discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
|
||||
if (args[0] === 'true' || args[0] === 'on') {
|
||||
bot.visibility = true
|
||||
bot.chat('/essentials:vanish disable')
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Bot\'s Visibility')
|
||||
.setDescription('The bot\'s visibility is now visible')
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
} else if (args[0] === 'false' || args[0] === 'off') {
|
||||
bot.visibility = false
|
||||
bot.chat('/essentials:vanish enable')
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Bot\'s Visibility')
|
||||
.setDescription('The bot\'s visibility is now invisible')
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
} else if (!args[0]) {
|
||||
bot.visibility = !bot.visibility
|
||||
const visibleOrInvisible = bot.visibility ? 'visible' : 'invisible'
|
||||
const enableOrDisable = bot.visibility ? 'disable' : 'enable'
|
||||
bot.chat(`/essentials:vanish ${enableOrDisable}`)
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Bot\'s Visibility')
|
||||
.setDescription(`The bot's visibility is now ${visibleOrInvisible}`)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
} else {
|
||||
throw new SyntaxError('Invalid argument')
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
const { EmbedBuilder } = require('discord.js')
|
||||
module.exports = {
|
||||
name: 'bruhify',
|
||||
alias: [],
|
||||
description: 'RecycleBot bruhify but actionbar',
|
||||
usage: '<message>',
|
||||
trusted: 0,
|
||||
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
bot.bruhifyText = args.join(' ')
|
||||
},
|
||||
discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
|
||||
bot.bruhifyText = args.join(' ')
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Bruhify')
|
||||
.setDescription(`Bruhify set to: ${bot.bruhifyText}`)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
module.exports = {
|
||||
name: 'cb',
|
||||
alias: ['cmd', 'commandblock', 'run'],
|
||||
description: 'Executes a command in the command core',
|
||||
usage: '<command>',
|
||||
trusted: 0,
|
||||
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
bot.core.run(args.join(' '))
|
||||
},
|
||||
discordExecute (bot, username, sender, prefix, args, channeldc) {
|
||||
bot.core.run(args.join(' '))
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
|
||||
module.exports = {
|
||||
name: 'clearchat',
|
||||
alias: ['cc'],
|
||||
description: 'Clears the chat',
|
||||
usage: '[player]',
|
||||
trusted: 0,
|
||||
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
if (args[0]) {
|
||||
bot.tellraw(args.join(' '), [{ text: '\n'.repeat(100), color: 'white' }, { text: `Your chat has been cleared by ${username}.`, color: 'dark_green' }])
|
||||
} else {
|
||||
bot.tellraw('@a', [{ text: '\n'.repeat(100), color: 'white' }, { text: 'The chat has been cleared.', color: 'dark_green' }])
|
||||
}
|
||||
},
|
||||
discordExecute (bot, username, sender, prefix, args, channeldc, message) {
|
||||
if (args[0]) {
|
||||
bot.tellraw(args.join(' '), [{ text: '\n'.repeat(100), color: 'white' }, { text: `Your chat has been cleared by ${username} (on Discord).`, color: 'dark_green' }])
|
||||
} else {
|
||||
bot.tellraw('@a', [{ text: '\n'.repeat(100), color: 'white' }, { text: 'The chat has been cleared.', color: 'dark_green' }])
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
module.exports = {
|
||||
name: 'clearchatqueue',
|
||||
description: 'Clears the bot\'s chat queue',
|
||||
alias: ['ccq'],
|
||||
usage: '',
|
||||
trusted: 0,
|
||||
execute (bot) {
|
||||
if (bot._chatQueue[0]) {
|
||||
bot.chatQueue = []
|
||||
bot._chatQueue = []
|
||||
}
|
||||
},
|
||||
discordExecute (bot) {
|
||||
if (bot._chatQueue[0]) {
|
||||
bot.chatQueue = []
|
||||
bot._chatQueue = []
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
|
||||
const { EmbedBuilder } = require('discord.js')
|
||||
|
||||
function list (bot, discord, channeldc, selector, config) {
|
||||
const message = []
|
||||
|
||||
if (discord) {
|
||||
for (const [index, { command, interval, list }] of Object.entries(bot.cloop.list)) {
|
||||
if (!list) continue
|
||||
message.push(index)
|
||||
message.push(' > ')
|
||||
message.push(`\`${command}\``)
|
||||
message.push(' - ')
|
||||
message.push(interval)
|
||||
message.push('\n')
|
||||
}
|
||||
|
||||
message.pop()
|
||||
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Cloops')
|
||||
.setDescription(message.join(''))
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
} else {
|
||||
message.push({ text: 'Cloops:', color: 'green' })
|
||||
message.push('\n')
|
||||
|
||||
for (const [index, { command, interval, list }] of Object.entries(bot.cloop.list)) {
|
||||
if (!list) continue
|
||||
message.push({ text: index, color: 'aqua' })
|
||||
message.push({ text: ' > ', color: 'gold' })
|
||||
message.push({ text: command, color: 'green' })
|
||||
message.push({ text: ' - ', color: 'gold' })
|
||||
message.push({ text: interval, color: 'green' })
|
||||
message.push('\n')
|
||||
}
|
||||
|
||||
message.pop()
|
||||
|
||||
bot.tellraw(selector, message)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
name: 'cloop',
|
||||
alias: [],
|
||||
description: 'Loop commands',
|
||||
usage: [
|
||||
'<hash> add <interval> <command>',
|
||||
'<hash> remove <index>',
|
||||
'<hash> removeall|clear',
|
||||
'<hash> list'
|
||||
],
|
||||
trusted: 1,
|
||||
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
if (args[1] === 'add' && args[3]) {
|
||||
if (!Number(args[2]) && Number(args[2]) !== 0) throw new SyntaxError('Invalid interval')
|
||||
bot.cloop.add(args.slice(3).join(' '), args[2])
|
||||
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') {
|
||||
list(bot, false, null, selector)
|
||||
} else if (args[1] === 'remove') {
|
||||
bot.cloop.remove(args[2])
|
||||
bot.tellraw(selector, [{ text: 'Removed cloop ' }, { text: args[2], color: 'aqua' }])
|
||||
} else if (args[1] === 'removeall' || args[1] === 'clear') {
|
||||
bot.cloop.clear()
|
||||
bot.tellraw(selector, [{ text: 'Removed all looped commands', color: 'white' }])
|
||||
} else {
|
||||
throw new SyntaxError('Invalid argument')
|
||||
}
|
||||
},
|
||||
discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
|
||||
if (args[0] === 'add' && args[2]) {
|
||||
if (!Number(args[1]) && Number(args[1]) !== 0) throw new SyntaxError('Invalid interval')
|
||||
bot.cloop.add(args.slice(2).join(' '), args[1])
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Cloop')
|
||||
.setDescription(`Added cloop \`${args.slice(2).join(' ')}\` with interval ${args[1]} to the cloops`)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
} else if (args[0] === 'list') {
|
||||
list(bot, true, channeldc, '@a', config)
|
||||
} else if (args[0] === 'remove') {
|
||||
bot.cloop.remove(args[1])
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Cloop')
|
||||
.setDescription(`Removed cloop \`${args[1]}\``)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
} else if (args[0] === 'removeall' || args[0] === 'clear') {
|
||||
bot.cloop.clear()
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Cloop')
|
||||
.setDescription('Removed all looped commands')
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
} else {
|
||||
throw new Error('Invalid argument')
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
const cowsay = require('cowsay2')
|
||||
const cows = require('cowsay2/cows')
|
||||
const { EmbedBuilder } = require('discord.js')
|
||||
module.exports = {
|
||||
name: 'cowsay',
|
||||
alias: [],
|
||||
description: 'Moo',
|
||||
usage: [
|
||||
'cow <message>',
|
||||
'list (not supported on Discord)'
|
||||
],
|
||||
trusted: 0,
|
||||
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
if (args[0] === 'list') {
|
||||
const listed = Object.keys(cows)
|
||||
|
||||
let primary = true
|
||||
const message = []
|
||||
|
||||
for (const value of listed) {
|
||||
message.push({
|
||||
text: value + ' ',
|
||||
color: (!((primary = !primary)) ? 'gold' : 'yellow'),
|
||||
clickEvent: {
|
||||
action: 'suggest_command',
|
||||
value: `${prefix}cowsay ${value} `
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
bot.tellraw(selector, message)
|
||||
} else {
|
||||
bot.tellraw(selector, { text: cowsay.say(args.slice(1).join(' '), { cow: cows[args[0]] }) })
|
||||
}
|
||||
},
|
||||
discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Cowsay')
|
||||
.setDescription(`\`\`\`\n${cowsay.say(args.slice(1).join(' '), { cow: cows[args[0]] })}\n\`\`\``)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
const { EmbedBuilder } = require('discord.js')
|
||||
module.exports = {
|
||||
name: 'creator',
|
||||
alias: [],
|
||||
description: 'Shows the bot\'s creator',
|
||||
usage: '',
|
||||
trusted: 0,
|
||||
execute (bot, username, 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' }, { text: ' (', color: 'dark_gray' }, { text: 'Cloned ', color: 'blue' }, { text: 'by ', color: 'white' }, { text: 'Parker', color: 'dark_red' }, { text: '2991', color: 'black' }, { text: ')', color: 'dark_gray' }])
|
||||
},
|
||||
discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Creator')
|
||||
.setDescription('ChomeNS Bot was created by chayapak (§9Cloned by §4Parker§02991)')
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
module.exports = {
|
||||
name: 'discord',
|
||||
alias: [],
|
||||
description: 'Shows the discord invite',
|
||||
usage: '',
|
||||
trusted: 0,
|
||||
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
bot.tellraw(selector, [
|
||||
{
|
||||
text: 'The Discord invite is ',
|
||||
color: 'white'
|
||||
},
|
||||
{
|
||||
text: 'https://discord.gg/xdgCkUyaA4',
|
||||
color: 'blue',
|
||||
clickEvent: {
|
||||
action: 'open_url',
|
||||
value: 'https://discord.gg/xdgCkUyaA4'
|
||||
}
|
||||
}
|
||||
])
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
const { resize } = require('../util/image')
|
||||
const axios = require('axios')
|
||||
const sharp = require('sharp')
|
||||
|
||||
module.exports = {
|
||||
name: 'draw',
|
||||
description: 'Draws an image',
|
||||
alias: [],
|
||||
trusted: 0,
|
||||
usage: '<image url (JPEG, PNG, WebP, AVIF, GIF, SVG, TIFF)>',
|
||||
execute: async function (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
let image
|
||||
try {
|
||||
const url = args.join(' ')
|
||||
|
||||
image = await axios.get('https://http-proxy.nongsonchome.repl.co', {
|
||||
params: {
|
||||
uri: url
|
||||
},
|
||||
responseType: 'arraybuffer'
|
||||
})
|
||||
|
||||
const loaded = sharp(image.data)
|
||||
|
||||
const metadata = await loaded
|
||||
.metadata()
|
||||
|
||||
const { width, height } = resize(metadata.width, metadata.height)
|
||||
|
||||
const { data, info } = await loaded
|
||||
.resize({ fit: 'fill', kernel: 'nearest', width, height })
|
||||
.raw()
|
||||
.toBuffer({ resolveWithObject: true })
|
||||
|
||||
bot.draw(data, info)
|
||||
} catch (_err) {
|
||||
const e = _err.toString() === 'Error: Input buffer contains unsupported image format' ? image.data.toString() : _err
|
||||
bot.tellraw(selector, { text: e, color: 'red' })
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
module.exports = {
|
||||
name: 'echo',
|
||||
alias: [],
|
||||
description: 'Says a message',
|
||||
usage: '<message>',
|
||||
trusted: 0,
|
||||
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
bot.chat(args.join(' '))
|
||||
},
|
||||
discordExecute (bot, username, sender, prefix, args, channeldc) {
|
||||
bot.chat(args.join(' '))
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
module.exports = {
|
||||
name: 'end',
|
||||
alias: [],
|
||||
description: 'Ends the bot\'s client',
|
||||
usage: '<hash>',
|
||||
trusted: 1,
|
||||
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
bot.end('end command')
|
||||
},
|
||||
discordExecute (bot, username, sender, prefix, args, channeldc, message) {
|
||||
bot.end('end command')
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
const { EmbedBuilder } = require('discord.js')
|
||||
const { VM } = require('vm2')
|
||||
const axios = require('axios')
|
||||
const util = require('util')
|
||||
const { stylize } = require('../util/colors/minecraft')
|
||||
module.exports = {
|
||||
name: 'eval',
|
||||
alias: [],
|
||||
description: 'Safe eval 100% secure!!!',
|
||||
trusted: 1,
|
||||
usage: [
|
||||
'run <code>',
|
||||
'reset'
|
||||
],
|
||||
async execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
if (args[0] === 'run') {
|
||||
try {
|
||||
bot.tellraw(selector, { text: util.inspect(bot.vm.run(args.slice(1).join(' ')), { stylize }).substring(0, 32000) })
|
||||
} catch (err) {
|
||||
bot.tellraw(selector, { text: util.inspect(err).replaceAll('runner', 'Parker2991'), color: 'red' })
|
||||
}
|
||||
}
|
||||
if (args[0] === 'reset') {
|
||||
bot.vm = new VM(bot.vmOptions)
|
||||
}
|
||||
if (args[0] === 'server') {
|
||||
const res = await axios.post(config.eval.serverUrl, new URLSearchParams({
|
||||
html: false,
|
||||
showErrorMsg: false,
|
||||
colors: 'minecraft',
|
||||
code: args.slice(1).join(' ')
|
||||
}).toString())
|
||||
bot.tellraw(selector, { text: res.data })
|
||||
}
|
||||
},
|
||||
async discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
|
||||
if (args[0] === 'run') {
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Output')
|
||||
.setDescription(`\`\`\`${util.inspect(bot.vm.run(args.slice(1).join(' '))).substring(0, 1950)}\`\`\``)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
} else if (args[0] === 'reset') {
|
||||
bot.vm = new VM(bot.vmOptions)
|
||||
} else if (args[0] === 'server') {
|
||||
const res = await axios.post(config.eval.serverUrl, new URLSearchParams({
|
||||
html: false,
|
||||
showErrorMsg: false,
|
||||
code: args.slice(1).join(' ')
|
||||
}).toString())
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Output')
|
||||
.setDescription(`\`\`\`${res.data}\`\`\``)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
} else {
|
||||
throw new SyntaxError('Invalid argument')
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,152 +0,0 @@
|
||||
|
||||
const { EmbedBuilder } = require('discord.js')
|
||||
module.exports = {
|
||||
name: 'help',
|
||||
alias: ['heko', 'cmds', 'commands'],
|
||||
description: 'Shows the help',
|
||||
usage: '[command]',
|
||||
trusted: 0,
|
||||
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
if (args[0]) {
|
||||
for (const command of bot.command_handler.commands) {
|
||||
function run () {
|
||||
let alias = command.name
|
||||
|
||||
if (command.alias.toString() !== '') {
|
||||
alias = command.alias.join(', ')
|
||||
}
|
||||
|
||||
const usage = []
|
||||
if (typeof command.usage === 'string') {
|
||||
usage.push({ text: `${prefix}${command.name} `, color: 'gold' })
|
||||
usage.push({ text: command.usage, color: 'aqua' })
|
||||
} else {
|
||||
for (const value of command.usage) {
|
||||
usage.push({ text: `${prefix}${command.name} `, color: 'gold' })
|
||||
usage.push({ text: value, color: 'aqua' })
|
||||
usage.push('\n')
|
||||
}
|
||||
usage.pop()
|
||||
}
|
||||
|
||||
const component = []
|
||||
component.push({ text: prefix + command.name, color: 'gold' })
|
||||
component.push({ text: ` (${alias})`, color: 'white' })
|
||||
component.push({ text: ' - ', color: 'gray' })
|
||||
component.push({ text: command.description, color: 'gray' })
|
||||
|
||||
component.push('\n')
|
||||
|
||||
component.push({ text: 'Trust level: ', color: 'green' })
|
||||
component.push({ text: command.trusted, color: 'yellow' })
|
||||
|
||||
component.push('\n')
|
||||
|
||||
component.push({ text: 'Supported on Discord: ', color: 'green' })
|
||||
component.push({ text: command.discordExecute ? 'true' : 'false', color: 'gold' })
|
||||
|
||||
component.push('\n')
|
||||
|
||||
component.push(usage)
|
||||
|
||||
bot.tellraw(selector, component)
|
||||
}
|
||||
|
||||
if (command.name === args[0]) run()
|
||||
for (const alias of command.alias) {
|
||||
if (alias === args[0]) run()
|
||||
}
|
||||
};
|
||||
} else {
|
||||
const generalCommands = []
|
||||
const trustedCommands = []
|
||||
const ownerCommands = []
|
||||
function component (command, color) {
|
||||
return {
|
||||
text: command.name + ' ',
|
||||
color,
|
||||
hoverEvent: {
|
||||
action: 'show_text',
|
||||
contents: [{
|
||||
text: 'Click here to see the information for this command',
|
||||
color: 'green'
|
||||
}]
|
||||
},
|
||||
clickEvent: {
|
||||
action: 'run_command',
|
||||
value: `${prefix}help ${command.name}`
|
||||
}
|
||||
}
|
||||
};
|
||||
for (const command of bot.command_handler.commands) {
|
||||
if (command.trusted !== 0 || command.proxy) continue
|
||||
generalCommands.push(component(command, 'green'))
|
||||
}
|
||||
for (const command of bot.command_handler.commands) {
|
||||
if (command.trusted !== 1 || command.proxy) continue
|
||||
trustedCommands.push(component(command, 'red'))
|
||||
}
|
||||
for (const command of bot.command_handler.commands) {
|
||||
if (command.trusted !== 2 || command.proxy) continue
|
||||
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' }]
|
||||
bot.tellraw(selector, [pre, generalCommands, trustedCommands, ownerCommands])
|
||||
}
|
||||
},
|
||||
discordExecute: async function (bot, username, sender, prefix, args, channeldc, message, config) {
|
||||
if (args[0]) {
|
||||
for (const command of bot.command_handler.commands) {
|
||||
function run () {
|
||||
let alias = command.name
|
||||
|
||||
if (command.alias.toString() !== '') {
|
||||
alias = command.alias.join(', ')
|
||||
}
|
||||
|
||||
const usage = []
|
||||
if (typeof command.usage === 'string') {
|
||||
usage.push(`${prefix}${command.name} ${command.usage}`)
|
||||
} else {
|
||||
for (const value of command.usage) {
|
||||
usage.push(`${prefix}${command.name} ${value}`)
|
||||
usage.push('\n')
|
||||
}
|
||||
usage.pop()
|
||||
}
|
||||
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle(`${prefix + command.name} (${alias}) - ${command.description}`)
|
||||
.setDescription(`Trust level: ${command.trusted}
|
||||
Supported: ${command.discordExecute ? 'true' : 'false'}
|
||||
${usage}`
|
||||
)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
}
|
||||
|
||||
if (command.name === args[0]) run()
|
||||
for (const alias of command.alias) {
|
||||
if (alias === args[0]) run()
|
||||
}
|
||||
};
|
||||
} else {
|
||||
let supportedCommands = ''
|
||||
let unsupportedCommands = ''
|
||||
for (const command of bot.command_handler.commands) {
|
||||
if (!command.discordExecute) continue
|
||||
supportedCommands += command.name + ' '
|
||||
}
|
||||
for (const command of bot.command_handler.commands) {
|
||||
if (command.discordExecute || command.proxy) continue
|
||||
unsupportedCommands += command.name + ' '
|
||||
}
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle(`Commands (Length: ${bot.command_handler.commands.length})`)
|
||||
.setDescription('**Supported Commands**\n' + supportedCommands + '\n**Unsupported Commands**\n' + unsupportedCommands)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
const { EmbedBuilder } = require('discord.js')
|
||||
module.exports = {
|
||||
name: 'list',
|
||||
alias: [],
|
||||
description: 'List players',
|
||||
usage: '',
|
||||
trusted: 0,
|
||||
execute: async function (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
try {
|
||||
const component = []
|
||||
component.push({ text: 'Players ', color: 'green' })
|
||||
component.push({ text: '(', color: 'dark_gray' })
|
||||
component.push({ text: bot.players.list.length, color: 'gray' })
|
||||
component.push({ text: ')', color: 'dark_gray' })
|
||||
component.push('\n')
|
||||
for (const property of bot.players.list) {
|
||||
// if (property.match.startsWith('@')) continue;
|
||||
component.push({
|
||||
text: property.name,
|
||||
color: 'yellow',
|
||||
clickEvent: {
|
||||
action: 'copy_to_clipboard',
|
||||
value: property.name
|
||||
},
|
||||
hoverEvent: {
|
||||
action: 'show_text',
|
||||
contents: [{
|
||||
text: 'Click here to copy the username to your clipboard',
|
||||
color: 'green'
|
||||
}]
|
||||
}
|
||||
})
|
||||
component.push({
|
||||
text: ' › ',
|
||||
color: 'dark_gray'
|
||||
})
|
||||
component.push({
|
||||
text: property.UUID,
|
||||
color: 'aqua',
|
||||
clickEvent: {
|
||||
action: 'copy_to_clipboard',
|
||||
value: property.UUID
|
||||
},
|
||||
hoverEvent: {
|
||||
action: 'show_text',
|
||||
contents: [{
|
||||
text: 'Click here to copy the UUID to your clipboard',
|
||||
color: 'green'
|
||||
}]
|
||||
}
|
||||
})
|
||||
component.push('\n')
|
||||
}
|
||||
component.pop()
|
||||
bot.tellraw(selector, component)
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
},
|
||||
discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
|
||||
try {
|
||||
let players = ''
|
||||
for (const property of bot.players.list) {
|
||||
// if (property.match.startsWith('@')) continue;
|
||||
players += `\`${property.name}\` › \`${property.UUID}\`` + '\n'
|
||||
}
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle(`Players (${bot.players.list.length})`)
|
||||
.setDescription(players.substring(0, 4096))
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,369 +0,0 @@
|
||||
/* eslint-disable no-case-declarations */
|
||||
|
||||
const fs = require('fs/promises')
|
||||
const { EmbedBuilder } = require('discord.js')
|
||||
const path = require('path')
|
||||
const getFilenameFromUrl = require('../util/getFilenameFromUrl')
|
||||
const fileExists = require('../util/file-exists')
|
||||
const fileList = require('../util/file-list')
|
||||
const axios = require('axios')
|
||||
const os = require('os')
|
||||
|
||||
let SONGS_PATH
|
||||
|
||||
if (os.hostname() === 'chomens-kubuntu') {
|
||||
SONGS_PATH = path.join(__dirname, '..', '..', 'nginx-html', 'midis')
|
||||
} else {
|
||||
SONGS_PATH = path.join(__dirname, '..', 'midis')
|
||||
}
|
||||
|
||||
let song
|
||||
|
||||
async function play (bot, values, discord, channeldc, selector, config) {
|
||||
try {
|
||||
const filepath = values.join(' ')
|
||||
|
||||
const seperator = path.sep // for hosting bot on windows
|
||||
|
||||
let absolutePath
|
||||
if (filepath.includes(seperator) && filepath !== '') {
|
||||
const pathSplitted = filepath.split(seperator)
|
||||
|
||||
const songs = await fileList(
|
||||
path.join(
|
||||
SONGS_PATH,
|
||||
pathSplitted[0]
|
||||
)
|
||||
)
|
||||
|
||||
// this part took a bunch of time to figure out, but still chomens moment!1!
|
||||
const lowerCaseFile = pathSplitted.pop().toLowerCase()
|
||||
const file = songs.filter((song) => song.toLowerCase().includes(lowerCaseFile))[0]
|
||||
|
||||
absolutePath = await resolve(path.join(pathSplitted.join(seperator), file))
|
||||
} else {
|
||||
const songs = await fileList(SONGS_PATH)
|
||||
const file = songs.filter((song) => song.toLowerCase().includes(filepath.toLowerCase()))[0]
|
||||
absolutePath = await resolve(file)
|
||||
}
|
||||
|
||||
song = await bot.music.load(await fs.readFile(absolutePath), path.basename(absolutePath))
|
||||
|
||||
if (discord) {
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Music')
|
||||
.setDescription(`Added ${song.name} to the song queue`)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
} else {
|
||||
bot.tellraw(selector, [{ text: 'Added ', color: 'white' }, { text: song.name, color: 'gold' }, { text: ' to the song queue', color: 'white' }])
|
||||
}
|
||||
|
||||
bot.music.queue.push(song)
|
||||
bot.music.play(song)
|
||||
} catch (e) {
|
||||
bot.console.error(e.stack)
|
||||
if (discord) {
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.error)
|
||||
.setTitle('Error')
|
||||
.setDescription('```SyntaxError: Invalid file```')
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
} else {
|
||||
bot.tellraw(selector, { text: 'SyntaxError: Invalid file', color: 'red' })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function playUrl (bot, values, discord, channeldc, selector, config) {
|
||||
let response
|
||||
try {
|
||||
const url = values.join(' ')
|
||||
response = await axios.get('https://http-proxy.nongsonchome.repl.co', {
|
||||
params: {
|
||||
uri: url
|
||||
},
|
||||
responseType: 'arraybuffer'
|
||||
})
|
||||
|
||||
song = await bot.music.load(response.data, getFilenameFromUrl(url))
|
||||
|
||||
if (discord) {
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Music')
|
||||
.setDescription(`Added ${song.name} to the song queue`)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
} else {
|
||||
bot.tellraw(selector, [{ text: 'Added ', color: 'white' }, { text: song.name, color: 'gold' }, { text: ' to the song queue', color: 'white' }])
|
||||
}
|
||||
|
||||
bot.music.queue.push(song)
|
||||
bot.music.play(song)
|
||||
} catch (_err) {
|
||||
const e = _err.toString().includes('Bad MIDI file. Expected \'MHdr\', got: ') ? response.data.toString() : _err
|
||||
if (discord) {
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.error)
|
||||
.setTitle('Error')
|
||||
.setDescription(`\`\`\`${e}\`\`\``)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
} else {
|
||||
bot.tellraw(selector, { text: e, color: 'red' })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function resolve (filepath) {
|
||||
if (!path.isAbsolute(filepath) && await fileExists(SONGS_PATH)) {
|
||||
return path.join(SONGS_PATH, filepath)
|
||||
}
|
||||
return filepath
|
||||
}
|
||||
|
||||
async function list (bot, discord, channeldc, prefix, selector, args, config) {
|
||||
try {
|
||||
let absolutePath
|
||||
if (args[1]) absolutePath = await resolve(path.join(SONGS_PATH, args.slice(1).join(' ')))
|
||||
else absolutePath = await resolve(SONGS_PATH)
|
||||
|
||||
if (!absolutePath.includes('midis')) throw new Error('bro trying to hack my server?!/1?!')
|
||||
|
||||
const listed = await fileList(absolutePath)
|
||||
|
||||
if (discord) {
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Songs')
|
||||
.setDescription(listed.join(', '))
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
return
|
||||
}
|
||||
|
||||
let primary = true
|
||||
const message = []
|
||||
|
||||
for (const value of listed) {
|
||||
const isFile = (await fs.lstat(path.join(absolutePath, value))).isFile()
|
||||
message.push({
|
||||
text: value + ' ',
|
||||
color: (!((primary = !primary)) ? 'gold' : 'yellow'),
|
||||
clickEvent: {
|
||||
action: 'suggest_command',
|
||||
value: `${prefix}music ${isFile ? 'play' : 'list'} ${path.join(args.slice(1).join(' '), value)}`
|
||||
},
|
||||
hoverEvent: {
|
||||
action: 'show_text',
|
||||
contents: [
|
||||
{ text: 'Name: ', color: 'white' },
|
||||
{ text: value, color: 'gold' },
|
||||
'\n',
|
||||
{ text: 'Click here to suggest the command!', color: 'green' }
|
||||
]
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
bot.tellraw(selector, message)
|
||||
} catch (e) {
|
||||
if (discord) {
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.error)
|
||||
.setTitle('Error')
|
||||
.setDescription(`\`\`\`${e.toString()}\`\`\``)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
} else {
|
||||
bot.tellraw(selector, { text: e.toString(), color: 'red' })
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
name: 'music',
|
||||
description: 'Plays music',
|
||||
alias: [],
|
||||
trusted: 0,
|
||||
usage: [
|
||||
'play <song|url>',
|
||||
'stop',
|
||||
'loop <all|current|off>',
|
||||
'list [directory]',
|
||||
'skip',
|
||||
'nowplaying',
|
||||
'queue'
|
||||
],
|
||||
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
switch (args[0]) {
|
||||
case 'play':
|
||||
case 'playurl': // deprecated
|
||||
if (args.slice(1).join(' ').startsWith('http')) {
|
||||
playUrl(bot, args.slice(1), false, null, selector, config)
|
||||
} else {
|
||||
play(bot, args.slice(1), false, null, selector, config)
|
||||
}
|
||||
break
|
||||
case 'stop':
|
||||
bot.tellraw(selector, { text: 'Cleared the song queue' })
|
||||
bot.music.stop()
|
||||
break
|
||||
case 'skip':
|
||||
try {
|
||||
bot.tellraw(selector, [{ text: 'Skipping ' }, { text: bot.music.song.name, color: 'gold' }])
|
||||
bot.music.skip()
|
||||
} catch (e) {
|
||||
throw new Error('No music is currently playing!')
|
||||
}
|
||||
break
|
||||
case 'loop':
|
||||
switch (args[1]) {
|
||||
case 'off':
|
||||
bot.music.loop = 0
|
||||
bot.tellraw(selector, [
|
||||
{
|
||||
text: 'Looping is now '
|
||||
},
|
||||
{
|
||||
text: 'disabled',
|
||||
color: 'red'
|
||||
}
|
||||
])
|
||||
break
|
||||
case 'current':
|
||||
bot.music.loop = 1
|
||||
bot.tellraw(selector, [
|
||||
{
|
||||
text: 'Now Looping '
|
||||
},
|
||||
{
|
||||
text: song.name,
|
||||
color: 'gold'
|
||||
}
|
||||
])
|
||||
break
|
||||
case 'all':
|
||||
bot.music.loop = 2
|
||||
bot.tellraw(selector, {
|
||||
text: 'Now looping every song'
|
||||
})
|
||||
break
|
||||
default:
|
||||
throw new SyntaxError('Invalid argument')
|
||||
}
|
||||
break
|
||||
case 'list':
|
||||
list(bot, false, null, prefix, selector, args, config)
|
||||
break
|
||||
case 'nowplaying':
|
||||
bot.tellraw(selector, [
|
||||
{
|
||||
text: 'Now playing '
|
||||
},
|
||||
{
|
||||
text: bot.music.song.name,
|
||||
color: 'gold'
|
||||
}
|
||||
])
|
||||
break
|
||||
case 'queue':
|
||||
const queueWithName = []
|
||||
for (const song of bot.music.queue) queueWithName.push(song.name)
|
||||
bot.tellraw(selector, [
|
||||
{
|
||||
text: 'Queue: ',
|
||||
color: 'green'
|
||||
},
|
||||
{
|
||||
text: queueWithName.join(', '),
|
||||
color: 'aqua'
|
||||
}
|
||||
])
|
||||
break
|
||||
default:
|
||||
throw new SyntaxError('Invalid argument')
|
||||
}
|
||||
},
|
||||
discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
|
||||
let Embed
|
||||
switch (args[0]) {
|
||||
case 'play':
|
||||
play(bot, args.slice(1), true, channeldc, config)
|
||||
break
|
||||
case 'playurl':
|
||||
playUrl(bot, args.slice(1), true, channeldc, config)
|
||||
break
|
||||
case 'stop':
|
||||
try {
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Stop')
|
||||
.setDescription('Cleared the song queue')
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
} catch (e) {
|
||||
return
|
||||
}
|
||||
bot.music.stop()
|
||||
break
|
||||
case 'skip':
|
||||
try {
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Skip')
|
||||
.setDescription(`Skipping ${bot.music.song.name}`)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
bot.music.skip()
|
||||
} catch (e) {
|
||||
throw new Error('No music is currently playing!')
|
||||
}
|
||||
break
|
||||
case 'loop':
|
||||
switch (args[1]) {
|
||||
case 'off':
|
||||
bot.music.loop = 0
|
||||
Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Loop')
|
||||
.setDescription('Looping is now disabled')
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
break
|
||||
case 'current':
|
||||
bot.music.loop = 1
|
||||
Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Loop')
|
||||
.setDescription(`Now looping ${song.name}`)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
break
|
||||
case 'all':
|
||||
bot.music.loop = 2
|
||||
Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Loop')
|
||||
.setDescription('Now looping every song')
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
break
|
||||
}
|
||||
break
|
||||
case 'list':
|
||||
list(bot, true, channeldc, prefix, '@a', args, config)
|
||||
break
|
||||
case 'nowplaying':
|
||||
Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Now playing')
|
||||
.setDescription(`Now playing ${bot.music.song.name}`)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
break
|
||||
case 'queue':
|
||||
const queueWithName = []
|
||||
for (const song of bot.music.queue) queueWithName.push(song.name)
|
||||
Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Queue')
|
||||
.setDescription(queueWithName.join(', '))
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
break
|
||||
default:
|
||||
throw new SyntaxError('Invalid argument')
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
module.exports = {
|
||||
name: 'netmsg',
|
||||
alias: ['networkmessage', 'irc'],
|
||||
description: 'Broadcasts a message to all of the servers that the bot is connected',
|
||||
usage: '<message>',
|
||||
trusted: 0,
|
||||
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
const message = args.join(' ')
|
||||
|
||||
if (message.toLowerCase().includes('netmsg')) return // lazy fix
|
||||
|
||||
const component = [
|
||||
{
|
||||
text: '[',
|
||||
color: 'dark_gray'
|
||||
},
|
||||
{
|
||||
text: bot.server.host === 'kitsune.icu' ? 'kit' : bot.server.host,
|
||||
color: 'gray'
|
||||
},
|
||||
bot.server.host === 'kitsune.icu'
|
||||
? {
|
||||
text: 'sune.icu',
|
||||
color: 'gray'
|
||||
}
|
||||
: '',
|
||||
{
|
||||
text: '] ',
|
||||
color: 'dark_gray'
|
||||
},
|
||||
{
|
||||
text: username,
|
||||
color: 'gray'
|
||||
},
|
||||
{
|
||||
text: ' \u203a ',
|
||||
color: 'dark_gray'
|
||||
},
|
||||
{
|
||||
text: message,
|
||||
color: 'gray'
|
||||
}
|
||||
]
|
||||
|
||||
const bots = bot.getBots()
|
||||
for (const bot of bots) {
|
||||
bot.tellraw(selector, component)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
module.exports = {
|
||||
name: 'refillcore',
|
||||
alias: ['rc'],
|
||||
description: 'Resets the bot\'s command core',
|
||||
usage: '',
|
||||
trusted: 0,
|
||||
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
bot.core.fillCore()
|
||||
},
|
||||
discordExecute (bot) {
|
||||
bot.core.fillCore()
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
const { between } = require('../util/between')
|
||||
module.exports = {
|
||||
name: 'rtp',
|
||||
alias: [],
|
||||
description: 'Randomly teleports the player',
|
||||
usage: '',
|
||||
trusted: 0,
|
||||
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
const pos = `${between(1000, 10000)} 100 ${between(1000, 10000)}`
|
||||
bot.tellraw(selector, [{ text: 'Teleporting ', color: 'white' }, { text: username, color: 'aqua' }, { text: ' to ', color: 'white' }, { text: pos, color: 'green' }, { text: '...', color: 'white' }])
|
||||
bot.core.run(`essentials:teleport ${sender} ${pos}`)
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/* eslint-disable no-eval */
|
||||
const util = require('util')
|
||||
const { stylize } = require('../util/colors/minecraft')
|
||||
const { EmbedBuilder } = require('discord.js')
|
||||
module.exports = {
|
||||
name: 'servereval',
|
||||
alias: [],
|
||||
description: 'Basically eval command but without vm2',
|
||||
trusted: 2,
|
||||
usage: '<ownerhash> <code>',
|
||||
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
try {
|
||||
bot.tellraw(selector, { text: util.inspect(eval(args.slice(1).join(' ')), { stylize }).substring(0, 32700) })
|
||||
} catch (err) {
|
||||
bot.tellraw(selector, { text: util.inspect(err).replaceAll('runner', 'home'), color: 'red' })
|
||||
}
|
||||
},
|
||||
discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
|
||||
try {
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Output')
|
||||
.setDescription(util.inspect(eval(args.join(' '))))
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
} catch (err) {
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.error)
|
||||
.setTitle('Error')
|
||||
.setDescription(`\`\`\`${util.inspect(err).replaceAll('runner', 'home')}\`\`\``)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
const os = require('os')
|
||||
const path = require('path')
|
||||
const fs = require('fs/promises')
|
||||
const { EmbedBuilder } = require('discord.js')
|
||||
|
||||
// should i move this to util?
|
||||
async function getCpuModelName () {
|
||||
const cpuInfo = await fs.readFile('/proc/cpuinfo')
|
||||
const lines = cpuInfo.toString().split('\n')
|
||||
// among us way of doing it
|
||||
const modelName = lines.find((line) => line.startsWith('model name')).split('\t: ')
|
||||
return modelName[1]
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
name: 'serverinfo',
|
||||
alias: [],
|
||||
description: 'Shows the info about the server that is hosting the bot',
|
||||
trusted: 0,
|
||||
usage: '',
|
||||
execute: async function (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
const component = []
|
||||
component.push({ text: 'Hostname: ', color: 'gold' })
|
||||
component.push({ text: os.hostname(), color: 'aqua' })
|
||||
component.push('\n')
|
||||
component.push({ text: 'Working directory: ', color: 'gold' })
|
||||
component.push({ text: path.join(__dirname, '..') /* if without .. it will includes the commands directory */, color: 'aqua' })
|
||||
component.push('\n')
|
||||
component.push({ text: 'OS architecture: ', color: 'gold' })
|
||||
component.push({ text: os.arch(), color: 'aqua' })
|
||||
component.push('\n')
|
||||
component.push({ text: 'OS platform: ', color: 'gold' })
|
||||
component.push({ text: os.platform(), color: 'aqua' })
|
||||
component.push('\n')
|
||||
component.push({ text: 'OS name: ', color: 'gold' })
|
||||
component.push({ text: os.version(), color: 'aqua' })
|
||||
component.push('\n')
|
||||
component.push({ text: 'CPU cores: ', color: 'gold' })
|
||||
component.push({ text: os.cpus().length, color: 'aqua' })
|
||||
component.push('\n')
|
||||
component.push({ text: 'CPU model: ', color: 'gold' })
|
||||
component.push({ text: await getCpuModelName(), color: 'aqua' })
|
||||
component.push('\n')
|
||||
component.push({ text: 'Total memory usage: ', color: 'gold' })
|
||||
component.push({ text: `${Math.floor(os.totalmem() / 1024 / 1024)} MB`, color: 'aqua' })
|
||||
component.push('\n')
|
||||
component.push({ text: 'Available memory usage: ', color: 'gold' })
|
||||
component.push({ text: `${Math.floor(os.freemem() / 1024 / 1024)} MB`, color: 'aqua' })
|
||||
bot.tellraw(selector, component)
|
||||
},
|
||||
discordExecute: async function (bot, username, sender, prefix, args, channeldc, message, config) {
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Server Info')
|
||||
.setDescription(`Hostname: \`${os.hostname()}\`
|
||||
Working directory: \`${path.join(__dirname, '..')}\`
|
||||
OS architecture: \`${os.arch()}\`
|
||||
OS platform: \`${os.platform()}\`
|
||||
OS name: \`${os.version()}\`
|
||||
CPU cores: \`${os.cpus().length}\`
|
||||
CPU model: \`${await getCpuModelName()}\`
|
||||
Total memory usage: \`${Math.floor(os.totalmem() / 1024 / 1024)} MB\`
|
||||
Available memory usage: \`${Math.floor(os.freemem() / 1024 / 1024)} MB\``)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
const { EmbedBuilder } = require('discord.js')
|
||||
module.exports = {
|
||||
name: 'test',
|
||||
alias: [],
|
||||
description: 'Tests if the bot is working',
|
||||
usage: '',
|
||||
trusted: 0,
|
||||
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
bot.tellraw(selector, [
|
||||
{
|
||||
text: `Username: ${username},`,
|
||||
color: 'green'
|
||||
},
|
||||
{
|
||||
text: ` Sender UUID: ${sender},`,
|
||||
color: 'green'
|
||||
},
|
||||
{
|
||||
text: ` Prefix: ${prefix},`,
|
||||
color: 'green'
|
||||
},
|
||||
{
|
||||
text: ` Args: ${args.join(', ').toString()}`,
|
||||
color: 'green'
|
||||
}
|
||||
])
|
||||
},
|
||||
discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Hello!')
|
||||
.setDescription('This is the first ever command to be discordified!' + '\n' + `More info: Username: ${username}, Prefix: ${prefix}, Args: ${args.join(' ')}`)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
const { EmbedBuilder } = require('discord.js')
|
||||
const moment = require('moment-timezone')
|
||||
module.exports = {
|
||||
name: 'time',
|
||||
alias: [],
|
||||
description: 'Shows the time',
|
||||
usage: '<timezone>',
|
||||
trusted: 0,
|
||||
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
const timezone = args.join(' ')
|
||||
|
||||
if (!moment.tz.names().map((zone) => zone.toLowerCase()).includes(timezone.toLowerCase())) {
|
||||
throw new SyntaxError('Invalid timezone')
|
||||
}
|
||||
|
||||
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' }]
|
||||
|
||||
bot.tellraw(selector, component)
|
||||
},
|
||||
discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
|
||||
const timezone = args.join(' ')
|
||||
|
||||
if (!moment.tz.names().map((zone) => zone.toLowerCase()).includes(timezone.toLowerCase())) {
|
||||
throw new SyntaxError('Invalid timezone')
|
||||
}
|
||||
|
||||
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 Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Time')
|
||||
.setDescription(description)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
const { EmbedBuilder } = require('discord.js')
|
||||
module.exports = {
|
||||
name: 'tpsbar',
|
||||
alias: ['tps'],
|
||||
description: 'Shows the server\'s TPS using Minecraft bossbar',
|
||||
usage: '<on|off>',
|
||||
trusted: 0,
|
||||
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
switch (args[0]) {
|
||||
case 'on':
|
||||
bot.tps.on()
|
||||
bot.tellraw(selector, [
|
||||
{
|
||||
text: 'TPSBar is now ',
|
||||
color: 'white'
|
||||
},
|
||||
{
|
||||
text: 'enabled',
|
||||
color: 'green'
|
||||
}
|
||||
])
|
||||
break
|
||||
case 'off':
|
||||
bot.tps.off()
|
||||
bot.tellraw(selector, [
|
||||
{
|
||||
text: 'TPSBar is now ',
|
||||
color: 'white'
|
||||
},
|
||||
{
|
||||
text: 'disabled',
|
||||
color: 'red'
|
||||
}
|
||||
])
|
||||
break
|
||||
default:
|
||||
throw new SyntaxError('Invalid argument')
|
||||
}
|
||||
},
|
||||
discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
|
||||
let Embed
|
||||
switch (args[0]) {
|
||||
case 'on':
|
||||
bot.tps.on()
|
||||
Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('TPSBar')
|
||||
.setDescription('TPSBar is now enabled')
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
break
|
||||
case 'off':
|
||||
bot.tps.off()
|
||||
Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('TPSBar')
|
||||
.setDescription('TPSBar is now disabled')
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
break
|
||||
default:
|
||||
throw new SyntaxError('Invalid argument')
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
const { EmbedBuilder } = require('discord.js')
|
||||
const { translate } = require('@vitalets/google-translate-api')
|
||||
module.exports = {
|
||||
name: 'translate',
|
||||
alias: [],
|
||||
description: 'Translate a message using Google Translate',
|
||||
usage: '<language 1> <language 2> <message>',
|
||||
trusted: 0,
|
||||
execute: async function (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
try {
|
||||
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' }])
|
||||
} catch (e) {
|
||||
bot.tellraw(selector, { text: String(e), color: 'red' })
|
||||
}
|
||||
},
|
||||
discordExecute: async function (bot, username, sender, prefix, args, channeldc, message, config) {
|
||||
try {
|
||||
const res = await translate(args.slice(2).join(' '), { from: args[0], to: args[1] })
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Result')
|
||||
.setDescription(res.text)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
} catch (e) {
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.error)
|
||||
.setTitle('Error')
|
||||
.setDescription(`\`\`\`${e}\`\`\``)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
const { EmbedBuilder } = require('discord.js')
|
||||
const moment = require('moment-timezone')
|
||||
module.exports = {
|
||||
name: 'uptime',
|
||||
alias: [],
|
||||
description: 'Shows the bot\'s uptime',
|
||||
usage: '',
|
||||
trusted: 0,
|
||||
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
const duration = moment.duration(Math.floor(performance.now()))
|
||||
const time = `${duration.days()} days, ${duration.hours()} hours, ${duration.minutes()} minutes, ${duration.seconds()} seconds` // moment please add duration.format()
|
||||
bot.tellraw(selector, [{ text: 'The bot\'s uptime is ', color: 'white' }, { text: time, color: 'green' }])
|
||||
},
|
||||
discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
|
||||
const duration = moment.duration(Math.floor(performance.now()))
|
||||
const time = `${duration.days()} days, ${duration.hours()} hours, ${duration.minutes()} minutes, ${duration.seconds()} seconds` // moment please add duration.format()
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Bot\'s Uptime')
|
||||
.setDescription(`The bot's uptime is ${time}`)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
const urban = require('urban-dictionary')
|
||||
module.exports = {
|
||||
name: 'urban',
|
||||
alias: [],
|
||||
description: 'Working Urban Dictionary',
|
||||
usage: '<word>',
|
||||
trusted: 0,
|
||||
async execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
try {
|
||||
const definitions = await urban.define(args.join(' '))
|
||||
|
||||
for (const definition of definitions) {
|
||||
bot.tellraw(selector, [{ text: '[', color: 'dark_red' }, { text: 'Urban', color: 'red' }, { text: '] ', color: 'dark_red' }, { text: definition.word, color: 'white' }, { text: ' - ', color: 'white' }, { text: definition.definition, color: 'white' }])
|
||||
}
|
||||
} catch (e) {
|
||||
bot.tellraw(selector, { text: e.toString(), color: 'red' })
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
const { EmbedBuilder } = require('discord.js')
|
||||
module.exports = {
|
||||
name: 'uuid',
|
||||
alias: [],
|
||||
description: 'Gets the UUID of a player. If no player specified it will show your UUID instead',
|
||||
usage: '[player (required on Discord)]',
|
||||
trusted: 0,
|
||||
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
if (args[0]) {
|
||||
const playername = args.join(' ')
|
||||
const player = bot.players.list.find((user) => user.name === playername)
|
||||
if (!player) throw new SyntaxError('Invalid username')
|
||||
const playerUUID = player.UUID
|
||||
bot.tellraw(selector,
|
||||
[
|
||||
{
|
||||
text: `${playername}'s UUID: `,
|
||||
color: 'green'
|
||||
},
|
||||
{
|
||||
text: playerUUID,
|
||||
color: 'aqua',
|
||||
clickEvent: {
|
||||
action: 'copy_to_clipboard',
|
||||
value: playerUUID
|
||||
},
|
||||
hoverEvent: {
|
||||
action: 'show_text',
|
||||
contents: [
|
||||
{
|
||||
text: 'Click here to copy the UUID to your clipboard',
|
||||
color: 'green'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
])
|
||||
} else {
|
||||
bot.tellraw(selector,
|
||||
[
|
||||
{
|
||||
text: 'Your UUID: ',
|
||||
color: 'green'
|
||||
},
|
||||
{
|
||||
text: sender,
|
||||
color: 'aqua',
|
||||
clickEvent: {
|
||||
action: 'copy_to_clipboard',
|
||||
value: sender
|
||||
},
|
||||
hoverEvent: {
|
||||
action: 'show_text',
|
||||
contents: [
|
||||
{
|
||||
text: 'Click here to copy the uuid to your clipboard',
|
||||
color: 'green'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
])
|
||||
}
|
||||
},
|
||||
discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
|
||||
if (args[0]) {
|
||||
const playername = args.join(' ')
|
||||
const player = bot.players.list.find((user) => user.name === playername)
|
||||
if (!player) throw new SyntaxError('Invalid username')
|
||||
const playerUUID = player.UUID
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('UUID')
|
||||
.setDescription(`${playername}'s UUID: ${playerUUID}`)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
} else {
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.error)
|
||||
.setTitle('Error')
|
||||
.setDescription('No player name specified')
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
module.exports = {
|
||||
name: 'validate',
|
||||
description: 'Validates a hash',
|
||||
alias: ['checkhash'],
|
||||
usage: '<hash|ownerHash>',
|
||||
trusted: 1,
|
||||
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
if (args[0] === hash) {
|
||||
bot.tellraw(selector, { text: 'Valid hash', color: 'green' })
|
||||
} else if (args[0] === ownerhash) {
|
||||
bot.tellraw(selector, { text: 'Valid OwnerHash', color: 'green' })
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
const wiki = require('wikipedia')
|
||||
const util = require('util')
|
||||
const { EmbedBuilder } = require('discord.js')
|
||||
module.exports = {
|
||||
name: 'wikipedia',
|
||||
alias: ['wiki'],
|
||||
description: 'Working Wikipedia!',
|
||||
usage: '<page>',
|
||||
trusted: 0,
|
||||
execute: async function (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
try {
|
||||
const page = await wiki.page(args.join(' '))
|
||||
const summary = await page.summary()
|
||||
bot.tellraw(selector, { text: summary.extract, color: 'green' })
|
||||
} catch (e) {
|
||||
bot.tellraw(selector, { text: e.toString(), color: 'red' })
|
||||
}
|
||||
},
|
||||
discordExecute: async function (bot, username, sender, prefix, args, channeldc, message, config) {
|
||||
try {
|
||||
const page = await wiki.page(args.join(' '))
|
||||
const summary = await page.summary()
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Output')
|
||||
.setDescription(summary.extract)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
} catch (e) {
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.error)
|
||||
.setTitle('Error')
|
||||
.setDescription(`\`\`\`${util.inspect(e)}\`\`\``)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,124 +0,0 @@
|
||||
const randomstring = require('randomstring')
|
||||
module.exports = {
|
||||
version: '1.19.2',
|
||||
prefixes: [
|
||||
'3*',
|
||||
'cbot3 ',
|
||||
'/cbot3 '
|
||||
],
|
||||
commandsDir: '../commands', // this will be used by the commands.js in the plugins folder so it needs ../
|
||||
proxy: {
|
||||
enabled: true,
|
||||
version: '1.19.2'
|
||||
},
|
||||
console: true,
|
||||
chat: {
|
||||
messageLength: 100
|
||||
},
|
||||
core: {
|
||||
layers: 3,
|
||||
refillInterval: 1000 * 60,
|
||||
|
||||
customName: [
|
||||
{
|
||||
text: 'https://doin-your.mom',
|
||||
color: 'dark_red'
|
||||
}
|
||||
|
||||
]
|
||||
},
|
||||
self_care: {
|
||||
prefix: true,
|
||||
op: true,
|
||||
cspy: true,
|
||||
vanish: true,
|
||||
nickname: true,
|
||||
socialspy: true,
|
||||
gamemode: true,
|
||||
mute: true,
|
||||
endCredits: true
|
||||
},
|
||||
eval: {
|
||||
serverUrl: 'http://localhost:4445/'
|
||||
},
|
||||
reconnectTimeout: 15000, // idk mabe
|
||||
timeoutInterval: 1000 * 40,
|
||||
self_care_check_interval: 2000,
|
||||
discord: {
|
||||
prefix: '!',
|
||||
servers: {
|
||||
'chipmunk.land:25565': '1152778909901934602',
|
||||
'thefreedomz.one:25565': '1152807307256811561',
|
||||
'24.69.170.247:25565': '1155838188586283109',
|
||||
'ipv4.fusselig.xyz:25565': '1152807355000565871',
|
||||
'kaboom.pw:25565': '1152807462836109402',
|
||||
'172.126.70.0:25565': '1160601659098017925',
|
||||
'24.69.170.247:25564': '1160600923467415602'
|
||||
},
|
||||
embedsColors: {
|
||||
normal: '#FFFF00',
|
||||
error: '#FF0000'
|
||||
}
|
||||
},
|
||||
servers: [
|
||||
// logging means log to console
|
||||
{
|
||||
host: 'chipmunk.land',
|
||||
port: 25565,
|
||||
username: randomstring.generate(8),
|
||||
kaboom: true,
|
||||
logging: true,
|
||||
useChat: false
|
||||
},
|
||||
{
|
||||
host: '172.126.70.0',
|
||||
port: 25565,
|
||||
username: randomstring.generate(8),
|
||||
kaboom: true,
|
||||
logging: true,
|
||||
useChat: false
|
||||
},
|
||||
{
|
||||
host: '24.69.170.247',
|
||||
port: 25564,
|
||||
username: randomstring.generate(8),
|
||||
kaboom: true,
|
||||
logging: true,
|
||||
useChat: false
|
||||
},
|
||||
{
|
||||
host: 'ipv4.fusselig.xyz',
|
||||
port: 25565,
|
||||
username: randomstring.generate(8),
|
||||
kaboom: true,
|
||||
logging: true,
|
||||
useChat: false
|
||||
},
|
||||
{
|
||||
host: 'kaboom.pw',
|
||||
port: 25565,
|
||||
username: randomstring.generate(8),
|
||||
kaboom: true,
|
||||
logging: true,
|
||||
useChat: false
|
||||
},
|
||||
|
||||
{
|
||||
host: 'thefreedomz.one',
|
||||
port: 25565,
|
||||
username: randomstring.generate(8),
|
||||
kaboom: true,
|
||||
logging: true,
|
||||
useChat: false
|
||||
},
|
||||
|
||||
{
|
||||
host: '24.69.170.247',
|
||||
port: 25565,
|
||||
username: randomstring.generate(8),
|
||||
kaboom: true,
|
||||
logging: true,
|
||||
useChat: false
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
module.exports = {
|
||||
version: '1.19.2',
|
||||
prefixes: [
|
||||
'default*',
|
||||
'defaultcbot ',
|
||||
'/defaultcbot '
|
||||
],
|
||||
commandsDir: '../commands', // this will be used by the commands.js in the plugins folder so it needs ../
|
||||
keys: {
|
||||
normalKey: 'normal hash key here',
|
||||
ownerHashKey: 'OwnerHash™ key here'
|
||||
},
|
||||
proxy: {
|
||||
enabled: true,
|
||||
version: '1.19.2'
|
||||
},
|
||||
console: true,
|
||||
chat: {
|
||||
messageLength: 100
|
||||
},
|
||||
core: {
|
||||
layers: 3,
|
||||
refillInterval: 1000 * 60,
|
||||
customName: [
|
||||
{
|
||||
text: 'ChomeNS ',
|
||||
color: 'yellow'
|
||||
},
|
||||
{
|
||||
text: 'Core',
|
||||
color: 'green'
|
||||
},
|
||||
{
|
||||
text: '\u2122',
|
||||
color: 'gold'
|
||||
}
|
||||
]
|
||||
},
|
||||
self_care: {
|
||||
prefix: true,
|
||||
op: true,
|
||||
cspy: true,
|
||||
vanish: true,
|
||||
nickname: true,
|
||||
socialspy: true,
|
||||
gamemode: true,
|
||||
mute: true,
|
||||
endCredits: true
|
||||
},
|
||||
eval: {
|
||||
serverUrl: 'http://localhost:4445/'
|
||||
},
|
||||
reconnectTimeout: 1000 * 2,
|
||||
timeoutInterval: 1000 * 40,
|
||||
self_care_check_interval: 2000,
|
||||
discord: {
|
||||
prefix: 'default!',
|
||||
servers: {
|
||||
'localhost:25565': '696969696969696969'
|
||||
},
|
||||
embedsColors: {
|
||||
normal: '#FFFF00',
|
||||
error: '#FF0000'
|
||||
}
|
||||
},
|
||||
servers: [
|
||||
// logging means log to console
|
||||
{
|
||||
host: 'localhost',
|
||||
port: 25565,
|
||||
username: 'ChomeNS_Bot',
|
||||
kaboom: false,
|
||||
logging: true,
|
||||
useChat: false
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
const fs = require('fs/promises')
|
||||
const fileExist = require('./util/file-exists')
|
||||
const path = require('path')
|
||||
const { createBot } = require('./bot')
|
||||
|
||||
let config
|
||||
|
||||
function load () {
|
||||
// these stuff takes time to load so i move it here
|
||||
const readline = require('node:readline')
|
||||
const { stdin: input, stdout: output } = require('node:process')
|
||||
const rl = readline.createInterface({ input, output })
|
||||
const { Client, GatewayIntentBits } = require('discord.js')
|
||||
const { MessageContent, GuildMessages, Guilds } = GatewayIntentBits
|
||||
|
||||
const dcclient = new Client({ intents: [Guilds, GuildMessages, MessageContent] })
|
||||
|
||||
let bots = []
|
||||
|
||||
dcclient.on('ready', () => {
|
||||
for (const server of config.servers) {
|
||||
const getBots = () => bots
|
||||
const setNewBot = (server, bot) => {
|
||||
bots = bots.filter((eachBot) => eachBot.server.host !== server)
|
||||
bots.push(bot)
|
||||
}
|
||||
createBot(server, config, getBots, setNewBot, dcclient, rl)
|
||||
}
|
||||
})
|
||||
require('dotenv').config()
|
||||
dcclient.login(process.env.discordtoken1)
|
||||
}
|
||||
|
||||
// TODO: improve this thing
|
||||
async function checkConfig () {
|
||||
if (!await fileExist(path.join(__dirname, 'config.js'))) {
|
||||
console.error('Config file doesn\'t exist, so the default one was created')
|
||||
await fs.copyFile(path.join(__dirname, 'default.js'), path.join(__dirname, 'config.js'))
|
||||
}
|
||||
config = require('./config')
|
||||
load()
|
||||
}
|
||||
|
||||
checkConfig()
|
||||
|
||||
process.on('uncaughtException', (e) => {
|
||||
console.log('uncaught ' + e.stack)
|
||||
})
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,77 +0,0 @@
|
||||
const { containsIllegalCharacters } = require('../util/containsIllegalCharacters')
|
||||
const { chatPacketListener, parsePlayerMessages } = require('../util/chat')
|
||||
const minecraftVersionToNumber = require('../util/minecraftVersionToNumber')
|
||||
|
||||
function inject (bot, dcclient, config) {
|
||||
bot.chatQueue = []
|
||||
bot._chatQueue = []
|
||||
|
||||
const _chatQueueInterval = setInterval(() => {
|
||||
if (bot.chatQueue.length !== 0) {
|
||||
if (containsIllegalCharacters(bot.chatQueue[0])) {
|
||||
bot.chatQueue.shift()
|
||||
return
|
||||
};
|
||||
// totallynotskidded™️ from mineflayer/lib/plugins/chat.js
|
||||
for (const subMessage of bot.chatQueue[0].split('\n')) {
|
||||
if (!subMessage) return
|
||||
let smallMsg
|
||||
for (let i = 0; i < subMessage.length; i += config.chat.messageLength) {
|
||||
smallMsg = subMessage.substring(i, i + config.chat.messageLength)
|
||||
bot._chatQueue.push(smallMsg)
|
||||
}
|
||||
}
|
||||
bot.chatQueue.shift()
|
||||
}
|
||||
}, 0)
|
||||
|
||||
const chatQueueInterval = setInterval(function () {
|
||||
if (bot._chatQueue.length !== 0) {
|
||||
if (bot._chatQueue[0].startsWith('/') && minecraftVersionToNumber(bot.version) >= 1.19) {
|
||||
// totallynotskidded™️ from mineflayer
|
||||
const command = bot._chatQueue[0].slice(1)
|
||||
const timestamp = BigInt(Date.now())
|
||||
bot._client.write('chat_command', {
|
||||
command,
|
||||
timestamp,
|
||||
salt: 0n,
|
||||
argumentSignatures: [],
|
||||
signedPreview: false,
|
||||
messageCount: 0,
|
||||
acknowledged: Buffer.alloc(3),
|
||||
// 1.19.2 Chat Command packet also includes an array of last seen messages
|
||||
previousMessages: []
|
||||
})
|
||||
} else {
|
||||
bot._client.chat(bot._chatQueue[0])
|
||||
}
|
||||
|
||||
bot._chatQueue.shift()
|
||||
}
|
||||
}, 450)
|
||||
|
||||
bot.chat = (message) => {
|
||||
bot.chatQueue.push(String(message))
|
||||
}
|
||||
|
||||
bot.on('end', () => {
|
||||
clearInterval(chatQueueInterval)
|
||||
clearInterval(_chatQueueInterval)
|
||||
})
|
||||
|
||||
function listener (packet) {
|
||||
chatPacketListener(
|
||||
packet,
|
||||
bot,
|
||||
minecraftVersionToNumber(bot.version) >= 1.19
|
||||
)
|
||||
}
|
||||
// TODO: support playerChat (formattedMessage doesn't exist on kaboom so prefixes like [OP] doesn't appear)
|
||||
// bot._client.on('playerChat', listener)
|
||||
bot._client.on('systemChat', listener)
|
||||
bot._client.on('chat', listener)
|
||||
|
||||
bot.on('message', (message, parsedMessage) => parsePlayerMessages(message, parsedMessage, bot))
|
||||
}
|
||||
|
||||
module.exports = { inject }
|
||||
@@ -1,123 +0,0 @@
|
||||
|
||||
const path = require('path')
|
||||
const { EmbedBuilder } = require('discord.js')
|
||||
function inject (bot, dcclient, config) {
|
||||
const loadFiles = require('../util/load_files')
|
||||
const channeldc = dcclient.channels.cache.get(config.discord.servers[`${bot.server.host}:${bot.server.port}`])
|
||||
bot.command_handler = {}
|
||||
bot.command_handler.commands = {}
|
||||
bot.command_handler.reload = async function () {
|
||||
bot.command_handler.commands = await loadFiles(path.join(__dirname, config.commandsDir))
|
||||
}
|
||||
bot.command_handler.reload()
|
||||
bot.command_handler.main = function (prefix, username, message, sender, channeldc, hash, ownerhash, selector) {
|
||||
bot.command_handler.reload()
|
||||
let raw
|
||||
let command
|
||||
const discord = !!message.content
|
||||
|
||||
discord
|
||||
? raw = message.content.substring(prefix.length)
|
||||
: raw = message.substring(prefix.length)
|
||||
|
||||
const [commandName, ...args] = raw.split(' ')
|
||||
command = bot.command_handler.commands.find((command) => command.name === commandName.toLowerCase())
|
||||
|
||||
try {
|
||||
const alias = bot.command_handler.commands.find((command) => command.alias.includes(commandName.toLowerCase()))
|
||||
if (alias) command = alias
|
||||
|
||||
if (prefix === '3*' && message.endsWith('3*') && message !== '3*') return
|
||||
if (!command) throw new Error(`Unknown command: "${commandName}"`)
|
||||
|
||||
if (command.trusted > 0) {
|
||||
const discordRoles = message.member?.roles?.cache // do i need the "?"s ?
|
||||
|
||||
// TODO: Don't hardcode the roles
|
||||
|
||||
// trusted and host
|
||||
// discord
|
||||
if (
|
||||
discord &&
|
||||
command.trusted === 1 &&
|
||||
!discordRoles.some((role) => role.name === 'Trusted' || role.name === 'chomens' || role.name === 'FNFBoyfriendBot Owner')
|
||||
) throw new Error('You\'re not in the trusted role!')
|
||||
// in game
|
||||
if (
|
||||
!discord &&
|
||||
command.trusted === 1 &&
|
||||
args[0] !== hash &&
|
||||
args[0] !== ownerhash
|
||||
|
||||
) throw new Error('Invalid hash')
|
||||
|
||||
// FNFBoyfriendBot Owner
|
||||
// || role.name === 'Host'
|
||||
if (
|
||||
discord &&
|
||||
command.trusted === 2 &&
|
||||
!discordRoles.some((role) => role.name === 'chomens' || role.name === 'FNFBoyfriendBot Owner')
|
||||
|
||||
) throw new Error('You\'re not in the host role!')
|
||||
// in game
|
||||
if (
|
||||
!discord &&
|
||||
command.trusted === 2 &&
|
||||
args[0] !== ownerhash
|
||||
) throw new Error('Invalid OwnerHash')
|
||||
}
|
||||
|
||||
if (prefix === config.discord.prefix) {
|
||||
if (!command.discordExecute) throw new Error('This command is not yet supported on Discord!')
|
||||
command.discordExecute(bot, username, sender, prefix, args, channeldc, message, config)
|
||||
} else {
|
||||
command.execute(bot, username, sender, prefix, args, config, hash, ownerhash, selector)
|
||||
}
|
||||
} catch (e) {
|
||||
if (prefix === config.discord.prefix) {
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.error)
|
||||
.setTitle('Error')
|
||||
.setDescription(`\`\`\`${e}\`\`\``)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
} else {
|
||||
bot.tellraw(selector, { text: String(e), color: 'red' })
|
||||
}
|
||||
}
|
||||
}
|
||||
bot.command_handler.run = function (username, message, sender, channeldc, hash, ownerhash, selector = '@a') {
|
||||
for (const prefix of config.prefixes) {
|
||||
if (!message.startsWith(prefix)) continue
|
||||
bot.command_handler.main(prefix, username, message, sender, channeldc, hash, ownerhash, selector)
|
||||
}
|
||||
}
|
||||
bot.on('chat', async (_username, _message) => {
|
||||
const username = _username?.replace(/§.?/g, '')
|
||||
const sender = bot.players.list.find((val) => val.name === username)?.UUID
|
||||
const message = _message?.replace(/* /§r/g */ /§.?/g, '')/* .replace(/§/g, '') */
|
||||
bot.command_handler.run(username, message, sender, channeldc, bot.hash, bot.ownerHash)
|
||||
})
|
||||
bot.on('cspy', async function (_username, _message) {
|
||||
const username = _username.replace(/§.?/g, '')
|
||||
const message = _message.replace(/§.?/g, '')
|
||||
const sender = bot.players.list.find((val) => val.name === username)?.UUID
|
||||
bot.command_handler.run(username, message, sender, channeldc, bot.hash, bot.ownerHash, username)
|
||||
})
|
||||
function handleDiscordMessages (message) {
|
||||
try {
|
||||
// ignores the message that comes from the bot itself
|
||||
if (message.author.id === dcclient.user.id) return
|
||||
// only receive messages in SPECIFIC channel
|
||||
if (message.channel.id !== channeldc.id) return
|
||||
if (!message.content.startsWith(config.discord.prefix)) return
|
||||
bot.command_handler.main(config.discord.prefix, message.member.displayName, message, 'no sender for discord', channeldc)
|
||||
} catch (e) {
|
||||
bot.console.error(e.stack)
|
||||
};
|
||||
}
|
||||
bot.on('end', () => {
|
||||
dcclient.off('messageCreate', handleDiscordMessages)
|
||||
})
|
||||
dcclient.on('messageCreate', handleDiscordMessages)
|
||||
};
|
||||
module.exports = { inject }
|
||||
@@ -1,107 +0,0 @@
|
||||
const moment = require('moment-timezone')
|
||||
|
||||
function inject (bot, _dcclient, config, rl) {
|
||||
// readline > fix on log
|
||||
function log (...args) {
|
||||
rl.output.write('\x1b[2K\r')
|
||||
console.log(args.toString())
|
||||
rl._refreshLine()
|
||||
};
|
||||
|
||||
const chatMessage = require('prismarine-chat')(bot.version)
|
||||
|
||||
function prefix (prefix, _message) {
|
||||
const message = `[${moment().format('DD/MM/YY HH:mm:ss')} ${prefix}§r] [${bot.server.host}] `
|
||||
const component = chatMessage.MessageBuilder.fromString(message).toJSON()
|
||||
return chatMessage.fromNotch(component).toAnsi() + _message
|
||||
}
|
||||
const originalConsole = console
|
||||
this.log = (...args) => {
|
||||
rl.output.write('\x1b[2K\r')
|
||||
originalConsole.log(args.toString())
|
||||
rl._refreshLine()
|
||||
}
|
||||
bot.console = {}
|
||||
bot.console.host = 'all'
|
||||
bot.console.log = function (message) {
|
||||
log(prefix('&6LOG', message))
|
||||
}
|
||||
bot.console.info = function (message) {
|
||||
log(prefix('&aINFO', message))
|
||||
}
|
||||
bot.console.error = function (error) {
|
||||
log(prefix('&cERROR', typeof error === 'string' ? error : error.stack))
|
||||
}
|
||||
|
||||
// previous message is op feature to have in console :)
|
||||
let previousMessage = ''
|
||||
bot.on('message', (message) => {
|
||||
if (!bot.options.logging) return
|
||||
if (previousMessage === message.toString()) return
|
||||
previousMessage = message.toString()
|
||||
bot.console.log(message.toAnsi())
|
||||
})
|
||||
|
||||
if (!config.console) return
|
||||
|
||||
function handleLine (line) {
|
||||
try {
|
||||
if (line.toLowerCase() === '' ||
|
||||
line.toLowerCase().startsWith(' ')) return
|
||||
|
||||
if (line.startsWith('.csvr ')) {
|
||||
const host = line.substring(6)
|
||||
for (const eachBot of bot.getBots()) eachBot.console.host = host
|
||||
bot.console.info(`Host set to: ${host}`)
|
||||
return
|
||||
}
|
||||
|
||||
if (bot.server.host !== bot.console.host && bot.console.host !== 'all') return
|
||||
if (line === '.kill') process.exit()
|
||||
|
||||
if (line.startsWith('.')) {
|
||||
return bot.command_handler.run(
|
||||
bot.username,
|
||||
config.prefixes[0] + line.substring(1),
|
||||
bot.uuid,
|
||||
null,
|
||||
'h',
|
||||
'o'
|
||||
)
|
||||
}
|
||||
bot.tellraw('@a', [
|
||||
{
|
||||
text: '[',
|
||||
color: 'dark_gray'
|
||||
},
|
||||
{
|
||||
text: `${bot.username} Console`,
|
||||
color: 'gray'
|
||||
},
|
||||
{
|
||||
text: '] ',
|
||||
color: 'dark_gray'
|
||||
},
|
||||
{
|
||||
text: 'chayapak ',
|
||||
color: 'green'
|
||||
},
|
||||
{
|
||||
text: '\u203a ',
|
||||
color: 'dark_gray'
|
||||
},
|
||||
chatMessage.MessageBuilder.fromString('&7' + line)
|
||||
])
|
||||
} catch (e) {
|
||||
bot.console.error(e)
|
||||
}
|
||||
}
|
||||
|
||||
rl.on('line', handleLine)
|
||||
|
||||
bot.on('end', () => {
|
||||
rl.off('line', handleLine)
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = { inject }
|
||||
@@ -1,115 +0,0 @@
|
||||
const nbt = require('prismarine-nbt');
|
||||
const Vec3 = require('vec3');
|
||||
|
||||
const relativePosition = new Vec3(0, 0, 0);
|
||||
|
||||
function inject(bot, dcclient, config) {
|
||||
const mcData = require('minecraft-data')(bot.version);
|
||||
const impulseMode = !bot.options.kaboom;
|
||||
const core = {
|
||||
// Initialize the height to 0
|
||||
height: 0,
|
||||
run(command) {
|
||||
try {
|
||||
// Check if height has reached the maximum configured height
|
||||
if (core.height >= config.core.layers) {
|
||||
// Reset the height to 0 and the relativePosition to (0, 0, 0)
|
||||
core.height = 0;
|
||||
relativePosition.x = 0;
|
||||
relativePosition.y = 0;
|
||||
relativePosition.z = 0;
|
||||
}
|
||||
|
||||
const location = {
|
||||
x: core.start.x + relativePosition.x,
|
||||
y: core.start.y + core.height, // Use the core height
|
||||
z: core.start.z + relativePosition.z
|
||||
};
|
||||
|
||||
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: 0b101
|
||||
});
|
||||
|
||||
// Increment the relativePosition.x and update the height accordingly
|
||||
relativePosition.x++;
|
||||
if (relativePosition.x >= 16) {
|
||||
relativePosition.x = 0;
|
||||
relativePosition.z++;
|
||||
if (relativePosition.z >= 16) {
|
||||
relativePosition.z = 0;
|
||||
core.height++; // Increment the height
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
bot.console.error(e);
|
||||
}
|
||||
},
|
||||
fillCore() {
|
||||
core.start = new Vec3(
|
||||
Math.floor(bot.position.x / 16) * 16,
|
||||
0 /* bot.position.y */,
|
||||
Math.floor(bot.position.z / 16) * 16
|
||||
).floor();
|
||||
core.end = core.start.clone().translate(16, config.core.layers, 16).subtract(new Vec3(1, 1, 1));
|
||||
|
||||
placeCore();
|
||||
}
|
||||
};
|
||||
|
||||
bot.core = core;
|
||||
|
||||
function placeCore() {
|
||||
try {
|
||||
const fillCommand = `minecraft:fill ${core.start.x} ${core.start.y} ${core.start.z} ${core.end.x} ${core.end.y} ${core.end.z} repeating_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) };
|
||||
|
||||
bot.write('set_creative_slot', {
|
||||
slot: 36,
|
||||
item: {
|
||||
present: true,
|
||||
itemId: impulseMode ? mcData.itemsByName.command_block.id : mcData.itemsByName.repeating_command_block.id,
|
||||
itemCount: 64,
|
||||
nbtData: nbt.comp({
|
||||
BlockEntityTag: nbt.comp({
|
||||
Command: nbt.string(fillCommand),
|
||||
auto: nbt.byte(1),
|
||||
TrackOutput: nbt.byte(0)
|
||||
})
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
bot.write('block_dig', {
|
||||
status: 0,
|
||||
location,
|
||||
face: 1
|
||||
});
|
||||
|
||||
bot.write('block_place', {
|
||||
location,
|
||||
direction: 1,
|
||||
hand: 0,
|
||||
cursorX: 0.5,
|
||||
cursorY: 0.5,
|
||||
cursorZ: 0.5,
|
||||
insideBlock: false
|
||||
});
|
||||
} catch (e) {
|
||||
bot.console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
bot.on('position', bot.core.fillCore);
|
||||
|
||||
const interval = setInterval(bot.core.fillCore, config.core.refillInterval);
|
||||
|
||||
bot.on('end', () => {
|
||||
clearInterval(interval);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = { inject };
|
||||
@@ -1,178 +0,0 @@
|
||||
|
||||
const { escapeMarkdown } = require('../util/escapeMarkdown')
|
||||
async function inject (bot, dcclient, config) {
|
||||
const chatMessage = require('prismarine-chat')(bot.version)
|
||||
const channel = dcclient.channels.cache.get(config.discord.servers[`${bot.server.host}:${bot.server.port}`])
|
||||
|
||||
let queue = ''
|
||||
const queueInterval = setInterval(() => {
|
||||
if (queue === '') return
|
||||
|
||||
channel.send({
|
||||
content: '```ansi\n' + queue.substring(0, 1986) + '\n```',
|
||||
allowedMentions: {
|
||||
parse: []
|
||||
}
|
||||
})
|
||||
queue = ''
|
||||
}, 1000)
|
||||
|
||||
bot.on('message', (message) => {
|
||||
const cleanMessage = escapeMarkdown(message.toAnsi(), true)
|
||||
const discordMsg = cleanMessage
|
||||
.replaceAll('@', '@\u200b')
|
||||
.replaceAll('http', 'http\u200b')
|
||||
.replaceAll('\u001b[9', '\u001b[3')
|
||||
if (message.toMotd().startsWith('§8[§eChomeNS §9Discord§8] §c')) return
|
||||
queue += '\n' + discordMsg
|
||||
})
|
||||
|
||||
// handle discord messages!!!
|
||||
async function handleDiscordMessages (message) {
|
||||
// Ignore messages from the bot itself
|
||||
if (message.author.id === dcclient.user.id) return
|
||||
|
||||
// Only handle messages in specified channel
|
||||
if (message.channel.id !== channel.id) return
|
||||
if (message.content.startsWith(config.discord.prefix)) return
|
||||
|
||||
try {
|
||||
const attachmentsComponent = []
|
||||
if (message.attachments) {
|
||||
for (const __attachment of message.attachments) {
|
||||
const _attachment = [...__attachment]
|
||||
const attachment = _attachment[1] // BEST WAY REAL!?/1?!
|
||||
attachmentsComponent.push({
|
||||
text: message.content === '' ? '[Attachment]' : ' [Attachment]', // may not be the best fix
|
||||
color: 'green',
|
||||
clickEvent: {
|
||||
action: 'open_url',
|
||||
value: attachment.proxyURL
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
const component = [
|
||||
{ text: '[', color: 'dark_gray', bold:false, },
|
||||
{
|
||||
text: 'FNF',
|
||||
color: 'dark_purple',
|
||||
bold:false,
|
||||
clickEvent: {
|
||||
action: 'open_url',
|
||||
value: 'https://discord.gg/GCKtG4erux'
|
||||
}
|
||||
},
|
||||
{
|
||||
text: 'Boyfriend',
|
||||
color: 'aqua',
|
||||
bold:false,
|
||||
clickEvent: {
|
||||
action: 'open_url',
|
||||
value: 'https://discord.gg/GCKtG4erux'
|
||||
}
|
||||
},
|
||||
{
|
||||
text: 'Bot',
|
||||
color: 'dark_red',
|
||||
bold: false,
|
||||
clickEvent: {
|
||||
action: 'open_url',
|
||||
value: 'https://discord.gg/GCKtG4erux'
|
||||
}
|
||||
},
|
||||
{
|
||||
text: ' Discord',
|
||||
color: 'blue',
|
||||
bold: false,
|
||||
clickEvent: {
|
||||
action: 'open_url',
|
||||
value: 'https://discord.gg/GCKtG4erux'
|
||||
}
|
||||
},
|
||||
{
|
||||
text: ']',
|
||||
color: 'dark_gray',
|
||||
bold: false,
|
||||
clickEvent: {
|
||||
action: 'open_url',
|
||||
value: 'https://discord.gg/GCKtG4erux'
|
||||
}
|
||||
},
|
||||
{
|
||||
text: '[',
|
||||
color: 'dark_gray',
|
||||
bold: false,
|
||||
clickEvent: {
|
||||
action: 'open_url',
|
||||
value: 'https://discord.gg/GCKtG4erux'
|
||||
}
|
||||
},
|
||||
{
|
||||
text: 'ChomeNS js ',
|
||||
color: 'yellow',
|
||||
bold:false,
|
||||
clickEvent: {
|
||||
action: 'open_url',
|
||||
value: 'https://discord.gg/GCKtG4erux'
|
||||
}
|
||||
},
|
||||
{
|
||||
text: 'Bot',
|
||||
color: 'yellow',
|
||||
bold:false,
|
||||
clickEvent: {
|
||||
action: 'open_url',
|
||||
value: 'https://discord.gg/GCKtG4erux'
|
||||
}
|
||||
},
|
||||
{ text: '] ', color: 'dark_gray', bold:false, },
|
||||
{
|
||||
text: message.member.displayName,
|
||||
color: 'red',
|
||||
clickEvent: {
|
||||
action: 'copy_to_clipboard',
|
||||
value: `${message.author.username}#${message.author.discriminator}`
|
||||
},
|
||||
hoverEvent: {
|
||||
action: 'show_text',
|
||||
value: [
|
||||
{
|
||||
text: message.author.username,
|
||||
color: 'white'
|
||||
},
|
||||
{
|
||||
text: '#',
|
||||
color: 'dark_gray'
|
||||
},
|
||||
{
|
||||
text: message.author.discriminator,
|
||||
color: 'gray'
|
||||
},
|
||||
'\n',
|
||||
{
|
||||
text: 'Click here to copy the tag to your clipboard',
|
||||
color: 'green'
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{ text: ' › ', color: 'dark_gray' },
|
||||
chatMessage.MessageBuilder.fromString('&7' + message.content),
|
||||
attachmentsComponent.length === 0 ? '' : attachmentsComponent
|
||||
]
|
||||
bot.tellraw('@a', component)
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
bot.on('end', () => {
|
||||
clearInterval(queueInterval)
|
||||
dcclient.off('messageCreate', handleDiscordMessages)
|
||||
})
|
||||
|
||||
dcclient.on('messageCreate', handleDiscordMessages)
|
||||
};
|
||||
|
||||
module.exports = { inject }
|
||||
@@ -1,53 +0,0 @@
|
||||
const convert = require('color-convert')
|
||||
|
||||
// eslint-disable-next-line require-jsdoc
|
||||
function inject (bot) {
|
||||
/**
|
||||
* draw which is totallynotskidded from ybot
|
||||
* @param {buffer} data data buffer
|
||||
* @param {*} info idk bout this
|
||||
* @param {object} prefix prefix in the output compoenent
|
||||
*/
|
||||
function draw (data, info, prefix = {}) {
|
||||
const pixels = []
|
||||
|
||||
// Data Buffer -> RGB Array
|
||||
for (let i = 0; i < data.length; i += info.channels) {
|
||||
pixels.push([
|
||||
data[i + 0],
|
||||
data[i + 1],
|
||||
data[i + 2]
|
||||
])
|
||||
}
|
||||
|
||||
const rows = []
|
||||
|
||||
// RGB Array -> Rows Array
|
||||
for (let i = 0; i < pixels.length; i += info.width) {
|
||||
const row = pixels.slice(i, i + info.width)
|
||||
|
||||
rows.push(row)
|
||||
}
|
||||
|
||||
const messages = []
|
||||
|
||||
for (const row of rows) {
|
||||
const message = [{ ...prefix, text: '' }]
|
||||
|
||||
for (const rgb of row) {
|
||||
message.push({
|
||||
text: '⎮',
|
||||
color: `#${convert.rgb.hex(rgb)}`
|
||||
})
|
||||
}
|
||||
|
||||
messages.push(message)
|
||||
}
|
||||
|
||||
for (const message of messages) bot.tellraw('@a', message)
|
||||
}
|
||||
|
||||
bot.draw = draw
|
||||
}
|
||||
|
||||
module.exports = { inject }
|
||||
@@ -1,18 +0,0 @@
|
||||
const crypto = require('crypto')
|
||||
|
||||
module.exports = {
|
||||
inject: function (bot, dcclient, config) {
|
||||
bot.hash = ''
|
||||
|
||||
const interval = setInterval(() => {
|
||||
const normalKey = process.env['chomensjs_key']
|
||||
const ownerHashKey = process.env['chomensjs_owner_key']
|
||||
bot.hash = crypto.createHash('sha256').update(Math.floor(Date.now() / 10000) + normalKey).digest('hex').substring(0, 16)
|
||||
bot.ownerHash = crypto.createHash('sha256').update(Math.floor(Date.now() / 10000) + ownerHashKey).digest('hex').substring(0, 16)
|
||||
}, 2000)
|
||||
bot.on('end', () => {
|
||||
clearInterval(interval)
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,136 +0,0 @@
|
||||
const { EventEmitter } = require('events')
|
||||
|
||||
class PlayerList {
|
||||
list = []
|
||||
|
||||
addPlayer (player) {
|
||||
this.removePlayer(player)
|
||||
|
||||
this.list.push(player)
|
||||
}
|
||||
|
||||
hasPlayer (player) {
|
||||
return this.getPlayer(player) !== undefined
|
||||
}
|
||||
|
||||
getPlayer (player) {
|
||||
let identifier
|
||||
|
||||
switch (typeof player) {
|
||||
case 'object':
|
||||
identifier = player.UUID
|
||||
break
|
||||
case 'string':
|
||||
identifier = player
|
||||
break
|
||||
default:
|
||||
throw new Error(`Get player called with ${player}`)
|
||||
}
|
||||
|
||||
return this.list.find((player) => [player.UUID, player.name].some((item) => item === identifier))
|
||||
}
|
||||
|
||||
getPlayers () {
|
||||
return Array.from(this.list)
|
||||
}
|
||||
|
||||
removePlayer (player) {
|
||||
this.list = this.list.filter(({ UUID }) => UUID !== player.UUID)
|
||||
}
|
||||
}
|
||||
|
||||
function inject (bot, dcclient, config) {
|
||||
bot.players = new PlayerList()
|
||||
|
||||
const tabCompletePlayerList = {
|
||||
list: [],
|
||||
interval: setInterval(async () => {
|
||||
bot.write('tab_complete', {
|
||||
text: '/scoreboard players add '
|
||||
})
|
||||
|
||||
const [packet] = await EventEmitter.once(bot._client, 'tab_complete')
|
||||
|
||||
return packet.matches
|
||||
.filter((match) => !match.tooltip)
|
||||
.map(({ match }) => match)
|
||||
}, 1000 * 3)
|
||||
}//???
|
||||
|
||||
bot._client.on('player_info', async (packet) => {
|
||||
for (const player of packet.data) {
|
||||
switch (packet.action) {
|
||||
case 0:
|
||||
addPlayer(player, packet)
|
||||
break
|
||||
case 1:
|
||||
updateGamemode(player, packet)
|
||||
break
|
||||
case 2:
|
||||
updatePing(player, packet)
|
||||
break
|
||||
case 3:
|
||||
updateDisplayName(player, packet)
|
||||
break
|
||||
case 4:
|
||||
removePlayer(player, packet)
|
||||
break
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
function addPlayer (player, packet) {
|
||||
if (bot.players.getPlayer(player)) bot.emit('player_unvanished', player, packet)
|
||||
else bot.emit('player_added', player, packet)
|
||||
|
||||
bot.players.addPlayer(player)
|
||||
}
|
||||
|
||||
function updateGamemode (player, packet) {
|
||||
const fullPlayer = bot.players.getPlayer(player)
|
||||
|
||||
bot.emit('onPlayerGamemodeUpdate', player, packet)
|
||||
|
||||
if (fullPlayer === undefined) return
|
||||
|
||||
fullPlayer.gamemode = player.gamemode
|
||||
}
|
||||
|
||||
function updatePing (player, packet) {
|
||||
const fullPlayer = bot.players.getPlayer(player)
|
||||
|
||||
bot.emit('player_ping_updated', player, packet)
|
||||
|
||||
if (fullPlayer === undefined) return
|
||||
|
||||
fullPlayer.ping = player.ping
|
||||
}
|
||||
|
||||
function updateDisplayName (player, packet) {
|
||||
const fullPlayer = bot.players.getPlayer(player)
|
||||
|
||||
bot.emit('player_display_name_updated', player, packet)
|
||||
|
||||
if (fullPlayer === undefined) return
|
||||
|
||||
fullPlayer.displayName = player.displayName
|
||||
}
|
||||
|
||||
function removePlayer (player, packet) {
|
||||
const fullPlayer = bot.players.getPlayer(player)
|
||||
const players = tabCompletePlayerList.list
|
||||
|
||||
if (fullPlayer && players.some((name) => name === fullPlayer.name)) {
|
||||
bot.emit('player_vanished', player)
|
||||
} else {
|
||||
bot.emit('player_removed', player, packet)
|
||||
bot.players.removePlayer(player)
|
||||
}
|
||||
}
|
||||
|
||||
bot.on('end', () => {
|
||||
clearInterval(tabCompletePlayerList.interval)
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = { inject }
|
||||
@@ -1,11 +0,0 @@
|
||||
|
||||
function inject (bot) {
|
||||
bot.position = { x: 0, y: 0, z: 0 }
|
||||
bot._client.on('position', (position) => {
|
||||
bot.position = position
|
||||
bot.write('teleport_confirm', { teleportId: position.teleportId })
|
||||
bot.emit('position', position)
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = { inject }
|
||||
@@ -1,129 +0,0 @@
|
||||
|
||||
const util = require('util')
|
||||
const mc = require('minecraft-protocol')
|
||||
const { loadPlugins } = require('../util/loadPlugins')
|
||||
const minecraftVersionToNumber = require('../util/minecraftVersionToNumber')
|
||||
|
||||
function inject (bot, dcclient, config) {
|
||||
if (!config.proxy.enabled) return
|
||||
|
||||
let index
|
||||
config.servers.forEach((server, _index) => {
|
||||
if (bot.server.host !== server.host) return
|
||||
index = _index
|
||||
})
|
||||
|
||||
bot.proxy = {}
|
||||
|
||||
const version = config.proxy.version
|
||||
const srv = mc.createServer({
|
||||
'online-mode': false,
|
||||
port: 25566 + index,
|
||||
keepAlive: false,
|
||||
version
|
||||
})
|
||||
|
||||
srv.on('login', (client) => {
|
||||
bot.console.info(`[Proxy] ${client.username} connected to proxy`)
|
||||
let clientEnded = false
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
let targetEnded = false
|
||||
|
||||
const target = mc.createClient({
|
||||
username: client.username,
|
||||
host: bot.server.host,
|
||||
port: bot.server.port,
|
||||
version
|
||||
})
|
||||
|
||||
const clientPacketBlacklist = []
|
||||
const targetPacketBlacklist = []
|
||||
|
||||
// should this be here or in the chat plugin?
|
||||
target.sendMessage = function (message) {
|
||||
if (message.startsWith('/') && minecraftVersionToNumber(target.version) >= 1.19) {
|
||||
// totallynotskidded™️ from mineflayer
|
||||
const command = message.slice(1)
|
||||
const timestamp = BigInt(Date.now())
|
||||
target.write('chat_command', {
|
||||
command,
|
||||
timestamp,
|
||||
salt: 0n,
|
||||
argumentSignatures: [],
|
||||
signedPreview: false,
|
||||
messageCount: 0,
|
||||
acknowledged: Buffer.alloc(3),
|
||||
// 1.19.2 Chat Command packet also includes an array of last seen messages
|
||||
previousMessages: []
|
||||
})
|
||||
} else {
|
||||
target.chat(message)
|
||||
}
|
||||
}
|
||||
|
||||
target.on('login', (packet) => {
|
||||
bot.console.info(`[Proxy] ${client.username} target logged in`)
|
||||
target.entityId = packet.entityId
|
||||
loadPlugins(bot, null, config, null, target, client, true, clientPacketBlacklist, targetPacketBlacklist)
|
||||
})
|
||||
|
||||
target.on('packet', (data, meta) => {
|
||||
if (!clientEnded &&
|
||||
meta.state === mc.states.PLAY &&
|
||||
client.state === mc.states.PLAY &&
|
||||
!targetPacketBlacklist.includes(meta.name)
|
||||
) client.write(meta.name, data)
|
||||
})
|
||||
|
||||
target.on('error', () => {})
|
||||
|
||||
target.on('end', targetEndListener)
|
||||
target.on('kick_disconnect', ({ reason }) => targetEndListener(JSON.parse(reason)))
|
||||
target.on('disconnect', ({ reason }) => targetEndListener(JSON.parse(reason)))
|
||||
|
||||
function targetEndListener (reason) {
|
||||
target.end()
|
||||
client.end(`Target disconnected with reason: ${util.inspect(reason)}`)
|
||||
targetEnded = true
|
||||
}
|
||||
|
||||
client.on('end', () => {
|
||||
clientEnded = true
|
||||
target.end()
|
||||
target.removeAllListeners()
|
||||
client.removeAllListeners()
|
||||
bot.console.info(`[Proxy] ${client.username} ended`)
|
||||
})
|
||||
|
||||
client.on('error', () => {
|
||||
clientEnded = true
|
||||
target.removeAllListeners()
|
||||
client.removeAllListeners()
|
||||
bot.console.info(`[Proxy] ${client.username} got error`)
|
||||
})
|
||||
|
||||
client.on('packet', (data, meta) => {
|
||||
if (clientPacketBlacklist.includes(meta.name)) return
|
||||
target.write(meta.name, data)
|
||||
})
|
||||
|
||||
bot.proxy[client.username] = {
|
||||
target,
|
||||
client
|
||||
}
|
||||
|
||||
function botEndListener (reason) {
|
||||
delete bot.proxy[client.username]
|
||||
client.end(`Bot disconnected with reason: ${util.inspect(reason)}`)
|
||||
bot.off('end', botEndListener)
|
||||
}
|
||||
bot.on('end', botEndListener)
|
||||
})
|
||||
|
||||
bot.on('end', () => {
|
||||
srv.close()
|
||||
srv.removeAllListeners()
|
||||
})
|
||||
};
|
||||
|
||||
module.exports = { inject }
|
||||
@@ -1,16 +0,0 @@
|
||||
|
||||
const { chatPacketListener, parsePlayerMessages } = require('../../util/chat')
|
||||
const minecraftVersionToNumber = require('../../util/minecraftVersionToNumber')
|
||||
function inject (bot, client, target) {
|
||||
function listener (packet) {
|
||||
chatPacketListener(packet, target, minecraftVersionToNumber(target.version) >= 1.10)
|
||||
}
|
||||
target.on('systemChat', listener)
|
||||
target.on('chat', listener)
|
||||
|
||||
target.on('message', (message, packet) => {
|
||||
parsePlayerMessages(message, packet, target)
|
||||
})
|
||||
};
|
||||
|
||||
module.exports = { inject }
|
||||
@@ -1,58 +0,0 @@
|
||||
const minecraftVersionToNumber = require('../../util/minecraftVersionToNumber')
|
||||
|
||||
function inject (bot, client, target, config, clientPacketBlacklist) {
|
||||
const { MessageBuilder } = require('prismarine-chat')(bot.version)
|
||||
clientPacketBlacklist.push('chat')
|
||||
clientPacketBlacklist.push('chat_message')
|
||||
client.on(minecraftVersionToNumber(target.version) >= 1.19 ? 'chat_message' : 'chat', (data) => {
|
||||
// not the best place to put command handler thing here but ok
|
||||
if (data.message?.startsWith('.')) {
|
||||
return bot.command_handler.run(
|
||||
client.username,
|
||||
config.prefixes[0] + data.message.substring(1),
|
||||
client.uuid,
|
||||
null,
|
||||
'h', // real hash hardcode
|
||||
'o',
|
||||
client.username,
|
||||
true,
|
||||
client,
|
||||
target
|
||||
)
|
||||
}
|
||||
|
||||
if (!data.message?.startsWith('/')) {
|
||||
const codeParsedMessage = data.message.replace(/%[^%]+%/g, (code) => {
|
||||
try {
|
||||
// eslint-disable-next-line no-eval
|
||||
return eval(code.substring(1).slice(0, -1))
|
||||
} catch (e) {
|
||||
return code
|
||||
}
|
||||
})
|
||||
bot.tellraw('@a', {
|
||||
color: 'dark_gray',
|
||||
translate: '[%s] [%s] %s \u203a %s',
|
||||
with: [
|
||||
{
|
||||
text: 'Chat',
|
||||
color: 'gray'
|
||||
},
|
||||
{
|
||||
text: 'Proxy',
|
||||
color: 'gray'
|
||||
},
|
||||
{
|
||||
selector: client.username,
|
||||
color: 'green'
|
||||
},
|
||||
MessageBuilder.fromString('&7' + codeParsedMessage)
|
||||
]
|
||||
})
|
||||
} else {
|
||||
target.sendMessage(data)
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
module.exports = { inject }
|
||||
@@ -1,48 +0,0 @@
|
||||
|
||||
function inject (bot, client, target, config) {
|
||||
let cspy = false
|
||||
let op = true
|
||||
// let gameMode = 1
|
||||
|
||||
target.on('message', (data) => {
|
||||
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
|
||||
})
|
||||
|
||||
target.on('entity_status', (data) => {
|
||||
if (data.entityId !== target.entityId) return
|
||||
|
||||
switch (data.entityStatus) {
|
||||
case 24:
|
||||
op = false
|
||||
break
|
||||
case 28:
|
||||
op = true
|
||||
break
|
||||
}
|
||||
})
|
||||
|
||||
// target.on('game_state_change', (data) => {
|
||||
// if (data.reason !== 3) return
|
||||
//
|
||||
// gameMode = data.gameMode
|
||||
// })
|
||||
//
|
||||
// target.on('login', (data) => {
|
||||
// gameMode = data.gameMode
|
||||
// })
|
||||
|
||||
const interval = setInterval(() => {
|
||||
if (bot.options.kaboom) {
|
||||
if (!op && config.self_care.op) target.sendMessage('/minecraft:op @s[type=player]')
|
||||
if (!cspy && config.self_care.cspy) target.sendMessage('/commandspy:commandspy on')
|
||||
}
|
||||
// if (gameMode !== 1 && config.self_care.gamemode) target.sendMessage('/minecraft:gamemode creative @s[type=player]')
|
||||
}, config.self_care_check_interval)
|
||||
|
||||
bot.on('end', () => {
|
||||
clearInterval(interval)
|
||||
})
|
||||
};
|
||||
|
||||
module.exports = { inject }
|
||||
@@ -1,90 +0,0 @@
|
||||
|
||||
function inject (bot, dcclient, config) {
|
||||
let vanish = false
|
||||
let nickname = true
|
||||
let socialspy = false
|
||||
let cspy = false
|
||||
let prefix = false
|
||||
|
||||
let op = false
|
||||
let gameMode = 1
|
||||
let muted = false
|
||||
|
||||
bot.on('message', (data) => {
|
||||
if (data.toString() === 'You are now completely invisible to normal users, and hidden from in-game commands.') vanish = true
|
||||
if (!bot.visibility && data.toString() === `Vanish for ${bot.username}: disabled`) vanish = false
|
||||
|
||||
if (data.toString() === 'You no longer have a nickname.') nickname = true
|
||||
if (data.toString().startsWith('Your nickname is now ')) nickname = false
|
||||
|
||||
if (data.toString() === `SocialSpy for ${bot.username}: enabled`) socialspy = true
|
||||
if (data.toString() === `SocialSpy for ${bot.username}: disabled`) socialspy = false
|
||||
|
||||
if (data.toString().startsWith('You have been muted')) muted = true
|
||||
if (data.toString() === 'You have been unmuted.') muted = 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 disabled CommandSpy' || data.toString() === ' Disabled your command spy.') cspy = false
|
||||
|
||||
if (data.toString() === 'You now have the tag: [ChomeNS Bot]' || // for 1.19.2 (or 1.19?) and older clones
|
||||
data.toString() === 'You now have the tag: &8[&eChomeNS Bot&8]'
|
||||
) {
|
||||
prefix = true
|
||||
return
|
||||
}
|
||||
if (data.toString().startsWith('You no longer have a tag')) prefix = false
|
||||
if (data.toString().startsWith('You now have the tag: ')) prefix = false
|
||||
})
|
||||
|
||||
bot._client.on('entity_status', (data) => {
|
||||
if (data.entityId !== bot.entityId) return
|
||||
|
||||
switch (data.entityStatus) {
|
||||
case 24:
|
||||
op = false
|
||||
|
||||
bot.emit('deop')
|
||||
break
|
||||
case 28:
|
||||
op = true
|
||||
|
||||
bot.emit('op')
|
||||
break
|
||||
}
|
||||
|
||||
bot.emit('entity_status', data)
|
||||
})
|
||||
|
||||
bot._client.on('game_state_change', (data) => {
|
||||
if (data.reason === 4 && config.self_care.endCredits) bot.write('client_command', { payload: 0 })
|
||||
|
||||
if (data.reason !== 3) return
|
||||
|
||||
gameMode = data.gameMode
|
||||
})
|
||||
|
||||
bot._client.on('login', (data) => {
|
||||
gameMode = data.gameMode
|
||||
})
|
||||
|
||||
const interval = setInterval(() => {
|
||||
if (bot.options.kaboom) {
|
||||
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 (!cspy && config.self_care.cspy) bot.chat('/commandspy:commandspy on')
|
||||
}
|
||||
|
||||
if (!vanish && config.self_care.vanish) bot.chat('/essentials:vanish enable')
|
||||
//if (!socialspy && config.self_care.socialspy) bot.chat('/essentials:socialspy enable')
|
||||
if (!nickname && config.self_care.nickname) bot.chat('/essentials:nickname off')
|
||||
|
||||
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)
|
||||
}, config.self_care_check_interval)
|
||||
|
||||
bot.on('end', () => {
|
||||
clearInterval(interval)
|
||||
})
|
||||
};
|
||||
|
||||
module.exports = { inject }
|
||||
@@ -1,12 +0,0 @@
|
||||
function inject (bot, dcclient, config) {
|
||||
const ChatMessage = require('prismarine-chat')(bot.version)
|
||||
bot.tellraw = function (selector, message) {
|
||||
if (bot.options.useChat && selector === '@a') {
|
||||
bot.chat(ChatMessage.fromNotch(message).toMotd().replaceAll('\xa7', '&'))
|
||||
return
|
||||
}
|
||||
bot.core.run(`minecraft:tellraw ${selector} ${JSON.stringify(message)}`)
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = { inject }
|
||||
@@ -1,75 +0,0 @@
|
||||
const clamp = require('../util/clamp')
|
||||
function inject (bot, dcclient, config) {
|
||||
const bossbarName = 'chomens_bot:tps'
|
||||
|
||||
let enabled = false
|
||||
bot.tps = {
|
||||
on () {
|
||||
enabled = true
|
||||
},
|
||||
off () {
|
||||
enabled = false
|
||||
bot.core.run(`minecraft:bossbar remove ${bossbarName}`)
|
||||
}
|
||||
}
|
||||
|
||||
const tickRates = []
|
||||
let nextIndex = 0
|
||||
let timeLastTimeUpdate = -1
|
||||
let timeGameJoined
|
||||
|
||||
const interval = setInterval(() => {
|
||||
if (!enabled) return
|
||||
|
||||
const component = {
|
||||
translate: 'TPS - %s',
|
||||
color: 'gray',
|
||||
bold: false,
|
||||
with: [
|
||||
{ text: getTickRate(), color: 'green' }
|
||||
]
|
||||
}
|
||||
bot.core.run(`minecraft:bossbar add ${bossbarName} ""`)
|
||||
bot.core.run(`minecraft:bossbar set ${bossbarName} players @a`)
|
||||
bot.core.run(`minecraft:bossbar set ${bossbarName} color yellow`)
|
||||
bot.core.run(`minecraft:bossbar set ${bossbarName} visible true`)
|
||||
bot.core.run(`minecraft:bossbar set ${bossbarName} style progress`)
|
||||
bot.core.run(`minecraft:bossbar set ${bossbarName} name ${JSON.stringify(component)}`)
|
||||
bot.core.run(`minecraft:bossbar set ${bossbarName} max 20`)
|
||||
bot.core.run(`minecraft:bossbar set ${bossbarName} value ${Math.floor(getTickRate())}`)
|
||||
}, 50)
|
||||
|
||||
function getTickRate () {
|
||||
if (Date.now() - timeGameJoined < 4000) return 'Calculating...'
|
||||
|
||||
let numTicks = 0
|
||||
let sumTickRates = 0.0
|
||||
for (const tickRate of tickRates) {
|
||||
if (tickRate > 0) {
|
||||
sumTickRates += tickRate
|
||||
numTicks++
|
||||
}
|
||||
}
|
||||
|
||||
const value = (sumTickRates / numTicks).toFixed(2)
|
||||
if (value > 20) return 20
|
||||
else return value
|
||||
}
|
||||
|
||||
bot.on('login', () => {
|
||||
nextIndex = 0
|
||||
timeGameJoined = timeLastTimeUpdate = Date.now()
|
||||
})
|
||||
|
||||
bot._client.on('update_time', () => {
|
||||
const now = Date.now()
|
||||
const timeElapsed = (now - timeLastTimeUpdate) / 1000.0
|
||||
tickRates[nextIndex] = clamp(20.0 / timeElapsed, 0.0, 20.0)
|
||||
nextIndex = (nextIndex + 1) % tickRates.length
|
||||
timeLastTimeUpdate = now
|
||||
})
|
||||
|
||||
bot.on('end', () => clearInterval(interval))
|
||||
}
|
||||
|
||||
module.exports = { inject }
|
||||
@@ -1,46 +0,0 @@
|
||||
const mc = require('minecraft-protocol')
|
||||
const crypto = require('crypto')
|
||||
const colorConvert = require('color-convert')
|
||||
|
||||
const uuid = require('uuid-by-string')
|
||||
const moment = require('moment-timezone')
|
||||
const cowsay = require('cowsay2')
|
||||
const cows = require('cowsay2/cows')
|
||||
const { VM } = require('vm2')
|
||||
const randomstring = require('randomstring')
|
||||
const mineflayer = require('mineflayer')
|
||||
const Vec3 = require('vec3')
|
||||
function inject (bot) {
|
||||
const chatMessage = require('prismarine-chat')(bot.version)
|
||||
const mcData = require('minecraft-data')(bot.version)
|
||||
bot.vmOptions = {
|
||||
timeout: 2000,
|
||||
sandbox: {
|
||||
run (cmd) {
|
||||
bot.core.run(cmd)
|
||||
},
|
||||
mc,
|
||||
mineflayer,
|
||||
chat: bot.chat,
|
||||
moment,
|
||||
randomstring,
|
||||
uuid,
|
||||
chatMessage,
|
||||
crypto,
|
||||
colorConvert,
|
||||
bruhifyText (message) {
|
||||
if (
|
||||
typeof message !== 'string'
|
||||
) throw new SyntaxError('message must be a string')
|
||||
bot.bruhifyText = message.substring(0, 1000)
|
||||
},
|
||||
cowsay,
|
||||
cows,
|
||||
mcData,
|
||||
Vec3
|
||||
}
|
||||
}
|
||||
bot.vm = new VM(bot.vmOptions)
|
||||
};
|
||||
|
||||
module.exports = { inject }
|
||||
@@ -1 +0,0 @@
|
||||
{"error":".zip archives do not support non-regular files","level":"error","msg":"unable to write file .cache/replit/modules/nodejs-18:v9-20230908-bb1b9fd","time":"2023-09-17T03:59:55Z"}
|
||||
@@ -1,13 +0,0 @@
|
||||
module.exports = {
|
||||
/**
|
||||
* this code is from somewhere i can't remember...
|
||||
* @param {Number} min
|
||||
* @param {Number} max
|
||||
* @return {Number}
|
||||
*/
|
||||
between: function (min, max) {
|
||||
return Math.floor(
|
||||
Math.random() * (max - min) + min
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,146 +0,0 @@
|
||||
/**
|
||||
* for the chat packet listener (in util cuz proxy + bot)
|
||||
* @param {object} packet chat packet
|
||||
* @param {object} bot bot
|
||||
* @param {boolean} mc119 minecraft 1.19 or newer
|
||||
*/
|
||||
function chatPacketListener (packet, bot, mc119) {
|
||||
// try catch prevents json parse error (happens with a custom server that sends an invalid json component for example)
|
||||
try {
|
||||
const ChatMessage = require('prismarine-chat')(bot.version)
|
||||
|
||||
const parsedMessage = JSON.parse(mc119 ? packet.formattedMessage : packet.message)
|
||||
// down here it prevents command set message
|
||||
|
||||
// for ayunboom cuz its 1.17.1
|
||||
// VVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
||||
if (parsedMessage.extra) {
|
||||
if (parsedMessage.extra[0].text === 'Command set: ') return
|
||||
}
|
||||
// for 1.18 or newer(?)
|
||||
// VVVVVVVVVVVVVVVVVVVVV
|
||||
if (parsedMessage.translate === 'advMode.setCommand.success') return
|
||||
|
||||
const message = ChatMessage.fromNotch(mc119 ? packet.formattedMessage : packet.message)
|
||||
|
||||
bot.emit('message', message, parsedMessage)
|
||||
} catch (e) {
|
||||
bot.console.error(e)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* new parse player messages, more accurate message real!11!!
|
||||
* @param {object} _message prismarine-chat ChatMessage - unused in code but used in legacy parsing
|
||||
* @param {object} parsedMessage parsed message in a js object
|
||||
* @param {object} bot bot
|
||||
*/
|
||||
function parsePlayerMessages (_message, parsedMessage, bot) {
|
||||
const ChatMessage = require('prismarine-chat')(bot.version)
|
||||
const vanillaKeys = [
|
||||
'chat.type.text',
|
||||
'chat.type.announcement',
|
||||
'chat.type.emote'
|
||||
]
|
||||
|
||||
// parse Extras™ chat messages
|
||||
if (
|
||||
parsedMessage.translate === '%s' &&
|
||||
parsedMessage.with?.length === 1 &&
|
||||
parsedMessage.with[0]?.text === '' &&
|
||||
parsedMessage.with[0]?.extra?.length === 5
|
||||
) {
|
||||
const trueMessageComponent = parsedMessage.with[0].extra
|
||||
const username = ChatMessage.fromNotch(trueMessageComponent[1]).toMotd()
|
||||
const message = ChatMessage.fromNotch(trueMessageComponent[4]).toMotd()
|
||||
bot.emit('chat', username, message)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// parse CommandSpy™ messages
|
||||
if (
|
||||
(
|
||||
parsedMessage.color === 'yellow' ||
|
||||
parsedMessage.color === 'aqua'
|
||||
) &&
|
||||
parsedMessage.extra?.length === 2
|
||||
) {
|
||||
const username = parsedMessage.text
|
||||
const command = parsedMessage.extra[1].text
|
||||
bot.emit('cspy', username, command)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// parse Minecraft Vanilla™ messages
|
||||
if (
|
||||
vanillaKeys.includes(parsedMessage.translate) &&
|
||||
parsedMessage.with.length >= 2
|
||||
) {
|
||||
const username = ChatMessage.fromNotch(parsedMessage.with[0]).toMotd()
|
||||
const message = ChatMessage.fromNotch(parsedMessage.with[1]).toMotd()
|
||||
bot.emit('chat', username, message)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
parsePlayerMessagesLegacy(_message, parsedMessage, bot)
|
||||
}
|
||||
|
||||
/**
|
||||
* LEGACY - parse player messages (for prismarine-chat)
|
||||
* @param {object} message prismarine-chat ChatMessage
|
||||
* @param {object} _parsedMessage parsed message in a js object
|
||||
* @param {object} bot bot
|
||||
*/
|
||||
function parsePlayerMessagesLegacy (message, _parsedMessage, bot) {
|
||||
try {
|
||||
// here is all the player message parsing thing
|
||||
const raw = message.toMotd() // lags the bot as you already know
|
||||
// if (raw.match(/.* .*: .*/g)) {
|
||||
// const username = raw.replace(/.*?\[.*?\] /g, '').replace(/:.*/g, '').replace(/§#....../gm, '')
|
||||
// const message = raw.split(': ').slice(1).join(' ').replace(/§#....../gm, '')
|
||||
// bot.emit('chat', username, message)
|
||||
// } else
|
||||
if (raw.match(/.* .*\u203a .*/g)) {
|
||||
const username = raw.replace(/.*?\[.*?\] /g, '').replace(/\u203a.*/g, '').replace(/§#....../gm, '').split(' ')[0]
|
||||
const message = raw.split('\u203a ').slice(1).join(' ').substring(2)
|
||||
bot.emit('chat', username, message)
|
||||
} else if (raw.match(/.* .*\u00BB .*/g)) {
|
||||
const username = raw.replace(/.*?\[.*?\] /g, '').replace(/\u00BB.*/g, '').replace(/§#....../gm, '').split(' ')[0]
|
||||
const message = raw.split('\u00BB ').slice(1).join(' ')
|
||||
bot.emit('chat', username, message)
|
||||
}
|
||||
// } else if (raw.match(/.* .*> .*/g)) {
|
||||
// const username = raw.replace(/.*?\[.*?\] /g, '').replace(/>.*/g, '').replace(/§#....../gm, '').split(' ')[0]
|
||||
// const message = raw.split('> ').slice(1).join(' ').substring(2)
|
||||
// bot.emit('chat', username, message)
|
||||
// } else if (raw.match(/<.*> .*/g)) {
|
||||
// const username = raw.substring(1).split('>')[0]
|
||||
// const message = raw.split('> ').slice(1).join(' ')
|
||||
//
|
||||
// bot.emit('chat', username, message)
|
||||
// } else if (raw.match(/§.*§b: §b\/.*/g)) {
|
||||
// const username = raw.split('§b: §b')[0]
|
||||
// const command = raw.split('§b: §b')[1]
|
||||
|
||||
// bot.emit('cspy', username, command)
|
||||
// } else if (raw.match(/§.*§e: §e\/.*/g)) {
|
||||
// const username = raw.split('§e: §e')[0]
|
||||
// const command = raw.split('§e: §e')[1]
|
||||
// bot.emit('cspy', username, command)
|
||||
// } else if (raw.match(/§.*§b: \/.*/g)) {
|
||||
// const username = raw.split('§b: ')[0]
|
||||
// const command = raw.split('§b: ')[1]
|
||||
|
||||
// bot.emit('cspy', username, command)
|
||||
// } else if (raw.match(/§.*§e: \/.*/g)) {
|
||||
// const username = raw.split('§e: ')[0]
|
||||
// const command = raw.split('§e: ')[1]
|
||||
// bot.emit('cspy', username, command)
|
||||
// }
|
||||
} catch (e) {}
|
||||
};
|
||||
|
||||
module.exports = { chatPacketListener, parsePlayerMessages }
|
||||
@@ -1,23 +0,0 @@
|
||||
|
||||
const styles = {
|
||||
bigint: '\xa76',
|
||||
boolean: '\xa76',
|
||||
date: '\xa75',
|
||||
module: '\xa7n',
|
||||
name: undefined,
|
||||
null: '\xa7l',
|
||||
number: '\xa76',
|
||||
regexp: '\xa74',
|
||||
special: '\xa73',
|
||||
string: '\xa72',
|
||||
symbol: '\xa72',
|
||||
undefined: '\xa78'
|
||||
}
|
||||
|
||||
function stylize (str, styleType) {
|
||||
const style = styles[styleType]
|
||||
if (style !== undefined) return `${style}${str}\xa7r`
|
||||
return str
|
||||
}
|
||||
|
||||
module.exports = { stylize, styles }
|
||||
@@ -1,22 +0,0 @@
|
||||
/**
|
||||
* escape markdown so on discord it will be \_ChipMC\_ instead of _ChipMC_
|
||||
* @param {String} text
|
||||
* @param {Boolean} zwsp
|
||||
* @return {String}
|
||||
*/
|
||||
function escapeMarkdown (text, zwsp) {
|
||||
let unescaped
|
||||
let escaped
|
||||
try {
|
||||
unescaped = text.replace(/\\(\*|@|_|`|~|\\)/g, '$1')
|
||||
escaped = unescaped.replace(/(\*|@|_|`|~|\\)/g, zwsp
|
||||
? '\u200b\u200b$1'
|
||||
: '\\$1'
|
||||
)
|
||||
} catch (e) {
|
||||
return unescaped
|
||||
}
|
||||
return escaped
|
||||
}
|
||||
|
||||
module.exports = { escapeMarkdown }
|
||||
@@ -1,14 +0,0 @@
|
||||
const path = require('path')
|
||||
/**
|
||||
* get filename from url
|
||||
* @param {string} urlStr the url
|
||||
* @return {string} filename
|
||||
* @example
|
||||
* getFilenameFromUrl('https://sus.red/amogus.mid?verysus=true') // returns 'amogus.mid'
|
||||
*/
|
||||
function getFilenameFromUrl (urlStr) {
|
||||
const url = new URL(urlStr)
|
||||
return path.basename(url.pathname)
|
||||
}
|
||||
|
||||
module.exports = getFilenameFromUrl
|
||||
@@ -1,27 +0,0 @@
|
||||
/**
|
||||
* resize image.
|
||||
* @param {number} width width
|
||||
* @param {number} height height
|
||||
* @return {object} width and height
|
||||
*/
|
||||
function resize (width, height) {
|
||||
const aspectRatio = width / height
|
||||
|
||||
let optimalWidth = Math.round(aspectRatio * 20 * (27 / 3))
|
||||
let optimalHeight = 20
|
||||
|
||||
if (optimalWidth > 320) {
|
||||
const reduction = optimalWidth / 320
|
||||
|
||||
optimalWidth = 320
|
||||
|
||||
optimalHeight *= reduction
|
||||
}
|
||||
|
||||
return {
|
||||
width: Math.floor(optimalWidth),
|
||||
height: Math.floor(optimalHeight)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { resize }
|
||||
@@ -1,33 +0,0 @@
|
||||
const fs = require('fs/promises')
|
||||
const util = require('util')
|
||||
const path = require('path')
|
||||
|
||||
/**
|
||||
* load plugins
|
||||
* @param {object} bot the bot object
|
||||
* @param {object} dcclient discord client
|
||||
* @param {object} config the config
|
||||
* @param {object} rl readline
|
||||
* @param {object} target proxy target
|
||||
* @param {object} client proxy client
|
||||
* @param {boolean} proxy is proxy
|
||||
* @param {array} clientPacketBlacklist the client packet blacklist
|
||||
* @param {array} targetPacketBlacklist target packet blacklist
|
||||
*/
|
||||
async function loadPlugins (bot, dcclient, config, rl, target, client, proxy, clientPacketBlacklist, targetPacketBlacklist) {
|
||||
const dir = path.join(__dirname, '..', 'plugins', proxy ? 'proxy' : '')
|
||||
const plugins = await fs.readdir(dir)
|
||||
plugins.forEach((plugin) => {
|
||||
if (!plugin.endsWith('.js')) return
|
||||
try {
|
||||
const plug = require(path.join(dir, plugin))
|
||||
if (!proxy) plug.inject(bot, dcclient, config, rl)
|
||||
else plug.inject(bot, client, target, config, clientPacketBlacklist, targetPacketBlacklist)
|
||||
} catch (e) {
|
||||
console.log(`Plugin ${plugin} is having exception loading the plugin:`)
|
||||
console.log(util.inspect(e))
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
module.exports = { loadPlugins }
|
||||
@@ -1,25 +0,0 @@
|
||||
const fs = require('fs/promises')
|
||||
const path = require('path')
|
||||
|
||||
/**
|
||||
* loads js files
|
||||
* @param {string} directory the directory that contains the js files
|
||||
* @return {Array} an array of require()ed js files
|
||||
*/
|
||||
async function loadPlugins (directory) {
|
||||
const plugins = []
|
||||
|
||||
for (const filename of await fs.readdir(directory)) {
|
||||
if (!filename.endsWith('.js')) continue
|
||||
|
||||
const filepath = path.join(directory, filename)
|
||||
|
||||
const plugin = require(filepath)
|
||||
|
||||
plugins.push(plugin)
|
||||
}
|
||||
|
||||
return plugins
|
||||
}
|
||||
|
||||
module.exports = loadPlugins
|
||||
@@ -1,17 +0,0 @@
|
||||
class CommandSource {
|
||||
constructor (player, sources, hash, owner = false, discordMessageEvent = null) {
|
||||
this.player = player
|
||||
this.sources = sources
|
||||
this.hash = hash
|
||||
this.owner = owner
|
||||
this.discordMessageEvent = discordMessageEvent
|
||||
}
|
||||
|
||||
sendFeedback () {}
|
||||
|
||||
sendError (message) {
|
||||
this.sendFeedback([{ text: '', color: 'dark_red' }, message], false)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = CommandSource
|
||||
@@ -1,70 +0,0 @@
|
||||
const mc = require('minecraft-protocol')
|
||||
const { EventEmitter } = require('events')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
// "buildstring":"FNFBoyfriendBotX V4.0.8a Build:97",
|
||||
//"FoundationBuildString":"Ultimate Foundation V1.0.1 Build:31",
|
||||
function createBot(options = {}) {
|
||||
const bot = new EventEmitter()
|
||||
const rs = require('randomstring')
|
||||
// Set some default values in options
|
||||
let r = Math.floor(Math.random() * 255) + 1;
|
||||
options.host ??= 'localhost'
|
||||
options.username ??= username()
|
||||
options.hideErrors ??= false // HACK: Hide errors by default as a lazy fix to console being spammed with them
|
||||
|
||||
bot.options = options
|
||||
|
||||
// Create our client object, put it on the bot, and register some events
|
||||
bot.on('init_client', client => {
|
||||
client.on('packet', (data, meta) => {
|
||||
bot.emit('packet', data, meta)
|
||||
bot.emit('packet.' + meta.name, data)
|
||||
})
|
||||
|
||||
client.on('login', () => {
|
||||
bot.uuid = client.uuid
|
||||
bot.username = client.username
|
||||
})
|
||||
|
||||
client.on('end', reason => bot.emit('end', reason))
|
||||
|
||||
client.on('error', error => bot.emit('error', error))
|
||||
|
||||
})
|
||||
const buildstring = process.env['buildstring']
|
||||
|
||||
const client = options.client ?? mc.createClient(options)
|
||||
bot._client = client
|
||||
bot.emit('init_client', client)
|
||||
|
||||
bot.bots = options.bots ?? [bot]
|
||||
|
||||
// Modules
|
||||
bot.loadModule = module => module(bot, options)
|
||||
|
||||
for (const filename of fs.readdirSync(path.join(__dirname, 'modules'))) {
|
||||
try {
|
||||
const module = require(path.join(__dirname, 'modules', filename))
|
||||
bot.loadModule(module)
|
||||
} catch (error) {
|
||||
console.error('Failed to load module', filename, ':', error)
|
||||
}
|
||||
}
|
||||
|
||||
return bot
|
||||
}
|
||||
|
||||
// ABot username function mabe mabe
|
||||
function username() {
|
||||
const characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'; // remove sus characters like ` or like ( or whatever because it breaks whatever
|
||||
let username = '';
|
||||
for (let i = 0; i < 8; i++) {
|
||||
const randomIndex = Math.floor(Math.random() * characters.length);
|
||||
username += characters[randomIndex];
|
||||
}
|
||||
return username;
|
||||
}
|
||||
|
||||
module.exports = createBot
|
||||
@@ -1,57 +0,0 @@
|
||||
const crypto = require('crypto')
|
||||
|
||||
module.exports = {
|
||||
name: 'abotval',
|
||||
|
||||
consoleOnly: true,
|
||||
|
||||
execute (context) {
|
||||
const bot = context.bot
|
||||
|
||||
const prefix = '<' // mabe not hardcode the prefix
|
||||
|
||||
const args = context.arguments
|
||||
let hashlol
|
||||
const key = process.env['abot_key']
|
||||
const date = new Date();
|
||||
const min = date.getMinutes();
|
||||
|
||||
const md5 = crypto.createHash('md5').update(`${min}--_${key}`).digest('hex');
|
||||
const basehash = crypto.createHash('sha256').update(md5).digest('hex');
|
||||
const hashe = btoa(basehash)
|
||||
const fullhash = crypto.createHash('sha256').update(hashe).digest('hex');
|
||||
hashlol = fullhash.substring(0, 16);
|
||||
//already have to token ready
|
||||
|
||||
|
||||
const hash = hashlol
|
||||
|
||||
const command = `${prefix}${args.shift()} ${hash} ${args.join(' ')}`
|
||||
|
||||
const peefix = {
|
||||
|
||||
clickEvent: { action:"open_url", value: "https://doin-your.mom"},
|
||||
"color": "#5A5A5A",
|
||||
"translate": '[%s] %s \u203a %s',
|
||||
"with": [
|
||||
{ "color": "aqua", "text": "FNFBoyfriendBotX"},
|
||||
{ "color": "aqua", "text": `${bot.username}`},
|
||||
{ "color": "white", "text": command},
|
||||
]// why name it that?? xD
|
||||
}
|
||||
|
||||
|
||||
context.bot.tellraw([peefix])
|
||||
}//this isnt how..
|
||||
}//./commands/tellraw.js
|
||||
// Done!
|
||||
//are ya able to help with the validation/hashing in mine?
|
||||
// Make a copy of this
|
||||
//ahh ok
|
||||
//whos not
|
||||
|
||||
// Can cars fly?
|
||||
//fr
|
||||
// look at the console
|
||||
// watch console rq
|
||||
// Rip our ram lmao
|
||||
@@ -1,12 +0,0 @@
|
||||
const CommandError = require('../CommandModules/command_error')
|
||||
|
||||
module.exports = {
|
||||
name: 'botdevhistory',
|
||||
execute (context) {
|
||||
|
||||
const message = context.arguments.join(' ')
|
||||
const bot = context.bot
|
||||
var prefix = '&8&l&m[&4&mParker2991&8]&8&m[&b&mBOYFRIEND&8]&8&m[&b&mCONSOLE&8]&r '
|
||||
bot.core.run('bcraw ' + prefix + 'Thank you for all that helped and contributed with the bot, it has been one hell of a ride with the bot hasnt it? From November 22, 2022 to now, 0.1 beta to 4.0 alpha, Mineflayer to Node-Minecraft-Protocol. I have enjoyed all the new people i have met throughout the development of the bot back to the days when the bot used mineflayer for most of its lifespan to the present as it now uses node-minecraft-protocol. Its about time for me to tell how development went in the bot well here it is, back in 0.1 beta of the bot it was skidded off of menbot 1.0 reason why? Well because LoginTimedout gave me the bot when ayunboom was still a thing and he helped throughout that time period bot and when 1.0 beta came around he he just stopped helping me on it why? because he had servers to run so yeah but anyway back then i didnt know what skidded like i do now so i thought i could get away with but i was wrong 💀. Early names considered for the bot were &6&lParkerBot &4&lDEMONBot &b&lWoomyBot &b&lBoyfriendBot,&r i kept the name &b&lBoyfriendBot&r throughout most of the early development but i got sick and tired of being harassed about the name being told it was gay but people really didnt know what it meant did they? It was referenced to Boyfriend from Friday Night Funkin’ so right around 1.0 released i renamed it to &b&lFNFBoyfriend&4&lBot &rand around 2.0 changed it to &5&lFNF&b&lBoyfriend&4&lBot &rand luckily avoided the harassment when i changed it i love coding and i want to learn how to code more thank you all!')
|
||||
}
|
||||
}
|
||||
@@ -1,191 +0,0 @@
|
||||
// TODO: Maybe add more authors
|
||||
const bots = [
|
||||
{
|
||||
name: { text: 'HBot', color: 'aqua', bold:true },
|
||||
authors: ['hhhzzzsss'],
|
||||
exclaimer:'HBOT HARRYBUTT LMAOOOOOOOOOOOOOOOOO',
|
||||
foundation: 'java/mcprotocollib',
|
||||
prefixes: ['#']
|
||||
},
|
||||
{
|
||||
name: [{ text: 'Evil', color: 'dark_red' }, {text:'Bot', color:'dark_purple'}],
|
||||
authors: ['FusseligerDev'],
|
||||
exclaimer:'',
|
||||
foundation: 'Java/Custom',
|
||||
prefixes: ['!']
|
||||
},
|
||||
{
|
||||
name: { text: 'SBot Java', color: 'white', bold:true }, // TODO: Gradient
|
||||
authors: ['evkc'],
|
||||
foundation: 'Java/MCProtocolLib',
|
||||
prefixes: [':']
|
||||
},
|
||||
{
|
||||
name: { text: 'SBot Rust', color: 'white', bold:true }, // TODO: Gradient
|
||||
authors: ['evkc'],
|
||||
foundation: 'Rust',
|
||||
prefixes: ['re:']
|
||||
},
|
||||
{
|
||||
name: { text: 'Z-Boy-Bot', color: 'dark_purple' }, // TODO: Gradient
|
||||
exclaimer: 'Most likely skidded along with kbot that the dev used',
|
||||
authors: ['Romnci'],
|
||||
foundation: 'NodeJS/mineflayer or Java/mcprotocollib idfk',
|
||||
prefixes: ['Z]']
|
||||
},
|
||||
{
|
||||
name: { text: 'ABot', color: 'gold', bold:true }, // TODO: Gradient
|
||||
exclaimer: '',
|
||||
authors: ['yfd'],
|
||||
foundation: 'NodeJS/Node-Minecraft-Protocol',
|
||||
prefixes: ['<']
|
||||
},
|
||||
{
|
||||
name: { text: 'FardBot', color: 'light_purple' },
|
||||
authors: ['_yfd'],
|
||||
exclaimer: 'bot is dead lol',
|
||||
foundation: 'NodeJS/Mineflayer',
|
||||
prefixes: ['<']
|
||||
},
|
||||
|
||||
{
|
||||
name: { text: 'ChipmunkBot', color: 'green' },
|
||||
authors: ['_ChipMC_'],
|
||||
exclaimer: 'chips? also shoutout to chip and chayapak for helping in the rewrite',
|
||||
|
||||
foundation: 'Java/MCProtocolLib',
|
||||
prefixes: ["'", "/'"]
|
||||
},
|
||||
{
|
||||
name: { text: 'ChipmunkBot Old', color: 'green' },
|
||||
authors: ['_ChipMC_'],
|
||||
foundation: 'NodeJS/Node-Minecraft-Protocol',
|
||||
|
||||
},
|
||||
{
|
||||
name: { text: 'TestBot', color: 'aqua' },
|
||||
authors: ['Blackilykat'],
|
||||
foundation: 'Java/MCProtocolLib',
|
||||
prefixes: ["-"]
|
||||
},
|
||||
{
|
||||
name: { text: 'UBot', color: 'grey' },
|
||||
authors: ['HexWoman'],
|
||||
exclaimer: 'UwU OwO',
|
||||
|
||||
foundation: 'NodeJS/node-minecraft-protocol',
|
||||
prefixes: ['"']
|
||||
},
|
||||
{
|
||||
name: { text: 'ChomeNS Bot Java', color: 'yellow'},
|
||||
authors: ['chayapak'],
|
||||
exclaimer: 'wow its my bot !! ! 4374621q43567%^&#%67868-- chayapak',
|
||||
foundation: 'Java/MCProtocolLib',
|
||||
prefixes: ['*', 'cbot ', '/cbot ']
|
||||
},
|
||||
{
|
||||
name: { text: 'ChomeNS Bot NodeJS', color: 'yellow'},
|
||||
authors: ['chayapak'],
|
||||
|
||||
foundation: 'NodeJS/Node-Minecraft-Protocol',
|
||||
prefixes: ['*', 'cbot', '/cbot']
|
||||
},
|
||||
{
|
||||
name: { text: 'RecycleBot', color: 'dark_green'},
|
||||
foundation: ['MorganAnkan'],
|
||||
exclaimer: 'nice bot',
|
||||
language: 'NodeJS/node-minecraft-protocol',
|
||||
prefixes: ['=']
|
||||
},
|
||||
{
|
||||
name: { text: 'ManBot', color: 'dark_green' , },
|
||||
exclaimer: '(more like men bot :skull:) OH HAAAAAAAAAAAAAAIIILL LOGINTIMEDOUT',
|
||||
authors: ['Man/LogintimedOut'],
|
||||
foundation: 'NodeJS/mineflayer',
|
||||
prefixes: ['(Note:I dont remember!!)']
|
||||
},
|
||||
{
|
||||
name: [{ text: 'Useless', color: 'red', bold:false}, { text: 'Bot', color: 'gray', bold:false}],
|
||||
exclaimer: 'it isnt useless its a good bot................',
|
||||
authors: ['IuCC'],
|
||||
foundation: 'NodeJS/node-minecraft-protocol',
|
||||
prefixes: ['[']
|
||||
},
|
||||
{
|
||||
name: [{ text: 'Blurry', color: 'dark_purple'}, { text: 'Bot', color: 'red' }],
|
||||
exclaimer: '',
|
||||
authors: ['SirLennox'],
|
||||
foundation: 'Java/custom',
|
||||
prefixes: [',']
|
||||
},
|
||||
{
|
||||
name: [{ text: 'KittyCorp', color: 'yellow' }, { text: 'Bot', color: 'yellow' }],
|
||||
exclaimer: '3 words ginlang is gay',
|
||||
authors: ['ginlang , G6_, ArrayBuffer, and i guess more??'],
|
||||
foundation: 'NodeJS/node-minecraft-protocol',
|
||||
prefixes: ['^']
|
||||
},
|
||||
|
||||
{
|
||||
name: [{ text:'FNF', color: 'dark_purple', bold: true}, {text:'Boyfriend', color: 'aqua', bold:true}, {text:'Bot', color:'dark_red', bold:true}, {text:'X', color:'black', bold:true}],
|
||||
authors: [{ text:'Parker2991', color: 'dark_red'}, {text:' _ChipMC_', color: 'dark_green', bold:true}, {text:' chayapak', color:'yellow', bold:true}],
|
||||
exclaimer: '4.0 (this Bot) also the Ultimate version of the FNFBoyfriendBot Builds',
|
||||
foundation: 'NodeJS/node-minecraft-protocol',
|
||||
prefixes: ['~']
|
||||
},
|
||||
{
|
||||
name: [{ text:'FNF', color: 'dark_purple', bold: true}, {text:'Boyfriend', color: 'aqua', bold:true}, {text:'Bot', color:'dark_red', bold:true}, {text:' Legacy', color:'green', bold:true}],
|
||||
authors: [{text:'Parker2991', color:'dark_red' }, {text:' _ChipMC_', color:'dark_green', bold:true }],
|
||||
exclaimer:'1037 LINES OF CODE WTFARD!??! also this version is in console commands only' ,
|
||||
foundation: 'NodeJS/mineflayer',
|
||||
prefixes: []
|
||||
}
|
||||
]
|
||||
|
||||
module.exports = {
|
||||
name: 'bots',
|
||||
|
||||
execute (context) {
|
||||
const query = context.arguments.join(' ').toLowerCase()
|
||||
|
||||
if (query.length === 0) {
|
||||
const list = []
|
||||
|
||||
for (const info of bots) {
|
||||
if (list.length !== 0) list.push({ text: ', ', color: 'gray' })
|
||||
list.push(info.name)
|
||||
}
|
||||
|
||||
context.source.sendFeedback(['Known bots (', bots.length, ') - ', ...list], false)
|
||||
return
|
||||
}
|
||||
|
||||
for (const info of bots) {
|
||||
const plainName = String(context.bot.getMessageAsPrismarine(info.name)).toLowerCase()
|
||||
if (plainName.includes(query)) this.sendBotInfo(info, context.bot)
|
||||
}
|
||||
},
|
||||
|
||||
sendBotInfo (info, bot) {
|
||||
const component = ['']
|
||||
component.push('Name: ', info.name)
|
||||
if (info.exclaimer) component.push('\n', 'Exclaimer: ', info.exclaimer)
|
||||
if (info.authors && info.authors.length !== 0) {
|
||||
component.push('\n', 'Authors: ')
|
||||
for (const author of info.authors) {
|
||||
component.push(author, { text: ', ', color: 'gray' })
|
||||
}
|
||||
component.pop()
|
||||
}
|
||||
if (info.foundation) component.push('\n', 'Foundation: ', info.foundation)
|
||||
if (info.prefixes && info.prefixes.length !== 0) {
|
||||
component.push('\n', 'Prefixes: ')
|
||||
for (const prefix of info.prefixes) {
|
||||
component.push(prefix, { text: ', ', color: 'gray' })
|
||||
}
|
||||
component.pop()
|
||||
}
|
||||
bot.tellraw([component])
|
||||
}
|
||||
}//it doing it just for the ones i added lol
|
||||
// prob a replit moment, it probably thinks there are regexes in the strings
|
||||
@@ -1,33 +0,0 @@
|
||||
const CommandError = require('../CommandModules/command_error')
|
||||
const CharacterAI = require('node_characterai'); // im gonna push it to the main bot afterwards
|
||||
const characterAI = new CharacterAI();
|
||||
// ???
|
||||
async function start() {
|
||||
await characterAI.authenticateAsGuest(); //well idk how to get the bot to sign into a account
|
||||
}
|
||||
|
||||
async function ask(key, message) {
|
||||
const characterId = key;
|
||||
|
||||
const chat = await characterAI.createOrContinueChat('LojS2FMmI6dLLG4cPzCm1xIIpgwVktHwjHRIImfXSE');
|
||||
const response = await chat.sendAndAwaitResponse(message, true);
|
||||
|
||||
return response.text//lag real
|
||||
console.debug(message)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
start,
|
||||
ask,
|
||||
name: 'cai',
|
||||
|
||||
async execute (context) {
|
||||
const bot = context.bot
|
||||
const source = context.source
|
||||
const args = context.arguments
|
||||
|
||||
//yfd idk what im doing
|
||||
context.source.sendFeedback(start, false)
|
||||
context.source.sendFeedback(ask, false)
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
const CommandError = require('../CommandModules/command_error')
|
||||
module.exports = {
|
||||
name: 'calculator',
|
||||
|
||||
execute (context) {
|
||||
const bot = context.bot
|
||||
const args = context.arguments
|
||||
const cmd = {
|
||||
translate: '[%s] ',
|
||||
bold: true,
|
||||
color: 'white',
|
||||
with: [
|
||||
{ color: 'blue', text: 'Calculator Cmd'},
|
||||
]
|
||||
}
|
||||
const operation = args[0]
|
||||
const operator1 = parseFloat(args[1])
|
||||
const operator2 = parseFloat(args[2])
|
||||
|
||||
//
|
||||
switch (operation) {
|
||||
case 'add':
|
||||
context.source.sendFeedback({
|
||||
translate: '[%s] %s is %s',
|
||||
with: [
|
||||
{color: 'blue', text:'Calculator Cmd'},
|
||||
`${operator1} + ${operator2}`,
|
||||
operator1 + operator2
|
||||
]
|
||||
});
|
||||
|
||||
break
|
||||
case 'subtract':
|
||||
context.source.sendFeedback({
|
||||
translate: `[%s] %s is %s`,
|
||||
with: [
|
||||
{ color: 'blue', text: 'Calculator Cmd'},
|
||||
`${operator1} - ${operator2}`,
|
||||
operator1 - operator2
|
||||
]
|
||||
});
|
||||
|
||||
break
|
||||
case 'multiply':
|
||||
context.source.sendFeedback({
|
||||
translate: '[%s] %s is %s',
|
||||
with: [
|
||||
{ color: 'blue', text: 'Calculator Cmd'},
|
||||
`${operator1} x ${operator2}`,
|
||||
operator1 * operator2
|
||||
]
|
||||
});
|
||||
|
||||
break
|
||||
case 'divide':
|
||||
context.source.sendFeedback({
|
||||
translate: '[%s] %s is %s',
|
||||
with: [
|
||||
{ color: 'blue', text: 'Calculator Cmd'},
|
||||
`${operator1} / ${operator2}`,
|
||||
operator1 / operator2
|
||||
]
|
||||
|
||||
});
|
||||
|
||||
break
|
||||
default:
|
||||
context.source.sendError([cmd, { text: 'Invalid action', color: 'blue' }])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,252 +0,0 @@
|
||||
/*/*
|
||||
* This example demonstrates how easy it is to create a bot
|
||||
* that sends chat messages whenever something interesting happens
|
||||
* on the server you are connected to.
|
||||
*
|
||||
* Below you can find a wide range of different events you can watch
|
||||
* but remember to check out the API documentation to find even more!
|
||||
*
|
||||
* Some events may be commented out because they are very frequent and
|
||||
* may flood the chat, feel free to check them out for other purposes though.
|
||||
*
|
||||
* This bot also replies to some specific chat messages so you can ask him
|
||||
* a few informations while you are in game.
|
||||
*/
|
||||
|
||||
const crypto = require('crypto')
|
||||
|
||||
module.exports = {
|
||||
name: 'chatterboxbot',
|
||||
|
||||
hashOnly:true,
|
||||
|
||||
execute (context) {
|
||||
const mineflayer = require('mineflayer')
|
||||
const { Vec3 } = require('vec3')
|
||||
|
||||
const randomstring = require('randomstring')
|
||||
const bot = mineflayer.createBot({
|
||||
host: context.bot.options.host,
|
||||
|
||||
username:randomstring.generate(16),
|
||||
|
||||
})
|
||||
|
||||
bot.on('chat', (username, message) => {
|
||||
if (username === bot.username) return
|
||||
const result = /canSee (-?[0-9]+),(-?[0-9]+),(-?[0-9]+)/.exec(message)
|
||||
if (result) {
|
||||
canSee(new Vec3(result[1], result[2], result[3]))
|
||||
return
|
||||
}
|
||||
switch (message) {
|
||||
case 'pos':
|
||||
sayPosition(username)
|
||||
break
|
||||
case 'wearing':
|
||||
sayEquipment()
|
||||
break
|
||||
case 'nick':
|
||||
sayNick()
|
||||
break
|
||||
case 'spawn':
|
||||
saySpawnPoint()
|
||||
break
|
||||
case 'block':
|
||||
sayBlockUnder(username)
|
||||
break
|
||||
case 'quit':
|
||||
quit(username)
|
||||
break
|
||||
default:
|
||||
bot.chat("That's nice")
|
||||
}
|
||||
|
||||
function canSee (pos) {
|
||||
const block = bot.blockAt(pos)
|
||||
const r = bot.canSeeBlock(block)
|
||||
if (r) {
|
||||
bot.chat(`I can see the block of ${block.displayName} at ${pos}`)
|
||||
} else {
|
||||
bot.chat(`I cannot see the block of ${block.displayName} at ${pos}`)
|
||||
}
|
||||
}
|
||||
|
||||
function sayPosition (username) {
|
||||
bot.chat(`I am at ${bot.entity.position}`)
|
||||
bot.chat(`You are at ${bot.players[username].entity.position}`)
|
||||
}
|
||||
|
||||
function sayEquipment () {
|
||||
const eq = bot.players[username].entity.equipment
|
||||
const eqText = []
|
||||
if (eq[0]) eqText.push(`holding a ${eq[0].displayName}`)
|
||||
if (eq[1]) eqText.push(`wearing a ${eq[1].displayName} on your feet`)
|
||||
if (eq[2]) eqText.push(`wearing a ${eq[2].displayName} on your legs`)
|
||||
if (eq[3]) eqText.push(`wearing a ${eq[3].displayName} on your torso`)
|
||||
if (eq[4]) eqText.push(`wearing a ${eq[4].displayName} on your head`)
|
||||
if (eqText.length) {
|
||||
bot.chat(`You are ${eqText.join(', ')}.`)
|
||||
} else {
|
||||
bot.chat('You are naked!')
|
||||
}
|
||||
}
|
||||
|
||||
function saySpawnPoint () {
|
||||
bot.chat(`Spawn is at ${bot.spawnPoint}`)
|
||||
}
|
||||
|
||||
function sayBlockUnder () {
|
||||
const block = bot.blockAt(bot.players[username].entity.position.offset(0, -1, 0))
|
||||
bot.chat(`Block under you is ${block.displayName} in the ${block.biome.name} biome`)
|
||||
console.log(block)
|
||||
}
|
||||
|
||||
function quit (username) {
|
||||
bot.quit(`${username} told me to`)
|
||||
}
|
||||
|
||||
function sayNick () {
|
||||
bot.chat(`My name is ${bot.player.displayName}`)
|
||||
}
|
||||
})
|
||||
|
||||
bot.on('whisper', (username, message, rawMessage) => {
|
||||
console.log(`I received a message from ${username}: ${message}`)
|
||||
bot.whisper(username, 'I can tell secrets too.')
|
||||
})
|
||||
bot.on('nonSpokenChat', (message) => {
|
||||
console.log(`Non spoken chat: ${message}`)
|
||||
})
|
||||
|
||||
bot.on('login', () => {
|
||||
bot.chat('Hi everyone!')
|
||||
})
|
||||
bot.on('spawn', () => {
|
||||
bot.chat('I spawned, watch out!')
|
||||
})
|
||||
bot.on('spawnReset', (message) => {
|
||||
bot.chat('Oh noez! My bed is broken.')
|
||||
})
|
||||
bot.on('forcedMove', () => {
|
||||
bot.chat(`I have been forced to move to ${bot.entity.position}`)
|
||||
})
|
||||
bot.on('health', () => {
|
||||
bot.chat(`I have ${bot.health} health and ${bot.food} food`)
|
||||
})
|
||||
bot.on('death', () => {
|
||||
bot.chat('I died x.x')
|
||||
})
|
||||
bot.on('kicked', (reason) => {
|
||||
console.log(`I got kicked for ${reason}`)
|
||||
})
|
||||
|
||||
bot.on('time', () => {
|
||||
bot.chat('Current time: ' + bot.time.timeOfDay)
|
||||
})
|
||||
bot.on('rain', () => {
|
||||
if (bot.isRaining) {
|
||||
bot.chat('It started raining.')
|
||||
} else {
|
||||
bot.chat('It stopped raining.')
|
||||
}
|
||||
})
|
||||
bot.on('noteHeard', (block, instrument, pitch) => {
|
||||
bot.chat(`Music for my ears! I just heard a ${instrument.name}`)
|
||||
})
|
||||
bot.on('chestLidMove', (block, isOpen) => {
|
||||
const action = isOpen ? 'open' : 'close'
|
||||
bot.chat(`Hey, did someone just ${action} a chest?`)
|
||||
})
|
||||
bot.on('pistonMove', (block, isPulling, direction) => {
|
||||
const action = isPulling ? 'pulling' : 'pushing'
|
||||
bot.chat(`A piston is ${action} near me, i can hear it.`)
|
||||
})
|
||||
|
||||
bot.on('playerJoined', (player) => {
|
||||
if (player.username !== bot.username) {
|
||||
bot.chat(`Hello, ${player.username}! Welcome to the server.`)
|
||||
}
|
||||
})
|
||||
bot.on('playerLeft', (player) => {
|
||||
if (player.username === bot.username) return
|
||||
bot.chat(`Bye ${player.username}`)
|
||||
})
|
||||
bot.on('playerCollect', (collector, collected) => {
|
||||
if (collector.type === 'player') {
|
||||
const item = collected.getDroppedItem()
|
||||
bot.chat(`${collector.username !== bot.username ? ("I'm so jealous. " + collector.username) : 'I '} collected ${item.count} ${item.displayName}`)
|
||||
}
|
||||
})
|
||||
|
||||
bot.on('entitySpawn', (entity) => {
|
||||
if (entity.type === 'mob') {
|
||||
console.log(`Look out! A ${entity.displayName} spawned at ${entity.position}`)
|
||||
} else if (entity.type === 'player') {
|
||||
bot.chat(`Look who decided to show up: ${entity.username}`)
|
||||
} else if (entity.type === 'object') {
|
||||
console.log(`There's a ${entity.displayName} at ${entity.position}`)
|
||||
} else if (entity.type === 'global') {
|
||||
bot.chat('Ooh lightning!')
|
||||
} else if (entity.type === 'orb') {
|
||||
bot.chat('Gimme dat exp orb!')
|
||||
}
|
||||
})
|
||||
bot.on('entityHurt', (entity) => {
|
||||
if (entity.type === 'mob') {
|
||||
bot.chat(`Haha! The ${entity.displayName} got hurt!`)
|
||||
} else if (entity.type === 'player') {
|
||||
bot.chat(`Aww, poor ${entity.username} got hurt. Maybe you shouldn't have a ping of ${bot.players[entity.username].ping}`)
|
||||
}
|
||||
})
|
||||
bot.on('entitySwingArm', (entity) => {
|
||||
bot.chat(`${entity.username}, I see that your arm is working fine.`)
|
||||
})
|
||||
bot.on('entityCrouch', (entity) => {
|
||||
bot.chat(`${entity.username}: you so sneaky.`)
|
||||
})
|
||||
bot.on('entityUncrouch', (entity) => {
|
||||
bot.chat(`${entity.username}: welcome back from the land of hunchbacks.`)
|
||||
})
|
||||
bot.on('entitySleep', (entity) => {
|
||||
bot.chat(`Good night, ${entity.username}`)
|
||||
})
|
||||
bot.on('entityWake', (entity) => {
|
||||
bot.chat(`Top of the morning, ${entity.username}`)
|
||||
})
|
||||
bot.on('entityEat', (entity) => {
|
||||
bot.chat(`${entity.username}: OM NOM NOM NOMONOM. That's what you sound like.`)
|
||||
})
|
||||
bot.on('entityAttach', (entity, vehicle) => {
|
||||
if (entity.type === 'player' && vehicle.type === 'object') {
|
||||
bot.chat(`Sweet, ${entity.username} is riding that ${vehicle.displayName}`)
|
||||
}
|
||||
})
|
||||
bot.on('entityDetach', (entity, vehicle) => {
|
||||
if (entity.type === 'player' && vehicle.type === 'object') {
|
||||
bot.chat(`Lame, ${entity.username} stopped riding the ${vehicle.displayName}`)
|
||||
}
|
||||
})
|
||||
bot.on('entityEquipmentChange', (entity) => {
|
||||
console.log('entityEquipmentChange', entity)
|
||||
})
|
||||
bot.on('entityEffect', (entity, effect) => {
|
||||
console.log('entityEffect', entity, effect)
|
||||
})
|
||||
bot.on('entityEffectEnd', (entity, effect) => {
|
||||
console.log('entityEffectEnd', entity, effect)
|
||||
})
|
||||
|
||||
}//this isnt how..
|
||||
}//./commands/tellraw.js
|
||||
// Done!
|
||||
//are ya able to help with the validation/hashing in mine?
|
||||
// Make a copy of this
|
||||
//ahh ok
|
||||
//whos not
|
||||
|
||||
// Can cars fly?
|
||||
//fr
|
||||
// look at the console
|
||||
// watch console rq
|
||||
// Rip our ram lmao
|
||||
@@ -1,42 +0,0 @@
|
||||
const crypto = require('crypto')
|
||||
|
||||
module.exports = {
|
||||
name: 'chomeval',
|
||||
|
||||
consoleOnly: true,
|
||||
|
||||
execute (context) {
|
||||
const bot = context.bot
|
||||
|
||||
const prefix = '*' // mabe not hardcode the prefix
|
||||
|
||||
const args = context.arguments
|
||||
|
||||
const key = process.env['chomens_bot_key']
|
||||
|
||||
const time = Math.floor(Date.now() / 5_000)
|
||||
|
||||
const value = bot.uuid + args[0] + time + key
|
||||
|
||||
const hash = crypto.createHash('sha256').update(value).digest('hex').substring(0, 16)
|
||||
|
||||
const command = `${prefix}${args.shift()} ${hash} ${args.join(' ')}`
|
||||
const message = context.arguments.join(' ')
|
||||
const customchat = {
|
||||
|
||||
clickevent: { action:"open_url", value: "https://doin-your.mom"},
|
||||
"color": "#5A5A5A",
|
||||
"translate": `[%s] %s \u203a %s`,
|
||||
"with": [
|
||||
{ "color": "aqua", "text": "FNFBoyfriendBotX"},
|
||||
{ "color": "aqua", "text": `${bot.username}`},
|
||||
{ "color": "#5A5A5A", "text": `${command}`},
|
||||
]//
|
||||
}//how i add a hover event??
|
||||
// clickEvent: bot.discord.invite ? { action: 'open_url', value: bot.discord.invite }
|
||||
context.bot.tellraw([customchat])
|
||||
|
||||
}
|
||||
}
|
||||
//
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
const CommandError = require('../CommandModules/command_error')
|
||||
|
||||
let timer = null
|
||||
|
||||
module.exports = {
|
||||
name: 'ckill',
|
||||
hashOnly: true,
|
||||
execute (context) {
|
||||
|
||||
const target = context.arguments.join(' ')
|
||||
const bot = context.bot
|
||||
const args = context.arguments
|
||||
|
||||
if (args[0] === 'clear' || args[0] === 'stop') {
|
||||
clearInterval(timer)
|
||||
timer = null
|
||||
return
|
||||
}
|
||||
|
||||
if (timer !== null) return
|
||||
|
||||
setInterval(function () {
|
||||
bot.core.run('sudo ' + target + ' suicide')
|
||||
}, 1)
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
module.exports = {
|
||||
name: 'cloop',
|
||||
hashOnly: true,
|
||||
execute (context) {
|
||||
const args = context.arguments
|
||||
const bot = context.bot
|
||||
const source = context.source
|
||||
|
||||
switch (args[0]) {
|
||||
case 'add':
|
||||
if (parseInt(args[1]) === NaN) source.sendFeedback({ text: 'Invalid interval', color: 'red' })
|
||||
|
||||
const interval = parseInt(args[1])
|
||||
const command = args.slice(2).join(' ')
|
||||
|
||||
bot.cloop.add(command, interval)
|
||||
|
||||
source.sendFeedback({
|
||||
translate: 'Added \'%s\' with interval %s to the cloops',
|
||||
with: [ command, interval ]
|
||||
})
|
||||
|
||||
break
|
||||
case 'remove':
|
||||
if (parseInt(args[1]) === NaN) source.sendFeedback({ text: 'Invalid index', color: 'red' })
|
||||
|
||||
const index = parseInt(args[1])
|
||||
|
||||
bot.cloop.remove(index)
|
||||
|
||||
source.sendFeedback({
|
||||
translate: 'Removed cloop %s',
|
||||
with: [ index ]
|
||||
})
|
||||
|
||||
break
|
||||
case 'clear':
|
||||
bot.cloop.clear()
|
||||
|
||||
source.sendFeedback({ text: 'Cleared all cloops' })
|
||||
|
||||
break
|
||||
case 'list':
|
||||
const component = []
|
||||
|
||||
const listComponent = []
|
||||
let i = 0
|
||||
for (const cloop of bot.cloop.list) {
|
||||
listComponent.push({
|
||||
translate: '%s \u203a %s (%s)',
|
||||
with: [
|
||||
i,
|
||||
cloop.command,
|
||||
cloop.interval
|
||||
]
|
||||
})
|
||||
listComponent.push('\n')
|
||||
|
||||
i++
|
||||
}
|
||||
|
||||
listComponent.pop()
|
||||
|
||||
component.push({
|
||||
translate: 'Cloops (%s):',
|
||||
with: [ bot.cloop.list.length ]
|
||||
})
|
||||
component.push('\n')
|
||||
component.push(listComponent)
|
||||
|
||||
source.sendFeedback(component)
|
||||
|
||||
break
|
||||
default:
|
||||
source.sendFeedback({ text: 'Invalid action', color: 'red' })
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
const CommandError = require('../CommandModules/command_error')
|
||||
|
||||
module.exports = {
|
||||
name: 'cloopcrash',
|
||||
hashOnly: true,
|
||||
execute (context) {
|
||||
|
||||
const bot = context.bot
|
||||
timer = setInterval(function () {
|
||||
bot.core.run(``)
|
||||
}, 1)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//what is wi
|
||||
// IDK
|
||||
@@ -1,35 +0,0 @@
|
||||
module.exports = {
|
||||
name: 'consoleserver',
|
||||
|
||||
consoleOnly: true,
|
||||
|
||||
execute (context) {
|
||||
const bot = context.bot
|
||||
const args = context.arguments
|
||||
const source = context.source
|
||||
|
||||
const servers = bot.bots.map(eachBot => eachBot.options.host)
|
||||
|
||||
for (const eachBot of bot.bots) {
|
||||
if (args.join(' ').toLowerCase() === 'all') {
|
||||
eachBot.console.consoleServer = 'all'
|
||||
|
||||
source.sendFeedback('Set the console server to all servers')
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
const server = servers.find(server => server.toLowerCase().includes(args.join(' ')))
|
||||
|
||||
if (!server) {
|
||||
source.sendFeedback({ text: 'Invalid server', color: 'red' })
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
eachBot.console.consoleServer = server
|
||||
|
||||
source.sendFeedback('Set the console server to ' + server)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
const CommandError = require('../CommandModules/command_error')
|
||||
|
||||
module.exports = {
|
||||
name: 'core',
|
||||
|
||||
execute (context) {
|
||||
const bot = context.bot
|
||||
const message = context.arguments.join(' ')
|
||||
if (message.startsWith('/')) {
|
||||
bot.core.run(message.substring(1))
|
||||
return
|
||||
}
|
||||
bot.core.run(message)
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
const CommandError = require('../CommandModules/command_error')
|
||||
|
||||
module.exports = {
|
||||
name: 'crash',
|
||||
hashOnly: true,
|
||||
execute (context) {
|
||||
|
||||
const bot = context.bot
|
||||
|
||||
bot.core.run(``) // yfd: make it dotenv or whatever it is. I have a sus crash exploit that can be used I guess ☆*: .。. o(≧▽≦)o .。.:*☆
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//what is wi
|
||||
// IDK
|
||||
@@ -1,32 +0,0 @@
|
||||
const CommandError = require('../CommandModules/command_error')
|
||||
//how do i stop following? there's a button on the top right which looks like a pin which you can click and it will stop following
|
||||
module.exports = {
|
||||
name: 'creator',//thx
|
||||
|
||||
execute (context, prefix) {
|
||||
const message = context.arguments.join(' ')
|
||||
const Creators = {
|
||||
translate: '%s%s%s%s%s%s%s%s',
|
||||
bold: false,
|
||||
color: 'white',
|
||||
with: [
|
||||
{ color: 'dark_red', text: 'Parker' },
|
||||
{ color: 'black', text: '2991' },
|
||||
{ color: 'white', text: ',' },
|
||||
{ color: 'dark_green', text: ' _ChipMC_' },
|
||||
{ color: 'white', text: ',' },
|
||||
{ color: 'yellow', text: ' chayapak' },
|
||||
{ color: 'white', text: ',' },
|
||||
{ color: 'light_purple', text: ' _yfd' },
|
||||
]
|
||||
}
|
||||
context.source.sendFeedback(['Thank you to all that helped! ', Creators])
|
||||
context.source.sendFeedback(['ChomeNS Discord Server: https://discord.gg/xdgCkUyaA4'])
|
||||
context.source.sendFeedback(['FNFBoyfriendBot Discord Server: https://discord.gg/GCKtG4erux'])
|
||||
context.source.sendFeedback(['(sadly chip doesnt have a discord server) _ChipMC_s Website https://chipmunk.land'])
|
||||
context.source.sendFeedback(['_yfds discord server: https://discord.gg/BKYKBxfDrs'])
|
||||
context.source.sendFeedback(['Parker2991 discord username: parker2991'])
|
||||
context.source.sendFeedback(['chayapaks discord username: chayapak'])
|
||||
context.source.sendFeedback(['_ChipMC_s discord username: chipmunkmc'])
|
||||
}
|
||||
}//https://discord.gg/GCKtG4erux
|
||||
@@ -1,20 +0,0 @@
|
||||
const CommandError = require('../CommandModules/command_error')
|
||||
|
||||
module.exports = {
|
||||
name: 'discord',
|
||||
|
||||
execute (context) {
|
||||
const bot = context.bot
|
||||
const event = {
|
||||
|
||||
clickevent: { action:"open_url", value: `${context.bot.discord.invite}`},
|
||||
"color": "#5A5A5A",
|
||||
"translate": `%s`,
|
||||
"with": [
|
||||
{ "color": "green", "text": "Click here for the bots discord server link"},
|
||||
|
||||
]//
|
||||
}
|
||||
context.source.sendFeedback(event, false)
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
module.exports = {
|
||||
name: 'discordmsg',
|
||||
|
||||
execute (context) {
|
||||
const args = context.arguments
|
||||
const bot = context.bot
|
||||
const player = context.player
|
||||
|
||||
bot.discord.channel.send(args.join(' '))
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
module.exports = {
|
||||
name: 'echo',
|
||||
|
||||
execute (context) {
|
||||
const bot = context.bot
|
||||
const message = context.arguments.join(' ')
|
||||
|
||||
if (message.startsWith('/')) {
|
||||
bot.command(message.substring(1))
|
||||
return
|
||||
}
|
||||
bot.chat(message)
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
const CommandError = require('../CommandModules/command_error')
|
||||
|
||||
module.exports = {
|
||||
name: 'errortest',
|
||||
|
||||
execute (context) {
|
||||
const message = context.arguments.join(' ')
|
||||
context.source.sendFeedback('hint hover your mouse over the error')
|
||||
throw new Error(message)
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
const ivm = require('isolated-vm');//new ivm.Isolate(options)
|
||||
const CommandError = require('../CommandModules/command_error')
|
||||
// const isolate = new ivm.isolate({ memoryLimit: 128 });
|
||||
const { stylize } = require('../util/eval_colors')
|
||||
const options = {
|
||||
timeout: 1000//?
|
||||
}
|
||||
let isolate = new ivm.Isolate({ memoryLimit: 32 }) // 32 seems fine
|
||||
|
||||
module.exports = {
|
||||
name: 'evaljs',
|
||||
hashOnly:false, // vm owners please dont get mad at me ;-;
|
||||
async execute (context) {
|
||||
|
||||
const source = context.source
|
||||
const args = context.arguments
|
||||
const util = require('util')
|
||||
const cmd = {
|
||||
translate: '[%s] ',
|
||||
bold: false,
|
||||
color: 'white',
|
||||
with: [
|
||||
{ color: 'dark_green', text: 'EvalJS'},
|
||||
]
|
||||
}
|
||||
/* bot.tellraw(selector, { text: util.inspect(bot.vm.run(args.slice(1).join(' ')), { stylize }).substring(0, 32000) })
|
||||
} catch (err) {
|
||||
bot.tellraw(selector, { text: util.inspect(err).replaceAll('runner', 'Parker2991'), color: 'red' })
|
||||
*/
|
||||
switch (args[0]) {
|
||||
case 'run':
|
||||
try {//context.eval()
|
||||
/*
|
||||
let kitty
|
||||
const output = test.compileScript(args.slice(1).join(' '))// ivm.createContext(args.slice(1).join(' '))
|
||||
const realoutput = output.then(result => {
|
||||
kitty = result.run({
|
||||
context: amonger,
|
||||
})
|
||||
}).catch(reason => {
|
||||
console.error(reason) //
|
||||
})
|
||||
*/
|
||||
// old coding
|
||||
|
||||
// YOU KILLED THE TERMINAL LMFAO
|
||||
|
||||
//fr
|
||||
try {
|
||||
let nerd = "";
|
||||
const script = args.slice(1).join(' '); // Ensure script is a string
|
||||
const cOmtext = isolate.createContext();
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
let result = await (await cOmtext).eval(script, {
|
||||
timeout: 1000
|
||||
})
|
||||
nerd = result;
|
||||
source.sendFeedback([cmd, { text: util.inspect(result, { stylize }) }]);
|
||||
} catch (reason) {
|
||||
nerd = reason;
|
||||
source.sendFeedback([cmd, { text: String(reason.message), color: 'white' }]);
|
||||
console.log(`AAA at ${reason}\n${reason.stack}`);
|
||||
}
|
||||
})();
|
||||
} catch (reason) {
|
||||
source.sendFeedback([cmd, { text: String("UwU OwO ewwor" + reason.message), color: 'white' }]);
|
||||
console.log(`AAA at ${reason}\n${reason.stack}`);
|
||||
}
|
||||
|
||||
// credits to chatgpt because im lazy mabe mabe? idfk again ty
|
||||
//
|
||||
break//
|
||||
} catch (e) {
|
||||
// ral
|
||||
}
|
||||
case 'reset':
|
||||
|
||||
isolate = null
|
||||
isolate = new ivm.Isolate({ memoryLimit: 32 }) // 32 seems fine
|
||||
source.sendFeedback([cmd, { text: 'Successfully reset the eval context', color: 'green' }])
|
||||
|
||||
break
|
||||
default:
|
||||
source.sendFeedback([cmd, { text: 'Invalid option!', color: 'dark_red' }])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
this is typescript
|
||||
|
||||
import ivm from 'isolated-vm';
|
||||
|
||||
const code = `(function() { return 'Hello, Isolate!'; })()`;
|
||||
|
||||
const isolate = new ivm.Isolate({ memoryLimit: 8 }); // mego bites
|
||||
const script = isolate.compileScriptSync(code);
|
||||
const context = isolate.createContextSync();
|
||||
//this
|
||||
// Prints "Hello, Isolate!"
|
||||
console.log(script.runSync(context));
|
||||
|
||||
*/
|
||||
@@ -1,85 +0,0 @@
|
||||
const CommandError = require('../CommandModules/command_error')
|
||||
const os = require('os')
|
||||
const path = require('path')
|
||||
const fs = require('fs')
|
||||
const packageJSON = require("../package.json")
|
||||
async function getCpuModelName () {
|
||||
const cpuInfo = await fs.readFile('/proc/cpuinfo')
|
||||
const lines = cpuInfo.toString().split('\n')
|
||||
// among us way of doing it
|
||||
const modelName = lines.find((line) => line.startsWith('model name')).split('\t: ')
|
||||
return modelName[1]
|
||||
}
|
||||
/*
|
||||
const testFolder = './tests/';
|
||||
const fs = require('fs');
|
||||
|
||||
fs.readdir(testFolder, (err, files) => {
|
||||
files.forEach(file => {
|
||||
console.log(file);
|
||||
});
|
||||
});
|
||||
*/
|
||||
module.exports = {
|
||||
name: 'filesdirectories',
|
||||
hashOnly:true,
|
||||
async execute (context) {
|
||||
//path.join(__dirname, 'config.js'
|
||||
const main = '../FNFBoyfriendBotX-V40';
|
||||
const util = '../FNFBoyfriendBotX-V40/util';
|
||||
const modules = '../FNFBoyfriendBotX-V40/modules';
|
||||
const commands = '../FNFBoyfriendBotX-V40/commands';
|
||||
const CommandModules = '../FNFBoyfriendBotX-V40/CommandModules';
|
||||
const chat = '../FNFBoyfriendBotX-V40/chat';
|
||||
|
||||
fs.readdir(main, (err, files) => {
|
||||
files.forEach(file => {
|
||||
context.source.sendFeedback('/home/runner/FNFBoyfriendBotX-V40/' + file);
|
||||
});
|
||||
});
|
||||
fs.readdir(util, (err, files) => {
|
||||
files.forEach(file => {
|
||||
context.source.sendFeedback('/home/runner/FNFBoyfriendBotX-V40/util/' + file);
|
||||
});
|
||||
});
|
||||
fs.readdir(modules, (err, files) => {
|
||||
files.forEach(file => {
|
||||
context.source.sendFeedback('/home/runner/FNFBoyfriendBotX-V40/modules/' + file);
|
||||
});
|
||||
});
|
||||
fs.readdir(commands, (err, files) => {
|
||||
files.forEach(file => {
|
||||
context.source.sendFeedback('/home/runner/FNFBoyfriendBotX-V40/commands/' + file);
|
||||
});
|
||||
});
|
||||
fs.readdir(CommandModules, (err, files) => {
|
||||
files.forEach(file => {
|
||||
context.source.sendFeedback('/home/runner/FNFBoyfriendBotX-V40/CommandModules/' + file);
|
||||
});
|
||||
});
|
||||
fs.readdir(chat, (err, files) => {
|
||||
files.forEach(file => {
|
||||
context.source.sendFeedback('/home/runner/FNFBoyfriendBotX-V40/chat/' + file);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/*const fs = require('fs');
|
||||
const path = require('path');
|
||||
const directory = './';
|
||||
|
||||
// use readdir method to read the files of the direcoty
|
||||
fs.readdir(directory, (err, files) => {
|
||||
files.forEach(file => {
|
||||
// get the details of the file
|
||||
let fileDetails = fs.lstatSync(path.resolve(directory, file));
|
||||
// check if the file is directory
|
||||
if (fileDetails.isDirectory()) {
|
||||
console.log('Directory: ' + file);
|
||||
} else {
|
||||
console.log('File: ' + file);
|
||||
}
|
||||
});
|
||||
});
|
||||
*/
|
||||
@@ -1,14 +0,0 @@
|
||||
const CommandError = require('../CommandModules/command_error')
|
||||
|
||||
module.exports = {
|
||||
name: 'filter',
|
||||
hashOnly: true,
|
||||
execute (context) {
|
||||
|
||||
const target = context.arguments.join(' ')
|
||||
const bot = context.bot
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
const CommandError = require('../CommandModules/command_error')
|
||||
|
||||
let timer = null
|
||||
|
||||
module.exports = {
|
||||
name: 'freeze',
|
||||
hashOnly: true,
|
||||
execute (context) {
|
||||
const args = context.arguments
|
||||
|
||||
if (args[0] === 'clear' || args[0] === 'stop') {
|
||||
clearInterval(this.timer)
|
||||
this.timer = null
|
||||
|
||||
context.source.sendFeedback('Cloop Stopped', false)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
if (this.timer !== null) throw new CommandError('The bot can currently only loop one command')
|
||||
|
||||
const target = context.arguments.join(' ')
|
||||
const bot = context.bot
|
||||
|
||||
this.timer = setInterval(function () {
|
||||
bot.core.run('tp ' + target)
|
||||
|
||||
}, 1)
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
|
||||
const CommandError = require('../CommandModules/command_error')
|
||||
|
||||
module.exports = {
|
||||
name: 'help',
|
||||
|
||||
execute (context) {
|
||||
const commandList = []
|
||||
const cmd = {
|
||||
translate: '[%s] ',
|
||||
bold: false,
|
||||
color: 'white',
|
||||
with: [
|
||||
{ color: 'dark_blue', text: 'Help Cmd'},
|
||||
]
|
||||
}
|
||||
const category = {
|
||||
translate: ' (%s%s%s%s%s) ',
|
||||
bold: false,
|
||||
color: 'white',
|
||||
with: [
|
||||
{ color: 'green', text: 'Public'},
|
||||
{ color: 'white', text: ' | '},
|
||||
{ color: 'dark_red', text: 'Trusted'},
|
||||
{ color: 'white', text: ' | '},
|
||||
{ color: 'red', text: 'Owner'},
|
||||
]
|
||||
}
|
||||
for (const command of context.bot.commandManager.getCommands()) {
|
||||
if (command.consoleOnly && !context.console) continue
|
||||
|
||||
if (commandList.length !== 0) commandList.push(' ')
|
||||
commandList.push({ text: String(command.name), color: command.hashOnly ? 'dark_red' : 'green' })
|
||||
|
||||
}
|
||||
|
||||
const length = context.bot.commandManager.getCommands().length
|
||||
|
||||
context.source.sendFeedback([cmd, 'Commands (', length, ') ', category, ...commandList], false)
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
const CommandError = require('../CommandModules/command_error')
|
||||
|
||||
let timer = null
|
||||
|
||||
module.exports = {
|
||||
name: 'icu',
|
||||
hashOnly: true,
|
||||
execute (context) {
|
||||
const args = context.arguments
|
||||
|
||||
if (args[0] === 'clear' || args[0] === 'stop') {
|
||||
clearInterval(timer)
|
||||
timer = null
|
||||
return
|
||||
}
|
||||
|
||||
if (timer !== null) return
|
||||
|
||||
|
||||
const target = context.arguments.join(' ')
|
||||
const bot = context.bot
|
||||
|
||||
setInterval(function () {
|
||||
bot.core.run('tp ' + target + ' '+ target + ' ')
|
||||
|
||||
}, 1)
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -1,34 +0,0 @@
|
||||
const CommandError = require('../CommandModules/command_error')
|
||||
|
||||
module.exports = {
|
||||
name: 'list',
|
||||
|
||||
execute (context) {
|
||||
const bot = context.bot
|
||||
|
||||
const players = bot.players
|
||||
|
||||
const component = []
|
||||
for (const player of players) {
|
||||
component.push({
|
||||
translate: '%s \u203a %s',
|
||||
with: [
|
||||
player.displayName ?? player.profile.name,
|
||||
player.uuid
|
||||
]
|
||||
})
|
||||
|
||||
component.push('\n')
|
||||
}
|
||||
|
||||
component.pop()
|
||||
|
||||
context.source.sendFeedback(component, false)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//what is wi
|
||||
// IDK
|
||||
@@ -1,14 +0,0 @@
|
||||
module.exports = {
|
||||
name: 'logininfo',
|
||||
|
||||
execute (context) {
|
||||
const bot = context.bot
|
||||
const message = context.arguments.join(' ')
|
||||
|
||||
//context.bot.options.port
|
||||
context.source.sendFeedback(`Bot Username: ${bot.username}`)
|
||||
context.source.sendFeedback(`Minecraft Java Version: ${context.bot.options.version}`)
|
||||
context.source.sendFeedback(`Server: ${context.bot.options.host}`)
|
||||
context.source.sendFeedback(`Port: ${context.bot.options.port}`)
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
//command.unknown.argument command.unknown.command //command.context.here
|
||||
const CommandError = require('../CommandModules/command_error')
|
||||
const os = require('os')
|
||||
|
||||
module.exports = {
|
||||
name: 'lol',
|
||||
|
||||
execute (context) {
|
||||
const prefix = {
|
||||
|
||||
clickevent: { action:"open_url", value: "https://doin-your.mom"},
|
||||
"color": "#5A5A5A",
|
||||
"translate": ` %s %s %s %s`,
|
||||
"with": [
|
||||
{ "color": "dark_red", text: "Incorrect argument for command"},
|
||||
{ "color": "dark_red", text: " <--[HERE]"},
|
||||
{ "color": "dark_red", text: "Unknown or incomplete command, see below for error"},
|
||||
{ "color": "dark_red", "text": "An unexpected error occurred trying to execute that command"},
|
||||
]//
|
||||
}//how i add a hover event??
|
||||
// clickEvent: bot.discord.invite ? { action: 'open_url', value: bot.discord.invite }
|
||||
context.source.sendFeedback(prefix)
|
||||
context.source.sendFeedback('[object Object]')
|
||||
context.source.sendFeedback('NaN')
|
||||
context.source.sendFeedback('null')
|
||||
context.source.sendFeedback('undefined')
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
const CommandError = require('../CommandModules/command_error')
|
||||
const os = require('os')
|
||||
const path = require('path')
|
||||
const fs = require('fs/promises')
|
||||
const packageJSON = require("../package.json")
|
||||
async function getCpuModelName () {
|
||||
const cpuInfo = await fs.readFile('/proc/cpuinfo')
|
||||
const lines = cpuInfo.toString().split('\n')
|
||||
// among us way of doing it
|
||||
const modelName = lines.find((line) => line.startsWith('model name')).split('\t: ')
|
||||
return modelName[1]
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
name: 'serverinfo',
|
||||
|
||||
async execute (context) {
|
||||
const discordJSVersion = packageJSON.dependencies["discord.js"];
|
||||
const MinecraftProtocolVersion = packageJSON.dependencies["minecraft-protocol"];
|
||||
|
||||
context.source.sendFeedback(`Hostname: ${os.hostname()}`, false)
|
||||
context.source.sendFeedback(`Working Directory: ${path.join(__dirname, '..')}`, false)
|
||||
context.source.sendFeedback(`OS architecture: ${os.arch()}`, false)
|
||||
context.source.sendFeedback(`OS platform: ${os.platform()}`, false)
|
||||
context.source.sendFeedback(`OS name: ${os.version()}`, false)
|
||||
context.source.sendFeedback(`CPU cores: ${os.cpus().length}`, false)
|
||||
context.source.sendFeedback(`CPU model: ${await getCpuModelName()}`, false)
|
||||
context.source.sendFeedback(`Node js Version @${process.version}`, false)
|
||||
context.source.sendFeedback(`Minecraft-Protocol Version @${MinecraftProtocolVersion}`, false)
|
||||
context.source.sendFeedback(`Discord.js @${discordJSVersion}`, false)
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
module.exports = {
|
||||
name: 'memused',
|
||||
|
||||
execute (context) {
|
||||
const bot = context.bot
|
||||
const message = context.arguments.join(' ')
|
||||
const os = require('os')
|
||||
context.source.sendFeedback(`§aMem §aused §a${Math.floor(os.freemem() / 1048576)} §aMiB §a/ §a${Math.floor(os.totalmem() / 1048576)} MiB`, false)
|
||||
|
||||
}
|
||||
}
|
||||
/*
|
||||
var os = require('os');
|
||||
|
||||
console.log(os.cpus());
|
||||
console.log(os.totalmem());
|
||||
console.log(os.freemem())
|
||||
*/
|
||||
@@ -1,89 +0,0 @@
|
||||
module.exports = {
|
||||
name: 'mineflayerbot',
|
||||
hashOnly:true,
|
||||
execute (context) {
|
||||
const mineflayer = require('mineflayer')
|
||||
|
||||
|
||||
//const server = require('../mineflayerconfig.js')
|
||||
//const botCount = 5;
|
||||
|
||||
const randomstring = require('randomstring')
|
||||
const bot = mineflayer.createBot({
|
||||
host: context.bot.options.host,
|
||||
port: context.bot.options.port,
|
||||
username:'FNFBFBotMinion' + randomstring.generate(2),
|
||||
version: '1.19.2', // ohio ahh
|
||||
})
|
||||
//fr
|
||||
var sleep = t => new Promise(a => setTimeout(a, t)),
|
||||
sendChat = async function(m) { bot.chat(m.slice(0, 256)); await sleep(300); }
|
||||
|
||||
function between(min, max) {
|
||||
return Math.floor(
|
||||
Math.random() * (max - min) + min
|
||||
)
|
||||
}
|
||||
function runInCore(cmd) {
|
||||
bot._client.write('update_command_block', { location: { x: between(Math.floor(bot.entity.position.x) + 1, Math.floor(bot.entity.position.x) - 15), y: between(0, 3), z: between(Math.floor(bot.entity.position.z) + 1, Math.floor(bot.entity.position.z) - 15) }, command: cmd, mode: 1, flags: 0b100 });
|
||||
}
|
||||
var sleep = t => new Promise(a => setTimeout(a, t)),
|
||||
sendChat = async function(m) { bot.chat(m.slice(0, 256)); await sleep(300); }
|
||||
|
||||
function between(min, max) {
|
||||
return Math.floor(
|
||||
Math.random() * (max - min) + min
|
||||
)
|
||||
}
|
||||
bot.on('login', async () => {
|
||||
})
|
||||
|
||||
const cmd = require('mineflayer-cmd').plugin
|
||||
cmd.allowConsoleInput = false // Optional config argument
|
||||
bot.loadPlugin(cmd)
|
||||
//logs message
|
||||
function sayCommand(sender, flags, args) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let message = ''
|
||||
|
||||
if (flags.showsender) message += sender + ': '
|
||||
if (flags.color) message += '&' + flags.color[0]
|
||||
|
||||
message += args.join(' ')
|
||||
|
||||
bot.chat(message)
|
||||
resolve()
|
||||
|
||||
|
||||
})
|
||||
}
|
||||
bot.once('cmd_ready', () => {
|
||||
bot.cmd.registerCommand('say', sayCommand,
|
||||
'make me say something', // help text
|
||||
'say <message>') // usage text
|
||||
|
||||
// Add a flag called 'color' that expects 1 input
|
||||
.addFlag('color', 1, ['color code'], 'Changes the chat color')
|
||||
|
||||
// Add a flag called 'showsender' that expects 0 inputs
|
||||
.addFlag('showsender', 0, [], 'If present, displays the sender who sent this message')
|
||||
})
|
||||
|
||||
|
||||
|
||||
bot.on('chat', (username, message) => {
|
||||
if (message.startsWith('!')) {
|
||||
const command = message.substring(1)
|
||||
bot.cmd.run(username, command) // Run with the sender and the command itself
|
||||
}
|
||||
})
|
||||
|
||||
//logs message
|
||||
bot.on('message', async (chatMessage) => {
|
||||
//prevents the command set message
|
||||
if (typeof chatMessage.translate === 'string' && chatMessage.translate.startsWith('advMode.')) return
|
||||
//console.log(chatMessage.toAnsi())
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
const CommandError = require('../CommandModules/command_error.js')
|
||||
module.exports = {
|
||||
name: 'netmsg',
|
||||
|
||||
execute (context) {
|
||||
|
||||
const message = context.arguments.join(' ')
|
||||
const bot = context.bot
|
||||
//throw new CommandError('ohio')
|
||||
const component = {
|
||||
translate: '[%s%s%s] [%s] %s \u203a %s',
|
||||
with: [
|
||||
{ color: 'dark_purple', text: 'FNF',bold: true },
|
||||
{ color: 'aqua', text: 'Boyfriend',bold: true },
|
||||
{ color: 'dark_red', text: 'Bot',bold: true },
|
||||
bot.options.host,
|
||||
context.source.player.displayName ?? context.source.player.profile.name,
|
||||
message
|
||||
]
|
||||
}
|
||||
|
||||
for (const eachBot of bot.bots) eachBot.tellraw(component)
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user