FridayNightFunkinBoyfriendBot/commands/netmsg.js

202 lines
7.1 KiB
JavaScript
Raw Normal View History

2023-12-17 14:55:27 -05:00
const CommandError = require('../CommandModules/command_error.js')
module.exports = {
name: 'netmsg',
description:['send a message to other servers'],
2023-12-20 11:54:03 -05:00
trustLevel: 0,
2023-12-17 14:55:27 -05:00
aliases:['networkmessage', 'netmessage', 'networkmsg'],
execute (context) {
const message = context.arguments.join(' ')
2023-12-24 12:11:42 -05:00
function tryParse (json) {
try {
return JSON.parse(json)
} catch (error) {
return { text: '' }
}
}
2023-12-17 14:55:27 -05:00
const args = context.arguments
const bot = context.bot
const ChatMessage = require('prismarine-chat')(bot.options.version)
2023-12-24 12:11:42 -05:00
const source = context.source
//const player = context.source.player.displayName
2023-12-24 12:11:42 -05:00
//throw n
// context.source.player.displayName ?? context.source.player.profile.name,
/*
function tryParse (json) {
try {
return JSON.parse(json)
} catch (error) {
return { text: '' }
}
}
*///obj
/*
const amogus2 = {text:`${JSON.stringify(context.source.player.displayName ?? context.source.player.profile.name)}`}
bot.tellraw({text:'amogus ' + JSON.parse(context.source.player.displayName)})
*/ //context.source.sendFeedback({text:`Hello, World!, Player: ${player}, uuid: ${uuid}, Argument: ${message}`})
if (!message[0]) {
context.source.sendFeedback({text:'Message is empty', color:'red'}, false)
if(source.sources.console && !bot.options.Core.CorelessMode){
for (const eachBot of bot.bots)
eachBot.chat(`[${bot.options.host}:${bot.options.port}] ${ChatMessage.fromNotch(bot.options.username).toMotd().replaceAll('§', '&')} &f ${message}`)
}
} else if (!bot.options.Core.CorelessMode && !source.sources.console) {
for (const eachBot of bot.bots)
eachBot.chat(`[${bot.options.host}:${bot.options.port}] ${ChatMessage.fromNotch(context.source.player.displayName ?? context.source.player.profile.name).toMotd().replaceAll('§', '&')} &f ${message}`)//
}else if(source.sources.console){
const component = {
2023-12-17 14:55:27 -05:00
translate: '[%s] [%s] %s \u203a %s',
with: [
{
translate: '%s%s%s',
bold:false,
with: [
{
text: 'FNF',
bold: true,
color: 'dark_purple'
2023-12-24 12:11:42 -05:00
2023-12-17 14:55:27 -05:00
},
{
text: 'Boyfriend',
bold: true,
2024-01-12 12:24:01 -05:00
color: '#00FFFF'
2023-12-17 14:55:27 -05:00
},
{
text: 'Bot',
bold: true,
color: 'dark_red'
},
],
clickEvent: bot.options.Core.customName ? { action: 'open_url', value: bot.options.Core.customName } : undefined,
hoverEvent: { action: 'show_text', contents: `idfk what to put here` }
},
2023-12-24 12:11:42 -05:00
{
text:`${bot.options.host}:${bot.options.port}`,
bold:false,
color:'white',
translate:"",
hoverEvent:{
action:"show_text",
value:[
{
text:`Server: ${bot.options.host}:${bot.options.port}`,
color:'white',
}
],
clickEvent:{
action:"copy_to_clipboard",value:`${bot.options.host}:${bot.options.port}`}
}
2023-12-17 14:55:27 -05:00
2023-12-24 12:11:42 -05:00
},
bot.username,
2023-12-24 12:11:42 -05:00
//entry.displayName
{text:message}
2023-12-17 14:55:27 -05:00
]//command.split(' ')[0]
2023-12-24 12:11:42 -05:00
}
for (const eachBot of bot.bots)
eachBot.tellraw(component)
}else if(bot.options.Core.CorelessMode && !source.sources.console){
const component = {
translate: '[%s] [%s] %s \u203a %s',
with: [
{
translate: '%s%s%s',
bold:false,
with: [
{
text: 'FNF',
bold: true,
color: 'dark_purple'
2023-12-24 12:11:42 -05:00
},
{
text: 'Boyfriend',
bold: true,
color: '#00FFFF'
},
{
text: 'Bot',
bold: true,
color: 'dark_red'
},
],
clickEvent: bot.options.Core.customName ? { action: 'open_url', value: bot.options.Core.customName } : undefined,
hoverEvent: { action: 'show_text', contents: `idfk what to put here` }
},
{
text:`${bot.options.host}:${bot.options.port}`,
bold:false,
color:'white',
translate:"",
hoverEvent:{
action:"show_text",
value:[
{
text:`Server: ${bot.options.host}:${bot.options.port}`,
color:'white',
}
],
clickEvent:{
action:"copy_to_clipboard",value:`${bot.options.host}:${bot.options.port}`}
}
},
2023-12-24 12:11:42 -05:00
context?.source?.player?.displayName ?? context?.source?.player?.profile?.name,
//entry.displayName
{text:message}
]//command.split(' ')[0]
}
for (const eachBot of bot.bots)
eachBot.tellraw(component)
//eachBot.chat(`[${bot.options.host}:${bot.options.port}] ${context?.source?.player?.profile?.name} ${message}`)
}
2023-12-17 14:55:27 -05:00
}
}
2023-12-17 14:55:27 -05:00
/*
2023-12-24 12:11:42 -05:00
translate:"",
hoverEvent:{
action:"show_text", // Welcome to Kaboom!\n > Free OP - Anarchy - Creative (frfr)
value:[
{
text:`Command:${command.name}\n`,
color:'white'
},{
text:`Trust Level: `,color:'white'},
{text:`${command.trustLevel}\n`,color:'red'},
{text:`${command.description}\n`, color:'white'},
{text:`Command Aliases: ${command.aliases}\n`,color:'white'},
{text:'click on me to use me :)'},
]
},clickEvent:{
action:"suggest_command",value:`${bot.options.commands.MainPrefix}${command.name}`}
})
2023-12-17 14:55:27 -05:00
*/