bot.tellraw()

i totally did not used the search icon thing in vscode
This commit is contained in:
ChomeNS 2022-11-07 18:30:37 +07:00
parent 766cf10267
commit 6895a37104
29 changed files with 81 additions and 73 deletions

View file

@ -7,7 +7,7 @@ module.exports = {
usage: '', usage: '',
trusted: 0, trusted: 0,
execute: function(bot) { execute: function(bot) {
bot.core.run('minecraft:tellraw @a ' + JSON.stringify(['', {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'}]}}])); bot.tellraw('@a', ['', {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: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) { discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) {
const Embed = new MessageEmbed() const Embed = new MessageEmbed()

View file

@ -11,11 +11,11 @@ module.exports = {
if (args[1]==='true') { if (args[1]==='true') {
bot.visibility = true; bot.visibility = true;
bot.chat('/essentials:vanish disable'); bot.chat('/essentials:vanish disable');
bot.core.run('minecraft:tellraw @a ' + JSON.stringify(['', {text: 'The bot\'s visibility is now ', color: 'white'}, {text: 'visible', color: 'green'}])); bot.tellraw('@a', ['', {text: 'The bot\'s visibility is now ', color: 'white'}, {text: 'visible', color: 'green'}]);
} else if (args[1]==='false') { } else if (args[1]==='false') {
bot.visibility = false; bot.visibility = false;
bot.chat('/essentials:vanish enable'); bot.chat('/essentials:vanish enable');
bot.core.run('minecraft:tellraw @a ' + JSON.stringify(['', {text: 'The bot\'s visibility is now ', color: 'white'}, {text: 'invisible', color: 'gold'}])); bot.tellraw('@a', ['', {text: 'The bot\'s visibility is now ', color: 'white'}, {text: 'invisible', color: 'gold'}]);
} else { } else {
throw new SyntaxError('Invalid argument'); throw new SyntaxError('Invalid argument');
} }

View file

@ -8,10 +8,10 @@ module.exports = {
usage: '', usage: '',
trusted: 0, trusted: 0,
execute: function(bot) { execute: function(bot) {
bot.core.run('minecraft:tellraw @a ' + JSON.stringify([{text: 'Changelogs:', color: 'green'}])); bot.tellraw('@a', [{text: 'Changelogs:', color: 'green'}]);
changelog.forEach((message, number) => { changelog.forEach((message, number) => {
number += 1; number += 1;
bot.core.run('minecraft:tellraw @a ' + JSON.stringify([{text: `${number}`, color: 'gray'}, {text: ' - ', color: 'dark_gray'}, {text: message, color: 'gray'}])); bot.tellraw('@a', [{text: `${number}`, color: 'gray'}, {text: ' - ', color: 'dark_gray'}, {text: message, color: 'gray'}]);
}); });
}, },
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc) { discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc) {

View file

@ -8,18 +8,18 @@ module.exports = {
trusted: 0, trusted: 0,
execute: function(bot, username, usernameraw, sender, prefix, args) { execute: function(bot, username, usernameraw, sender, prefix, args) {
if (args[0]==='specific') { if (args[0]==='specific') {
bot.core.run(`minecraft:tellraw ${args[1]} ` + JSON.stringify([{text: `${'\n'.repeat(100)}`, color: 'white'}, {text: `Your chat has been cleared by ${username}.`, color: 'dark_green'}])); bot.tellraw(args[1], [{text: `${'\n'.repeat(100)}`, color: 'white'}, {text: `Your chat has been cleared by ${username}.`, color: 'dark_green'}]);
return; return;
} else { } else {
bot.core.run(`minecraft:tellraw @a ` + JSON.stringify([{text: `${'\n'.repeat(100)}`, color: 'white'}, {text: 'The chat has been cleared.', color: 'dark_green'}])); bot.tellraw('@a', [{text: `${'\n'.repeat(100)}`, color: 'white'}, {text: 'The chat has been cleared.', color: 'dark_green'}]);
} }
}, },
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) { discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) {
if (args[0]==='specific') { if (args[0]==='specific') {
bot.core.run(`minecraft:tellraw ${args[1]} ` + JSON.stringify([{text: `${'\n'.repeat(100)}`, color: 'white'}, {text: `Your chat has been cleared by ${username} (on Discord).`, color: 'dark_green'}])); bot.tellraw(args[1], [{text: `${'\n'.repeat(100)}`, color: 'white'}, {text: `Your chat has been cleared by ${username} (on Discord).`, color: 'dark_green'}]);
return; return;
} else { } else {
bot.core.run('minecraft:tellraw @a ' + JSON.stringify([{text: `${'\n'.repeat(100)}`, color: 'white'}, {text: 'The chat has been cleared.', color: 'dark_green'}])); bot.tellraw('@a', [{text: `${'\n'.repeat(100)}`, color: 'white'}, {text: 'The chat has been cleared.', color: 'dark_green'}]);
} }
}, },
}; };

View file

@ -52,7 +52,7 @@ function list(bot, discord, channeldc) {
message.pop(); message.pop();
bot.core.run('minecraft:tellraw @a ' + JSON.stringify(message)); bot.tellraw('@a', message);
} }
module.exports = { module.exports = {
name: 'cloop', name: 'cloop',
@ -68,7 +68,7 @@ module.exports = {
if (args[3]) { if (args[3]) {
if (!Number(args[2]) && Number(args[2]) !== 0) throw new SyntaxError('Invalid interval'); if (!Number(args[2]) && Number(args[2]) !== 0) throw new SyntaxError('Invalid interval');
add(args.slice(3).join(' '), args[2], bot); add(args.slice(3).join(' '), args[2], bot);
bot.core.run('minecraft:tellraw @a ' + JSON.stringify([{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'}])); bot.tellraw('@a', [{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 { } else {
throw new Error('Invalid hash'); throw new Error('Invalid hash');
@ -86,7 +86,7 @@ module.exports = {
if (args[1]==='remove') { if (args[1]==='remove') {
if (args[0]===bot.hash) { if (args[0]===bot.hash) {
remove(args[2]); remove(args[2]);
bot.core.run('minecraft:tellraw @a ' + JSON.stringify(['', {text: 'Removed cloop '}, {text: args[2], color: 'aqua'}])); bot.tellraw('@a', ['', {text: 'Removed cloop '}, {text: args[2], color: 'aqua'}]);
} else { } else {
throw new Error('Invalid hash'); throw new Error('Invalid hash');
} }
@ -95,7 +95,7 @@ module.exports = {
if (args[1]==='removeall') { if (args[1]==='removeall') {
if (args[0]===bot.hash) { if (args[0]===bot.hash) {
clear(); clear();
bot.core.run('minecraft:tellraw @a ' + JSON.stringify(['', {text: 'Removed all looped commands', color: 'white'}])); bot.tellraw('@a', ['', {text: 'Removed all looped commands', color: 'white'}]);
} else { } else {
throw new Error('Invalid hash'); throw new Error('Invalid hash');
} }

View file

@ -9,7 +9,7 @@ module.exports = {
trusted: 0, trusted: 0,
execute: function(bot, username, usernameraw, sender, prefix, args) { execute: function(bot, username, usernameraw, sender, prefix, args) {
if (args[0]!=='list') { if (args[0]!=='list') {
bot.core.run('minecraft:tellraw @a ' + JSON.stringify({text: `${cowsay.say(args.slice(1).join(' '), {cow: cows[args[0]]})}`})); bot.tellraw('@a', {text: `${cowsay.say(args.slice(1).join(' '), {cow: cows[args[0]]})}`});
} else { } else {
let color = '§6'; let color = '§6';
let message = ''; let message = '';
@ -22,7 +22,7 @@ module.exports = {
}; };
message += color + value + ' '; message += color + value + ' ';
}); });
bot.core.run('minecraft:tellraw @a ' + JSON.stringify([{text: 'Cows: ', color: 'green'}, '\n', {text: message, color: 'red'}])); bot.tellraw('@a', [{text: 'Cows: ', color: 'green'}, '\n', {text: message, color: 'red'}]);
} }
}, },
}; };

View file

@ -7,7 +7,7 @@ module.exports = {
usage: '', usage: '',
trusted: 0, trusted: 0,
execute: function(bot) { execute: function(bot) {
bot.core.run('minecraft:tellraw @a ' + JSON.stringify([{text: 'ChomeNS Bot ', color: 'yellow'}, {text: 'was created by ', color: 'white'}, {text: 'chayapak', color: 'gold'}])); bot.tellraw('@a', [{text: 'ChomeNS Bot ', color: 'yellow'}, {text: 'was created by ', color: 'white'}, {text: 'chayapak', color: 'gold'}]);
}, },
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) { discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) {
const Embed = new MessageEmbed() const Embed = new MessageEmbed()

View file

@ -5,7 +5,7 @@ module.exports = {
usage: '', usage: '',
trusted: 0, trusted: 0,
execute: function(bot) { execute: function(bot) {
bot.core.run('minecraft:tellraw @a' + JSON.stringify([ bot.tellraw('@a', [
{ {
text: 'The Discord invite is ', text: 'The Discord invite is ',
color: 'white', color: 'white',
@ -18,6 +18,6 @@ module.exports = {
value: 'https://discord.gg/xdgCkUyaA4', value: 'https://discord.gg/xdgCkUyaA4',
}, },
}, },
])); ]);
}, },
}; };

View file

@ -34,7 +34,7 @@ module.exports = {
bot.draw(data, info); bot.draw(data, info);
} catch (e) { } catch (e) {
bot.core.run('minecraft:tellraw @a ' + JSON.stringify({text: 'SyntaxError: Invalid URL', color: 'red'})); bot.tellraw('@a', {text: 'SyntaxError: Invalid URL', color: 'red'});
} }
}, },
}; };

View file

@ -15,10 +15,10 @@ module.exports = {
// if (!entity) throw new SyntaxError('Invalid entity'); // if (!entity) throw new SyntaxError('Invalid entity');
// if (!args[1]) { // if (!args[1]) {
// bot.core.run('minecraft:execute unless entity @s[name= run ] run execute as @a at @r[\'limit\'=10] run summon minecraft:' + entity.name); // bot.core.run('minecraft:execute unless entity @s[name= run ] run execute as @a at @r[\'limit\'=10] run summon minecraft:' + entity.name);
// bot.core.run('minecraft:tellraw @a ' + JSON.stringify(['', {text: 'Entity ', color: 'white'}, {text: entity.displayName, color: 'green'}, {text: ' spawning at everyone...', color: 'white'}])); // bot.tellraw('@a', ['', {text: 'Entity ', color: 'white'}, {text: entity.displayName, color: 'green'}, {text: ' spawning at everyone...', color: 'white'}]);
// } else if (args[1]==='specific' && args[2]) { // } else if (args[1]==='specific' && args[2]) {
// bot.core.run('minecraft:execute unless entity @s[name= run ] run execute as @a at ' + args[2] + ' run summon minecraft:' + entity.name); // bot.core.run('minecraft:execute unless entity @s[name= run ] run execute as @a at ' + args[2] + ' run summon minecraft:' + entity.name);
// bot.core.run('minecraft:tellraw @a ' + JSON.stringify(['', {text: `Entity `, color: 'white'}, {text: entity.displayName, color: 'green'}, {text: ' spawning at ', color: 'white'}, {text: `${args[2]}`, color: 'aqua'}])); // bot.tellraw('@a', ['', {text: `Entity `, color: 'white'}, {text: entity.displayName, color: 'green'}, {text: ' spawning at ', color: 'white'}, {text: `${args[2]}`, color: 'aqua'}]);
// } // }
}, },
}; };

View file

@ -14,9 +14,9 @@ module.exports = {
execute: function(bot, username, usernameraw, sender, prefix, args, config) { execute: function(bot, username, usernameraw, sender, prefix, args, config) {
if (args[0]==='run') { if (args[0]==='run') {
try { try {
bot.core.run('minecraft:tellraw @a ' + JSON.stringify({text: `${util.inspect(bot.vm.run(args.slice(1).join(' ')), {stylize: stylize})}`.substring(0, 1900)})); bot.tellraw('@a', {text: `${util.inspect(bot.vm.run(args.slice(1).join(' ')), {stylize: stylize})}`.substring(0, 1900)});
} catch (err) { } catch (err) {
bot.core.run('minecraft:tellraw @a ' + JSON.stringify({text: `${util.inspect(err).replaceAll('runner', 'chayapak1')}`, color: 'red'})); bot.tellraw('@a', {text: `${util.inspect(err).replaceAll('runner', 'chayapak1')}`, color: 'red'});
} }
} }
if (args[0]==='reset') { if (args[0]==='reset') {
@ -30,9 +30,9 @@ module.exports = {
colors: 'minecraft', colors: 'minecraft',
code: args[1], code: args[1],
})).then((res) => { })).then((res) => {
bot.core.run('minecraft:tellraw @a ' + JSON.stringify({text: `${res.data}`})); bot.tellraw('@a', {text: `${res.data}`});
}).catch((err) => { }).catch((err) => {
bot.core.run('minecraft:tellraw @a ' + JSON.stringify({text: `${err}`, color: 'red'})); bot.tellraw('@a', {text: `${err}`, color: 'red'});
}); });
} }
// if (args[0]==='dineval') { // if (args[0]==='dineval') {
@ -43,9 +43,9 @@ module.exports = {
// colors: 'minecraft', // colors: 'minecraft',
// }, // },
// }).then((res) => { // }).then((res) => {
// bot.core.run('minecraft:tellraw @a ' + JSON.stringify({text: `${res.data}`})); // bot.tellraw('@a', {text: `${res.data}`}));
// }).catch((e) => { // }).catch((e) => {
// bot.core.run('minecraft:tellraw @a ' + JSON.stringify({text: `${e}`, color: 'red'})); // bot.tellraw('@a', {text: `${e}`, color: 'red'});
// }); // });
// } // }
}, },

View file

@ -36,10 +36,10 @@ module.exports = {
if (command.alias.toString()!=='') { if (command.alias.toString()!=='') {
alias = command.alias.join(', '); alias = command.alias.join(', ');
} }
bot.core.run('minecraft:tellraw @a ' + JSON.stringify([{text: prefix + command.name, color: 'gold'}, {text: ` (${alias})`, color: 'white'}, {text: ' - ', color: 'gray'}, {text: command.description, color: 'gray'}])); bot.tellraw('@a', [{text: prefix + command.name, color: 'gold'}, {text: ` (${alias})`, color: 'white'}, {text: ' - ', color: 'gray'}, {text: command.description, color: 'gray'}]);
bot.core.run('minecraft:tellraw @a ' + JSON.stringify([{text: 'Trust level: ', color: 'green'}, {text: command.trusted, color: 'yellow'}])); bot.tellraw('@a', [{text: 'Trust level: ', color: 'green'}, {text: command.trusted, color: 'yellow'}]);
bot.core.run('minecraft:tellraw @a ' + JSON.stringify([{text: 'Supported on Discord: ', color: 'green'}, {text: discordSupported, color: 'gold'}])); bot.tellraw('@a', [{text: 'Supported on Discord: ', color: 'green'}, {text: discordSupported, color: 'gold'}]);
bot.core.run('minecraft:tellraw @a ' + JSON.stringify([{text: prefix + command.name, color: 'gold'}, {text: ' ' + command.usage, color: 'aqua'}])); bot.tellraw('@a', [{text: prefix + command.name, color: 'gold'}, {text: ' ' + command.usage, color: 'aqua'}]);
} }
if (command.name === args[0]) m(); if (command.name === args[0]) m();
@ -49,7 +49,7 @@ module.exports = {
}; };
} else { } else {
const pre = [{'text': 'Commands ', 'color': 'gray'}, {'text': '(', 'color': 'gray'}, {'text': '⬤ Public', 'color': 'green'}, {'text': ' ⬤ Trusted', 'color': 'red'}, {'text': ' ⬤ Owner', 'color': 'dark_red'}, {'text': ') -', 'color': 'gray'}]; const pre = [{'text': 'Commands ', 'color': 'gray'}, {'text': '(', 'color': 'gray'}, {'text': '⬤ Public', 'color': 'green'}, {'text': ' ⬤ Trusted', 'color': 'red'}, {'text': ' ⬤ Owner', 'color': 'dark_red'}, {'text': ') -', 'color': 'gray'}];
bot.core.run('minecraft:tellraw @a ' + JSON.stringify([pre, {text: generalCommands, color: 'green'}, {text: trustedCommands, color: 'red'}, {text: ownerCommands, color: 'dark_red'}])); bot.tellraw('@a', [pre, {text: generalCommands, color: 'green'}, {text: trustedCommands, color: 'red'}, {text: ownerCommands, color: 'dark_red'}]);
} }
}, },
discordExecute: async function(bot, username, usernameraw, sender, prefix, args, channeldc) { discordExecute: async function(bot, username, usernameraw, sender, prefix, args, channeldc) {

View file

@ -9,11 +9,11 @@ module.exports = {
trusted: 0, trusted: 0,
execute: async function(bot) { execute: async function(bot) {
try { try {
bot.core.run('minecraft:tellraw @a ' + JSON.stringify(['', {text: 'Players:', color: 'green'}])); bot.tellraw('@a', ['', {text: 'Players:', color: 'green'}]);
await sleep(60); await sleep(60);
for (const property of bot.players.list) { for (const property of bot.players.list) {
// if (property.match.startsWith('@')) continue; // if (property.match.startsWith('@')) continue;
bot.core.run('minecraft:tellraw @a ' + JSON.stringify(['', {text: `${property.name}`, color: 'yellow'}, {text: ' ', color: 'aqua'}, {text: `${property.UUID}`, color: 'aqua'}])); bot.tellraw('@a', ['', {text: `${property.name}`, color: 'yellow'}, {text: ' ', color: 'aqua'}, {text: `${property.UUID}`, color: 'aqua'}]);
} }
} catch (e) { } catch (e) {
return; return;

View file

@ -29,7 +29,7 @@ async function play(bot, values, discord, channeldc) {
.setDescription(`Added ${song.name} to the song queue`); .setDescription(`Added ${song.name} to the song queue`);
channeldc.send({embeds: [Embed]}); channeldc.send({embeds: [Embed]});
} else { } else {
bot.core.run('minecraft:tellraw @a ' + JSON.stringify([{text: 'Added ', color: 'white'}, {text: song.name, color: 'gold'}, {text: ' to the song queue', color: 'white'}])); bot.tellraw('@a', [{text: 'Added ', color: 'white'}, {text: song.name, color: 'gold'}, {text: ' to the song queue', color: 'white'}]);
} }
} catch (e) { } catch (e) {
if (discord) { if (discord) {
@ -39,7 +39,7 @@ async function play(bot, values, discord, channeldc) {
.setDescription(`\`\`\`SyntaxError: Invalid file\`\`\``); .setDescription(`\`\`\`SyntaxError: Invalid file\`\`\``);
channeldc.send({embeds: [Embed]}); channeldc.send({embeds: [Embed]});
} else { } else {
bot.core.run('minecraft:tellraw @a ' + JSON.stringify({text: 'SyntaxError: Invalid file', color: 'red'})); bot.tellraw('@a', {text: 'SyntaxError: Invalid file', color: 'red'});
} }
} }
} }
@ -63,7 +63,7 @@ async function playUrl(bot, values, discord, channeldc) {
.setDescription(`Added ${song.name} to the song queue`); .setDescription(`Added ${song.name} to the song queue`);
channeldc.send({embeds: [Embed]}); channeldc.send({embeds: [Embed]});
} else { } else {
bot.core.run('minecraft:tellraw @a ' + JSON.stringify([{text: 'Added ', color: 'white'}, {text: song.name, color: 'gold'}, {text: ' to the song queue', color: 'white'}])); bot.tellraw('@a', [{text: 'Added ', color: 'white'}, {text: song.name, color: 'gold'}, {text: ' to the song queue', color: 'white'}]);
} }
} catch (e) { } catch (e) {
if (discord) { if (discord) {
@ -73,7 +73,7 @@ async function playUrl(bot, values, discord, channeldc) {
.setDescription(`\`\`\`SyntaxError: Invalid URL\`\`\``); .setDescription(`\`\`\`SyntaxError: Invalid URL\`\`\``);
channeldc.send({embeds: [Embed]}); channeldc.send({embeds: [Embed]});
} else { } else {
bot.core.run('minecraft:tellraw @a ' + JSON.stringify({text: 'SyntaxError: Invalid URL', color: 'red'})); bot.tellraw('@a', {text: 'SyntaxError: Invalid URL', color: 'red'});
} }
} }
} }
@ -124,7 +124,7 @@ async function list(bot, discord, channeldc) {
}}); }});
}); });
bot.core.run('minecraft:tellraw @a ' + JSON.stringify(message)); bot.tellraw('@a', message);
}; };
module.exports = { module.exports = {
@ -142,7 +142,7 @@ module.exports = {
} }
if (args[0]==='stop') { if (args[0]==='stop') {
try { try {
bot.core.run('minecraft:tellraw @a ' + JSON.stringify({text: 'Cleared the song queue'})); bot.tellraw('@a', {text: 'Cleared the song queue'});
} catch (e) { } catch (e) {
return; return;
} }
@ -150,7 +150,7 @@ module.exports = {
} }
if (args[0]==='skip') { if (args[0]==='skip') {
try { try {
bot.core.run('minecraft:tellraw @a ' + JSON.stringify([{text: 'Skipping '}, {text: bot.music.song.name, color: 'gold'}])); bot.tellraw('@a', [{text: 'Skipping '}, {text: bot.music.song.name, color: 'gold'}]);
bot.music.skip(); bot.music.skip();
} catch (e) { } catch (e) {
throw new Error('No music is currently playing!'); throw new Error('No music is currently playing!');
@ -159,22 +159,22 @@ module.exports = {
if (args[0]==='loop') { if (args[0]==='loop') {
if (args[1] === 'off') { if (args[1] === 'off') {
bot.music.loop = 0; bot.music.loop = 0;
bot.core.run('minecraft:tellraw @a ' + JSON.stringify([{text: 'Looping is now '}, {text: 'disabled', color: 'red'}])); bot.tellraw('@a', [{text: 'Looping is now '}, {text: 'disabled', color: 'red'}]);
} }
if (args[1] === 'current') { if (args[1] === 'current') {
bot.music.loop = 1; bot.music.loop = 1;
bot.core.run('minecraft:tellraw @a ' + JSON.stringify([{text: 'Now Looping '}, {text: song.name, color: 'gold'}])); bot.tellraw('@a', [{text: 'Now Looping '}, {text: song.name, color: 'gold'}]);
} }
if (args[1] === 'all') { if (args[1] === 'all') {
bot.music.loop = 2; bot.music.loop = 2;
bot.core.run('minecraft:tellraw @a ' + JSON.stringify({text: 'Now looping every song in the queue'})); bot.tellraw('@a', {text: 'Now looping every song in the queue'});
} }
} }
if (args[0]==='list') { if (args[0]==='list') {
list(bot); list(bot);
} }
if (args[0]==='nowplaying') { if (args[0]==='nowplaying') {
bot.core.run('minecraft:tellraw @a ' + JSON.stringify([{text: 'Now playing '}, {text: bot.music.song.name, color: 'gold'}])); bot.tellraw('@a', [{text: 'Now playing '}, {text: bot.music.song.name, color: 'gold'}]);
} }
}, },
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) { discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) {

View file

@ -6,7 +6,7 @@ module.exports = {
usage: '', usage: '',
trusted: 0, trusted: 0,
execute: function(bot, username, usernameraw, sender, prefix, args) { execute: function(bot, username, usernameraw, sender, prefix, args) {
bot.core.run('minecraft:tellraw @a ' + JSON.stringify( bot.tellraw('@a',
[ [
{ {
text: 'Your username is: ', text: 'Your username is: ',
@ -29,6 +29,6 @@ module.exports = {
], ],
}, },
}, },
])); ]);
}, },
}; };

View file

@ -8,7 +8,7 @@ module.exports = {
trusted: 0, trusted: 0,
execute: function(bot, username, usernameraw, sender, prefix, args) { execute: function(bot, username, usernameraw, sender, prefix, args) {
const rtppos = `${between(20000000, 500000)} 100 ${between(20000000, 500000)}`; const rtppos = `${between(20000000, 500000)} 100 ${between(20000000, 500000)}`;
bot.core.run('minecraft:tellraw @a ' + JSON.stringify([{text: 'Teleporting ', color: 'white'}, {text: username, color: 'aqua'}, {text: ' to ', color: 'white'}, {text: rtppos, color: 'green'}, {text: '...', color: 'white'}])); bot.tellraw('@a', [{text: 'Teleporting ', color: 'white'}, {text: username, color: 'aqua'}, {text: ' to ', color: 'white'}, {text: rtppos, color: 'green'}, {text: '...', color: 'white'}]);
bot.core.run(`essentials:teleport ${sender} ${rtppos}`); bot.core.run(`essentials:teleport ${sender} ${rtppos}`);
}, },
}; };

View file

@ -10,9 +10,9 @@ module.exports = {
execute: function(bot, username, usernameraw, sender, prefix, args) { execute: function(bot, username, usernameraw, sender, prefix, args) {
if (args[0]===bot.ownerHash) { if (args[0]===bot.ownerHash) {
try { try {
bot.core.run('minecraft:tellraw @a ' + JSON.stringify({text: `${util.inspect(eval(args.slice(1).join(' ')), {stylize: stylize})}`.substring(0, 1900)})); bot.tellraw('@a', {text: `${util.inspect(eval(args.slice(1).join(' ')), {stylize: stylize})}`.substring(0, 1900)});
} catch (err) { } catch (err) {
bot.core.run('minecraft:tellraw @a ' + JSON.stringify({text: `${util.inspect(err).replaceAll('runner', 'chayapak1')}`, color: 'red'})); bot.tellraw('@a', {text: `${util.inspect(err).replaceAll('runner', 'chayapak1')}`, color: 'red'});
} }
} else { } else {
throw new Error('Invalid OwnerHash'); throw new Error('Invalid OwnerHash');

View file

@ -7,7 +7,7 @@ module.exports = {
usage: '', usage: '',
trusted: 0, trusted: 0,
execute: function(bot, username, usernameraw, sender, prefix, args) { execute: function(bot, username, usernameraw, sender, prefix, args) {
bot.core.run('minecraft:tellraw @a ' + JSON.stringify(['', {'text': `Username: ${username},`, 'color': 'green'}, {'text': ` Raw username: ${usernameraw},`, 'color': 'green'}, {'text': ` Sender UUID: ${sender},`, 'color': 'green'}, {'text': ` Prefix: ${prefix},`, 'color': 'green'}, {'text': ` Args: ${args.join(', ').toString()}`, 'color': 'green'}])); bot.tellraw('@a', ['', {'text': `Username: ${username},`, 'color': 'green'}, {'text': ` Raw username: ${usernameraw},`, 'color': 'green'}, {'text': ` Sender UUID: ${sender},`, 'color': 'green'}, {'text': ` Prefix: ${prefix},`, 'color': 'green'}, {'text': ` Args: ${args.join(', ').toString()}`, 'color': 'green'}]);
}, },
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc) { discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc) {
const Embed = new MessageEmbed() const Embed = new MessageEmbed()

View file

@ -10,9 +10,9 @@ module.exports = {
execute: async function(bot, username, usernameraw, sender, prefix, args) { execute: async function(bot, username, usernameraw, sender, prefix, args) {
try { try {
const res = await translate(args.slice(2).join(' '), {from: args[0], to: args[1]}); const res = await translate(args.slice(2).join(' '), {from: args[0], to: args[1]});
bot.core.run('minecraft:tellraw @a ' + JSON.stringify(['', {text: 'Result: ', color: 'gold'}, {text: res.text, color: 'green'}])); bot.tellraw('@a', ['', {text: 'Result: ', color: 'gold'}, {text: res.text, color: 'green'}]);
} catch (e) { } catch (e) {
bot.core.run('minecraft:tellraw @a ' + JSON.stringify({text: String(e), color: 'red'})); bot.tellraw('@a', {text: String(e), color: 'red'});
} }
}, },
discordExecute: async function(bot, username, usernameraw, sender, prefix, args, channeldc, message) { discordExecute: async function(bot, username, usernameraw, sender, prefix, args, channeldc, message) {

View file

@ -8,7 +8,7 @@ module.exports = {
usage: '', usage: '',
trusted: 0, trusted: 0,
execute: function(bot) { execute: function(bot) {
bot.core.run('minecraft:tellraw @a ' + JSON.stringify(['', {text: 'The bot\'s uptime is ', color: 'white'}, {text: `${secondsToHms(Math.floor(performance.now() / 1000))}`, color: 'green'}])); bot.tellraw('@a', ['', {text: 'The bot\'s uptime is ', color: 'white'}, {text: `${secondsToHms(Math.floor(performance.now() / 1000))}`, color: 'green'}]);
}, },
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) { discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) {
const Embed = new MessageEmbed() const Embed = new MessageEmbed()

View file

@ -9,11 +9,11 @@ module.exports = {
execute: function(bot, username, usernameraw, sender, prefix, args) { execute: function(bot, username, usernameraw, sender, prefix, args) {
urban.autocompleteExtra(args[0], (error, results) => { urban.autocompleteExtra(args[0], (error, results) => {
if (error) { if (error) {
bot.core.run('minecraft:tellraw @a ' + JSON.stringify(['', {text: '[', color: 'dark_red'}, {text: 'Urban', color: 'red'}, {text: '] ', color: 'dark_red'}, {text: error.message, color: 'red'}])); bot.tellraw('@a', ['', {text: '[', color: 'dark_red'}, {text: 'Urban', color: 'red'}, {text: '] ', color: 'dark_red'}, {text: error.message, color: 'red'}]);
return; return;
} }
results.forEach(({preview, term}) => { results.forEach(({preview, term}) => {
bot.core.run('minecraft:tellraw @a ' + JSON.stringify(['', {text: '[', color: 'dark_red'}, {text: 'Urban', color: 'red'}, {text: '] ', color: 'dark_red'}, {text: term, color: 'white'}, {text: ' - ', color: 'white'}, {text: preview, color: 'white'}])); bot.tellraw('@a', ['', {text: '[', color: 'dark_red'}, {text: 'Urban', color: 'red'}, {text: '] ', color: 'dark_red'}, {text: term, color: 'white'}, {text: ' - ', color: 'white'}, {text: preview, color: 'white'}]);
}); });
}); });
}, },

View file

@ -11,7 +11,7 @@ module.exports = {
const playername = args.join(' '); const playername = args.join(' ');
const player = bot.playersAddedPlayers[playername]; const player = bot.playersAddedPlayers[playername];
if (player === undefined) throw new SyntaxError('Invalid Username'); if (player === undefined) throw new SyntaxError('Invalid Username');
bot.core.run('minecraft:tellraw @a ' + JSON.stringify( bot.tellraw('@a',
[ [
{ {
text: `${playername}'s UUID: `, text: `${playername}'s UUID: `,
@ -34,9 +34,9 @@ module.exports = {
], ],
}, },
}, },
])); ]);
} else { } else {
bot.core.run('minecraft:tellraw @a ' + JSON.stringify( bot.tellraw('@a',
[ [
{ {
text: `Your UUID: `, text: `Your UUID: `,
@ -59,7 +59,7 @@ module.exports = {
], ],
}, },
}, },
])); ]);
} }
}, },
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) { discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) {

View file

@ -7,11 +7,11 @@ module.exports = {
trusted: 1, trusted: 1,
execute: function(bot, username, usernameraw, sender, prefix, args) { execute: function(bot, username, usernameraw, sender, prefix, args) {
if (args[0]===bot.hash) { if (args[0]===bot.hash) {
bot.core.run('minecraft:tellraw @a ' + JSON.stringify({text: 'Valid hash', color: 'green'})); bot.tellraw('@a', {text: 'Valid hash', color: 'green'});
} else if (args[0]===bot.ownerHash) { } else if (args[0]===bot.ownerHash) {
bot.core.run('minecraft:tellraw @a ' + JSON.stringify({text: 'Valid OwnerHash', color: 'green'})); bot.tellraw('@a', {text: 'Valid OwnerHash', color: 'green'});
} else { } else {
bot.core.run('minecraft:tellraw @a ' + JSON.stringify({text: 'Invalid hash', color: 'red'})); bot.tellraw('@a', {text: 'Invalid hash', color: 'red'});
} }
}, },
}; };

View file

@ -12,9 +12,9 @@ module.exports = {
try { try {
const page = await wiki.page(args.join(' ')); const page = await wiki.page(args.join(' '));
const summary = await page.summary(); const summary = await page.summary();
bot.core.run('minecraft:tellraw @a ' + JSON.stringify({text: summary.extract, color: 'green'})); bot.tellraw('@a', {text: summary.extract, color: 'green'});
} catch (e) { } catch (e) {
bot.core.run('minecraft:tellraw @a ' + JSON.stringify({text: e.toString(), color: 'red'})); bot.tellraw('@a', {text: e.toString(), color: 'red'});
} }
}, },
discordExecute: async function(bot, username, usernameraw, sender, prefix, args, channeldc) { discordExecute: async function(bot, username, usernameraw, sender, prefix, args, channeldc) {

View file

@ -246,7 +246,7 @@ function main() {
loginfinish = true; loginfinish = true;
await sleep(1400); await sleep(1400);
bot.core.run('minecraft:tellraw @a ' + JSON.stringify([{text: 'ChomeNS Bot', color: 'yellow'}, {text: ' - ', color: 'dark_gray'}, {text: 'made by ', color: 'gray'}, {text: 'chayapak', color: 'gold'}])); bot.tellraw('@a', [{text: 'ChomeNS Bot', color: 'yellow'}, {text: ' - ', color: 'dark_gray'}, {text: 'made by ', color: 'gray'}, {text: 'chayapak', color: 'gold'}]);
}); });
bot.on('parsed_chat', async function(message, data) { bot.on('parsed_chat', async function(message, data) {
@ -353,10 +353,10 @@ dcclient.on('ready', async () => {
} }
if (line.toLowerCase().startsWith('.servereval ')) { if (line.toLowerCase().startsWith('.servereval ')) {
try { try {
bot.core.run('minecraft:tellraw @a ' + JSON.stringify({text: `${util.inspect(eval(`${line.substring(12)}`))}`, color: 'green'})); bot.tellraw('@a', {text: `${util.inspect(eval(`${line.substring(12)}`))}`, color: 'green'});
return; return;
} catch (err) { } catch (err) {
bot.core.run('minecraft:tellraw @a ' + JSON.stringify({text: `${util.inspect(err)}`, color: 'red'})); bot.tellraw('@a', {text: `${util.inspect(err)}`, color: 'red'});
return; return;
} }
} }
@ -374,7 +374,7 @@ dcclient.on('ready', async () => {
} }
if (line==='.kill') process.exit(); if (line==='.kill') process.exit();
if (line.startsWith('.')) return bot.command_handler.run('Console', '§a§lConsole§r', '*' + line.substring(1), 'c0ns0le-uuid'); if (line.startsWith('.')) return bot.command_handler.run('Console', '§a§lConsole§r', '*' + line.substring(1), 'c0ns0le-uuid');
bot.core.run('minecraft:tellraw @a ' + JSON.stringify(['', {'text': '[', 'color': 'dark_gray'}, {'text': `${bot.username} Console`, 'color': 'gray'}, {'text': '] ', 'color': 'dark_gray'}, {'text': 'chayapak ', 'color': 'green'}, {'text': ' ', 'color': 'dark_gray'}, chatMessage.MessageBuilder.fromString('&7' + line)])); bot.tellraw('@a', ['', {'text': '[', 'color': 'dark_gray'}, {'text': `${bot.username} Console`, 'color': 'gray'}, {'text': '] ', 'color': 'dark_gray'}, {'text': 'chayapak ', 'color': 'green'}, {'text': ' ', 'color': 'dark_gray'}, chatMessage.MessageBuilder.fromString('&7' + line)]);
} catch (e) { } catch (e) {
console.log(e); console.log(e);
} }
@ -439,7 +439,7 @@ dcclient.on('messageCreate', async (message) => {
chatMessage.MessageBuilder.fromString('&7' + message.content), chatMessage.MessageBuilder.fromString('&7' + message.content),
attachmentsComponent.length === 0 ? '' : attachmentsComponent, attachmentsComponent.length === 0 ? '' : attachmentsComponent,
]; ];
bot.core.run('minecraft:tellraw @a ' + JSON.stringify(component)); bot.tellraw('@a', component);
} catch (e) { } catch (e) {
return; return;
} }

View file

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

View file

@ -38,7 +38,7 @@ function inject(bot) {
messages.push(message); messages.push(message);
} }
for (const message of messages) bot.core.run(`minecraft:tellraw @a ${JSON.stringify(message)}`); for (const message of messages) bot.tellraw('@a', message);
} }
bot.draw = draw; bot.draw = draw;

View file

@ -58,7 +58,7 @@ function inject(bot) {
} }
bot.music.queue.shift(); bot.music.queue.shift();
if (!bot.music.queue[0]) { if (!bot.music.queue[0]) {
bot.core.run('minecraft:tellraw @a ' + JSON.stringify({text: 'Finished playing every song in the queue'})); bot.tellraw('@a', {text: 'Finished playing every song in the queue'});
bot.music.stop(); bot.music.stop();
return; return;
} }

8
plugins/tellraw.js Normal file
View file

@ -0,0 +1,8 @@
/* eslint-disable max-len */
function inject(bot) {
bot.tellraw = function(selector, message) {
bot.core.run(`minecraft:tellraw ${selector} ${typeof message === 'string' ? message : JSON.stringify(message)}`);
};
};
module.exports = {inject};