move custom chat to plugins + fix list

This commit is contained in:
ChomeNS 2022-11-17 10:30:51 +07:00
parent 3c244904ef
commit b23f46bff8
4 changed files with 34 additions and 23 deletions

View file

@ -6,7 +6,7 @@ module.exports = {
description: 'List players',
usage: '',
trusted: 0,
execute: async function(bot) {
execute: async function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
try {
const component = [];
component.push({text: 'Players ', color: 'green'});

View file

@ -38,7 +38,7 @@ function inject(bot, dcclient, config) {
.setDescription(`\`\`\`${e}\`\`\``);
channeldc.send({embeds: [Embed]});
} else {
bot.tellraw('@a', {text: String(e), color: 'red'});
bot.tellraw(selector, {text: String(e), color: 'red'});
}
}
};

View file

@ -9,8 +9,6 @@ function inject(bot, dcclient, config) {
index = _index;
});
const {MessageBuilder} = require('prismarine-chat')(bot.version);
const version = bot.version;
const srv = mc.createServer({
'online-mode': false,
@ -78,25 +76,6 @@ function inject(bot, dcclient, config) {
client.username,
);
}
bot.tellraw('@a', {
color: 'dark_gray',
translate: '[%s] [%s] %s \u203a %s',
with: [
{
text: 'Chat',
color: 'gray',
},
{
text: 'Proxy',
color: 'gray',
},
{
text: client.username,
color: 'green',
},
MessageBuilder.fromString('&7' + data.message),
],
});
return;
}
targetClient.write(meta.name, data);

View file

@ -0,0 +1,32 @@
/* eslint-disable require-jsdoc */
function inject(bot, client, targetClient) {
const {MessageBuilder} = require('prismarine-chat')(bot.version);
client.on('packet', (data, meta) => {
if (meta.name === 'chat' &&
!data.message?.startsWith('/') &&
!data.message?.startsWith('.')
) {
bot.tellraw('@a', {
color: 'dark_gray',
translate: '[%s] [%s] %s \u203a %s',
with: [
{
text: 'Chat',
color: 'gray',
},
{
text: 'Proxy',
color: 'gray',
},
{
text: client.username,
color: 'green',
},
MessageBuilder.fromString('&7' + data.message),
],
});
}
});
};
module.exports = {inject};