mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-13 18:34:54 -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
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
|||
/launcher_accounts.json
|
||||
/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) {
|
||||
const bot = new EventEmitter()
|
||||
bot.options = {
|
||||
username: !server.kaboom
|
||||
? 'ChomeNS_Bot'
|
||||
: randomstring.generate(8),
|
||||
host: server.host,
|
||||
port: server.port,
|
||||
username: server.username ?? randomstring.generate(8),
|
||||
host: server.host ?? 'localhost',
|
||||
port: server.port ?? 25565,
|
||||
version: config.version,
|
||||
kaboom: server.kaboom,
|
||||
logging: server.logging,
|
||||
useChat: server.useChat,
|
||||
kaboom: server.kaboom ?? false,
|
||||
logging: server.logging ?? true,
|
||||
useChat: server.useChat ?? false,
|
||||
checkTimeoutInterval: config.timeoutInterval,
|
||||
hideErrors: true
|
||||
}
|
||||
|
@ -56,7 +54,7 @@ async function createBot (server, config, getBots, setNewBot, dcclient, rl) {
|
|||
|
||||
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(
|
||||
`Connecting to: \`${bot.server.host}:${bot.server.port}\``
|
||||
|
|
25
config.js
25
config.js
|
@ -54,23 +54,20 @@ module.exports = {
|
|||
timeoutInterval: 1000 * 40,
|
||||
self_care_check_interval: 2000,
|
||||
discord: {
|
||||
prefix: '!',
|
||||
token: 'OTcxNjUwNDU2NzA5Mzk4NTY5.G3lKC2._XQNTTU1Jqmaam_A0JKSe93GP1vFZvDpiXqZzA',
|
||||
servers: {
|
||||
'sus.shhnowisnottheti.me': '990140129245020221',
|
||||
'play.kaboom.pw': '1000355361196355674',
|
||||
'129.159.58.114': '998945155316973650',
|
||||
'192.168.1.103': '1002806756885413978',
|
||||
'kitsune.icu': '1004006678460637315',
|
||||
'fallback.kitsune.icu': '1050764247518412850',
|
||||
'chayapak.chipmunk.land': '1010734897796763758',
|
||||
'play.chipmunk.land': '1042590315464364032',
|
||||
'mcslot.eu': '1057090538404323338'
|
||||
'play.kaboom.pw:25565': '1000355361196355674',
|
||||
'sus.shhnowisnottheti.me:25565': '990140129245020221',
|
||||
'kitsune.icu:61530': '1004006678460637315',
|
||||
'play.chipmunk.land:25565': '1042590315464364032',
|
||||
'mcslot.eu:25565': '1057090538404323338',
|
||||
'chayapak.chipmunk.land:25565': '1010734897796763758'
|
||||
},
|
||||
embedsColors: {
|
||||
normal: '#FFFF00',
|
||||
error: '#FF0000'
|
||||
},
|
||||
prefix: '!'
|
||||
}
|
||||
},
|
||||
servers: [
|
||||
// logging means log to console
|
||||
|
@ -90,7 +87,7 @@ module.exports = {
|
|||
},
|
||||
{
|
||||
host: 'kitsune.icu',
|
||||
port: 25565,
|
||||
port: 61530,
|
||||
kaboom: true,
|
||||
logging: false,
|
||||
useChat: false
|
||||
|
@ -103,14 +100,14 @@ module.exports = {
|
|||
useChat: false
|
||||
},
|
||||
{
|
||||
host: 'mcslot.eu',
|
||||
host: 'chayapak.chipmunk.land',
|
||||
port: 25565,
|
||||
kaboom: true,
|
||||
logging: true,
|
||||
useChat: false
|
||||
},
|
||||
{
|
||||
host: 'chayapak.chipmunk.land',
|
||||
host: 'mcslot.eu',
|
||||
port: 25565,
|
||||
kaboom: 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
|
||||
}
|
||||
]
|
||||
}
|
56
index.js
56
index.js
|
@ -1,27 +1,47 @@
|
|||
const readline = require('node:readline')
|
||||
const { stdin: input, stdout: output } = require('node:process')
|
||||
const rl = readline.createInterface({ input, output })
|
||||
const config = require('./config')
|
||||
const fs = require('fs/promises')
|
||||
const fileExist = require('./util/file-exists')
|
||||
const path = require('path')
|
||||
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', () => {
|
||||
for (const server of config.servers) {
|
||||
const getBots = () => bots
|
||||
const setNewBot = (server, bot) => {
|
||||
bots = bots.filter((eachBot) => eachBot.server.host !== server)
|
||||
bots.push(bot)
|
||||
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)
|
||||
}
|
||||
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) => {
|
||||
console.log('uncaught ' + e.stack)
|
||||
|
|
|
@ -11,7 +11,7 @@ function inject (bot, _dcclient, config, rl) {
|
|||
const chatMessage = require('prismarine-chat')(bot.version)
|
||||
|
||||
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()
|
||||
return chatMessage.fromNotch(component).toAnsi() + _message
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
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])
|
||||
const channel = dcclient.channels.cache.get(config.discord.servers[`${bot.server.host}:${bot.server.port}`])
|
||||
|
||||
let queue = ''
|
||||
const queueInterval = setInterval(() => {
|
||||
|
|
Loading…
Reference in a new issue