mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-14 10:44:55 -05:00
add date to console + big config change
This commit is contained in:
parent
e6773a9f62
commit
0f4aa08108
7 changed files with 138 additions and 44 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
||||||
/launcher_accounts.json
|
/launcher_accounts.json
|
||||||
/node_modules
|
/node_modules
|
||||||
/package-lock.json
|
/package-lock.json
|
||||||
|
/config.js
|
16
bot.js
16
bot.js
|
@ -17,15 +17,13 @@ const randomstring = require('randomstring')
|
||||||
async function createBot (server, config, getBots, setNewBot, dcclient, rl) {
|
async function createBot (server, config, getBots, setNewBot, dcclient, rl) {
|
||||||
const bot = new EventEmitter()
|
const bot = new EventEmitter()
|
||||||
bot.options = {
|
bot.options = {
|
||||||
username: !server.kaboom
|
username: server.username ?? randomstring.generate(8),
|
||||||
? 'ChomeNS_Bot'
|
host: server.host ?? 'localhost',
|
||||||
: randomstring.generate(8),
|
port: server.port ?? 25565,
|
||||||
host: server.host,
|
|
||||||
port: server.port,
|
|
||||||
version: config.version,
|
version: config.version,
|
||||||
kaboom: server.kaboom,
|
kaboom: server.kaboom ?? false,
|
||||||
logging: server.logging,
|
logging: server.logging ?? true,
|
||||||
useChat: server.useChat,
|
useChat: server.useChat ?? false,
|
||||||
checkTimeoutInterval: config.timeoutInterval,
|
checkTimeoutInterval: config.timeoutInterval,
|
||||||
hideErrors: true
|
hideErrors: true
|
||||||
}
|
}
|
||||||
|
@ -56,7 +54,7 @@ async function createBot (server, config, getBots, setNewBot, dcclient, rl) {
|
||||||
|
|
||||||
setNewBot(bot.server.host, bot)
|
setNewBot(bot.server.host, bot)
|
||||||
|
|
||||||
const channel = dcclient.channels.cache.get(config.discord.servers[bot.server.host])
|
const channel = dcclient.channels.cache.get(config.discord.servers[`${bot.server.host}:${bot.server.port}`])
|
||||||
|
|
||||||
channel.send(
|
channel.send(
|
||||||
`Connecting to: \`${bot.server.host}:${bot.server.port}\``
|
`Connecting to: \`${bot.server.host}:${bot.server.port}\``
|
||||||
|
|
25
config.js
25
config.js
|
@ -54,23 +54,20 @@ module.exports = {
|
||||||
timeoutInterval: 1000 * 40,
|
timeoutInterval: 1000 * 40,
|
||||||
self_care_check_interval: 2000,
|
self_care_check_interval: 2000,
|
||||||
discord: {
|
discord: {
|
||||||
|
prefix: '!',
|
||||||
token: 'OTcxNjUwNDU2NzA5Mzk4NTY5.G3lKC2._XQNTTU1Jqmaam_A0JKSe93GP1vFZvDpiXqZzA',
|
token: 'OTcxNjUwNDU2NzA5Mzk4NTY5.G3lKC2._XQNTTU1Jqmaam_A0JKSe93GP1vFZvDpiXqZzA',
|
||||||
servers: {
|
servers: {
|
||||||
'sus.shhnowisnottheti.me': '990140129245020221',
|
'play.kaboom.pw:25565': '1000355361196355674',
|
||||||
'play.kaboom.pw': '1000355361196355674',
|
'sus.shhnowisnottheti.me:25565': '990140129245020221',
|
||||||
'129.159.58.114': '998945155316973650',
|
'kitsune.icu:61530': '1004006678460637315',
|
||||||
'192.168.1.103': '1002806756885413978',
|
'play.chipmunk.land:25565': '1042590315464364032',
|
||||||
'kitsune.icu': '1004006678460637315',
|
'mcslot.eu:25565': '1057090538404323338',
|
||||||
'fallback.kitsune.icu': '1050764247518412850',
|
'chayapak.chipmunk.land:25565': '1010734897796763758'
|
||||||
'chayapak.chipmunk.land': '1010734897796763758',
|
|
||||||
'play.chipmunk.land': '1042590315464364032',
|
|
||||||
'mcslot.eu': '1057090538404323338'
|
|
||||||
},
|
},
|
||||||
embedsColors: {
|
embedsColors: {
|
||||||
normal: '#FFFF00',
|
normal: '#FFFF00',
|
||||||
error: '#FF0000'
|
error: '#FF0000'
|
||||||
},
|
}
|
||||||
prefix: '!'
|
|
||||||
},
|
},
|
||||||
servers: [
|
servers: [
|
||||||
// logging means log to console
|
// logging means log to console
|
||||||
|
@ -90,7 +87,7 @@ module.exports = {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
host: 'kitsune.icu',
|
host: 'kitsune.icu',
|
||||||
port: 25565,
|
port: 61530,
|
||||||
kaboom: true,
|
kaboom: true,
|
||||||
logging: false,
|
logging: false,
|
||||||
useChat: false
|
useChat: false
|
||||||
|
@ -103,14 +100,14 @@ module.exports = {
|
||||||
useChat: false
|
useChat: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
host: 'mcslot.eu',
|
host: 'chayapak.chipmunk.land',
|
||||||
port: 25565,
|
port: 25565,
|
||||||
kaboom: true,
|
kaboom: true,
|
||||||
logging: true,
|
logging: true,
|
||||||
useChat: false
|
useChat: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
host: 'chayapak.chipmunk.land',
|
host: 'mcslot.eu',
|
||||||
port: 25565,
|
port: 25565,
|
||||||
kaboom: true,
|
kaboom: true,
|
||||||
logging: true,
|
logging: true,
|
||||||
|
|
78
default.js
Normal file
78
default.js
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
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!',
|
||||||
|
token: 'token here',
|
||||||
|
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
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
42
index.js
42
index.js
|
@ -1,16 +1,23 @@
|
||||||
const readline = require('node:readline')
|
const fs = require('fs/promises')
|
||||||
const { stdin: input, stdout: output } = require('node:process')
|
const fileExist = require('./util/file-exists')
|
||||||
const rl = readline.createInterface({ input, output })
|
const path = require('path')
|
||||||
const config = require('./config')
|
|
||||||
const { createBot } = require('./bot')
|
const { createBot } = require('./bot')
|
||||||
const { Client, GatewayIntentBits } = require('discord.js')
|
|
||||||
const { MessageContent, GuildMessages, Guilds } = GatewayIntentBits
|
|
||||||
|
|
||||||
const dcclient = new Client({ intents: [Guilds, GuildMessages, MessageContent] })
|
let config
|
||||||
|
|
||||||
let bots = []
|
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
|
||||||
|
|
||||||
dcclient.on('ready', () => {
|
const dcclient = new Client({ intents: [Guilds, GuildMessages, MessageContent] })
|
||||||
|
|
||||||
|
let bots = []
|
||||||
|
|
||||||
|
dcclient.on('ready', () => {
|
||||||
for (const server of config.servers) {
|
for (const server of config.servers) {
|
||||||
const getBots = () => bots
|
const getBots = () => bots
|
||||||
const setNewBot = (server, bot) => {
|
const setNewBot = (server, bot) => {
|
||||||
|
@ -19,9 +26,22 @@ dcclient.on('ready', () => {
|
||||||
}
|
}
|
||||||
createBot(server, config, getBots, setNewBot, dcclient, rl)
|
createBot(server, config, getBots, setNewBot, dcclient, rl)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
dcclient.login(config.discord.token)
|
dcclient.login(config.discord.token)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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) => {
|
process.on('uncaughtException', (e) => {
|
||||||
console.log('uncaught ' + e.stack)
|
console.log('uncaught ' + e.stack)
|
||||||
|
|
|
@ -11,7 +11,7 @@ function inject (bot, _dcclient, config, rl) {
|
||||||
const chatMessage = require('prismarine-chat')(bot.version)
|
const chatMessage = require('prismarine-chat')(bot.version)
|
||||||
|
|
||||||
function prefix (prefix, _message) {
|
function prefix (prefix, _message) {
|
||||||
const message = `[${moment().format('HH:mm:ss')} ${prefix}§r] [${bot.server.host}] `
|
const message = `[${moment().format('DD/MM/YY HH:mm:ss')} ${prefix}§r] [${bot.server.host}] `
|
||||||
const component = chatMessage.MessageBuilder.fromString(message).toJSON()
|
const component = chatMessage.MessageBuilder.fromString(message).toJSON()
|
||||||
return chatMessage.fromNotch(component).toAnsi() + _message
|
return chatMessage.fromNotch(component).toAnsi() + _message
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
const { escapeMarkdown } = require('../util/escapeMarkdown')
|
const { escapeMarkdown } = require('../util/escapeMarkdown')
|
||||||
async function inject (bot, dcclient, config) {
|
async function inject (bot, dcclient, config) {
|
||||||
const chatMessage = require('prismarine-chat')(bot.version)
|
const chatMessage = require('prismarine-chat')(bot.version)
|
||||||
const channel = dcclient.channels.cache.get(config.discord.servers[bot.server.host])
|
const channel = dcclient.channels.cache.get(config.discord.servers[`${bot.server.host}:${bot.server.port}`])
|
||||||
|
|
||||||
let queue = ''
|
let queue = ''
|
||||||
const queueInterval = setInterval(() => {
|
const queueInterval = setInterval(() => {
|
||||||
|
|
Loading…
Reference in a new issue