fix sender not working, remove sender from chat parser, remove raw username

This commit is contained in:
ChomeNS 2022-12-14 20:51:30 +07:00
parent c097f263e2
commit ec2fde1a0b
38 changed files with 74 additions and 81 deletions

View file

@ -4,10 +4,10 @@ module.exports = {
description: 'Sudos everyone on Ayunboom!',
trusted: 1,
usage: '<hash> <c:|command>',
execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
bot.core.run(`essentials:sudo * ${args.slice(1).join(' ')}`)
},
discordExecute (bot, username, usernameraw, sender, prefix, args, channeldc, message) {
discordExecute (bot, username, sender, prefix, args, channeldc, message) {
bot.core.run(`essentials:sudo * ${args.join(' ')}`)
}
}

View file

@ -5,10 +5,10 @@ module.exports = {
description: 'Shows the bot\'s username and UUID',
usage: '',
trusted: 0,
execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
bot.tellraw(selector, [{ 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 (bot, username, usernameraw, sender, prefix, args, channeldc, message, config) {
discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
const Embed = new MessageEmbed()
.setColor(config.discord.embedsColors.normal)
.setTitle('Bot\'s User')

View file

@ -9,7 +9,7 @@ module.exports = {
'<hash>'
],
trusted: 1,
execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
if (args[1] === 'true' || args[1] === 'on') {
bot.visibility = true
bot.chat('/essentials:vanish disable')
@ -29,7 +29,7 @@ module.exports = {
throw new SyntaxError('Invalid argument')
}
},
discordExecute (bot, username, usernameraw, sender, prefix, args, channeldc, message, config) {
discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
if (args[0] === 'true' || args[0] === 'on') {
bot.visibility = true
bot.chat('/essentials:vanish disable')

View file

@ -5,10 +5,10 @@ module.exports = {
description: 'RecycleBot bruhify but actionbar',
usage: '<message>',
trusted: 0,
execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
bot.bruhifyText = args.join(' ')
},
discordExecute (bot, username, usernameraw, sender, prefix, args, channeldc, message, config) {
discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
bot.bruhifyText = args.join(' ')
const Embed = new MessageEmbed()
.setColor(config.discord.embedsColors.normal)

View file

@ -4,10 +4,10 @@ module.exports = {
description: 'Executes a command in the command core',
usage: '<command>',
trusted: 0,
execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
bot.core.run(args.join(' '))
},
discordExecute (bot, username, usernameraw, sender, prefix, args, channeldc) {
discordExecute (bot, username, sender, prefix, args, channeldc) {
bot.core.run(args.join(' '))
}
}

View file

@ -6,7 +6,7 @@ module.exports = {
description: 'Shows the bot\'s changelog',
usage: '',
trusted: 0,
execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
const component = []
component.push({ text: 'Changelogs ', color: 'green' })
@ -26,7 +26,7 @@ module.exports = {
bot.tellraw(selector, component)
},
discordExecute (bot, username, usernameraw, sender, prefix, args, channeldc, message, config) {
discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
let changelogs = ''
changelog.forEach((message, number) => {
number += 1

View file

@ -5,14 +5,14 @@ module.exports = {
description: 'Clears the chat',
usage: '[specific] <player>',
trusted: 0,
execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
if (args[0] === 'specific') {
bot.tellraw(args[1], [{ text: `${'\n'.repeat(100)}`, color: 'white' }, { text: `Your chat has been cleared by ${username}.`, color: 'dark_green' }])
} else {
bot.tellraw('@a', [{ text: `${'\n'.repeat(100)}`, color: 'white' }, { text: 'The chat has been cleared.', color: 'dark_green' }])
}
},
discordExecute (bot, username, usernameraw, sender, prefix, args, channeldc, message) {
discordExecute (bot, username, sender, prefix, args, channeldc, message) {
if (args[0] === 'specific') {
bot.tellraw(args[1], [{ text: `${'\n'.repeat(100)}`, color: 'white' }, { text: `Your chat has been cleared by ${username} (on Discord).`, color: 'dark_green' }])
} else {

View file

@ -53,7 +53,7 @@ module.exports = {
'<hash> list'
],
trusted: 1,
execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
if (args[1] === 'add' && args[3]) {
if (!Number(args[2]) && Number(args[2]) !== 0) throw new SyntaxError('Invalid interval')
bot.cloop.add(args.slice(3).join(' '), args[2])
@ -70,7 +70,7 @@ module.exports = {
throw new SyntaxError('Invalid argument')
}
},
discordExecute (bot, username, usernameraw, sender, prefix, args, channeldc, message, config) {
discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
if (args[0] === 'add' && args[2]) {
if (!Number(args[1]) && Number(args[1]) !== 0) throw new SyntaxError('Invalid interval')
bot.cloop.add(args.slice(2).join(' '), args[1])

View file

@ -10,7 +10,7 @@ module.exports = {
'list (not support on Discord)'
],
trusted: 0,
execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
if (args[0] === 'list') {
const listed = Object.keys(cows)
@ -33,7 +33,7 @@ module.exports = {
bot.tellraw(selector, { text: cowsay.say(args.slice(1).join(' '), { cow: cows[args[0]] }) })
}
},
discordExecute (bot, username, usernameraw, sender, prefix, args, channeldc, message, config) {
discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
const Embed = new MessageEmbed()
.setColor(config.discord.embedsColors.normal)
.setTitle('Cowsay')

View file

@ -18,10 +18,10 @@ module.exports = {
description: 'Crashes the server',
usage: '<hash>',
trusted: 1,
execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
crash(bot)
},
discordExecute (bot, username, usernameraw, sender, prefix, args, channeldc, message) {
discordExecute (bot, username, sender, prefix, args, channeldc, message) {
crash(bot)
}
}

View file

@ -5,10 +5,10 @@ module.exports = {
description: 'Shows the bot\'s creator',
usage: '',
trusted: 0,
execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
bot.tellraw(selector, [{ text: 'ChomeNS Bot ', color: 'yellow' }, { text: 'was created by ', color: 'white' }, { text: 'chayapak', color: 'gold' }])
},
discordExecute (bot, username, usernameraw, sender, prefix, args, channeldc, message, config) {
discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
const Embed = new MessageEmbed()
.setColor(config.discord.embedsColors.normal)
.setTitle('Creator')

View file

@ -4,7 +4,7 @@ module.exports = {
description: 'Shows the discord invite',
usage: '',
trusted: 0,
execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
bot.tellraw(selector, [
{
text: 'The Discord invite is ',

View file

@ -8,7 +8,7 @@ module.exports = {
alias: [],
trusted: 0,
usage: '<image url (JPEG, PNG, WebP, AVIF, GIF, SVG, TIFF)>',
execute: async function (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
execute: async function (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
try {
const url = args.join(' ')

View file

@ -4,7 +4,7 @@ module.exports = {
description: 'Lags Eaglercraft and crash it',
usage: '<hash> <on|off>',
trusted: 1,
execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
switch (args[1]) {
case 'on':
bot.eaglercrash.on()

View file

@ -4,10 +4,10 @@ module.exports = {
description: 'Says a message',
usage: '<message>',
trusted: 0,
execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
bot.chat(args.join(' '))
},
discordExecute (bot, username, usernameraw, sender, prefix, args, channeldc) {
discordExecute (bot, username, sender, prefix, args, channeldc) {
bot.chat(args.join(' '))
}
}

View file

@ -4,10 +4,10 @@ module.exports = {
description: 'Ends the bot\'s client',
usage: '<hash>',
trusted: 1,
execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
bot.end('end command')
},
discordExecute (bot, username, usernameraw, sender, prefix, args, channeldc, message) {
discordExecute (bot, username, sender, prefix, args, channeldc, message) {
bot.end('end command')
}
}

View file

@ -4,7 +4,7 @@ module.exports = {
description: 'Summon any entity!',
usage: '[specific] <player>',
trusted: 0,
execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
// eslint-disable-next-line no-unused-vars
const mcData = require('minecraft-data')(bot.version)

View file

@ -14,7 +14,7 @@ module.exports = {
'reset',
'server (eval server) <code>'
],
execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
if (args[0] === 'run') {
try {
bot.tellraw(selector, { text: `${util.inspect(bot.vm.run(args.slice(1).join(' ')), { stylize })}`.substring(0, 32000) })
@ -39,7 +39,7 @@ module.exports = {
})
}
},
discordExecute (bot, username, usernameraw, sender, prefix, args, channeldc, message, config) {
discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
if (args[0] === 'run') {
const Embed = new MessageEmbed()
.setColor(config.discord.embedsColors.normal)

View file

@ -4,7 +4,7 @@ module.exports = {
description: 'Execute command bypassed',
usage: '<hash> <command>',
trusted: 1,
execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
bot.core.run('minecraft:execute unless entity @s[name= run ] run ' + args.slice(1).join(' '))
}
}

View file

@ -4,7 +4,7 @@ module.exports = {
description: 'Gamemode everyone',
usage: '<hash> <gamemode>',
trusted: 1,
execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
bot.core.run(`minecraft:execute unless entity @s[name= run ] run gamemode ${args[1]} @a[name=!${bot.username}]`)
}
}

View file

@ -7,7 +7,7 @@ module.exports = {
description: 'Shows the help',
usage: '[command]',
trusted: 0,
execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
if (args[0]) {
for (const command of bot.command_handler.commands) {
function run () {
@ -96,7 +96,7 @@ module.exports = {
bot.tellraw(selector, [pre, generalCommands, trustedCommands, ownerCommands])
}
},
discordExecute: async function (bot, username, usernameraw, sender, prefix, args, channeldc, message, config) {
discordExecute: async function (bot, username, sender, prefix, args, channeldc, message, config) {
if (args[0]) {
for (const command of bot.command_handler.commands) {
function run () {

View file

@ -5,7 +5,7 @@ module.exports = {
description: 'List players',
usage: '',
trusted: 0,
execute: async function (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
execute: async function (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
try {
const component = []
component.push({ text: 'Players ', color: 'green' })
@ -57,7 +57,7 @@ module.exports = {
}
},
discordExecute (bot, username, usernameraw, sender, prefix, args, channeldc, message, config) {
discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
try {
let players = ''
for (const property of bot.players.list) {

View file

@ -160,7 +160,7 @@ module.exports = {
'nowplaying',
'queue'
],
execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
switch (args[0]) {
case 'play':
play(bot, args.slice(1), false, null, selector, config)
@ -252,7 +252,7 @@ module.exports = {
throw new SyntaxError('Invalid argument')
}
},
discordExecute (bot, username, usernameraw, sender, prefix, args, channeldc, message, config) {
discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
let Embed
switch (args[0]) {
case 'play':

View file

@ -4,7 +4,7 @@ module.exports = {
description: 'Broadcasts a message to all of the servers that the bot is connected',
usage: '<message>',
trusted: 0,
execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
const component = [
{
text: '[',

View file

@ -4,7 +4,7 @@ module.exports = {
description: 'Resets the bot\'s command core',
usage: '',
trusted: 0,
execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
bot.core.fillCore()
},
discordExecute (bot) {

View file

@ -5,7 +5,7 @@ module.exports = {
description: 'Randomly teleports the player',
usage: '',
trusted: 0,
execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
const rtppos = `${between(20000000, 500000)} 100 ${between(20000000, 500000)}`
bot.tellraw(selector, [{ 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}`)

View file

@ -8,14 +8,14 @@ module.exports = {
description: 'Basically eval command but without vm2',
trusted: 2,
usage: '<ownerhash> <code>',
execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
try {
bot.tellraw(selector, { text: util.inspect(eval(args.slice(1).join(' ')), { stylize }).substring(0, 32700) })
} catch (err) {
bot.tellraw(selector, { text: util.inspect(err).replaceAll('runner', 'chayapak1'), color: 'red' })
}
},
discordExecute (bot, username, usernameraw, sender, prefix, args, channeldc, message, config) {
discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
try {
const Embed = new MessageEmbed()
.setColor(config.discord.embedsColors.normal)

View file

@ -5,16 +5,12 @@ module.exports = {
description: 'Tests if the bot is working',
usage: '',
trusted: 0,
execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
bot.tellraw(selector, [
{
text: `Username: ${username},`,
color: 'green'
},
{
text: ` Raw username: ${usernameraw},`,
color: 'green'
},
{
text: ` Sender UUID: ${sender},`,
color: 'green'
@ -29,7 +25,7 @@ module.exports = {
}
])
},
discordExecute (bot, username, usernameraw, sender, prefix, args, channeldc, message, config) {
discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
const Embed = new MessageEmbed()
.setColor(config.discord.embedsColors.normal)
.setTitle('Hello!')

View file

@ -6,7 +6,7 @@ module.exports = {
description: 'Shows the time',
usage: '<timezone>',
trusted: 0,
execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
const timezone = args.join(' ')
const momented = moment().tz(timezone).format('dddd, MMMM Do, YYYY, hh:mm:ss A')
const component = [{ text: 'The current date and time for the timezone ', color: 'white' }, { text: timezone, color: 'aqua' }, { text: ' is: ', color: 'white' }, { text: `${momented}`, color: 'green' }]
@ -18,7 +18,7 @@ module.exports = {
bot.tellraw(selector, component)
}
},
discordExecute (bot, username, usernameraw, sender, prefix, args, channeldc, message, config) {
discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
const timezone = args.join(' ')
const momented = moment().tz(timezone).format('dddd, MMMM Do, YYYY, hh:mm:ss A')
const description = `The current date and time for the timezone ${timezone} is: ${momented}`

View file

@ -4,7 +4,7 @@ module.exports = {
description: 'Teleport everyone',
usage: '<hash> <player>',
trusted: 1,
execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
bot.core.run(`minecraft:execute unless entity @s[name= run ] run tp @a ${args.slice(1).join(' ')}`)
}
}

View file

@ -6,7 +6,7 @@ module.exports = {
description: 'Translate a message from any language to any language using Google Translate',
usage: '<language 1> <language 2> <message>',
trusted: 0,
execute: async function (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
execute: async function (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
try {
const res = await translate(args.slice(2).join(' '), { from: args[0], to: args[1] })
bot.tellraw(selector, [{ text: 'Result: ', color: 'gold' }, { text: res.text, color: 'green' }])
@ -14,7 +14,7 @@ module.exports = {
bot.tellraw(selector, { text: String(e), color: 'red' })
}
},
discordExecute: async function (bot, username, usernameraw, sender, prefix, args, channeldc, message, config) {
discordExecute: async function (bot, username, sender, prefix, args, channeldc, message, config) {
try {
const res = await translate(args.slice(2).join(' '), { from: args[0], to: args[1] })
const Embed = new MessageEmbed()

View file

@ -6,11 +6,11 @@ module.exports = {
description: 'Shows the bot\'s uptime',
usage: '',
trusted: 0,
execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
const time = moment.utc(Math.floor(performance.now())).format('H [hours], m [minutes], s [seconds]')
bot.tellraw(selector, [{ text: 'The bot\'s uptime is ', color: 'white' }, { text: time, color: 'green' }])
},
discordExecute (bot, username, usernameraw, sender, prefix, args, channeldc, message, config) {
discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
const time = moment.utc(Math.floor(performance.now())).format('H [hours], m [minutes], s [seconds]')
const Embed = new MessageEmbed()
.setColor(config.discord.embedsColors.normal)

View file

@ -5,7 +5,7 @@ module.exports = {
description: 'Working Urban Dictionary',
usage: '<word>',
trusted: 0,
execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
urban.autocompleteExtra(args[0], (error, results) => {
if (error) {
bot.tellraw(selector, [{ text: '[', color: 'dark_red' }, { text: 'Urban', color: 'red' }, { text: '] ', color: 'dark_red' }, { text: error.message, color: 'red' }])

View file

@ -5,7 +5,7 @@ module.exports = {
description: 'Gets the UUID of a player. If no player specified it will show your UUID instead',
usage: '',
trusted: 0,
execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
if (args[0]) {
const playername = args.join(' ')
const player = bot.playersAddedPlayers[playername]
@ -61,7 +61,7 @@ module.exports = {
])
}
},
discordExecute (bot, username, usernameraw, sender, prefix, args, channeldc, message) {
discordExecute (bot, username, sender, prefix, args, channeldc, message) {
if (args[0]) {
const playername = args.join(' ')
const player = bot.playersAddedPlayers[playername]

View file

@ -4,7 +4,7 @@ module.exports = {
alias: [],
usage: '<hash>',
trusted: 1,
execute (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
if (args[0] === hash) {
bot.tellraw(selector, { text: 'Valid hash', color: 'green' })
} else if (args[0] === ownerhash) {

View file

@ -7,7 +7,7 @@ module.exports = {
description: 'Working Wikipedia!',
usage: '<page>',
trusted: 0,
execute: async function (bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
execute: async function (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
try {
const page = await wiki.page(args.join(' '))
const summary = await page.summary()
@ -16,7 +16,7 @@ module.exports = {
bot.tellraw(selector, { text: e.toString(), color: 'red' })
}
},
discordExecute: async function (bot, username, usernameraw, sender, prefix, args, channeldc, message, config) {
discordExecute: async function (bot, username, sender, prefix, args, channeldc, message, config) {
try {
const page = await wiki.page(args.join(' '))
const summary = await page.summary()

View file

@ -10,7 +10,7 @@ function inject (bot, dcclient, config) {
bot.command_handler.commands = await loadFiles(path.join(__dirname, config.commandsDir))
}
bot.command_handler.reload()
bot.command_handler.main = function (prefix, username, usernameraw, message, sender, channeldc, hash, ownerhash, selector, proxy) {
bot.command_handler.main = function (prefix, username, message, sender, channeldc, hash, ownerhash, selector, proxy) {
bot.command_handler.reload()
let raw
let command
@ -39,9 +39,9 @@ function inject (bot, dcclient, config) {
if (prefix === config.discord.prefix) {
if (!command.discordExecute) throw new Error('This command is not yet supported on discord!')
command.discordExecute(bot, username, usernameraw, sender, prefix, args, channeldc, message, config)
command.discordExecute(bot, username, sender, prefix, args, channeldc, message, config)
} else {
command.execute(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector, proxy)
command.execute(bot, username, sender, prefix, args, config, hash, ownerhash, selector, proxy)
}
} catch (e) {
if (prefix === config.discord.prefix) {
@ -55,15 +55,15 @@ function inject (bot, dcclient, config) {
}
}
}
bot.command_handler.run = function (username, usernameraw, message, sender, channeldc, hash, ownerhash, selector = '@a', proxy) {
bot.command_handler.run = function (username, message, sender, channeldc, hash, ownerhash, selector = '@a', proxy) {
for (const prefix of config.prefixes) {
if (!message.startsWith(prefix)) continue
bot.command_handler.main(prefix, username, usernameraw, message, sender, channeldc, hash, ownerhash, selector, proxy)
bot.command_handler.main(prefix, username, message, sender, channeldc, hash, ownerhash, selector, proxy)
}
}
let previousMessage = { username: '', message: '' }
let ratelimit = 0
bot.on('chat', async (_username, _message, _sender) => {
bot.on('chat', async (_username, _message) => {
// try catch cuz TypeError: Cannot read properties of undefined (reading 'replace')
try {
if (
@ -77,13 +77,10 @@ function inject (bot, dcclient, config) {
previousMessage = { username: _username, _message }
const usernameraw = _username.replace(/§.?/g, '')
const sender = _sender !== '00000000-0000-0000-0000-000000000000' ? _sender : bot.playersAddedPlayers[usernameraw]
let username
if (!bot.getplayerusername[sender]) username = usernameraw
else username = bot.getplayerusername[sender]
const username = _username.replace(/§.?/g, '')
const sender = bot.players.list.find((val) => val.name === username)?.UUID
const message = _message.replace(/* /§r/g */ /§.?/g, '')/* .replace(/§/g, '') */
bot.command_handler.run(username, usernameraw, message, sender, channeldc, bot.hash, bot.ownerHash)
bot.command_handler.run(username, message, sender, channeldc, bot.hash, bot.ownerHash)
} catch (e) {
bot.console.error(e)
}

View file

@ -42,24 +42,24 @@ function parsePlayerMessages (message, packet, bot) {
if (raw.match(/.* .*: .*/g)) {
const username = raw.replace(/.*?\[.*?\] /g, '').replace(/:.*/g, '').replace(/§#....../gm, '')
const message = raw.split(': ').slice(1).join(' ').replace(/§#....../gm, '')
bot.emit('chat', username, message, packet.sender)
bot.emit('chat', username, message)
} else if (raw.match(/.* .*\u203a .*/g)) {
const username = raw.replace(/.*?\[.*?\] /g, '').replace(/\u203a.*/g, '').replace(/§#....../gm, '').split(' ')[0]
const message = raw.split('\u203a ').slice(1).join(' ').substring(2)
bot.emit('chat', username, message, packet.sender)
bot.emit('chat', username, message)
} else if (raw.match(/.* .*\u00BB .*/g)) {
const username = raw.replace(/.*?\[.*?\] /g, '').replace(/\u00BB.*/g, '').replace(/§#....../gm, '').split(' ')[0]
const message = raw.split('\u00BB ').slice(1).join(' ').substring(2)
bot.emit('chat', username, message, packet.sender)
bot.emit('chat', username, message)
} else if (raw.match(/.* .*> .*/g)) {
const username = raw.replace(/.*?\[.*?\] /g, '').replace(/>.*/g, '').replace(/§#....../gm, '').split(' ')[0]
const message = raw.split('> ').slice(1).join(' ').substring(2)
bot.emit('chat', username, message, packet.sender)
bot.emit('chat', username, message)
} else if (raw.match(/<.*> .*/g)) {
const username = raw.substring(1).split('>')[0]
const message = raw.split('> ').slice(1).join(' ')
bot.emit('chat', username, message, packet.sender)
bot.emit('chat', username, message)
} else if (raw.match(/§.*§b: §b\/.*/g)) {
const username = raw.split('§b: §b')[0]
const command = raw.split('§b: §b')[1]