mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-14 10:44:55 -05:00
this took ages to do (real)
This commit is contained in:
parent
d0f16fd484
commit
953ec94cb0
4 changed files with 93 additions and 130 deletions
12
config.js
12
config.js
|
@ -33,12 +33,12 @@ module.exports = {
|
|||
'discord': {
|
||||
'token': 'OTcxNjUwNDU2NzA5Mzk4NTY5.G3lKC2._XQNTTU1Jqmaam_A0JKSe93GP1vFZvDpiXqZzA',
|
||||
'servers': {
|
||||
'sus.shhnowisnottheti.me:25565': '990140129245020221',
|
||||
'kaboom.pw:25565': '1000355361196355674',
|
||||
'129.159.58.114:25565': '998945155316973650',
|
||||
'192.168.1.103:25565': '1002806756885413978',
|
||||
'kitsune.icu:25565': '1004006678460637315',
|
||||
'mc.chomens41793.ga:25565': '1010734897796763758',
|
||||
'sus.shhnowisnottheti.me': '990140129245020221',
|
||||
'play.kaboom.pw': '1000355361196355674',
|
||||
'129.159.58.114': '998945155316973650',
|
||||
'192.168.1.103': '1002806756885413978',
|
||||
'kitsune.icu': '1004006678460637315',
|
||||
'mc.chomens41793.ga': '1010734897796763758',
|
||||
},
|
||||
'prefix': '!',
|
||||
},
|
||||
|
|
126
index.js
126
index.js
|
@ -43,17 +43,7 @@ const dcclient = new Client({
|
|||
intents,
|
||||
});
|
||||
|
||||
const ayunboomchannel = config.discord.servers['sus.shhnowisnottheti.me:25565'];
|
||||
const dinboomchannel = config.discord.servers['129.159.58.114:25565'];
|
||||
const kaboomchannel = config.discord.servers['kaboom.pw:25565'];
|
||||
const localclonechannel = config.discord.servers['192.168.1.103:25565'];
|
||||
const kitsunechannel = config.discord.servers['kitsune.icu:25565'];
|
||||
const chomensserverchannel = config.discord.servers['mc.chomens41793.ga:25565'];
|
||||
let chomenschannel = '969773424387981356';
|
||||
const hashchannel = '980438368422871151';
|
||||
const ownerhashchannel = '980786390247833620';
|
||||
|
||||
function botThings() {
|
||||
async function botThings() {
|
||||
bot = new EventEmitter();
|
||||
bot.options = {
|
||||
username: process.argv[2] === 'mc.chomens41793.ga' ?
|
||||
|
@ -80,6 +70,8 @@ function botThings() {
|
|||
bot.getplayerusername = {};
|
||||
if (typeof bot.messageLogging === 'undefined') bot.messageLogging = true;
|
||||
|
||||
await sleep(500);
|
||||
|
||||
loadPlugins(bot, dcclient, config, rl);
|
||||
}
|
||||
|
||||
|
@ -87,6 +79,8 @@ function botThings() {
|
|||
* Main bot function
|
||||
*/
|
||||
function main() {
|
||||
const channel = dcclient.channels.cache.get(config.discord.servers[process.argv[2]]);
|
||||
|
||||
// allink's chat queue
|
||||
chatQueue = setInterval(function() {
|
||||
try {
|
||||
|
@ -162,8 +156,6 @@ function main() {
|
|||
channel.send(
|
||||
`Successfully logged in to: \`${bot.options.host}:${bot.options.port}\``,
|
||||
);
|
||||
loginfinish = false;
|
||||
started = false;
|
||||
bot.eaglercrashstarted = false;
|
||||
await sleep(1500);
|
||||
bot.createCore();
|
||||
|
@ -197,7 +189,6 @@ function main() {
|
|||
};
|
||||
bot.vm = new VM(bot.vmoptions);
|
||||
|
||||
loginfinish = true;
|
||||
await sleep(1400);
|
||||
bot.tellraw('@a', [
|
||||
{
|
||||
|
@ -256,114 +247,7 @@ function main() {
|
|||
|
||||
dcclient.on('ready', async () => {
|
||||
botThings();
|
||||
// Find the Discord channel messages will be sent to
|
||||
if (process.argv[2] === 'sus.shhnowisnottheti.me') {
|
||||
channel = dcclient.channels.cache.get(ayunboomchannel);
|
||||
bot.channel = dcclient.channels.cache.get(ayunboomchannel);
|
||||
}
|
||||
if (process.argv[2] === '129.159.58.114') {
|
||||
channel = dcclient.channels.cache.get(dinboomchannel);
|
||||
bot.channel = dcclient.channels.cache.get(dinboomchannel);
|
||||
}
|
||||
if (process.argv[2] === 'kaboom.pw') {
|
||||
channel = dcclient.channels.cache.get(kaboomchannel);
|
||||
bot.channel = dcclient.channels.cache.get(kaboomchannel);
|
||||
}
|
||||
if (process.argv[2] === '192.168.1.103') {
|
||||
channel = dcclient.channels.cache.get(localclonechannel);
|
||||
bot.channel = dcclient.channels.cache.get(localclonechannel);
|
||||
}
|
||||
if (process.argv[2] === 'kitsune.icu') {
|
||||
channel = dcclient.channels.cache.get(kitsunechannel);
|
||||
bot.channel = dcclient.channels.cache.get(kitsunechannel);
|
||||
}
|
||||
if (process.argv[2] === 'mc.chomens41793.ga') {
|
||||
channel = dcclient.channels.cache.get(chomensserverchannel);
|
||||
bot.channel = dcclient.channels.cache.get(chomensserverchannel);
|
||||
}
|
||||
await sleep(200);
|
||||
main();
|
||||
chomenschannel = dcclient.channels.cache.get(chomenschannel);
|
||||
bot.hashchannel = dcclient.channels.cache.get(hashchannel);
|
||||
bot.ownerhashchannel = dcclient.channels.cache.get(ownerhashchannel);
|
||||
bot.channelId = channel.id;
|
||||
attachmentlink = '';
|
||||
});
|
||||
|
||||
// Redirect Discord messages to in-game chat
|
||||
dcclient.on('messageCreate', async (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) {
|
||||
message.attachments.forEach((value) => {
|
||||
attachmentsComponent.push({
|
||||
text: ' [Attachment]',
|
||||
color: 'green',
|
||||
clickEvent: {
|
||||
action: 'open_url',
|
||||
value: value.proxyURL,
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
const component = [
|
||||
{text: '[', color: 'dark_gray'},
|
||||
{text: 'ChomeNS ', color: 'yellow',
|
||||
clickEvent: {
|
||||
action: 'open_url',
|
||||
value: 'https://discord.gg/xdgCkUyaA4',
|
||||
},
|
||||
},
|
||||
{text: 'Discord', color: 'blue',
|
||||
clickEvent: {
|
||||
action: 'open_url',
|
||||
value: 'https://discord.gg/xdgCkUyaA4',
|
||||
},
|
||||
},
|
||||
{text: '] ', color: 'dark_gray'},
|
||||
{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) {
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
dcclient.login(config.discord.token);
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
/* eslint-disable max-len */
|
||||
const {escapeMarkdown} = require('../util/escapeMarkdown');
|
||||
function inject(bot, dcclient, config) {
|
||||
async function inject(bot, dcclient, config, rl) {
|
||||
const channel = dcclient.channels.cache.get(config.discord.servers[bot.options.host]);
|
||||
|
||||
let queue = '';
|
||||
const queueInterval = setInterval(() => {
|
||||
if (queue === '') return;
|
||||
|
||||
bot.channel.send({
|
||||
channel.send({
|
||||
content: '```ansi\n' + queue.substring(0, 1986) + '\n```',
|
||||
allowedMentions: {
|
||||
parse: [],
|
||||
|
@ -26,6 +29,82 @@ function inject(bot, dcclient, config) {
|
|||
bot.once('end', () => {
|
||||
clearInterval(queueInterval);
|
||||
});
|
||||
|
||||
// handle discord messages!!!
|
||||
dcclient.on('messageCreate', async (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) {
|
||||
message.attachments.forEach((value) => {
|
||||
attachmentsComponent.push({
|
||||
text: message.content === '' ? '[Attachment]' : ' [Attachment]', // may not be the best fix
|
||||
color: 'green',
|
||||
clickEvent: {
|
||||
action: 'open_url',
|
||||
value: value.proxyURL,
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
const component = [
|
||||
{text: '[', color: 'dark_gray'},
|
||||
{text: 'ChomeNS ', color: 'yellow',
|
||||
clickEvent: {
|
||||
action: 'open_url',
|
||||
value: 'https://discord.gg/xdgCkUyaA4',
|
||||
},
|
||||
},
|
||||
{text: 'Discord', color: 'blue',
|
||||
clickEvent: {
|
||||
action: 'open_url',
|
||||
value: 'https://discord.gg/xdgCkUyaA4',
|
||||
},
|
||||
},
|
||||
{text: '] ', color: 'dark_gray'},
|
||||
{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) {
|
||||
return;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = {inject};
|
||||
|
|
2
run.js
2
run.js
|
@ -26,7 +26,7 @@ function start(host, port) {
|
|||
if (host=='129.159.58.114') {
|
||||
theServer = 'dinboom';
|
||||
}
|
||||
if (host=='kaboom.pw') {
|
||||
if (host=='play.kaboom.pw') {
|
||||
theServer = 'kaboom';
|
||||
}
|
||||
if (host=='192.168.1.103') {
|
||||
|
|
Loading…
Reference in a new issue