forked from afspiegeling/NitoriBot
Compare commits
145
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1a63807a7c | ||
|
|
9dce8155bd | ||
|
|
b0ce56d5c1 | ||
|
|
3c32ea5035 | ||
|
|
99e6a2b0e5 | ||
|
|
619f423574 | ||
|
|
f39660471d | ||
|
|
21cd397781 | ||
|
|
d5212e8e5c | ||
|
|
0f219ce5f6 | ||
|
|
24e981fc9e | ||
|
|
b3ba585f01 | ||
|
|
fde361b0fb | ||
|
|
fce93b87c8 | ||
|
|
b26ff81a1e | ||
|
|
5f2c3c533f | ||
|
|
89eacecf45 | ||
|
|
3317024e2d | ||
|
|
03514e4f57 | ||
|
|
b39148b53e | ||
|
|
288fbba036 | ||
|
|
9c230811b4 | ||
|
|
b17b363971 | ||
|
|
0661068e8f | ||
|
|
ec7e3fc5af | ||
|
|
23e738aa59 | ||
|
|
758d777439 | ||
|
|
38f91a0266 | ||
|
|
a0559985d8 | ||
|
|
48d0611194 | ||
|
|
bd60ff8325 | ||
|
|
c6c293348b | ||
|
|
5291ebced4 | ||
|
|
d2ee401e5d | ||
|
|
cf4560be24 | ||
|
|
58a020dfd4 | ||
|
|
b10e9bddf5 | ||
|
|
f788ae5df7 | ||
|
|
61c3a4adfc | ||
|
|
c059edeb4e | ||
|
|
27a6b07845 | ||
|
|
df0208d9e6 | ||
|
|
62e9b55e92 | ||
|
|
4df2a8e3f0 | ||
|
|
4aeda035f4 | ||
|
|
aee503525e | ||
|
|
83533cef46 | ||
|
|
fcbd9f983c | ||
|
|
fa15c03c6d | ||
|
|
5d5700b61d | ||
|
|
2f21f670e0 | ||
|
|
e33988d103 | ||
|
|
e7a8aa226c | ||
|
|
881c2a8d0e | ||
|
|
f9e0406143 | ||
|
|
232546aeab | ||
|
|
68e4836359 | ||
|
|
b71f4a2ab0 | ||
|
|
872cf09c6a | ||
|
|
a76e65b18f | ||
|
|
d2e2124fbe | ||
|
|
c99d3ab302 | ||
|
|
9d1d818d30 | ||
|
|
d7f216e441 | ||
|
|
127ec9eb42 | ||
|
|
346f1eb0de | ||
|
|
cee0a22f55 | ||
|
|
422db19bdb | ||
|
|
06258b3a0c | ||
|
|
dc08bcad37 | ||
|
|
28be25d2e6 | ||
|
|
c1c09466b4 | ||
|
|
c0149e36d1 | ||
|
|
a7c9a37481 | ||
|
|
8bd1e92381 | ||
|
|
7cb0524f24 | ||
|
|
a8a0b210be | ||
|
|
229f4c5664 | ||
|
|
37e19521a4 | ||
|
|
799b49569e | ||
|
|
c522270815 | ||
|
|
e92153bb81 | ||
|
|
25ee0ce1e4 | ||
|
|
b9ae2a3bf7 | ||
|
|
3a1d335753 | ||
|
|
668312461f | ||
|
|
18e2278ebd | ||
|
|
1fd50ab7fa | ||
|
|
6d43ecc249 | ||
|
|
7eadb4eccd | ||
|
|
59ab5966c4 | ||
|
|
697eed1616 | ||
|
|
ffbe6f72a8 | ||
|
|
124778fd4b | ||
|
|
e690e1006c | ||
|
|
2075f57443 | ||
|
|
2e50641297 | ||
|
|
3a5b5bdbbc | ||
|
|
122e8e7df0 | ||
|
|
23288717ab | ||
|
|
639a2b0eaa | ||
|
|
f60f5c4a15 | ||
|
|
572e09989c | ||
|
|
ad4f35bb4c | ||
|
|
e655f831d3 | ||
|
|
a140a2d12e | ||
|
|
8f61177250 | ||
|
|
ab87e748f9 | ||
|
|
ca45444dd5 | ||
|
|
ac2f59d14d | ||
|
|
ee887d5081 | ||
|
|
0a637e0c8f | ||
|
|
3344fc6e2e | ||
|
|
0aed4d7d7a | ||
|
|
831fda8607 | ||
|
|
c6f77b0ac3 | ||
|
|
e75576a488 | ||
|
|
0b264d7aaf | ||
|
|
fda85555fc | ||
|
|
6c77eb0405 | ||
|
|
86dee2fc1c | ||
|
|
0e3d337f03 | ||
|
|
ab0bee81fb | ||
|
|
43d7ab7b82 | ||
|
|
166abfcae8 | ||
|
|
9585f64ab7 | ||
|
|
648f4431d7 | ||
|
|
2a812961e1 | ||
|
|
e5741ffac1 | ||
|
|
b295cc2d0f | ||
|
|
6eeb079ced | ||
|
|
5e08befb6b | ||
|
|
088e0a4c02 | ||
|
|
2a7819cf09 | ||
|
|
2f48ffea12 | ||
|
|
2604709b53 | ||
|
|
210c69ed07 | ||
|
|
d571a1654e | ||
|
|
0b31c50a29 | ||
|
|
bca181e8ec | ||
|
|
7c85c53eb1 | ||
|
|
47ff57eeb6 | ||
|
|
ebd52989bf | ||
|
|
21040143c7 | ||
|
|
2d49c8003f |
@@ -0,0 +1,12 @@
|
||||
#
|
||||
# https://help.github.com/articles/dealing-with-line-endings/
|
||||
#
|
||||
# Linux start script should use lf
|
||||
/gradlew text eol=lf
|
||||
|
||||
# These are Windows script files and should use crlf
|
||||
*.bat text eol=crlf
|
||||
|
||||
# Binary files should be left untouched
|
||||
*.jar binary
|
||||
|
||||
+14
-1
@@ -1 +1,14 @@
|
||||
.git
|
||||
# Ignore Gradle project-specific cache directory
|
||||
.gradle
|
||||
|
||||
# Ignore Gradle build output directory
|
||||
build
|
||||
|
||||
# Ignore Kotlin plugin data
|
||||
.kotlin
|
||||
|
||||
# Ignore the bin folder vscode keeps creating
|
||||
bin
|
||||
|
||||
# Ignore the config
|
||||
config.yaml
|
||||
|
||||
Generated
+3
@@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
Generated
+9
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
Generated
+6
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<bytecodeTargetLevel target="25" />
|
||||
</component>
|
||||
</project>
|
||||
Generated
+17
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleJvm" value="25" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
</set>
|
||||
</option>
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
Generated
+7
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="KotlinJpsPluginSettings">
|
||||
<option name="externalSystemId" value="Gradle" />
|
||||
<option name="version" value="2.3.10" />
|
||||
</component>
|
||||
</project>
|
||||
Generated
+5
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_25" default="true" project-jdk-name="25 (4)" project-jdk-type="JavaSDK" />
|
||||
</project>
|
||||
Generated
+6
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,11 +0,0 @@
|
||||
# chomens-bot-js
|
||||
***(originally named chomens-bot-mc)***\
|
||||
\
|
||||
Archive of ChomeNS Bot Javascript source code.\
|
||||
\
|
||||
Some of the code are messy and hardcoded so you might wanna change some of it.\
|
||||
\
|
||||
Explore the code and see how it works!\
|
||||
Also note that the core is broken sometimes.
|
||||
|
||||
R.I.P ChomeNS Bot Javascript
|
||||
@@ -1,128 +0,0 @@
|
||||
const mc = require('minecraft-protocol')
|
||||
const { EventEmitter } = require('events')
|
||||
const { loadPlugins } = require('./util/loadPlugins')
|
||||
const util = require('node:util')
|
||||
const randomstring = require('randomstring')
|
||||
|
||||
/**
|
||||
* makes the bot
|
||||
* @param {object} server the server object used in the config
|
||||
* @param {object} config the config file
|
||||
* @param {Function} getBots get bots function in index.js
|
||||
* @param {Function} setNewBot ig real
|
||||
* @param {Class} dcclient discord client
|
||||
* @param {object} rl readline.
|
||||
* @return {object} the bot object
|
||||
*/
|
||||
async function createBot (server, config, getBots, setNewBot, dcclient, rl) {
|
||||
const bot = new EventEmitter()
|
||||
bot.options = {
|
||||
username: server.username ?? randomstring.generate(8),
|
||||
host: server.host ?? 'localhost',
|
||||
port: server.port ?? 25565,
|
||||
version: config.version,
|
||||
kaboom: server.kaboom ?? true,
|
||||
logging: server.logging ?? true,
|
||||
useChat: server.useChat ?? false,
|
||||
checkTimeoutInterval: config.timeoutInterval,
|
||||
hideErrors: true
|
||||
}
|
||||
|
||||
// among us fix for bot.options.host and bot.options.port
|
||||
bot.server = {
|
||||
host: server.host,
|
||||
port: server.port
|
||||
}
|
||||
|
||||
bot.visibility = false
|
||||
bot.getBots = getBots
|
||||
|
||||
bot.end = (reason = 'end', event) => {
|
||||
bot.emit('end', reason, event)
|
||||
bot.removeAllListeners()
|
||||
bot._client.end()
|
||||
bot._client.removeAllListeners()
|
||||
}
|
||||
|
||||
bot._client = mc.createClient(bot.options)
|
||||
|
||||
bot.setMaxListeners(Infinity)
|
||||
bot._client.setMaxListeners(Infinity)
|
||||
|
||||
bot.version = bot._client.version
|
||||
bot.write = (name, data) => bot._client.write(name, data)
|
||||
|
||||
setNewBot(bot.server.host, bot)
|
||||
|
||||
const channel = dcclient.channels.cache.get(config.discord.servers[`${bot.server.host}:${bot.server.port}`])
|
||||
|
||||
channel.send(
|
||||
`Connecting to: \`${bot.server.host}:${bot.server.port}\``
|
||||
)
|
||||
|
||||
bot._client.on('login', (data) => bot.emit('login', data))
|
||||
|
||||
bot.on('login', async function (data) {
|
||||
bot.entityId = data.entityId
|
||||
bot.uuid = bot._client.uuid
|
||||
bot.username = bot._client.username
|
||||
|
||||
channel.send(
|
||||
`Successfully logged in to: \`${bot.server.host}:${bot.server.port}\``
|
||||
)
|
||||
})
|
||||
|
||||
await loadPlugins(bot, dcclient, config, rl)
|
||||
|
||||
bot._client.on('end', (reason) => {
|
||||
bot.end(reason, 'end')
|
||||
})
|
||||
|
||||
bot.on('end', (reason, event) => {
|
||||
bot.console.info(
|
||||
`Disconnected from ${bot.server.host} (${event} event): ${util.inspect(reason)}`
|
||||
)
|
||||
channel.send(`Disconnected: \`${util.inspect(reason)}\``)
|
||||
|
||||
let timeout = config.reconnectTimeout
|
||||
|
||||
try {
|
||||
if (reason.text) {
|
||||
if (reason.text ===
|
||||
'Wait 5 seconds before connecting, thanks! :)' ||
|
||||
reason.text ===
|
||||
'You are logging in too fast, try again later.'
|
||||
) timeout = 1000 * 7
|
||||
}
|
||||
} catch (e) {
|
||||
bot.console.error(e)
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
bot.end()
|
||||
createBot(server, config, getBots, setNewBot, dcclient, rl)
|
||||
}, timeout)
|
||||
})
|
||||
|
||||
bot._client.on('keep_alive', ({ keepAliveId }) => {
|
||||
bot.write('keep_alive', { keepAliveId })
|
||||
})
|
||||
|
||||
bot._client.on('kick_disconnect', (data) => {
|
||||
const parsed = JSON.parse(data.reason)
|
||||
bot.end(parsed, 'kick_disconnect')
|
||||
})
|
||||
|
||||
bot._client.on('disconnect', (data) => {
|
||||
const parsed = JSON.parse(data.reason)
|
||||
bot.end(parsed, 'disconnect')
|
||||
})
|
||||
|
||||
bot._client.on('error', (data) => {
|
||||
bot.end(data, 'error')
|
||||
})
|
||||
|
||||
return bot
|
||||
};
|
||||
|
||||
module.exports = { createBot }
|
||||
@@ -1,18 +0,0 @@
|
||||
const { EmbedBuilder } = require('discord.js')
|
||||
module.exports = {
|
||||
name: 'botuser',
|
||||
alias: [],
|
||||
description: 'Shows the bot\'s username and UUID',
|
||||
usage: '',
|
||||
trusted: 0,
|
||||
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, sender, prefix, args, channeldc, message, config) {
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Bot\'s User')
|
||||
.setDescription(`The bot's username is: \`${bot.username}\` and the UUID is: \`${bot.uuid}\``)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
const { EmbedBuilder } = require('discord.js')
|
||||
module.exports = {
|
||||
name: 'botvisibility',
|
||||
alias: ['botvis', 'togglevis', 'togglevisibility'],
|
||||
description: 'Changes the bot\'s visibility',
|
||||
usage: [
|
||||
'<hash> <true|false>',
|
||||
'<hash> <on|off>',
|
||||
'<hash>'
|
||||
],
|
||||
trusted: 1,
|
||||
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')
|
||||
bot.tellraw(selector, [{ text: 'The bot\'s visibility is now ', color: 'white' }, { text: 'visible', color: 'green' }])
|
||||
} else if (args[1] === 'false' || args[1] === 'off') {
|
||||
bot.visibility = false
|
||||
bot.chat('/essentials:vanish enable')
|
||||
bot.tellraw(selector, [{ text: 'The bot\'s visibility is now ', color: 'white' }, { text: 'invisible', color: 'gold' }])
|
||||
} else if (!args[1]) {
|
||||
bot.visibility = !bot.visibility
|
||||
const greenOrGold = bot.visibility ? 'green' : 'gold'
|
||||
const visibleOrInvisible = bot.visibility ? 'visible' : 'invisible'
|
||||
const enableOrDisable = bot.visibility ? 'disable' : 'enable'
|
||||
bot.chat(`/essentials:vanish ${enableOrDisable}`)
|
||||
bot.tellraw(selector, [{ text: 'The bot\'s visibility is now ', color: 'white' }, { text: visibleOrInvisible, color: greenOrGold }])
|
||||
} else {
|
||||
throw new SyntaxError('Invalid argument')
|
||||
}
|
||||
},
|
||||
discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
|
||||
if (args[0] === 'true' || args[0] === 'on') {
|
||||
bot.visibility = true
|
||||
bot.chat('/essentials:vanish disable')
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Bot\'s Visibility')
|
||||
.setDescription('The bot\'s visibility is now visible')
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
} else if (args[0] === 'false' || args[0] === 'off') {
|
||||
bot.visibility = false
|
||||
bot.chat('/essentials:vanish enable')
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Bot\'s Visibility')
|
||||
.setDescription('The bot\'s visibility is now invisible')
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
} else if (!args[0]) {
|
||||
bot.visibility = !bot.visibility
|
||||
const visibleOrInvisible = bot.visibility ? 'visible' : 'invisible'
|
||||
const enableOrDisable = bot.visibility ? 'disable' : 'enable'
|
||||
bot.chat(`/essentials:vanish ${enableOrDisable}`)
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Bot\'s Visibility')
|
||||
.setDescription(`The bot's visibility is now ${visibleOrInvisible}`)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
} else {
|
||||
throw new SyntaxError('Invalid argument')
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
const { EmbedBuilder } = require('discord.js')
|
||||
module.exports = {
|
||||
name: 'bruhify',
|
||||
alias: [],
|
||||
description: 'RecycleBot bruhify but actionbar',
|
||||
usage: '<message>',
|
||||
trusted: 0,
|
||||
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
bot.bruhifyText = args.join(' ')
|
||||
},
|
||||
discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
|
||||
bot.bruhifyText = args.join(' ')
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Bruhify')
|
||||
.setDescription(`Bruhify set to: ${bot.bruhifyText}`)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
module.exports = {
|
||||
name: 'cb',
|
||||
alias: ['cmd', 'commandblock', 'run'],
|
||||
description: 'Executes a command in the command core',
|
||||
usage: '<command>',
|
||||
trusted: 0,
|
||||
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
bot.core.run(args.join(' '))
|
||||
},
|
||||
discordExecute (bot, username, sender, prefix, args, channeldc) {
|
||||
bot.core.run(args.join(' '))
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
|
||||
module.exports = {
|
||||
name: 'clearchat',
|
||||
alias: ['cc'],
|
||||
description: 'Clears the chat',
|
||||
usage: '[player]',
|
||||
trusted: 0,
|
||||
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
if (args[0]) {
|
||||
bot.tellraw(args.join(' '), [{ 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, sender, prefix, args, channeldc, message) {
|
||||
if (args[0]) {
|
||||
bot.tellraw(args.join(' '), [{ text: '\n'.repeat(100), color: 'white' }, { text: `Your chat has been cleared by ${username} (on Discord).`, color: 'dark_green' }])
|
||||
} else {
|
||||
bot.tellraw('@a', [{ text: '\n'.repeat(100), color: 'white' }, { text: 'The chat has been cleared.', color: 'dark_green' }])
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
module.exports = {
|
||||
name: 'clearchatqueue',
|
||||
description: 'Clears the bot\'s chat queue',
|
||||
alias: ['ccq'],
|
||||
usage: '',
|
||||
trusted: 0,
|
||||
execute (bot) {
|
||||
if (bot._chatQueue[0]) {
|
||||
bot.chatQueue = []
|
||||
bot._chatQueue = []
|
||||
}
|
||||
},
|
||||
discordExecute (bot) {
|
||||
if (bot._chatQueue[0]) {
|
||||
bot.chatQueue = []
|
||||
bot._chatQueue = []
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
|
||||
const { EmbedBuilder } = require('discord.js')
|
||||
|
||||
function list (bot, discord, channeldc, selector, config) {
|
||||
const message = []
|
||||
|
||||
if (discord) {
|
||||
for (const [index, { command, interval, list }] of Object.entries(bot.cloop.list)) {
|
||||
if (!list) continue
|
||||
message.push(index)
|
||||
message.push(' > ')
|
||||
message.push(`\`${command}\``)
|
||||
message.push(' - ')
|
||||
message.push(interval)
|
||||
message.push('\n')
|
||||
}
|
||||
|
||||
message.pop()
|
||||
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Cloops')
|
||||
.setDescription(message.join(''))
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
} else {
|
||||
message.push({ text: 'Cloops:', color: 'green' })
|
||||
message.push('\n')
|
||||
|
||||
for (const [index, { command, interval, list }] of Object.entries(bot.cloop.list)) {
|
||||
if (!list) continue
|
||||
message.push({ text: index, color: 'aqua' })
|
||||
message.push({ text: ' > ', color: 'gold' })
|
||||
message.push({ text: command, color: 'green' })
|
||||
message.push({ text: ' - ', color: 'gold' })
|
||||
message.push({ text: interval, color: 'green' })
|
||||
message.push('\n')
|
||||
}
|
||||
|
||||
message.pop()
|
||||
|
||||
bot.tellraw(selector, message)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
name: 'cloop',
|
||||
alias: [],
|
||||
description: 'Loop commands',
|
||||
usage: [
|
||||
'<hash> add <interval> <command>',
|
||||
'<hash> remove <index>',
|
||||
'<hash> removeall|clear',
|
||||
'<hash> list'
|
||||
],
|
||||
trusted: 1,
|
||||
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])
|
||||
bot.tellraw(selector, [{ 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 if (args[1] === 'list') {
|
||||
list(bot, false, null, selector)
|
||||
} else if (args[1] === 'remove') {
|
||||
bot.cloop.remove(args[2])
|
||||
bot.tellraw(selector, [{ text: 'Removed cloop ' }, { text: args[2], color: 'aqua' }])
|
||||
} else if (args[1] === 'removeall' || args[1] === 'clear') {
|
||||
bot.cloop.clear()
|
||||
bot.tellraw(selector, [{ text: 'Removed all looped commands', color: 'white' }])
|
||||
} else {
|
||||
throw new SyntaxError('Invalid argument')
|
||||
}
|
||||
},
|
||||
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])
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Cloop')
|
||||
.setDescription(`Added cloop \`${args.slice(2).join(' ')}\` with interval ${args[1]} to the cloops`)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
} else if (args[0] === 'list') {
|
||||
list(bot, true, channeldc, '@a', config)
|
||||
} else if (args[0] === 'remove') {
|
||||
bot.cloop.remove(args[1])
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Cloop')
|
||||
.setDescription(`Removed cloop \`${args[1]}\``)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
} else if (args[0] === 'removeall' || args[0] === 'clear') {
|
||||
bot.cloop.clear()
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Cloop')
|
||||
.setDescription('Removed all looped commands')
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
} else {
|
||||
throw new Error('Invalid argument')
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
const cowsay = require('cowsay2')
|
||||
const cows = require('cowsay2/cows')
|
||||
const { EmbedBuilder } = require('discord.js')
|
||||
module.exports = {
|
||||
name: 'cowsay',
|
||||
alias: [],
|
||||
description: 'Moo',
|
||||
usage: [
|
||||
'cow <message>',
|
||||
'list (not supported on Discord)'
|
||||
],
|
||||
trusted: 0,
|
||||
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
if (args[0] === 'list') {
|
||||
const listed = Object.keys(cows)
|
||||
|
||||
let primary = true
|
||||
const message = []
|
||||
|
||||
for (const value of listed) {
|
||||
message.push({
|
||||
text: value + ' ',
|
||||
color: (!((primary = !primary)) ? 'gold' : 'yellow'),
|
||||
clickEvent: {
|
||||
action: 'suggest_command',
|
||||
value: `${prefix}cowsay ${value} `
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
bot.tellraw(selector, message)
|
||||
} else {
|
||||
bot.tellraw(selector, { text: cowsay.say(args.slice(1).join(' '), { cow: cows[args[0]] }) })
|
||||
}
|
||||
},
|
||||
discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Cowsay')
|
||||
.setDescription(`\`\`\`\n${cowsay.say(args.slice(1).join(' '), { cow: cows[args[0]] })}\n\`\`\``)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
const { EmbedBuilder } = require('discord.js')
|
||||
module.exports = {
|
||||
name: 'creator',
|
||||
alias: [],
|
||||
description: 'Shows the bot\'s creator',
|
||||
usage: '',
|
||||
trusted: 0,
|
||||
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' }, { text: ' (', color: 'dark_gray' }, { text: 'Cloned ', color: 'blue' }, { text: 'by ', color: 'white' }, { text: 'Parker', color: 'dark_red' }, { text: '2991', color: 'black' }, { text: ')', color: 'dark_gray' }])
|
||||
},
|
||||
discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Creator')
|
||||
.setDescription('ChomeNS Bot was created by chayapak (§9Cloned by §4Parker§02991)')
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
module.exports = {
|
||||
name: 'discord',
|
||||
alias: [],
|
||||
description: 'Shows the discord invite',
|
||||
usage: '',
|
||||
trusted: 0,
|
||||
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
bot.tellraw(selector, [
|
||||
{
|
||||
text: 'The Discord invite is ',
|
||||
color: 'white'
|
||||
},
|
||||
{
|
||||
text: 'https://discord.gg/xdgCkUyaA4',
|
||||
color: 'blue',
|
||||
clickEvent: {
|
||||
action: 'open_url',
|
||||
value: 'https://discord.gg/xdgCkUyaA4'
|
||||
}
|
||||
}
|
||||
])
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
const { resize } = require('../util/image')
|
||||
const axios = require('axios')
|
||||
const sharp = require('sharp')
|
||||
|
||||
module.exports = {
|
||||
name: 'draw',
|
||||
description: 'Draws an image',
|
||||
alias: [],
|
||||
trusted: 0,
|
||||
usage: '<image url (JPEG, PNG, WebP, AVIF, GIF, SVG, TIFF)>',
|
||||
execute: async function (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
let image
|
||||
try {
|
||||
const url = args.join(' ')
|
||||
|
||||
image = await axios.get('https://http-proxy.nongsonchome.repl.co', {
|
||||
params: {
|
||||
uri: url
|
||||
},
|
||||
responseType: 'arraybuffer'
|
||||
})
|
||||
|
||||
const loaded = sharp(image.data)
|
||||
|
||||
const metadata = await loaded
|
||||
.metadata()
|
||||
|
||||
const { width, height } = resize(metadata.width, metadata.height)
|
||||
|
||||
const { data, info } = await loaded
|
||||
.resize({ fit: 'fill', kernel: 'nearest', width, height })
|
||||
.raw()
|
||||
.toBuffer({ resolveWithObject: true })
|
||||
|
||||
bot.draw(data, info)
|
||||
} catch (_err) {
|
||||
const e = _err.toString() === 'Error: Input buffer contains unsupported image format' ? image.data.toString() : _err
|
||||
bot.tellraw(selector, { text: e, color: 'red' })
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
module.exports = {
|
||||
name: 'echo',
|
||||
alias: [],
|
||||
description: 'Says a message',
|
||||
usage: '<message>',
|
||||
trusted: 0,
|
||||
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
bot.chat(args.join(' '))
|
||||
},
|
||||
discordExecute (bot, username, sender, prefix, args, channeldc) {
|
||||
bot.chat(args.join(' '))
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
module.exports = {
|
||||
name: 'end',
|
||||
alias: [],
|
||||
description: 'Ends the bot\'s client',
|
||||
usage: '<hash>',
|
||||
trusted: 1,
|
||||
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
bot.end('end command')
|
||||
},
|
||||
discordExecute (bot, username, sender, prefix, args, channeldc, message) {
|
||||
bot.end('end command')
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
const { EmbedBuilder } = require('discord.js')
|
||||
const { VM } = require('vm2')
|
||||
const axios = require('axios')
|
||||
const util = require('util')
|
||||
const { stylize } = require('../util/colors/minecraft')
|
||||
module.exports = {
|
||||
name: 'eval',
|
||||
alias: [],
|
||||
description: 'Safe eval 100% secure!!!',
|
||||
trusted: 1,
|
||||
usage: [
|
||||
'run <code>',
|
||||
'reset'
|
||||
],
|
||||
async 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) })
|
||||
} catch (err) {
|
||||
bot.tellraw(selector, { text: util.inspect(err).replaceAll('runner', 'Parker2991'), color: 'red' })
|
||||
}
|
||||
}
|
||||
if (args[0] === 'reset') {
|
||||
bot.vm = new VM(bot.vmOptions)
|
||||
}
|
||||
if (args[0] === 'server') {
|
||||
const res = await axios.post(config.eval.serverUrl, new URLSearchParams({
|
||||
html: false,
|
||||
showErrorMsg: false,
|
||||
colors: 'minecraft',
|
||||
code: args.slice(1).join(' ')
|
||||
}).toString())
|
||||
bot.tellraw(selector, { text: res.data })
|
||||
}
|
||||
},
|
||||
async discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
|
||||
if (args[0] === 'run') {
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Output')
|
||||
.setDescription(`\`\`\`${util.inspect(bot.vm.run(args.slice(1).join(' '))).substring(0, 1950)}\`\`\``)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
} else if (args[0] === 'reset') {
|
||||
bot.vm = new VM(bot.vmOptions)
|
||||
} else if (args[0] === 'server') {
|
||||
const res = await axios.post(config.eval.serverUrl, new URLSearchParams({
|
||||
html: false,
|
||||
showErrorMsg: false,
|
||||
code: args.slice(1).join(' ')
|
||||
}).toString())
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Output')
|
||||
.setDescription(`\`\`\`${res.data}\`\`\``)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
} else {
|
||||
throw new SyntaxError('Invalid argument')
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,152 +0,0 @@
|
||||
//samething here
|
||||
const { EmbedBuilder } = require('discord.js')
|
||||
module.exports = {
|
||||
name: 'help',
|
||||
alias: ['heko', 'cmds', 'commands'],
|
||||
description: 'Shows the help',
|
||||
usage: '[command]',
|
||||
trusted: 0,
|
||||
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
if (args[0]) {
|
||||
for (const command of bot.command_handler.commands) {
|
||||
function run () {
|
||||
let alias = command.name
|
||||
|
||||
if (command.alias.toString() !== '') {
|
||||
alias = command.alias.join(', ')
|
||||
}
|
||||
|
||||
const usage = []
|
||||
if (typeof command.usage === 'string') {
|
||||
usage.push({ text: `${prefix}${command.name} `, color: 'gold' })
|
||||
usage.push({ text: command.usage, color: 'aqua' })
|
||||
} else {
|
||||
for (const value of command.usage) {
|
||||
usage.push({ text: `${prefix}${command.name} `, color: 'gold' })
|
||||
usage.push({ text: value, color: 'aqua' })
|
||||
usage.push('\n')
|
||||
}
|
||||
usage.pop()
|
||||
}
|
||||
|
||||
const component = []
|
||||
component.push({ text: prefix + command.name, color: 'gold' })
|
||||
component.push({ text: ` (${alias})`, color: 'white' })
|
||||
component.push({ text: ' - ', color: 'gray' })
|
||||
component.push({ text: command.description, color: 'gray' })
|
||||
|
||||
component.push('\n')
|
||||
|
||||
component.push({ text: 'Trust level: ', color: 'green' })
|
||||
component.push({ text: command.trusted, color: 'yellow' })
|
||||
|
||||
component.push('\n')
|
||||
|
||||
component.push({ text: 'Supported on Discord: ', color: 'green' })
|
||||
component.push({ text: command.discordExecute ? 'true' : 'false', color: 'gold' })
|
||||
|
||||
component.push('\n')
|
||||
|
||||
component.push(usage)
|
||||
|
||||
bot.tellraw(selector, component)
|
||||
}
|
||||
|
||||
if (command.name === args[0]) run()
|
||||
for (const alias of command.alias) {
|
||||
if (alias === args[0]) run()
|
||||
}
|
||||
};
|
||||
} else {
|
||||
const generalCommands = []
|
||||
const trustedCommands = []
|
||||
const ownerCommands = []
|
||||
function component (command, color) {
|
||||
return {
|
||||
text: command.name + ' ',
|
||||
color,
|
||||
hoverEvent: {
|
||||
action: 'show_text',
|
||||
contents: [{
|
||||
text: 'Click here to see the information for this command',
|
||||
color: 'green'
|
||||
}]
|
||||
},
|
||||
clickEvent: {
|
||||
action: 'run_command',
|
||||
value: `${prefix}help ${command.name}`
|
||||
}
|
||||
}
|
||||
};
|
||||
for (const command of bot.command_handler.commands) {
|
||||
if (command.trusted !== 0 || command.proxy) continue
|
||||
generalCommands.push(component(command, 'green'))
|
||||
}
|
||||
for (const command of bot.command_handler.commands) {
|
||||
if (command.trusted !== 1 || command.proxy) continue
|
||||
trustedCommands.push(component(command, 'red'))
|
||||
}
|
||||
for (const command of bot.command_handler.commands) {
|
||||
if (command.trusted !== 2 || command.proxy) continue
|
||||
ownerCommands.push(component(command, 'dark_red'))
|
||||
}
|
||||
|
||||
const pre = [{ text: 'Commands ', color: 'gray' }, { text: '(', color: 'dark_gray' }, { text: 'Length: ', color: 'gray' }, { text: bot.command_handler.commands.length, color: 'green' }, { text: ') ', color: 'dark_gray' }, { text: '(', color: 'dark_gray' }, { text: 'Public ', color: 'green' }, { text: 'Trusted ', color: 'red' }, { text: 'Owner', color: 'dark_red' }, { text: ') - ', color: 'dark_gray' }]
|
||||
bot.tellraw(selector, [pre, generalCommands, trustedCommands, ownerCommands])
|
||||
}
|
||||
},
|
||||
discordExecute: async function (bot, username, sender, prefix, args, channeldc, message, config) {
|
||||
if (args[0]) {
|
||||
for (const command of bot.command_handler.commands) {
|
||||
function run () {
|
||||
let alias = command.name
|
||||
|
||||
if (command.alias.toString() !== '') {
|
||||
alias = command.alias.join(', ')
|
||||
}
|
||||
|
||||
const usage = []
|
||||
if (typeof command.usage === 'string') {
|
||||
usage.push(`${prefix}${command.name} ${command.usage}`)
|
||||
} else {
|
||||
for (const value of command.usage) {
|
||||
usage.push(`${prefix}${command.name} ${value}`)
|
||||
usage.push('\n')
|
||||
}
|
||||
usage.pop()
|
||||
}
|
||||
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle(`${prefix + command.name} (${alias}) - ${command.description}`)
|
||||
.setDescription(`Trust level: ${command.trusted}
|
||||
Supported: ${command.discordExecute ? 'true' : 'false'}
|
||||
${usage}`
|
||||
)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
}
|
||||
|
||||
if (command.name === args[0]) run()
|
||||
for (const alias of command.alias) {
|
||||
if (alias === args[0]) run()
|
||||
}
|
||||
};
|
||||
} else {
|
||||
let supportedCommands = ''
|
||||
let unsupportedCommands = ''
|
||||
for (const command of bot.command_handler.commands) {
|
||||
if (!command.discordExecute) continue
|
||||
supportedCommands += command.name + ' '
|
||||
}
|
||||
for (const command of bot.command_handler.commands) {
|
||||
if (command.discordExecute || command.proxy) continue
|
||||
unsupportedCommands += command.name + ' '
|
||||
}
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle(`Commands (Length: ${bot.command_handler.commands.length})`)
|
||||
.setDescription('**Supported Commands**\n' + supportedCommands + '\n**Unsupported Commands**\n' + unsupportedCommands)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
const { EmbedBuilder } = require('discord.js')
|
||||
module.exports = {
|
||||
name: 'list',
|
||||
alias: [],
|
||||
description: 'List players',
|
||||
usage: '',
|
||||
trusted: 0,
|
||||
execute: async function (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
try {
|
||||
const component = []
|
||||
component.push({ text: 'Players ', color: 'green' })
|
||||
component.push({ text: '(', color: 'dark_gray' })
|
||||
component.push({ text: bot.players.list.length, color: 'gray' })
|
||||
component.push({ text: ')', color: 'dark_gray' })
|
||||
component.push('\n')
|
||||
for (const property of bot.players.list) {
|
||||
// if (property.match.startsWith('@')) continue;
|
||||
component.push({
|
||||
text: property.name,
|
||||
color: 'yellow',
|
||||
clickEvent: {
|
||||
action: 'copy_to_clipboard',
|
||||
value: property.name
|
||||
},
|
||||
hoverEvent: {
|
||||
action: 'show_text',
|
||||
contents: [{
|
||||
text: 'Click here to copy the username to your clipboard',
|
||||
color: 'green'
|
||||
}]
|
||||
}
|
||||
})
|
||||
component.push({
|
||||
text: ' › ',
|
||||
color: 'dark_gray'
|
||||
})
|
||||
component.push({
|
||||
text: property.UUID,
|
||||
color: 'aqua',
|
||||
clickEvent: {
|
||||
action: 'copy_to_clipboard',
|
||||
value: property.UUID
|
||||
},
|
||||
hoverEvent: {
|
||||
action: 'show_text',
|
||||
contents: [{
|
||||
text: 'Click here to copy the UUID to your clipboard',
|
||||
color: 'green'
|
||||
}]
|
||||
}
|
||||
})
|
||||
component.push('\n')
|
||||
}
|
||||
component.pop()
|
||||
bot.tellraw(selector, component)
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
},
|
||||
discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
|
||||
try {
|
||||
let players = ''
|
||||
for (const property of bot.players.list) {
|
||||
// if (property.match.startsWith('@')) continue;
|
||||
players += `\`${property.name}\` › \`${property.UUID}\`` + '\n'
|
||||
}
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle(`Players (${bot.players.list.length})`)
|
||||
.setDescription(players.substring(0, 4096))
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,369 +0,0 @@
|
||||
/* eslint-disable no-case-declarations */
|
||||
|
||||
const fs = require('fs/promises')
|
||||
const { EmbedBuilder } = require('discord.js')
|
||||
const path = require('path')
|
||||
const getFilenameFromUrl = require('../util/getFilenameFromUrl')
|
||||
const fileExists = require('../util/file-exists')
|
||||
const fileList = require('../util/file-list')
|
||||
const axios = require('axios')
|
||||
const os = require('os')
|
||||
|
||||
let SONGS_PATH
|
||||
|
||||
if (os.hostname() === 'chomens-kubuntu') {
|
||||
SONGS_PATH = path.join(__dirname, '..', '..', 'nginx-html', 'midis')
|
||||
} else {
|
||||
SONGS_PATH = path.join(__dirname, '..', 'midis')
|
||||
}
|
||||
|
||||
let song
|
||||
|
||||
async function play (bot, values, discord, channeldc, selector, config) {
|
||||
try {
|
||||
const filepath = values.join(' ')
|
||||
|
||||
const seperator = path.sep // for hosting bot on windows
|
||||
|
||||
let absolutePath
|
||||
if (filepath.includes(seperator) && filepath !== '') {
|
||||
const pathSplitted = filepath.split(seperator)
|
||||
|
||||
const songs = await fileList(
|
||||
path.join(
|
||||
SONGS_PATH,
|
||||
pathSplitted[0]
|
||||
)
|
||||
)
|
||||
|
||||
// this part took a bunch of time to figure out, but still chomens moment!1!
|
||||
const lowerCaseFile = pathSplitted.pop().toLowerCase()
|
||||
const file = songs.filter((song) => song.toLowerCase().includes(lowerCaseFile))[0]
|
||||
|
||||
absolutePath = await resolve(path.join(pathSplitted.join(seperator), file))
|
||||
} else {
|
||||
const songs = await fileList(SONGS_PATH)
|
||||
const file = songs.filter((song) => song.toLowerCase().includes(filepath.toLowerCase()))[0]
|
||||
absolutePath = await resolve(file)
|
||||
}
|
||||
|
||||
song = await bot.music.load(await fs.readFile(absolutePath), path.basename(absolutePath))
|
||||
|
||||
if (discord) {
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Music')
|
||||
.setDescription(`Added ${song.name} to the song queue`)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
} else {
|
||||
bot.tellraw(selector, [{ text: 'Added ', color: 'white' }, { text: song.name, color: 'gold' }, { text: ' to the song queue', color: 'white' }])
|
||||
}
|
||||
|
||||
bot.music.queue.push(song)
|
||||
bot.music.play(song)
|
||||
} catch (e) {
|
||||
bot.console.error(e.stack)
|
||||
if (discord) {
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.error)
|
||||
.setTitle('Error')
|
||||
.setDescription('```SyntaxError: Invalid file```')
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
} else {
|
||||
bot.tellraw(selector, { text: 'SyntaxError: Invalid file', color: 'red' })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function playUrl (bot, values, discord, channeldc, selector, config) {
|
||||
let response
|
||||
try {
|
||||
const url = values.join(' ')
|
||||
response = await axios.get('https://http-proxy.nongsonchome.repl.co', {
|
||||
params: {
|
||||
uri: url
|
||||
},
|
||||
responseType: 'arraybuffer'
|
||||
})
|
||||
|
||||
song = await bot.music.load(response.data, getFilenameFromUrl(url))
|
||||
|
||||
if (discord) {
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Music')
|
||||
.setDescription(`Added ${song.name} to the song queue`)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
} else {
|
||||
bot.tellraw(selector, [{ text: 'Added ', color: 'white' }, { text: song.name, color: 'gold' }, { text: ' to the song queue', color: 'white' }])
|
||||
}
|
||||
|
||||
bot.music.queue.push(song)
|
||||
bot.music.play(song)
|
||||
} catch (_err) {
|
||||
const e = _err.toString().includes('Bad MIDI file. Expected \'MHdr\', got: ') ? response.data.toString() : _err
|
||||
if (discord) {
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.error)
|
||||
.setTitle('Error')
|
||||
.setDescription(`\`\`\`${e}\`\`\``)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
} else {
|
||||
bot.tellraw(selector, { text: e, color: 'red' })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function resolve (filepath) {
|
||||
if (!path.isAbsolute(filepath) && await fileExists(SONGS_PATH)) {
|
||||
return path.join(SONGS_PATH, filepath)
|
||||
}
|
||||
return filepath
|
||||
}
|
||||
|
||||
async function list (bot, discord, channeldc, prefix, selector, args, config) {
|
||||
try {
|
||||
let absolutePath
|
||||
if (args[1]) absolutePath = await resolve(path.join(SONGS_PATH, args.slice(1).join(' ')))
|
||||
else absolutePath = await resolve(SONGS_PATH)
|
||||
|
||||
if (!absolutePath.includes('midis')) throw new Error('bro trying to hack my server?!/1?!')
|
||||
|
||||
const listed = await fileList(absolutePath)
|
||||
|
||||
if (discord) {
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Songs')
|
||||
.setDescription(listed.join(', '))
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
return
|
||||
}
|
||||
|
||||
let primary = true
|
||||
const message = []
|
||||
|
||||
for (const value of listed) {
|
||||
const isFile = (await fs.lstat(path.join(absolutePath, value))).isFile()
|
||||
message.push({
|
||||
text: value + ' ',
|
||||
color: (!((primary = !primary)) ? 'gold' : 'yellow'),
|
||||
clickEvent: {
|
||||
action: 'suggest_command',
|
||||
value: `${prefix}music ${isFile ? 'play' : 'list'} ${path.join(args.slice(1).join(' '), value)}`
|
||||
},
|
||||
hoverEvent: {
|
||||
action: 'show_text',
|
||||
contents: [
|
||||
{ text: 'Name: ', color: 'white' },
|
||||
{ text: value, color: 'gold' },
|
||||
'\n',
|
||||
{ text: 'Click here to suggest the command!', color: 'green' }
|
||||
]
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
bot.tellraw(selector, message)
|
||||
} catch (e) {
|
||||
if (discord) {
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.error)
|
||||
.setTitle('Error')
|
||||
.setDescription(`\`\`\`${e.toString()}\`\`\``)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
} else {
|
||||
bot.tellraw(selector, { text: e.toString(), color: 'red' })
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
name: 'music',
|
||||
description: 'Plays music',
|
||||
alias: [],
|
||||
trusted: 0,
|
||||
usage: [
|
||||
'play <song|url>',
|
||||
'stop',
|
||||
'loop <all|current|off>',
|
||||
'list [directory]',
|
||||
'skip',
|
||||
'nowplaying',
|
||||
'queue'
|
||||
],
|
||||
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
switch (args[0]) {
|
||||
case 'play':
|
||||
case 'playurl': // deprecated
|
||||
if (args.slice(1).join(' ').startsWith('http')) {
|
||||
playUrl(bot, args.slice(1), false, null, selector, config)
|
||||
} else {
|
||||
play(bot, args.slice(1), false, null, selector, config)
|
||||
}
|
||||
break
|
||||
case 'stop':
|
||||
bot.tellraw(selector, { text: 'Cleared the song queue' })
|
||||
bot.music.stop()
|
||||
break
|
||||
case 'skip':
|
||||
try {
|
||||
bot.tellraw(selector, [{ text: 'Skipping ' }, { text: bot.music.song.name, color: 'gold' }])
|
||||
bot.music.skip()
|
||||
} catch (e) {
|
||||
throw new Error('No music is currently playing!')
|
||||
}
|
||||
break
|
||||
case 'loop':
|
||||
switch (args[1]) {
|
||||
case 'off':
|
||||
bot.music.loop = 0
|
||||
bot.tellraw(selector, [
|
||||
{
|
||||
text: 'Looping is now '
|
||||
},
|
||||
{
|
||||
text: 'disabled',
|
||||
color: 'red'
|
||||
}
|
||||
])
|
||||
break
|
||||
case 'current':
|
||||
bot.music.loop = 1
|
||||
bot.tellraw(selector, [
|
||||
{
|
||||
text: 'Now Looping '
|
||||
},
|
||||
{
|
||||
text: song.name,
|
||||
color: 'gold'
|
||||
}
|
||||
])
|
||||
break
|
||||
case 'all':
|
||||
bot.music.loop = 2
|
||||
bot.tellraw(selector, {
|
||||
text: 'Now looping every song'
|
||||
})
|
||||
break
|
||||
default:
|
||||
throw new SyntaxError('Invalid argument')
|
||||
}
|
||||
break
|
||||
case 'list':
|
||||
list(bot, false, null, prefix, selector, args, config)
|
||||
break
|
||||
case 'nowplaying':
|
||||
bot.tellraw(selector, [
|
||||
{
|
||||
text: 'Now playing '
|
||||
},
|
||||
{
|
||||
text: bot.music.song.name,
|
||||
color: 'gold'
|
||||
}
|
||||
])
|
||||
break
|
||||
case 'queue':
|
||||
const queueWithName = []
|
||||
for (const song of bot.music.queue) queueWithName.push(song.name)
|
||||
bot.tellraw(selector, [
|
||||
{
|
||||
text: 'Queue: ',
|
||||
color: 'green'
|
||||
},
|
||||
{
|
||||
text: queueWithName.join(', '),
|
||||
color: 'aqua'
|
||||
}
|
||||
])
|
||||
break
|
||||
default:
|
||||
throw new SyntaxError('Invalid argument')
|
||||
}
|
||||
},
|
||||
discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
|
||||
let Embed
|
||||
switch (args[0]) {
|
||||
case 'play':
|
||||
play(bot, args.slice(1), true, channeldc, config)
|
||||
break
|
||||
case 'playurl':
|
||||
playUrl(bot, args.slice(1), true, channeldc, config)
|
||||
break
|
||||
case 'stop':
|
||||
try {
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Stop')
|
||||
.setDescription('Cleared the song queue')
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
} catch (e) {
|
||||
return
|
||||
}
|
||||
bot.music.stop()
|
||||
break
|
||||
case 'skip':
|
||||
try {
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Skip')
|
||||
.setDescription(`Skipping ${bot.music.song.name}`)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
bot.music.skip()
|
||||
} catch (e) {
|
||||
throw new Error('No music is currently playing!')
|
||||
}
|
||||
break
|
||||
case 'loop':
|
||||
switch (args[1]) {
|
||||
case 'off':
|
||||
bot.music.loop = 0
|
||||
Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Loop')
|
||||
.setDescription('Looping is now disabled')
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
break
|
||||
case 'current':
|
||||
bot.music.loop = 1
|
||||
Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Loop')
|
||||
.setDescription(`Now looping ${song.name}`)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
break
|
||||
case 'all':
|
||||
bot.music.loop = 2
|
||||
Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Loop')
|
||||
.setDescription('Now looping every song')
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
break
|
||||
}
|
||||
break
|
||||
case 'list':
|
||||
list(bot, true, channeldc, prefix, '@a', args, config)
|
||||
break
|
||||
case 'nowplaying':
|
||||
Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Now playing')
|
||||
.setDescription(`Now playing ${bot.music.song.name}`)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
break
|
||||
case 'queue':
|
||||
const queueWithName = []
|
||||
for (const song of bot.music.queue) queueWithName.push(song.name)
|
||||
Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Queue')
|
||||
.setDescription(queueWithName.join(', '))
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
break
|
||||
default:
|
||||
throw new SyntaxError('Invalid argument')
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
module.exports = {
|
||||
name: 'netmsg',
|
||||
alias: ['networkmessage', 'irc'],
|
||||
description: 'Broadcasts a message to all of the servers that the bot is connected',
|
||||
usage: '<message>',
|
||||
trusted: 0,
|
||||
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
const message = args.join(' ')
|
||||
|
||||
if (message.toLowerCase().includes('netmsg')) return // lazy fix
|
||||
|
||||
const component = [
|
||||
{
|
||||
text: '[',
|
||||
color: 'dark_gray'
|
||||
},
|
||||
{
|
||||
text: bot.server.host === 'kitsune.icu' ? 'kit' : bot.server.host,
|
||||
color: 'gray'
|
||||
},
|
||||
bot.server.host === 'kitsune.icu'
|
||||
? {
|
||||
text: 'sune.icu',
|
||||
color: 'gray'
|
||||
}
|
||||
: '',
|
||||
{
|
||||
text: '] ',
|
||||
color: 'dark_gray'
|
||||
},
|
||||
{
|
||||
text: username,
|
||||
color: 'gray'
|
||||
},
|
||||
{
|
||||
text: ' \u203a ',
|
||||
color: 'dark_gray'
|
||||
},
|
||||
{
|
||||
text: message,
|
||||
color: 'gray'
|
||||
}
|
||||
]
|
||||
|
||||
const bots = bot.getBots()
|
||||
for (const bot of bots) {
|
||||
bot.tellraw(selector, component)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
module.exports = {
|
||||
name: 'refillcore',
|
||||
alias: ['rc'],
|
||||
description: 'Resets the bot\'s command core',
|
||||
usage: '',
|
||||
trusted: 0,
|
||||
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
bot.core.fillCore()
|
||||
},
|
||||
discordExecute (bot) {
|
||||
bot.core.fillCore()
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
const { between } = require('../util/between')
|
||||
module.exports = {
|
||||
name: 'rtp',
|
||||
alias: [],
|
||||
description: 'Randomly teleports the player',
|
||||
usage: '',
|
||||
trusted: 0,
|
||||
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
const pos = `${between(1000, 10000)} 100 ${between(1000, 10000)}`
|
||||
bot.tellraw(selector, [{ text: 'Teleporting ', color: 'white' }, { text: username, color: 'aqua' }, { text: ' to ', color: 'white' }, { text: pos, color: 'green' }, { text: '...', color: 'white' }])
|
||||
bot.core.run(`essentials:teleport ${sender} ${pos}`)
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/* eslint-disable no-eval */
|
||||
const util = require('util')
|
||||
const { stylize } = require('../util/colors/minecraft')
|
||||
const { EmbedBuilder } = require('discord.js')
|
||||
module.exports = {
|
||||
name: 'servereval',
|
||||
alias: [],
|
||||
description: 'Basically eval command but without vm2',
|
||||
trusted: 2,
|
||||
usage: '<ownerhash> <code>',
|
||||
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', 'home'), color: 'red' })
|
||||
}
|
||||
},
|
||||
discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
|
||||
try {
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Output')
|
||||
.setDescription(util.inspect(eval(args.join(' '))))
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
} catch (err) {
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.error)
|
||||
.setTitle('Error')
|
||||
.setDescription(`\`\`\`${util.inspect(err).replaceAll('runner', 'home')}\`\`\``)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
const os = require('os')
|
||||
const path = require('path')
|
||||
const fs = require('fs/promises')
|
||||
const { EmbedBuilder } = require('discord.js')
|
||||
|
||||
// should i move this to util?
|
||||
async function getCpuModelName () {
|
||||
const cpuInfo = await fs.readFile('/proc/cpuinfo')
|
||||
const lines = cpuInfo.toString().split('\n')
|
||||
// among us way of doing it
|
||||
const modelName = lines.find((line) => line.startsWith('model name')).split('\t: ')
|
||||
return modelName[1]
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
name: 'serverinfo',
|
||||
alias: [],
|
||||
description: 'Shows the info about the server that is hosting the bot',
|
||||
trusted: 0,
|
||||
usage: '',
|
||||
execute: async function (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
const component = []
|
||||
component.push({ text: 'Hostname: ', color: 'gold' })
|
||||
component.push({ text: os.hostname(), color: 'aqua' })
|
||||
component.push('\n')
|
||||
component.push({ text: 'Working directory: ', color: 'gold' })
|
||||
component.push({ text: path.join(__dirname, '..') /* if without .. it will includes the commands directory */, color: 'aqua' })
|
||||
component.push('\n')
|
||||
component.push({ text: 'OS architecture: ', color: 'gold' })
|
||||
component.push({ text: os.arch(), color: 'aqua' })
|
||||
component.push('\n')
|
||||
component.push({ text: 'OS platform: ', color: 'gold' })
|
||||
component.push({ text: os.platform(), color: 'aqua' })
|
||||
component.push('\n')
|
||||
component.push({ text: 'OS name: ', color: 'gold' })
|
||||
component.push({ text: os.version(), color: 'aqua' })
|
||||
component.push('\n')
|
||||
component.push({ text: 'CPU cores: ', color: 'gold' })
|
||||
component.push({ text: os.cpus().length, color: 'aqua' })
|
||||
component.push('\n')
|
||||
component.push({ text: 'CPU model: ', color: 'gold' })
|
||||
component.push({ text: await getCpuModelName(), color: 'aqua' })
|
||||
component.push('\n')
|
||||
component.push({ text: 'Total memory usage: ', color: 'gold' })
|
||||
component.push({ text: `${Math.floor(os.totalmem() / 1024 / 1024)} MB`, color: 'aqua' })
|
||||
component.push('\n')
|
||||
component.push({ text: 'Available memory usage: ', color: 'gold' })
|
||||
component.push({ text: `${Math.floor(os.freemem() / 1024 / 1024)} MB`, color: 'aqua' })
|
||||
bot.tellraw(selector, component)
|
||||
},
|
||||
discordExecute: async function (bot, username, sender, prefix, args, channeldc, message, config) {
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Server Info')
|
||||
.setDescription(`Hostname: \`${os.hostname()}\`
|
||||
Working directory: \`${path.join(__dirname, '..')}\`
|
||||
OS architecture: \`${os.arch()}\`
|
||||
OS platform: \`${os.platform()}\`
|
||||
OS name: \`${os.version()}\`
|
||||
CPU cores: \`${os.cpus().length}\`
|
||||
CPU model: \`${await getCpuModelName()}\`
|
||||
Total memory usage: \`${Math.floor(os.totalmem() / 1024 / 1024)} MB\`
|
||||
Available memory usage: \`${Math.floor(os.freemem() / 1024 / 1024)} MB\``)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
const { EmbedBuilder } = require('discord.js')
|
||||
module.exports = {
|
||||
name: 'test',
|
||||
alias: [],
|
||||
description: 'Tests if the bot is working',
|
||||
usage: '',
|
||||
trusted: 0,
|
||||
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
bot.tellraw(selector, [
|
||||
{
|
||||
text: `Username: ${username},`,
|
||||
color: 'green'
|
||||
},
|
||||
{
|
||||
text: ` Sender UUID: ${sender},`,
|
||||
color: 'green'
|
||||
},
|
||||
{
|
||||
text: ` Prefix: ${prefix},`,
|
||||
color: 'green'
|
||||
},
|
||||
{
|
||||
text: ` Args: ${args.join(', ').toString()}`,
|
||||
color: 'green'
|
||||
}
|
||||
])
|
||||
},
|
||||
discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Hello!')
|
||||
.setDescription('This is the first ever command to be discordified!' + '\n' + `More info: Username: ${username}, Prefix: ${prefix}, Args: ${args.join(' ')}`)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
const { EmbedBuilder } = require('discord.js')
|
||||
const moment = require('moment-timezone')
|
||||
module.exports = {
|
||||
name: 'time',
|
||||
alias: [],
|
||||
description: 'Shows the time',
|
||||
usage: '<timezone>',
|
||||
trusted: 0,
|
||||
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
const timezone = args.join(' ')
|
||||
|
||||
if (!moment.tz.names().map((zone) => zone.toLowerCase()).includes(timezone.toLowerCase())) {
|
||||
throw new SyntaxError('Invalid timezone')
|
||||
}
|
||||
|
||||
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' }]
|
||||
|
||||
bot.tellraw(selector, component)
|
||||
},
|
||||
discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
|
||||
const timezone = args.join(' ')
|
||||
|
||||
if (!moment.tz.names().map((zone) => zone.toLowerCase()).includes(timezone.toLowerCase())) {
|
||||
throw new SyntaxError('Invalid timezone')
|
||||
}
|
||||
|
||||
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}`
|
||||
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Time')
|
||||
.setDescription(description)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
const { EmbedBuilder } = require('discord.js')
|
||||
module.exports = {
|
||||
name: 'tpsbar',
|
||||
alias: ['tps'],
|
||||
description: 'Shows the server\'s TPS using Minecraft bossbar',
|
||||
usage: '<on|off>',
|
||||
trusted: 0,
|
||||
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
switch (args[0]) {
|
||||
case 'on':
|
||||
bot.tps.on()
|
||||
bot.tellraw(selector, [
|
||||
{
|
||||
text: 'TPSBar is now ',
|
||||
color: 'white'
|
||||
},
|
||||
{
|
||||
text: 'enabled',
|
||||
color: 'green'
|
||||
}
|
||||
])
|
||||
break
|
||||
case 'off':
|
||||
bot.tps.off()
|
||||
bot.tellraw(selector, [
|
||||
{
|
||||
text: 'TPSBar is now ',
|
||||
color: 'white'
|
||||
},
|
||||
{
|
||||
text: 'disabled',
|
||||
color: 'red'
|
||||
}
|
||||
])
|
||||
break
|
||||
default:
|
||||
throw new SyntaxError('Invalid argument')
|
||||
}
|
||||
},
|
||||
discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
|
||||
let Embed
|
||||
switch (args[0]) {
|
||||
case 'on':
|
||||
bot.tps.on()
|
||||
Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('TPSBar')
|
||||
.setDescription('TPSBar is now enabled')
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
break
|
||||
case 'off':
|
||||
bot.tps.off()
|
||||
Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('TPSBar')
|
||||
.setDescription('TPSBar is now disabled')
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
break
|
||||
default:
|
||||
throw new SyntaxError('Invalid argument')
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
const { EmbedBuilder } = require('discord.js')
|
||||
const { translate } = require('@vitalets/google-translate-api')
|
||||
module.exports = {
|
||||
name: 'translate',
|
||||
alias: [],
|
||||
description: 'Translate a message using Google Translate',
|
||||
usage: '<language 1> <language 2> <message>',
|
||||
trusted: 0,
|
||||
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' }])
|
||||
} catch (e) {
|
||||
bot.tellraw(selector, { text: String(e), color: 'red' })
|
||||
}
|
||||
},
|
||||
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 EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Result')
|
||||
.setDescription(res.text)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
} catch (e) {
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.error)
|
||||
.setTitle('Error')
|
||||
.setDescription(`\`\`\`${e}\`\`\``)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
const { EmbedBuilder } = require('discord.js')
|
||||
const moment = require('moment-timezone')
|
||||
module.exports = {
|
||||
name: 'uptime',
|
||||
alias: [],
|
||||
description: 'Shows the bot\'s uptime',
|
||||
usage: '',
|
||||
trusted: 0,
|
||||
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
const duration = moment.duration(Math.floor(performance.now()))
|
||||
const time = `${duration.days()} days, ${duration.hours()} hours, ${duration.minutes()} minutes, ${duration.seconds()} seconds` // moment please add duration.format()
|
||||
bot.tellraw(selector, [{ text: 'The bot\'s uptime is ', color: 'white' }, { text: time, color: 'green' }])
|
||||
},
|
||||
discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
|
||||
const duration = moment.duration(Math.floor(performance.now()))
|
||||
const time = `${duration.days()} days, ${duration.hours()} hours, ${duration.minutes()} minutes, ${duration.seconds()} seconds` // moment please add duration.format()
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Bot\'s Uptime')
|
||||
.setDescription(`The bot's uptime is ${time}`)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
const urban = require('urban-dictionary')
|
||||
module.exports = {
|
||||
name: 'urban',
|
||||
alias: [],
|
||||
description: 'Working Urban Dictionary',
|
||||
usage: '<word>',
|
||||
trusted: 0,
|
||||
async execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
try {
|
||||
const definitions = await urban.define(args.join(' '))
|
||||
|
||||
for (const definition of definitions) {
|
||||
bot.tellraw(selector, [{ text: '[', color: 'dark_red' }, { text: 'Urban', color: 'red' }, { text: '] ', color: 'dark_red' }, { text: definition.word, color: 'white' }, { text: ' - ', color: 'white' }, { text: definition.definition, color: 'white' }])
|
||||
}//
|
||||
} catch (e) {
|
||||
bot.tellraw(selector, { text: e.toString(), color: 'red' })
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
const { EmbedBuilder } = require('discord.js')
|
||||
module.exports = {
|
||||
name: 'uuid',
|
||||
alias: [],
|
||||
description: 'Gets the UUID of a player. If no player specified it will show your UUID instead',
|
||||
usage: '[player (required on Discord)]',
|
||||
trusted: 0,
|
||||
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
if (args[0]) {
|
||||
const playername = args.join(' ')
|
||||
const player = bot.players.list.find((user) => user.name === playername)
|
||||
if (!player) throw new SyntaxError('Invalid username')
|
||||
const playerUUID = player.UUID
|
||||
bot.tellraw(selector,
|
||||
[
|
||||
{
|
||||
text: `${playername}'s UUID: `,
|
||||
color: 'green'
|
||||
},
|
||||
{
|
||||
text: playerUUID,
|
||||
color: 'aqua',
|
||||
clickEvent: {
|
||||
action: 'copy_to_clipboard',
|
||||
value: playerUUID
|
||||
},
|
||||
hoverEvent: {
|
||||
action: 'show_text',
|
||||
contents: [
|
||||
{
|
||||
text: 'Click here to copy the UUID to your clipboard',
|
||||
color: 'green'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
])
|
||||
} else {
|
||||
bot.tellraw(selector,
|
||||
[
|
||||
{
|
||||
text: 'Your UUID: ',
|
||||
color: 'green'
|
||||
},
|
||||
{
|
||||
text: sender,
|
||||
color: 'aqua',
|
||||
clickEvent: {
|
||||
action: 'copy_to_clipboard',
|
||||
value: sender
|
||||
},
|
||||
hoverEvent: {
|
||||
action: 'show_text',
|
||||
contents: [
|
||||
{
|
||||
text: 'Click here to copy the uuid to your clipboard',
|
||||
color: 'green'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
])
|
||||
}
|
||||
},
|
||||
discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
|
||||
if (args[0]) {
|
||||
const playername = args.join(' ')
|
||||
const player = bot.players.list.find((user) => user.name === playername)
|
||||
if (!player) throw new SyntaxError('Invalid username')
|
||||
const playerUUID = player.UUID
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('UUID')
|
||||
.setDescription(`${playername}'s UUID: ${playerUUID}`)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
} else {
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.error)
|
||||
.setTitle('Error')
|
||||
.setDescription('No player name specified')
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
module.exports = {
|
||||
name: 'validate',
|
||||
description: 'Validates a hash',
|
||||
alias: ['checkhash'],
|
||||
usage: '<hash|ownerHash>',
|
||||
trusted: 1,
|
||||
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) {
|
||||
bot.tellraw(selector, { text: 'Valid OwnerHash', color: 'green' })
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
const wiki = require('wikipedia')
|
||||
const util = require('util')
|
||||
const { EmbedBuilder } = require('discord.js')
|
||||
module.exports = {
|
||||
name: 'wikipedia',
|
||||
alias: ['wiki'],
|
||||
description: 'Working Wikipedia!',
|
||||
usage: '<page>',
|
||||
trusted: 0,
|
||||
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()
|
||||
bot.tellraw(selector, { text: summary.extract, color: 'green' })
|
||||
} catch (e) {
|
||||
bot.tellraw(selector, { text: e.toString(), color: 'red' })
|
||||
}
|
||||
},
|
||||
discordExecute: async function (bot, username, sender, prefix, args, channeldc, message, config) {
|
||||
try {
|
||||
const page = await wiki.page(args.join(' '))
|
||||
const summary = await page.summary()
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Output')
|
||||
.setDescription(summary.extract)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
} catch (e) {
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.error)
|
||||
.setTitle('Error')
|
||||
.setDescription(`\`\`\`${util.inspect(e)}\`\`\``)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
const randomstring = require('randomstring')
|
||||
module.exports = {
|
||||
version: '1.19.2',
|
||||
prefixes: [
|
||||
'3*',
|
||||
'cbot3 ',
|
||||
'/cbot3 '
|
||||
],
|
||||
commandsDir: '../commands', // this will be used by the commands.js in the plugins folder so it needs ../
|
||||
proxy: {
|
||||
enabled: false,
|
||||
version: '1.10'
|
||||
},
|
||||
console: true,
|
||||
chat: {
|
||||
messageLength: 100
|
||||
},
|
||||
core: {
|
||||
layers: 3,
|
||||
refillInterval: 1000 * 60,
|
||||
|
||||
customName: [
|
||||
{
|
||||
text: 'https://doin-your.mom',
|
||||
color: 'dark_red'
|
||||
}
|
||||
|
||||
]
|
||||
},
|
||||
self_care: {
|
||||
prefix: true,
|
||||
op: true,
|
||||
cspy: true,
|
||||
vanish: true,
|
||||
nickname: true,
|
||||
socialspy: true,
|
||||
gamemode: true,
|
||||
mute: true,
|
||||
endCredits: true
|
||||
},
|
||||
eval: {
|
||||
serverUrl: 'http://localhost:4445/'
|
||||
},
|
||||
reconnectTimeout: 15000, // idk mabe
|
||||
timeoutInterval: 1000 * 40,
|
||||
self_care_check_interval: 2000,
|
||||
discord: {
|
||||
prefix: '!',
|
||||
servers: {
|
||||
|
||||
|
||||
'mc.opengamesllc.com:25565': '1152807355000565871',
|
||||
'kaboom.pw:25565': '1152807462836109402',
|
||||
'168.100.232.7:25565':'1155838188586283109',
|
||||
},
|
||||
embedsColors: {
|
||||
normal: '#FFFF00',
|
||||
error: '#FF0000'
|
||||
}
|
||||
},
|
||||
servers: [
|
||||
// logging means log to console
|
||||
|
||||
|
||||
{
|
||||
host: 'mc.opengamesllc.com',
|
||||
port: 25565,
|
||||
username: randomstring.generate(8),
|
||||
kaboom: true,
|
||||
logging: true,
|
||||
useChat: false
|
||||
},
|
||||
{
|
||||
host: '168.100.232.7',
|
||||
port: 25565,
|
||||
username: randomstring.generate(8),
|
||||
kaboom: true,
|
||||
logging: true,
|
||||
useChat: false
|
||||
},
|
||||
|
||||
{
|
||||
host: 'kaboom.pw',
|
||||
port: 25565,
|
||||
username: randomstring.generate(8),
|
||||
kaboom: true,
|
||||
logging: true,
|
||||
useChat: false
|
||||
},
|
||||
|
||||
]
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
module.exports = {
|
||||
version: '1.19.2',
|
||||
prefixes: [
|
||||
'default*',
|
||||
'defaultcbot ',
|
||||
'/defaultcbot '
|
||||
],
|
||||
commandsDir: '../commands', // this will be used by the commands.js in the plugins folder so it needs ../
|
||||
keys: {
|
||||
normalKey: 'normal hash key here',
|
||||
ownerHashKey: 'OwnerHash™ key here'
|
||||
},
|
||||
proxy: {
|
||||
enabled: true,
|
||||
version: '1.19.2'
|
||||
},
|
||||
console: true,
|
||||
chat: {
|
||||
messageLength: 100
|
||||
},
|
||||
core: {
|
||||
layers: 3,
|
||||
refillInterval: 1000 * 60,
|
||||
customName: [
|
||||
{
|
||||
text: 'ChomeNS ',
|
||||
color: 'yellow'
|
||||
},
|
||||
{
|
||||
text: 'Core',
|
||||
color: 'green'
|
||||
},
|
||||
{
|
||||
text: '\u2122',
|
||||
color: 'gold'
|
||||
}
|
||||
]
|
||||
},
|
||||
self_care: {
|
||||
prefix: true,
|
||||
op: true,
|
||||
cspy: true,
|
||||
vanish: true,
|
||||
nickname: true,
|
||||
socialspy: true,
|
||||
gamemode: true,
|
||||
mute: true,
|
||||
endCredits: true
|
||||
},
|
||||
eval: {
|
||||
serverUrl: 'http://localhost:4445/'
|
||||
},
|
||||
reconnectTimeout: 1000 * 2,
|
||||
timeoutInterval: 1000 * 40,
|
||||
self_care_check_interval: 2000,
|
||||
discord: {
|
||||
prefix: 'default!',
|
||||
servers: {
|
||||
'localhost:25565': '696969696969696969'
|
||||
},
|
||||
embedsColors: {
|
||||
normal: '#FFFF00',
|
||||
error: '#FF0000'
|
||||
}
|
||||
},
|
||||
servers: [
|
||||
// logging means log to console
|
||||
{
|
||||
host: 'localhost',
|
||||
port: 25565,
|
||||
username: 'ChomeNS_Bot',
|
||||
kaboom: false,
|
||||
logging: true,
|
||||
useChat: false
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
const fs = require('fs/promises')
|
||||
const fileExist = require('./util/file-exists')
|
||||
const path = require('path')
|
||||
const { createBot } = require('./bot')
|
||||
|
||||
let config
|
||||
|
||||
function load () {
|
||||
// these stuff takes time to load so i move it here
|
||||
const readline = require('node:readline')
|
||||
const { stdin: input, stdout: output } = require('node:process')
|
||||
const rl = readline.createInterface({ input, output })
|
||||
const { Client, GatewayIntentBits } = require('discord.js')
|
||||
const { MessageContent, GuildMessages, Guilds } = GatewayIntentBits
|
||||
|
||||
const dcclient = new Client({ intents: [Guilds, GuildMessages, MessageContent] })
|
||||
|
||||
let bots = []
|
||||
|
||||
dcclient.on('ready', () => {
|
||||
for (const server of config.servers) {
|
||||
const getBots = () => bots
|
||||
const setNewBot = (server, bot) => {
|
||||
bots = bots.filter((eachBot) => eachBot.server.host !== server)
|
||||
bots.push(bot)
|
||||
}
|
||||
createBot(server, config, getBots, setNewBot, dcclient, rl)
|
||||
}
|
||||
})
|
||||
require('dotenv').config()
|
||||
dcclient.login(process.env.discordtoken)
|
||||
}
|
||||
|
||||
// TODO: improve this thing
|
||||
async function checkConfig () {
|
||||
if (!await fileExist(path.join(__dirname, 'config.js'))) {
|
||||
console.error('Config file doesn\'t exist, so the default one was created')
|
||||
await fs.copyFile(path.join(__dirname, 'default.js'), path.join(__dirname, 'config.js'))
|
||||
}
|
||||
config = require('./config')
|
||||
load()
|
||||
}
|
||||
|
||||
checkConfig()
|
||||
|
||||
process.on('uncaughtException', (e) => {
|
||||
console.log('uncaught ' + e.stack)
|
||||
})
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,26 +0,0 @@
|
||||
const convert = require('color-convert')
|
||||
module.exports = {
|
||||
inject: function (bot) {
|
||||
bot.bruhifyText = ''
|
||||
let startHue = 0
|
||||
const timer = setInterval(() => {
|
||||
if (bot.bruhifyText === '') return
|
||||
|
||||
let hue = startHue
|
||||
const displayName = bot.bruhifyText
|
||||
const increment = (360 / Math.max(displayName.length, 20))
|
||||
const component = []
|
||||
for (const character of displayName) {
|
||||
const color = convert.hsv.hex(hue, 100, 100)
|
||||
component.push({ text: character, color: `#${color}` })
|
||||
hue = (hue + increment) % 360
|
||||
}
|
||||
bot.core.run(`minecraft:title @a actionbar ${JSON.stringify(component)}`)
|
||||
startHue = (startHue + increment) % 360
|
||||
}, 100)
|
||||
|
||||
bot.on('end', () => {
|
||||
clearInterval(timer)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
const { containsIllegalCharacters } = require('../util/containsIllegalCharacters')
|
||||
const { chatPacketListener, parsePlayerMessages } = require('../util/chat')
|
||||
const minecraftVersionToNumber = require('../util/minecraftVersionToNumber')
|
||||
|
||||
function inject (bot, dcclient, config) {
|
||||
bot.chatQueue = []
|
||||
bot._chatQueue = []
|
||||
|
||||
const _chatQueueInterval = setInterval(() => {
|
||||
if (bot.chatQueue.length !== 0) {
|
||||
if (containsIllegalCharacters(bot.chatQueue[0])) {
|
||||
bot.chatQueue.shift()
|
||||
return
|
||||
};
|
||||
|
||||
for (const subMessage of bot.chatQueue[0].split('\n')) {
|
||||
if (!subMessage) return
|
||||
let smallMsg
|
||||
for (let i = 0; i < subMessage.length; i += config.chat.messageLength) {
|
||||
smallMsg = subMessage.substring(i, i + config.chat.messageLength)
|
||||
bot._chatQueue.push(smallMsg)
|
||||
}
|
||||
}
|
||||
bot.chatQueue.shift()
|
||||
}
|
||||
}, 0)
|
||||
|
||||
const chatQueueInterval = setInterval(function () {
|
||||
if (bot._chatQueue.length !== 0) {
|
||||
if (bot._chatQueue[0].startsWith('/') && minecraftVersionToNumber(bot.version) >= 1.19) {
|
||||
// totallynotskidded™️ from mineflayer
|
||||
const command = bot._chatQueue[0].slice(1)
|
||||
const timestamp = BigInt(Date.now())
|
||||
bot._client.write('chat_command', {
|
||||
command,
|
||||
timestamp,
|
||||
salt: 0n,
|
||||
argumentSignatures: [],
|
||||
signedPreview: false,
|
||||
messageCount: 0,
|
||||
acknowledged: Buffer.alloc(3),
|
||||
previousMessages: []
|
||||
})
|
||||
} else {
|
||||
bot._client.chat(bot._chatQueue[0])
|
||||
}
|
||||
|
||||
bot._chatQueue.shift()
|
||||
}
|
||||
}, 450)
|
||||
|
||||
bot.chat = (message) => {
|
||||
bot.chatQueue.push(String(message))
|
||||
}
|
||||
|
||||
bot.on('end', () => {
|
||||
clearInterval(chatQueueInterval)
|
||||
clearInterval(_chatQueueInterval)
|
||||
})
|
||||
|
||||
function listener (packet) {
|
||||
chatPacketListener(
|
||||
packet,
|
||||
bot,
|
||||
minecraftVersionToNumber(bot.version) >= 1.19
|
||||
)
|
||||
}
|
||||
// TODO: support playerChat (formattedMessage doesn't exist on kaboom so prefixes like [OP] doesn't appear)
|
||||
// bot._client.on('playerChat', listener)
|
||||
bot._client.on('systemChat', listener)
|
||||
bot._client.on('chat', listener)
|
||||
|
||||
bot.on('message', (message, parsedMessage) => parsePlayerMessages(message, parsedMessage, bot))
|
||||
}
|
||||
|
||||
module.exports = { inject }
|
||||
@@ -1,25 +0,0 @@
|
||||
function inject (bot) {
|
||||
bot.cloop = {
|
||||
list: [],
|
||||
add (command, interval, list = true) {
|
||||
const id = setInterval(() => bot.core.run(command), interval)
|
||||
|
||||
const thingsToPush /* ig not the best variable name */ = { id, interval, command, list }
|
||||
bot.cloop.list.push(thingsToPush)
|
||||
|
||||
return thingsToPush
|
||||
},
|
||||
remove (item) {
|
||||
clearInterval(bot.cloop.list[item].id)
|
||||
|
||||
bot.cloop.list.splice(item, 1)
|
||||
},
|
||||
clear () {
|
||||
for (const interval of bot.cloop.list) clearInterval(interval.id)
|
||||
|
||||
bot.cloop.list = []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { inject }
|
||||
@@ -1,123 +0,0 @@
|
||||
|
||||
const path = require('path')
|
||||
const { EmbedBuilder } = require('discord.js')
|
||||
function inject (bot, dcclient, config) {
|
||||
const loadFiles = require('../util/load_files')
|
||||
const channeldc = dcclient.channels.cache.get(config.discord.servers[`${bot.server.host}:${bot.server.port}`])
|
||||
bot.command_handler = {}
|
||||
bot.command_handler.commands = {}
|
||||
bot.command_handler.reload = async function () {
|
||||
bot.command_handler.commands = await loadFiles(path.join(__dirname, config.commandsDir))
|
||||
}
|
||||
bot.command_handler.reload()
|
||||
bot.command_handler.main = function (prefix, username, message, sender, channeldc, hash, ownerhash, selector) {
|
||||
bot.command_handler.reload()
|
||||
let raw
|
||||
let command
|
||||
const discord = !!message.content
|
||||
|
||||
discord
|
||||
? raw = message.content.substring(prefix.length)
|
||||
: raw = message.substring(prefix.length)
|
||||
|
||||
const [commandName, ...args] = raw.split(' ')
|
||||
command = bot.command_handler.commands.find((command) => command.name === commandName.toLowerCase())
|
||||
|
||||
try {
|
||||
const alias = bot.command_handler.commands.find((command) => command.alias.includes(commandName.toLowerCase()))
|
||||
if (alias) command = alias
|
||||
|
||||
if (prefix === '3*' && message.endsWith('3*') && message !== '3*') return
|
||||
if (!command) throw new Error(`Unknown command: "${commandName}"`)
|
||||
|
||||
if (command.trusted > 0) {
|
||||
const discordRoles = message.member?.roles?.cache // do i need the "?"s ?
|
||||
|
||||
// TODO: Don't hardcode the roles
|
||||
|
||||
// trusted and host
|
||||
// discord
|
||||
if (
|
||||
discord &&
|
||||
command.trusted === 1 &&
|
||||
!discordRoles.some((role) => role.name === 'Trusted' || role.name === 'chomens' || role.name === 'FNFBoyfriendBot Owner')
|
||||
) throw new Error('You\'re not in the trusted role!')
|
||||
// in game
|
||||
if (
|
||||
!discord &&
|
||||
command.trusted === 1 &&
|
||||
args[0] !== hash &&
|
||||
args[0] !== ownerhash
|
||||
|
||||
) throw new Error('Invalid hash')
|
||||
|
||||
// FNFBoyfriendBot Owner
|
||||
// || role.name === 'Host'
|
||||
if (
|
||||
discord &&
|
||||
command.trusted === 2 &&
|
||||
!discordRoles.some((role) => role.name === 'chomens' || role.name === 'FNFBoyfriendBot Owner')
|
||||
|
||||
) throw new Error('You\'re not in the host role!')
|
||||
// in game
|
||||
if (
|
||||
!discord &&
|
||||
command.trusted === 2 &&
|
||||
args[0] !== ownerhash
|
||||
) throw new Error('Invalid OwnerHash')
|
||||
}
|
||||
|
||||
if (prefix === config.discord.prefix) {
|
||||
if (!command.discordExecute) throw new Error('This command is not yet supported on Discord!')
|
||||
command.discordExecute(bot, username, sender, prefix, args, channeldc, message, config)
|
||||
} else {
|
||||
command.execute(bot, username, sender, prefix, args, config, hash, ownerhash, selector)
|
||||
}
|
||||
} catch (e) {
|
||||
if (prefix === config.discord.prefix) {
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.error)
|
||||
.setTitle('Error')
|
||||
.setDescription(`\`\`\`${e}\`\`\``)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
} else {
|
||||
bot.tellraw(selector, { text: String(e), color: 'red' })
|
||||
}
|
||||
}
|
||||
}
|
||||
bot.command_handler.run = function (username, message, sender, channeldc, hash, ownerhash, selector = '@a') {
|
||||
for (const prefix of config.prefixes) {
|
||||
if (!message.startsWith(prefix)) continue
|
||||
bot.command_handler.main(prefix, username, message, sender, channeldc, hash, ownerhash, selector)
|
||||
}
|
||||
}
|
||||
bot.on('chat', async (_username, _message) => {
|
||||
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, message, sender, channeldc, bot.hash, bot.ownerHash)
|
||||
})
|
||||
bot.on('cspy', async function (_username, _message) {
|
||||
const username = _username.replace(/§.?/g, '')
|
||||
const message = _message.replace(/§.?/g, '')
|
||||
const sender = bot.players.list.find((val) => val.name === username)?.UUID
|
||||
bot.command_handler.run(username, message, sender, channeldc, bot.hash, bot.ownerHash, username)
|
||||
})
|
||||
function handleDiscordMessages (message) {
|
||||
try {
|
||||
// ignores the message that comes from the bot itself
|
||||
if (message.author.id === dcclient.user.id) return
|
||||
// only receive messages in SPECIFIC channel
|
||||
if (message.channel.id !== channeldc.id) return
|
||||
if (!message.content.startsWith(config.discord.prefix)) return
|
||||
bot.command_handler.main(config.discord.prefix, message.member.displayName, message, 'no sender for discord', channeldc)
|
||||
} catch (e) {
|
||||
bot.console.error(e.stack)
|
||||
};
|
||||
}
|
||||
bot.on('end', () => {
|
||||
dcclient.off('messageCreate', handleDiscordMessages)
|
||||
})
|
||||
dcclient.on('messageCreate', handleDiscordMessages)
|
||||
};
|
||||
module.exports = { inject }
|
||||
@@ -1,107 +0,0 @@
|
||||
const moment = require('moment-timezone')
|
||||
|
||||
function inject (bot, _dcclient, config, rl) {
|
||||
// readline > fix on log
|
||||
function log (...args) {
|
||||
rl.output.write('\x1b[2K\r')
|
||||
console.log(args.toString())
|
||||
rl._refreshLine()
|
||||
};
|
||||
|
||||
const chatMessage = require('prismarine-chat')(bot.version)
|
||||
|
||||
function prefix (prefix, _message) {
|
||||
const message = `[${moment().format('DD/MM/YY HH:mm:ss')} ${prefix}§r] [${bot.server.host}] `
|
||||
const component = chatMessage.MessageBuilder.fromString(message).toJSON()
|
||||
return chatMessage.fromNotch(component).toAnsi() + _message
|
||||
}
|
||||
const originalConsole = console
|
||||
this.log = (...args) => {
|
||||
rl.output.write('\x1b[2K\r')
|
||||
originalConsole.log(args.toString())
|
||||
rl._refreshLine()
|
||||
}
|
||||
bot.console = {}
|
||||
bot.console.host = 'all'
|
||||
bot.console.log = function (message) {
|
||||
log(prefix('&6LOG', message))
|
||||
}
|
||||
bot.console.info = function (message) {
|
||||
log(prefix('&aINFO', message))
|
||||
}
|
||||
bot.console.error = function (error) {
|
||||
log(prefix('&cERROR', typeof error === 'string' ? error : error.stack))
|
||||
}
|
||||
|
||||
// previous message is op feature to have in console :)
|
||||
let previousMessage = ''
|
||||
bot.on('message', (message) => {
|
||||
if (!bot.options.logging) return
|
||||
if (previousMessage === message.toString()) return
|
||||
previousMessage = message.toString()
|
||||
bot.console.log(message.toAnsi())
|
||||
})
|
||||
|
||||
if (!config.console) return
|
||||
|
||||
function handleLine (line) {
|
||||
try {
|
||||
if (line.toLowerCase() === '' ||
|
||||
line.toLowerCase().startsWith(' ')) return
|
||||
|
||||
if (line.startsWith('.csvr ')) {
|
||||
const host = line.substring(6)
|
||||
for (const eachBot of bot.getBots()) eachBot.console.host = host
|
||||
bot.console.info(`Host set to: ${host}`)
|
||||
return
|
||||
}
|
||||
|
||||
if (bot.server.host !== bot.console.host && bot.console.host !== 'all') return
|
||||
if (line === '.kill') process.exit()
|
||||
|
||||
if (line.startsWith('.')) {
|
||||
return bot.command_handler.run(
|
||||
bot.username,
|
||||
config.prefixes[0] + line.substring(1),
|
||||
bot.uuid,
|
||||
null,
|
||||
'h',
|
||||
'o'
|
||||
)
|
||||
}
|
||||
bot.tellraw('@a', [
|
||||
{
|
||||
text: '[',
|
||||
color: 'dark_gray'
|
||||
},
|
||||
{
|
||||
text: `${bot.username} Console`,
|
||||
color: 'gray'
|
||||
},
|
||||
{
|
||||
text: '] ',
|
||||
color: 'dark_gray'
|
||||
},
|
||||
{
|
||||
text: 'chayapak ',
|
||||
color: 'green'
|
||||
},
|
||||
{
|
||||
text: '\u203a ',
|
||||
color: 'dark_gray'
|
||||
},
|
||||
chatMessage.MessageBuilder.fromString('&7' + line)
|
||||
])
|
||||
} catch (e) {
|
||||
bot.console.error(e)
|
||||
}
|
||||
}
|
||||
|
||||
rl.on('line', handleLine)
|
||||
|
||||
bot.on('end', () => {
|
||||
rl.off('line', handleLine)
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = { inject }
|
||||
@@ -1,115 +0,0 @@
|
||||
const nbt = require('prismarine-nbt');
|
||||
const Vec3 = require('vec3');
|
||||
|
||||
const relativePosition = new Vec3(0, 0, 0);
|
||||
|
||||
function inject(bot, dcclient, config) {
|
||||
const mcData = require('minecraft-data')(bot.version);
|
||||
const impulseMode = !bot.options.kaboom;
|
||||
const core = {
|
||||
// Initialize the height to 0
|
||||
height: 0,
|
||||
run(command) {
|
||||
try {
|
||||
// Check if height has reached the maximum configured height
|
||||
if (core.height >= config.core.layers) {
|
||||
// Reset the height to 0 and the relativePosition to (0, 0, 0)
|
||||
core.height = 0;
|
||||
relativePosition.x = 0;
|
||||
relativePosition.y = 0;
|
||||
relativePosition.z = 0;
|
||||
}
|
||||
|
||||
const location = {
|
||||
x: core.start.x + relativePosition.x,
|
||||
y: core.start.y + core.height, // Use the core height
|
||||
z: core.start.z + relativePosition.z
|
||||
};
|
||||
|
||||
if (impulseMode) bot.write('update_command_block', { location, command: '', mode: 0, flags: 0 });
|
||||
bot.write('update_command_block', {
|
||||
location,
|
||||
command: String(command).substring(0, 32767),
|
||||
mode: impulseMode ? 2 : 1,
|
||||
flags: 0b101
|
||||
});
|
||||
|
||||
// Increment the relativePosition.x and update the height accordingly
|
||||
relativePosition.x++;
|
||||
if (relativePosition.x >= 16) {
|
||||
relativePosition.x = 0;
|
||||
relativePosition.z++;
|
||||
if (relativePosition.z >= 16) {
|
||||
relativePosition.z = 0;
|
||||
core.height++; // Increment the height
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
bot.console.error(e);
|
||||
}
|
||||
},
|
||||
fillCore() {
|
||||
core.start = new Vec3(
|
||||
Math.floor(bot.position.x / 16) * 16,
|
||||
0 /* bot.position.y */,
|
||||
Math.floor(bot.position.z / 16) * 16
|
||||
).floor();
|
||||
core.end = core.start.clone().translate(16, config.core.layers, 16).subtract(new Vec3(1, 1, 1));
|
||||
|
||||
placeCore();
|
||||
}
|
||||
};
|
||||
|
||||
bot.core = core;
|
||||
|
||||
function placeCore() {
|
||||
try {
|
||||
const fillCommand = `minecraft:fill ${core.start.x} ${core.start.y} ${core.start.z} ${core.end.x} ${core.end.y} ${core.end.z} repeating_command_block{CustomName:'${JSON.stringify(config.core.customName)}'}`;
|
||||
const location = { x: Math.floor(bot.position.x), y: Math.floor(bot.position.y) - 1, z: Math.floor(bot.position.z) };
|
||||
|
||||
bot.write('set_creative_slot', {
|
||||
slot: 36,
|
||||
item: {
|
||||
present: true,
|
||||
itemId: impulseMode ? mcData.itemsByName.command_block.id : mcData.itemsByName.repeating_command_block.id,
|
||||
itemCount: 64,
|
||||
nbtData: nbt.comp({
|
||||
BlockEntityTag: nbt.comp({
|
||||
Command: nbt.string(fillCommand),
|
||||
auto: nbt.byte(1),
|
||||
TrackOutput: nbt.byte(0)
|
||||
})
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
bot.write('block_dig', {
|
||||
status: 0,
|
||||
location,
|
||||
face: 1
|
||||
});
|
||||
|
||||
bot.write('block_place', {
|
||||
location,
|
||||
direction: 1,
|
||||
hand: 0,
|
||||
cursorX: 0.5,
|
||||
cursorY: 0.5,
|
||||
cursorZ: 0.5,
|
||||
insideBlock: false
|
||||
});
|
||||
} catch (e) {
|
||||
bot.console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
bot.on('position', bot.core.fillCore);
|
||||
|
||||
const interval = setInterval(bot.core.fillCore, config.core.refillInterval);
|
||||
|
||||
bot.on('end', () => {
|
||||
clearInterval(interval);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = { inject };
|
||||
@@ -1,178 +0,0 @@
|
||||
|
||||
const { escapeMarkdown } = require('../util/escapeMarkdown')
|
||||
async function inject (bot, dcclient, config) {
|
||||
const chatMessage = require('prismarine-chat')(bot.version)
|
||||
const channel = dcclient.channels.cache.get(config.discord.servers[`${bot.server.host}:${bot.server.port}`])
|
||||
|
||||
let queue = ''
|
||||
const queueInterval = setInterval(() => {
|
||||
if (queue === '') return
|
||||
|
||||
channel.send({
|
||||
content: '```ansi\n' + queue.substring(0, 1986) + '\n```',
|
||||
allowedMentions: {
|
||||
parse: []
|
||||
}
|
||||
})
|
||||
queue = ''
|
||||
}, 1000)
|
||||
|
||||
bot.on('message', (message) => {
|
||||
const cleanMessage = escapeMarkdown(message.toAnsi(), true)
|
||||
const discordMsg = cleanMessage
|
||||
.replaceAll('@', '@\u200b')
|
||||
.replaceAll('http', 'http\u200b')
|
||||
.replaceAll('\u001b[9', '\u001b[3')
|
||||
if (message.toMotd().startsWith('§8[§eChomeNS §9Discord§8] §c')) return
|
||||
queue += '\n' + discordMsg
|
||||
})
|
||||
|
||||
// handle discord messages!!!
|
||||
async function handleDiscordMessages (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) {
|
||||
for (const __attachment of message.attachments) {
|
||||
const _attachment = [...__attachment]
|
||||
const attachment = _attachment[1] // BEST WAY REAL!?/1?!
|
||||
attachmentsComponent.push({
|
||||
text: message.content === '' ? '[Attachment]' : ' [Attachment]', // may not be the best fix
|
||||
color: 'green',
|
||||
clickEvent: {
|
||||
action: 'open_url',
|
||||
value: attachment.proxyURL
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
const component = [
|
||||
{ text: '[', color: 'dark_gray', bold:false, },
|
||||
{
|
||||
text: 'FNF',
|
||||
color: 'dark_purple',
|
||||
bold:false,
|
||||
clickEvent: {
|
||||
action: 'open_url',
|
||||
value: 'https://discord.gg/GCKtG4erux'
|
||||
}
|
||||
},
|
||||
{
|
||||
text: 'Boyfriend',
|
||||
color: 'aqua',
|
||||
bold:false,
|
||||
clickEvent: {
|
||||
action: 'open_url',
|
||||
value: 'https://discord.gg/GCKtG4erux'
|
||||
}
|
||||
},
|
||||
{
|
||||
text: 'Bot',
|
||||
color: 'dark_red',
|
||||
bold: false,
|
||||
clickEvent: {
|
||||
action: 'open_url',
|
||||
value: 'https://discord.gg/GCKtG4erux'
|
||||
}
|
||||
},
|
||||
{
|
||||
text: ' Discord',
|
||||
color: 'blue',
|
||||
bold: false,
|
||||
clickEvent: {
|
||||
action: 'open_url',
|
||||
value: 'https://discord.gg/GCKtG4erux'
|
||||
}
|
||||
},
|
||||
{
|
||||
text: ']',
|
||||
color: 'dark_gray',
|
||||
bold: false,
|
||||
clickEvent: {
|
||||
action: 'open_url',
|
||||
value: 'https://discord.gg/GCKtG4erux'
|
||||
}
|
||||
},
|
||||
{
|
||||
text: '[',
|
||||
color: 'dark_gray',
|
||||
bold: false,
|
||||
clickEvent: {
|
||||
action: 'open_url',
|
||||
value: 'https://discord.gg/GCKtG4erux'
|
||||
}
|
||||
},
|
||||
{
|
||||
text: 'ChomeNS js ',
|
||||
color: 'yellow',
|
||||
bold:false,
|
||||
clickEvent: {
|
||||
action: 'open_url',
|
||||
value: 'https://discord.gg/GCKtG4erux'
|
||||
}
|
||||
},
|
||||
{
|
||||
text: 'Bot',
|
||||
color: 'yellow',
|
||||
bold:false,
|
||||
clickEvent: {
|
||||
action: 'open_url',
|
||||
value: 'https://discord.gg/GCKtG4erux'
|
||||
}
|
||||
},
|
||||
{ text: '] ', color: 'dark_gray', bold:false, },
|
||||
{
|
||||
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) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
bot.on('end', () => {
|
||||
clearInterval(queueInterval)
|
||||
dcclient.off('messageCreate', handleDiscordMessages)
|
||||
})
|
||||
|
||||
dcclient.on('messageCreate', handleDiscordMessages)
|
||||
};
|
||||
|
||||
module.exports = { inject }
|
||||
@@ -1,53 +0,0 @@
|
||||
const convert = require('color-convert')
|
||||
|
||||
// eslint-disable-next-line require-jsdoc
|
||||
function inject (bot) {
|
||||
/**
|
||||
* draw which is totallynotskidded from ybot
|
||||
* @param {buffer} data data buffer
|
||||
* @param {*} info idk bout this
|
||||
* @param {object} prefix prefix in the output compoenent
|
||||
*/
|
||||
function draw (data, info, prefix = {}) {
|
||||
const pixels = []
|
||||
|
||||
// Data Buffer -> RGB Array
|
||||
for (let i = 0; i < data.length; i += info.channels) {
|
||||
pixels.push([
|
||||
data[i + 0],
|
||||
data[i + 1],
|
||||
data[i + 2]
|
||||
])
|
||||
}
|
||||
|
||||
const rows = []
|
||||
|
||||
// RGB Array -> Rows Array
|
||||
for (let i = 0; i < pixels.length; i += info.width) {
|
||||
const row = pixels.slice(i, i + info.width)
|
||||
|
||||
rows.push(row)
|
||||
}
|
||||
|
||||
const messages = []
|
||||
|
||||
for (const row of rows) {
|
||||
const message = [{ ...prefix, text: '' }]
|
||||
|
||||
for (const rgb of row) {
|
||||
message.push({
|
||||
text: '⎮',
|
||||
color: `#${convert.rgb.hex(rgb)}`
|
||||
})
|
||||
}
|
||||
|
||||
messages.push(message)
|
||||
}
|
||||
|
||||
for (const message of messages) bot.tellraw('@a', message)
|
||||
}
|
||||
|
||||
bot.draw = draw
|
||||
}
|
||||
|
||||
module.exports = { inject }
|
||||
@@ -1,18 +0,0 @@
|
||||
const crypto = require('crypto')
|
||||
|
||||
module.exports = {
|
||||
inject: function (bot, dcclient, config) {
|
||||
bot.hash = ''
|
||||
|
||||
const interval = setInterval(() => {
|
||||
const normalKey = process.env['chomensjs_key']
|
||||
const ownerHashKey = process.env['chomensjs_owner_key']
|
||||
bot.hash = crypto.createHash('sha256').update(Math.floor(Date.now() / 10000) + normalKey).digest('hex').substring(0, 16)
|
||||
bot.ownerHash = crypto.createHash('sha256').update(Math.floor(Date.now() / 10000) + ownerHashKey).digest('hex').substring(0, 16)
|
||||
}, 2000)
|
||||
bot.on('end', () => {
|
||||
clearInterval(interval)
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,190 +0,0 @@
|
||||
const path = require('path')
|
||||
const { Midi } = require('@tonejs/midi')
|
||||
const { convertMidi } = require('../util/midi_converter')
|
||||
const convertNBS = require('../util/nbs_converter')
|
||||
const parseTXTSong = require('../util/txt_song_parser')
|
||||
|
||||
const soundNames = {
|
||||
harp: 'minecraft:block.note_block.harp',
|
||||
basedrum: 'minecraft:block.note_block.basedrum',
|
||||
snare: 'minecraft:block.note_block.snare',
|
||||
hat: 'minecraft:block.note_block.hat',
|
||||
bass: 'minecraft:block.note_block.bass',
|
||||
flute: 'minecraft:block.note_block.flute',
|
||||
bell: 'minecraft:block.note_block.bell',
|
||||
guitar: 'minecraft:block.note_block.guitar',
|
||||
chime: 'minecraft:block.note_block.chime',
|
||||
xylophone: 'minecraft:block.note_block.xylophone',
|
||||
iron_xylophone: 'minecraft:block.note_block.iron_xylophone',
|
||||
cow_bell: 'minecraft:block.note_block.cow_bell',
|
||||
didgeridoo: 'minecraft:block.note_block.didgeridoo',
|
||||
bit: 'minecraft:block.note_block.bit',
|
||||
banjo: 'minecraft:block.note_block.banjo',
|
||||
pling: 'minecraft:block.note_block.pling'
|
||||
}
|
||||
|
||||
function inject (bot) {
|
||||
bot.music = function () {}
|
||||
bot.music.song = null
|
||||
bot.music.loop = 0
|
||||
bot.music.queue = []
|
||||
let time = 0
|
||||
let startTime = 0
|
||||
let noteIndex = 0
|
||||
bot.music.skip = function () {
|
||||
if (bot.music.loop === 2) {
|
||||
bot.music.queue.push(bot.music.queue.shift())
|
||||
bot.music.play(bot.music.queue[0])
|
||||
} else {
|
||||
bot.music.queue.shift()
|
||||
}
|
||||
resetTime()
|
||||
}
|
||||
|
||||
const bossbarName = 'chomens_bot:music' // maybe make this in the config?
|
||||
|
||||
const selector = '@a[tag=!nomusic,tag=!chomens_bot_nomusic]'
|
||||
|
||||
const interval = setInterval(async () => {
|
||||
if (!bot.music.queue.length) return
|
||||
bot.music.song = bot.music.queue[0]
|
||||
time = Date.now() - startTime
|
||||
/*
|
||||
// bot.core.run('minecraft:title @a[tag=!nomusic] actionbar ' + JSON.stringify(toComponent()))
|
||||
|
||||
// is spamming commands in core as a self care a good idea?
|
||||
// btw this is totallynotskidded™️ from my song bot except the bossbarName (above)
|
||||
bot.core.run(`minecraft:bossbar add ${bossbarName} ""`) // is setting the name to "" as a placeholder a good idea?
|
||||
bot.core.run(`minecraft:bossbar set ${bossbarName} players ${selector}`)
|
||||
bot.core.run(`minecraft:bossbar set ${bossbarName} name ${JSON.stringify(toComponent())}`)
|
||||
bot.core.run(`minecraft:bossbar set ${bossbarName} color yellow`) // should i use purple lol
|
||||
bot.core.run(`minecraft:bossbar set ${bossbarName} visible true`)
|
||||
bot.core.run(`minecraft:bossbar set ${bossbarName} value ${Math.floor(time)}`)
|
||||
bot.core.run(`minecraft:bossbar set ${bossbarName} max ${bot.music.song.length}`)
|
||||
*/
|
||||
bot.core.run(`title @a actionbar ${JSON.stringify(toComponent())}`)
|
||||
|
||||
while (bot.music.song?.notes[noteIndex]?.time <= time) {
|
||||
const note = bot.music.song.notes[noteIndex]
|
||||
const floatingPitch = 2 ** ((note.pitch - 12) / 12.0)
|
||||
bot.core.run(`minecraft:execute as ${selector} at @s run playsound ${soundNames[note.instrument]} record @s ~ ~ ~ ${note.volume} ${floatingPitch}`)
|
||||
noteIndex++
|
||||
if (noteIndex >= bot.music.song.notes.length) {
|
||||
bot.tellraw('@a', [
|
||||
{
|
||||
text: 'Finished playing '
|
||||
},
|
||||
{
|
||||
text: bot.music.song.name,
|
||||
color: 'gold'
|
||||
}
|
||||
])
|
||||
|
||||
if (bot.music.loop === 1) {
|
||||
resetTime()
|
||||
return
|
||||
}
|
||||
if (bot.music.loop === 2) {
|
||||
resetTime()
|
||||
bot.music.queue.push(bot.music.queue.shift())
|
||||
bot.music.play(bot.music.queue[0])
|
||||
return
|
||||
}
|
||||
bot.music.queue.shift()
|
||||
bot.music.song = null // useless?
|
||||
if (!bot.music.queue[0]) {
|
||||
bot.music.stop()
|
||||
return
|
||||
}
|
||||
if (bot.music.queue[0].notes.length > 0) {
|
||||
if (bot.music.queue.length !== 1) resetTime()
|
||||
bot.music.play(bot.music.queue[0])
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 50)
|
||||
|
||||
bot.on('end', () => {
|
||||
clearInterval(interval)
|
||||
})
|
||||
|
||||
bot.music.load = async function (buffer, fallbackName = '[unknown]') {
|
||||
let song
|
||||
switch (path.extname(fallbackName)) {
|
||||
case '.nbs':
|
||||
song = convertNBS(buffer)
|
||||
if (song.name === '') song.name = fallbackName
|
||||
break
|
||||
case '.txt':
|
||||
song = parseTXTSong(buffer.toString())
|
||||
song.name = fallbackName
|
||||
break
|
||||
default:
|
||||
// TODO: use worker_threads so the entire bot doesn't freeze (for example parsing we are number 1 black midi)
|
||||
|
||||
// eslint-disable-next-line no-case-declarations
|
||||
const midi = new Midi(buffer)
|
||||
song = convertMidi(midi)
|
||||
if (song.name === '') song.name = fallbackName
|
||||
break
|
||||
}
|
||||
return song
|
||||
}
|
||||
|
||||
bot.music.play = function (song) {
|
||||
if (bot.music.queue.length === 1) resetTime()
|
||||
}
|
||||
|
||||
bot.music.stop = function () {
|
||||
bot.music.song = null
|
||||
bot.music.loop = 0
|
||||
bot.music.queue = []
|
||||
resetTime()
|
||||
}
|
||||
|
||||
function resetTime () {
|
||||
time = 0
|
||||
startTime = Date.now()
|
||||
noteIndex = 0
|
||||
bot.core.run(`minecraft:bossbar remove ${bossbarName}`) // maybe not a good place to put it here but idk
|
||||
}
|
||||
|
||||
function formatTime (time) {
|
||||
const seconds = Math.floor(time / 1000)
|
||||
|
||||
return `${Math.floor(seconds / 60)}:${(seconds % 60).toString().padStart(2, '0')}`
|
||||
}
|
||||
|
||||
function toComponent () {
|
||||
const component = [
|
||||
// { text: '[', color: 'dark_gray' },
|
||||
// { text: 'ChomeNS Bot', color: 'yellow' },
|
||||
// { text: '] ', color: 'dark_gray' },
|
||||
// { text: 'Now Playing', color: 'gold' },
|
||||
// { text: ' | ', color: 'dark_gray' },
|
||||
{ text: bot.music.song.name, color: 'green' },
|
||||
{ text: ' | ', color: 'dark_gray' },
|
||||
{ text: formatTime(time), color: 'gray' },
|
||||
{ text: ' / ', color: 'dark_gray' },
|
||||
{ text: formatTime(bot.music.song.length), color: 'gray' },
|
||||
{ text: ' | ', color: 'dark_gray' },
|
||||
{ text: noteIndex, color: 'gray' },
|
||||
{ text: ' / ', color: 'dark_gray' },
|
||||
{ text: bot.music.song.notes.length, color: 'gray' }
|
||||
]
|
||||
|
||||
if (bot.music.loop === 1) {
|
||||
component.push({ text: ' | ', color: 'dark_gray' })
|
||||
component.push({ text: 'Looping Current', color: 'green' })
|
||||
}
|
||||
if (bot.music.loop === 2) {
|
||||
component.push({ text: ' | ', color: 'dark_gray' })
|
||||
component.push({ text: 'Looping All', color: 'green' })
|
||||
}
|
||||
|
||||
return component
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { inject }
|
||||
@@ -1,136 +0,0 @@
|
||||
const { EventEmitter } = require('events')
|
||||
|
||||
class PlayerList {
|
||||
list = []
|
||||
|
||||
addPlayer (player) {
|
||||
this.removePlayer(player)
|
||||
|
||||
this.list.push(player)
|
||||
}
|
||||
|
||||
hasPlayer (player) {
|
||||
return this.getPlayer(player) !== undefined
|
||||
}
|
||||
|
||||
getPlayer (player) {
|
||||
let identifier
|
||||
|
||||
switch (typeof player) {
|
||||
case 'object':
|
||||
identifier = player.UUID
|
||||
break
|
||||
case 'string':
|
||||
identifier = player
|
||||
break
|
||||
default:
|
||||
throw new Error(`Get player called with ${player}`)
|
||||
}
|
||||
|
||||
return this.list.find((player) => [player.UUID, player.name].some((item) => item === identifier))
|
||||
}
|
||||
|
||||
getPlayers () {
|
||||
return Array.from(this.list)
|
||||
}
|
||||
|
||||
removePlayer (player) {
|
||||
this.list = this.list.filter(({ UUID }) => UUID !== player.UUID)
|
||||
}
|
||||
}
|
||||
|
||||
function inject (bot, dcclient, config) {
|
||||
bot.players = new PlayerList()
|
||||
|
||||
const tabCompletePlayerList = {
|
||||
list: [],
|
||||
interval: setInterval(async () => {
|
||||
bot.write('tab_complete', {
|
||||
text: '/scoreboard players add '
|
||||
})
|
||||
|
||||
const [packet] = await EventEmitter.once(bot._client, 'tab_complete')
|
||||
|
||||
return packet.matches
|
||||
.filter((match) => !match.tooltip)
|
||||
.map(({ match }) => match)
|
||||
}, 1000 * 3)
|
||||
}//???
|
||||
|
||||
bot._client.on('player_info', async (packet) => {
|
||||
for (const player of packet.data) {
|
||||
switch (packet.action) {
|
||||
case 0:
|
||||
addPlayer(player, packet)
|
||||
break
|
||||
case 1:
|
||||
updateGamemode(player, packet)
|
||||
break
|
||||
case 2:
|
||||
updatePing(player, packet)
|
||||
break
|
||||
case 3:
|
||||
updateDisplayName(player, packet)
|
||||
break
|
||||
case 4:
|
||||
removePlayer(player, packet)
|
||||
break
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
function addPlayer (player, packet) {
|
||||
if (bot.players.getPlayer(player)) bot.emit('player_unvanished', player, packet)
|
||||
else bot.emit('player_added', player, packet)
|
||||
|
||||
bot.players.addPlayer(player)
|
||||
}
|
||||
|
||||
function updateGamemode (player, packet) {
|
||||
const fullPlayer = bot.players.getPlayer(player)
|
||||
|
||||
bot.emit('onPlayerGamemodeUpdate', player, packet)
|
||||
|
||||
if (fullPlayer === undefined) return
|
||||
|
||||
fullPlayer.gamemode = player.gamemode
|
||||
}
|
||||
|
||||
function updatePing (player, packet) {
|
||||
const fullPlayer = bot.players.getPlayer(player)
|
||||
|
||||
bot.emit('player_ping_updated', player, packet)
|
||||
|
||||
if (fullPlayer === undefined) return
|
||||
|
||||
fullPlayer.ping = player.ping
|
||||
}
|
||||
|
||||
function updateDisplayName (player, packet) {
|
||||
const fullPlayer = bot.players.getPlayer(player)
|
||||
|
||||
bot.emit('player_display_name_updated', player, packet)
|
||||
|
||||
if (fullPlayer === undefined) return
|
||||
|
||||
fullPlayer.displayName = player.displayName
|
||||
}
|
||||
|
||||
function removePlayer (player, packet) {
|
||||
const fullPlayer = bot.players.getPlayer(player)
|
||||
const players = tabCompletePlayerList.list
|
||||
|
||||
if (fullPlayer && players.some((name) => name === fullPlayer.name)) {
|
||||
bot.emit('player_vanished', player)
|
||||
} else {
|
||||
bot.emit('player_removed', player, packet)
|
||||
bot.players.removePlayer(player)
|
||||
}
|
||||
}
|
||||
|
||||
bot.on('end', () => {
|
||||
clearInterval(tabCompletePlayerList.interval)
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = { inject }
|
||||
@@ -1,11 +0,0 @@
|
||||
|
||||
function inject (bot) {
|
||||
bot.position = { x: 0, y: 0, z: 0 }
|
||||
bot._client.on('position', (position) => {
|
||||
bot.position = position
|
||||
bot.write('teleport_confirm', { teleportId: position.teleportId })
|
||||
bot.emit('position', position)
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = { inject }
|
||||
@@ -1,129 +0,0 @@
|
||||
|
||||
const util = require('util')
|
||||
const mc = require('minecraft-protocol')
|
||||
const { loadPlugins } = require('../util/loadPlugins')
|
||||
const minecraftVersionToNumber = require('../util/minecraftVersionToNumber')
|
||||
|
||||
function inject (bot, dcclient, config) {
|
||||
if (!config.proxy.enabled) return
|
||||
|
||||
let index
|
||||
config.servers.forEach((server, _index) => {
|
||||
if (bot.server.host !== server.host) return
|
||||
index = _index
|
||||
})
|
||||
|
||||
bot.proxy = {}
|
||||
|
||||
const version = config.proxy.version
|
||||
const srv = mc.createServer({
|
||||
'online-mode': false,
|
||||
port: 25566 + index,
|
||||
keepAlive: false,
|
||||
version
|
||||
})
|
||||
|
||||
srv.on('login', (client) => {
|
||||
bot.console.info(`[Proxy] ${client.username} connected to proxy`)
|
||||
let clientEnded = false
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
let targetEnded = false
|
||||
|
||||
const target = mc.createClient({
|
||||
username: client.username,
|
||||
host: bot.server.host,
|
||||
port: bot.server.port,
|
||||
version
|
||||
})
|
||||
|
||||
const clientPacketBlacklist = []
|
||||
const targetPacketBlacklist = []
|
||||
|
||||
// should this be here or in the chat plugin?
|
||||
target.sendMessage = function (message) {
|
||||
if (message.startsWith('/') && minecraftVersionToNumber(target.version) >= 1.19) {
|
||||
// totallynotskidded™️ from mineflayer
|
||||
const command = message.slice(1)
|
||||
const timestamp = BigInt(Date.now())
|
||||
target.write('chat_command', {
|
||||
command,
|
||||
timestamp,
|
||||
salt: 0n,
|
||||
argumentSignatures: [],
|
||||
signedPreview: false,
|
||||
messageCount: 0,
|
||||
acknowledged: Buffer.alloc(3),
|
||||
// 1.19.2 Chat Command packet also includes an array of last seen messages
|
||||
previousMessages: []
|
||||
})
|
||||
} else {
|
||||
target.chat(message)
|
||||
}
|
||||
}
|
||||
|
||||
target.on('login', (packet) => {
|
||||
bot.console.info(`[Proxy] ${client.username} target logged in`)
|
||||
target.entityId = packet.entityId
|
||||
loadPlugins(bot, null, config, null, target, client, true, clientPacketBlacklist, targetPacketBlacklist)
|
||||
})
|
||||
|
||||
target.on('packet', (data, meta) => {
|
||||
if (!clientEnded &&
|
||||
meta.state === mc.states.PLAY &&
|
||||
client.state === mc.states.PLAY &&
|
||||
!targetPacketBlacklist.includes(meta.name)
|
||||
) client.write(meta.name, data)
|
||||
})
|
||||
|
||||
target.on('error', () => {})
|
||||
|
||||
target.on('end', targetEndListener)
|
||||
target.on('kick_disconnect', ({ reason }) => targetEndListener(JSON.parse(reason)))
|
||||
target.on('disconnect', ({ reason }) => targetEndListener(JSON.parse(reason)))
|
||||
|
||||
function targetEndListener (reason) {
|
||||
target.end()
|
||||
client.end(`Target disconnected with reason: ${util.inspect(reason)}`)
|
||||
targetEnded = true
|
||||
}
|
||||
|
||||
client.on('end', () => {
|
||||
clientEnded = true
|
||||
target.end()
|
||||
target.removeAllListeners()
|
||||
client.removeAllListeners()
|
||||
bot.console.info(`[Proxy] ${client.username} ended`)
|
||||
})
|
||||
|
||||
client.on('error', () => {
|
||||
clientEnded = true
|
||||
target.removeAllListeners()
|
||||
client.removeAllListeners()
|
||||
bot.console.info(`[Proxy] ${client.username} got error`)
|
||||
})
|
||||
|
||||
client.on('packet', (data, meta) => {
|
||||
if (clientPacketBlacklist.includes(meta.name)) return
|
||||
target.write(meta.name, data)
|
||||
})
|
||||
|
||||
bot.proxy[client.username] = {
|
||||
target,
|
||||
client
|
||||
}
|
||||
|
||||
function botEndListener (reason) {
|
||||
delete bot.proxy[client.username]
|
||||
client.end(`Bot disconnected with reason: ${util.inspect(reason)}`)
|
||||
bot.off('end', botEndListener)
|
||||
}
|
||||
bot.on('end', botEndListener)
|
||||
})
|
||||
|
||||
bot.on('end', () => {
|
||||
srv.close()
|
||||
srv.removeAllListeners()
|
||||
})
|
||||
};
|
||||
|
||||
module.exports = { inject }
|
||||
@@ -1,16 +0,0 @@
|
||||
|
||||
const { chatPacketListener, parsePlayerMessages } = require('../../util/chat')
|
||||
const minecraftVersionToNumber = require('../../util/minecraftVersionToNumber')
|
||||
function inject (bot, client, target) {
|
||||
function listener (packet) {
|
||||
chatPacketListener(packet, target, minecraftVersionToNumber(target.version) >= 1.10)
|
||||
}
|
||||
target.on('systemChat', listener)
|
||||
target.on('chat', listener)
|
||||
|
||||
target.on('message', (message, packet) => {
|
||||
parsePlayerMessages(message, packet, target)
|
||||
})
|
||||
};
|
||||
|
||||
module.exports = { inject }
|
||||
@@ -1,58 +0,0 @@
|
||||
const minecraftVersionToNumber = require('../../util/minecraftVersionToNumber')
|
||||
|
||||
function inject (bot, client, target, config, clientPacketBlacklist) {
|
||||
const { MessageBuilder } = require('prismarine-chat')(bot.version)
|
||||
clientPacketBlacklist.push('chat')
|
||||
clientPacketBlacklist.push('chat_message')
|
||||
client.on(minecraftVersionToNumber(target.version) >= 1.19 ? 'chat_message' : 'chat', (data) => {
|
||||
// not the best place to put command handler thing here but ok
|
||||
if (data.message?.startsWith('.')) {
|
||||
return bot.command_handler.run(
|
||||
client.username,
|
||||
config.prefixes[0] + data.message.substring(1),
|
||||
client.uuid,
|
||||
null,
|
||||
'h', // real hash hardcode
|
||||
'o',
|
||||
client.username,
|
||||
true,
|
||||
client,
|
||||
target
|
||||
)
|
||||
}
|
||||
|
||||
if (!data.message?.startsWith('/')) {
|
||||
const codeParsedMessage = data.message.replace(/%[^%]+%/g, (code) => {
|
||||
try {
|
||||
// eslint-disable-next-line no-eval
|
||||
return eval(code.substring(1).slice(0, -1))
|
||||
} catch (e) {
|
||||
return code
|
||||
}
|
||||
})
|
||||
bot.tellraw('@a', {
|
||||
color: 'dark_gray',
|
||||
translate: '[%s] [%s] %s \u203a %s',
|
||||
with: [
|
||||
{
|
||||
text: 'Chat',
|
||||
color: 'gray'
|
||||
},
|
||||
{
|
||||
text: 'Proxy',
|
||||
color: 'gray'
|
||||
},
|
||||
{
|
||||
selector: client.username,
|
||||
color: 'green'
|
||||
},
|
||||
MessageBuilder.fromString('&7' + codeParsedMessage)
|
||||
]
|
||||
})
|
||||
} else {
|
||||
target.sendMessage(data)
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
module.exports = { inject }
|
||||
@@ -1,48 +0,0 @@
|
||||
|
||||
function inject (bot, client, target, config) {
|
||||
let cspy = false
|
||||
let op = true
|
||||
// let gameMode = 1
|
||||
|
||||
target.on('message', (data) => {
|
||||
if (data.toString() === 'Successfully enabled CommandSpy' || data.toString() === ' Enabled your command spy.' || data.toString() === ' Your command spy is already enabled.') cspy = true
|
||||
if (data.toString() === 'Successfully disabled CommandSpy' || data.toString() === ' Disabled your command spy.') cspy = false
|
||||
})
|
||||
|
||||
target.on('entity_status', (data) => {
|
||||
if (data.entityId !== target.entityId) return
|
||||
|
||||
switch (data.entityStatus) {
|
||||
case 24:
|
||||
op = false
|
||||
break
|
||||
case 28:
|
||||
op = true
|
||||
break
|
||||
}
|
||||
})
|
||||
|
||||
// target.on('game_state_change', (data) => {
|
||||
// if (data.reason !== 3) return
|
||||
//
|
||||
// gameMode = data.gameMode
|
||||
// })
|
||||
//
|
||||
// target.on('login', (data) => {
|
||||
// gameMode = data.gameMode
|
||||
// })
|
||||
|
||||
const interval = setInterval(() => {
|
||||
if (bot.options.kaboom) {
|
||||
if (!op && config.self_care.op) target.sendMessage('/minecraft:op @s[type=player]')
|
||||
if (!cspy && config.self_care.cspy) target.sendMessage('/commandspy:commandspy on')
|
||||
}
|
||||
// if (gameMode !== 1 && config.self_care.gamemode) target.sendMessage('/minecraft:gamemode creative @s[type=player]')
|
||||
}, config.self_care_check_interval)
|
||||
|
||||
bot.on('end', () => {
|
||||
clearInterval(interval)
|
||||
})
|
||||
};
|
||||
|
||||
module.exports = { inject }
|
||||
@@ -1,90 +0,0 @@
|
||||
|
||||
function inject (bot, dcclient, config) {
|
||||
let vanish = false
|
||||
let nickname = true
|
||||
let socialspy = false
|
||||
let cspy = false
|
||||
let prefix = false
|
||||
|
||||
let op = false
|
||||
let gameMode = 1
|
||||
let muted = false
|
||||
|
||||
bot.on('message', (data) => {
|
||||
if (data.toString() === 'You are now completely invisible to normal users, and hidden from in-game commands.') vanish = true
|
||||
if (!bot.visibility && data.toString() === `Vanish for ${bot.username}: disabled`) vanish = false
|
||||
|
||||
if (data.toString() === 'You no longer have a nickname.') nickname = true
|
||||
if (data.toString().startsWith('Your nickname is now ')) nickname = false
|
||||
|
||||
if (data.toString() === `SocialSpy for ${bot.username}: enabled`) socialspy = true
|
||||
if (data.toString() === `SocialSpy for ${bot.username}: disabled`) socialspy = false
|
||||
|
||||
if (data.toString().startsWith('You have been muted')) muted = true
|
||||
if (data.toString() === 'You have been unmuted.') muted = false
|
||||
|
||||
if (data.toString() === 'Successfully enabled CommandSpy' || data.toString() === ' Enabled your command spy.' || data.toString() === ' Your command spy is already enabled.') cspy = true
|
||||
if (data.toString() === 'Successfully disabled CommandSpy' || data.toString() === ' Disabled your command spy.') cspy = false
|
||||
|
||||
if (data.toString() === 'You now have the tag: [ChomeNS Bot]' || // for 1.19.2 (or 1.19?) and older clones
|
||||
data.toString() === 'You now have the tag: &8[&eChomeNS Bot&8]'
|
||||
) {
|
||||
prefix = true
|
||||
return
|
||||
}
|
||||
if (data.toString().startsWith('You no longer have a tag')) prefix = false
|
||||
if (data.toString().startsWith('You now have the tag: ')) prefix = false
|
||||
})
|
||||
|
||||
bot._client.on('entity_status', (data) => {
|
||||
if (data.entityId !== bot.entityId) return
|
||||
|
||||
switch (data.entityStatus) {
|
||||
case 24:
|
||||
op = false
|
||||
|
||||
bot.emit('deop')
|
||||
break
|
||||
case 28:
|
||||
op = true
|
||||
|
||||
bot.emit('op')
|
||||
break
|
||||
}
|
||||
|
||||
bot.emit('entity_status', data)
|
||||
})
|
||||
|
||||
bot._client.on('game_state_change', (data) => {
|
||||
if (data.reason === 4 && config.self_care.endCredits) bot.write('client_command', { payload: 0 })
|
||||
|
||||
if (data.reason !== 3) return
|
||||
|
||||
gameMode = data.gameMode
|
||||
})
|
||||
|
||||
bot._client.on('login', (data) => {
|
||||
gameMode = data.gameMode
|
||||
})
|
||||
|
||||
const interval = setInterval(() => {
|
||||
if (bot.options.kaboom) {
|
||||
if (!prefix && config.self_care.prefix) bot.chat('/extras:prefix &8[&eChomeNS Bot&8]')
|
||||
if (!op && config.self_care.op) bot.chat('/minecraft:op @s[type=player]')
|
||||
if (!cspy && config.self_care.cspy) bot.chat('/commandspy:commandspy on')
|
||||
}
|
||||
|
||||
if (!vanish && config.self_care.vanish) bot.chat('/essentials:vanish enable')
|
||||
//if (!socialspy && config.self_care.socialspy) bot.chat('/essentials:socialspy enable')
|
||||
if (!nickname && config.self_care.nickname) bot.chat('/essentials:nickname off')
|
||||
|
||||
if (gameMode !== 1 && config.self_care.gamemode) bot.chat('/minecraft:gamemode creative @s[type=player]')
|
||||
if (muted && config.self_care.mute) bot.chat('/essentials:mute ' + bot.uuid)
|
||||
}, config.self_care_check_interval)
|
||||
|
||||
bot.on('end', () => {
|
||||
clearInterval(interval)
|
||||
})
|
||||
};
|
||||
|
||||
module.exports = { inject }
|
||||
@@ -1,12 +0,0 @@
|
||||
function inject (bot, dcclient, config) {
|
||||
const ChatMessage = require('prismarine-chat')(bot.version)
|
||||
bot.tellraw = function (selector, message) {
|
||||
if (bot.options.useChat && selector === '@a') {
|
||||
bot.chat(ChatMessage.fromNotch(message).toMotd().replaceAll('\xa7', '&'))
|
||||
return
|
||||
}
|
||||
bot.core.run(`minecraft:tellraw ${selector} ${JSON.stringify(message)}`)
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = { inject }
|
||||
@@ -1,75 +0,0 @@
|
||||
const clamp = require('../util/clamp')
|
||||
function inject (bot, dcclient, config) {
|
||||
const bossbarName = 'chomens_bot:tps'
|
||||
|
||||
let enabled = false
|
||||
bot.tps = {
|
||||
on () {
|
||||
enabled = true
|
||||
},
|
||||
off () {
|
||||
enabled = false
|
||||
bot.core.run(`minecraft:bossbar remove ${bossbarName}`)
|
||||
}
|
||||
}
|
||||
|
||||
const tickRates = []
|
||||
let nextIndex = 0
|
||||
let timeLastTimeUpdate = -1
|
||||
let timeGameJoined
|
||||
|
||||
const interval = setInterval(() => {
|
||||
if (!enabled) return
|
||||
|
||||
const component = {
|
||||
translate: 'TPS - %s',
|
||||
color: 'gray',
|
||||
bold: false,
|
||||
with: [
|
||||
{ text: getTickRate(), color: 'green' }
|
||||
]
|
||||
}
|
||||
bot.core.run(`minecraft:bossbar add ${bossbarName} ""`)
|
||||
bot.core.run(`minecraft:bossbar set ${bossbarName} players @a`)
|
||||
bot.core.run(`minecraft:bossbar set ${bossbarName} color yellow`)
|
||||
bot.core.run(`minecraft:bossbar set ${bossbarName} visible true`)
|
||||
bot.core.run(`minecraft:bossbar set ${bossbarName} style progress`)
|
||||
bot.core.run(`minecraft:bossbar set ${bossbarName} name ${JSON.stringify(component)}`)
|
||||
bot.core.run(`minecraft:bossbar set ${bossbarName} max 20`)
|
||||
bot.core.run(`minecraft:bossbar set ${bossbarName} value ${Math.floor(getTickRate())}`)
|
||||
}, 50)
|
||||
|
||||
function getTickRate () {
|
||||
if (Date.now() - timeGameJoined < 4000) return 'Calculating...'
|
||||
|
||||
let numTicks = 0
|
||||
let sumTickRates = 0.0
|
||||
for (const tickRate of tickRates) {
|
||||
if (tickRate > 0) {
|
||||
sumTickRates += tickRate
|
||||
numTicks++
|
||||
}
|
||||
}
|
||||
|
||||
const value = (sumTickRates / numTicks).toFixed(2)
|
||||
if (value > 20) return 20
|
||||
else return value
|
||||
}
|
||||
|
||||
bot.on('login', () => {
|
||||
nextIndex = 0
|
||||
timeGameJoined = timeLastTimeUpdate = Date.now()
|
||||
})
|
||||
|
||||
bot._client.on('update_time', () => {
|
||||
const now = Date.now()
|
||||
const timeElapsed = (now - timeLastTimeUpdate) / 1000.0
|
||||
tickRates[nextIndex] = clamp(20.0 / timeElapsed, 0.0, 20.0)
|
||||
nextIndex = (nextIndex + 1) % tickRates.length
|
||||
timeLastTimeUpdate = now
|
||||
})
|
||||
|
||||
bot.on('end', () => clearInterval(interval))
|
||||
}
|
||||
|
||||
module.exports = { inject }
|
||||
@@ -1,46 +0,0 @@
|
||||
const mc = require('minecraft-protocol')
|
||||
const crypto = require('crypto')
|
||||
const colorConvert = require('color-convert')
|
||||
|
||||
const uuid = require('uuid-by-string')
|
||||
const moment = require('moment-timezone')
|
||||
const cowsay = require('cowsay2')
|
||||
const cows = require('cowsay2/cows')
|
||||
const { VM } = require('vm2')
|
||||
const randomstring = require('randomstring')
|
||||
const mineflayer = require('mineflayer')
|
||||
const Vec3 = require('vec3')
|
||||
function inject (bot) {
|
||||
const chatMessage = require('prismarine-chat')(bot.version)
|
||||
const mcData = require('minecraft-data')(bot.version)
|
||||
bot.vmOptions = {
|
||||
timeout: 2000,
|
||||
sandbox: {
|
||||
run (cmd) {
|
||||
bot.core.run(cmd)
|
||||
},
|
||||
mc,
|
||||
mineflayer,
|
||||
chat: bot.chat,
|
||||
moment,
|
||||
randomstring,
|
||||
uuid,
|
||||
chatMessage,
|
||||
crypto,
|
||||
colorConvert,
|
||||
bruhifyText (message) {
|
||||
if (
|
||||
typeof message !== 'string'
|
||||
) throw new SyntaxError('message must be a string')
|
||||
bot.bruhifyText = message.substring(0, 1000)
|
||||
},
|
||||
cowsay,
|
||||
cows,
|
||||
mcData,
|
||||
Vec3
|
||||
}
|
||||
}
|
||||
bot.vm = new VM(bot.vmOptions)
|
||||
};
|
||||
|
||||
module.exports = { inject }
|
||||
@@ -1 +0,0 @@
|
||||
{"error":".zip archives do not support non-regular files","level":"error","msg":"unable to write file .cache/replit/modules/nodejs-18:v9-20230908-bb1b9fd","time":"2023-09-17T03:59:55Z"}
|
||||
@@ -1,13 +0,0 @@
|
||||
module.exports = {
|
||||
/**
|
||||
* this code is from somewhere i can't remember...
|
||||
* @param {Number} min
|
||||
* @param {Number} max
|
||||
* @return {Number}
|
||||
*/
|
||||
between: function (min, max) {
|
||||
return Math.floor(
|
||||
Math.random() * (max - min) + min
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,146 +0,0 @@
|
||||
/**
|
||||
* for the chat packet listener (in util cuz proxy + bot)
|
||||
* @param {object} packet chat packet
|
||||
* @param {object} bot bot
|
||||
* @param {boolean} mc119 minecraft 1.19 or newer
|
||||
*/
|
||||
function chatPacketListener (packet, bot, mc119) {
|
||||
// try catch prevents json parse error (happens with a custom server that sends an invalid json component for example)
|
||||
try {
|
||||
const ChatMessage = require('prismarine-chat')(bot.version)
|
||||
|
||||
const parsedMessage = JSON.parse(mc119 ? packet.formattedMessage : packet.message)
|
||||
// down here it prevents command set message
|
||||
|
||||
// for ayunboom cuz its 1.17.1
|
||||
// VVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
||||
if (parsedMessage.extra) {
|
||||
if (parsedMessage.extra[0].text === 'Command set: ') return
|
||||
}
|
||||
// for 1.18 or newer(?)
|
||||
// VVVVVVVVVVVVVVVVVVVVV
|
||||
if (parsedMessage.translate === 'advMode.setCommand.success') return
|
||||
|
||||
const message = ChatMessage.fromNotch(mc119 ? packet.formattedMessage : packet.message)
|
||||
|
||||
bot.emit('message', message, parsedMessage)
|
||||
} catch (e) {
|
||||
bot.console.error(e)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* new parse player messages, more accurate message real!11!!
|
||||
* @param {object} _message prismarine-chat ChatMessage - unused in code but used in legacy parsing
|
||||
* @param {object} parsedMessage parsed message in a js object
|
||||
* @param {object} bot bot
|
||||
*/
|
||||
function parsePlayerMessages (_message, parsedMessage, bot) {
|
||||
const ChatMessage = require('prismarine-chat')(bot.version)
|
||||
const vanillaKeys = [
|
||||
'chat.type.text',
|
||||
'chat.type.announcement',
|
||||
'chat.type.emote'
|
||||
]
|
||||
|
||||
// parse Extras™ chat messages
|
||||
if (
|
||||
parsedMessage.translate === '%s' &&
|
||||
parsedMessage.with?.length === 1 &&
|
||||
parsedMessage.with[0]?.text === '' &&
|
||||
parsedMessage.with[0]?.extra?.length === 5
|
||||
) {
|
||||
const trueMessageComponent = parsedMessage.with[0].extra
|
||||
const username = ChatMessage.fromNotch(trueMessageComponent[1]).toMotd()
|
||||
const message = ChatMessage.fromNotch(trueMessageComponent[4]).toMotd()
|
||||
bot.emit('chat', username, message)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// parse CommandSpy™ messages
|
||||
if (
|
||||
(
|
||||
parsedMessage.color === 'yellow' ||
|
||||
parsedMessage.color === 'aqua'
|
||||
) &&
|
||||
parsedMessage.extra?.length === 2
|
||||
) {
|
||||
const username = parsedMessage.text
|
||||
const command = parsedMessage.extra[1].text
|
||||
bot.emit('cspy', username, command)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// parse Minecraft Vanilla™ messages
|
||||
if (
|
||||
vanillaKeys.includes(parsedMessage.translate) &&
|
||||
parsedMessage.with.length >= 2
|
||||
) {
|
||||
const username = ChatMessage.fromNotch(parsedMessage.with[0]).toMotd()
|
||||
const message = ChatMessage.fromNotch(parsedMessage.with[1]).toMotd()
|
||||
bot.emit('chat', username, message)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
parsePlayerMessagesLegacy(_message, parsedMessage, bot)
|
||||
}
|
||||
|
||||
/**
|
||||
* LEGACY - parse player messages (for prismarine-chat)
|
||||
* @param {object} message prismarine-chat ChatMessage
|
||||
* @param {object} _parsedMessage parsed message in a js object
|
||||
* @param {object} bot bot
|
||||
*/
|
||||
function parsePlayerMessagesLegacy (message, _parsedMessage, bot) {
|
||||
try {
|
||||
// here is all the player message parsing thing
|
||||
const raw = message.toMotd() // lags the bot as you already know
|
||||
// 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)
|
||||
// } 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)
|
||||
} 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(' ')
|
||||
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)
|
||||
// } else if (raw.match(/<.*> .*/g)) {
|
||||
// const username = raw.substring(1).split('>')[0]
|
||||
// const message = raw.split('> ').slice(1).join(' ')
|
||||
//
|
||||
// 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]
|
||||
|
||||
// bot.emit('cspy', username, command)
|
||||
// } else if (raw.match(/§.*§e: §e\/.*/g)) {
|
||||
// const username = raw.split('§e: §e')[0]
|
||||
// const command = raw.split('§e: §e')[1]
|
||||
// bot.emit('cspy', username, command)
|
||||
// } else if (raw.match(/§.*§b: \/.*/g)) {
|
||||
// const username = raw.split('§b: ')[0]
|
||||
// const command = raw.split('§b: ')[1]
|
||||
|
||||
// bot.emit('cspy', username, command)
|
||||
// } else if (raw.match(/§.*§e: \/.*/g)) {
|
||||
// const username = raw.split('§e: ')[0]
|
||||
// const command = raw.split('§e: ')[1]
|
||||
// bot.emit('cspy', username, command)
|
||||
// }
|
||||
} catch (e) {}
|
||||
};
|
||||
|
||||
module.exports = { chatPacketListener, parsePlayerMessages }
|
||||
@@ -1,6 +0,0 @@
|
||||
function clamp (value, min, max) {
|
||||
if (value < min) return min
|
||||
return Math.min(value, max)
|
||||
}
|
||||
|
||||
module.exports = clamp
|
||||
@@ -1,23 +0,0 @@
|
||||
|
||||
const styles = {
|
||||
bigint: '\xa76',
|
||||
boolean: '\xa76',
|
||||
date: '\xa75',
|
||||
module: '\xa7n',
|
||||
name: undefined,
|
||||
null: '\xa7l',
|
||||
number: '\xa76',
|
||||
regexp: '\xa74',
|
||||
special: '\xa73',
|
||||
string: '\xa72',
|
||||
symbol: '\xa72',
|
||||
undefined: '\xa78'
|
||||
}
|
||||
|
||||
function stylize (str, styleType) {
|
||||
const style = styles[styleType]
|
||||
if (style !== undefined) return `${style}${str}\xa7r`
|
||||
return str
|
||||
}
|
||||
|
||||
module.exports = { stylize, styles }
|
||||
@@ -1,18 +0,0 @@
|
||||
/**
|
||||
* character allowed in mc chat
|
||||
* @param {String} character the character
|
||||
* @return {boolean} allowed
|
||||
*/
|
||||
function isAllowedCharacter (character) {
|
||||
return character !== '\xa7' && character !== '\x7f'
|
||||
}
|
||||
/**
|
||||
* mc chat check if contains illegal chars.
|
||||
* @param {String} string the string
|
||||
* @return {boolean} if contains then true else false
|
||||
*/
|
||||
function containsIllegalCharacters (string) {
|
||||
for (let i = 0; i < string.length; i++) if (!isAllowedCharacter(string[i])) return true
|
||||
}
|
||||
|
||||
module.exports = { containsIllegalCharacters, isAllowedCharacter }
|
||||
@@ -1,22 +0,0 @@
|
||||
/**
|
||||
* escape markdown so on discord it will be \_ChipMC\_ instead of _ChipMC_
|
||||
* @param {String} text
|
||||
* @param {Boolean} zwsp
|
||||
* @return {String}
|
||||
*/
|
||||
function escapeMarkdown (text, zwsp) {
|
||||
let unescaped
|
||||
let escaped
|
||||
try {
|
||||
unescaped = text.replace(/\\(\*|@|_|`|~|\\)/g, '$1')
|
||||
escaped = unescaped.replace(/(\*|@|_|`|~|\\)/g, zwsp
|
||||
? '\u200b\u200b$1'
|
||||
: '\\$1'
|
||||
)
|
||||
} catch (e) {
|
||||
return unescaped
|
||||
}
|
||||
return escaped
|
||||
}
|
||||
|
||||
module.exports = { escapeMarkdown }
|
||||
@@ -1,19 +0,0 @@
|
||||
const fs = require('fs/promises')
|
||||
|
||||
/**
|
||||
* check if file exists
|
||||
* @param {String} filepath the file path
|
||||
* @return {boolean} if file exists true else false
|
||||
*/
|
||||
async function fileExists (filepath) {
|
||||
try {
|
||||
await fs.access(filepath)
|
||||
return true
|
||||
} catch (error) {
|
||||
if (error.code !== 'ENOENT') throw error
|
||||
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = fileExists
|
||||
@@ -1,18 +0,0 @@
|
||||
const fs = require('fs/promises')
|
||||
|
||||
/**
|
||||
* just list the files
|
||||
* @param {String} filepath file path
|
||||
* @return {Array} component.
|
||||
*/
|
||||
async function list (filepath = '.') {
|
||||
const files = await fs.readdir(filepath)
|
||||
|
||||
const component = []
|
||||
for (const filename of files) {
|
||||
component.push(filename)
|
||||
}
|
||||
return component
|
||||
}
|
||||
|
||||
module.exports = list
|
||||
@@ -1,14 +0,0 @@
|
||||
const path = require('path')
|
||||
/**
|
||||
* get filename from url
|
||||
* @param {string} urlStr the url
|
||||
* @return {string} filename
|
||||
* @example
|
||||
* getFilenameFromUrl('https://sus.red/amogus.mid?verysus=true') // returns 'amogus.mid'
|
||||
*/
|
||||
function getFilenameFromUrl (urlStr) {
|
||||
const url = new URL(urlStr)
|
||||
return path.basename(url.pathname)
|
||||
}
|
||||
|
||||
module.exports = getFilenameFromUrl
|
||||
@@ -1,27 +0,0 @@
|
||||
/**
|
||||
* resize image.
|
||||
* @param {number} width width
|
||||
* @param {number} height height
|
||||
* @return {object} width and height
|
||||
*/
|
||||
function resize (width, height) {
|
||||
const aspectRatio = width / height
|
||||
|
||||
let optimalWidth = Math.round(aspectRatio * 20 * (27 / 3))
|
||||
let optimalHeight = 20
|
||||
|
||||
if (optimalWidth > 320) {
|
||||
const reduction = optimalWidth / 320
|
||||
|
||||
optimalWidth = 320
|
||||
|
||||
optimalHeight *= reduction
|
||||
}
|
||||
|
||||
return {
|
||||
width: Math.floor(optimalWidth),
|
||||
height: Math.floor(optimalHeight)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { resize }
|
||||
@@ -1,33 +0,0 @@
|
||||
const fs = require('fs/promises')
|
||||
const util = require('util')
|
||||
const path = require('path')
|
||||
|
||||
/**
|
||||
* load plugins
|
||||
* @param {object} bot the bot object
|
||||
* @param {object} dcclient discord client
|
||||
* @param {object} config the config
|
||||
* @param {object} rl readline
|
||||
* @param {object} target proxy target
|
||||
* @param {object} client proxy client
|
||||
* @param {boolean} proxy is proxy
|
||||
* @param {array} clientPacketBlacklist the client packet blacklist
|
||||
* @param {array} targetPacketBlacklist target packet blacklist
|
||||
*/
|
||||
async function loadPlugins (bot, dcclient, config, rl, target, client, proxy, clientPacketBlacklist, targetPacketBlacklist) {
|
||||
const dir = path.join(__dirname, '..', 'plugins', proxy ? 'proxy' : '')
|
||||
const plugins = await fs.readdir(dir)
|
||||
plugins.forEach((plugin) => {
|
||||
if (!plugin.endsWith('.js')) return
|
||||
try {
|
||||
const plug = require(path.join(dir, plugin))
|
||||
if (!proxy) plug.inject(bot, dcclient, config, rl)
|
||||
else plug.inject(bot, client, target, config, clientPacketBlacklist, targetPacketBlacklist)
|
||||
} catch (e) {
|
||||
console.log(`Plugin ${plugin} is having exception loading the plugin:`)
|
||||
console.log(util.inspect(e))
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
module.exports = { loadPlugins }
|
||||
@@ -1,25 +0,0 @@
|
||||
const fs = require('fs/promises')
|
||||
const path = require('path')
|
||||
|
||||
/**
|
||||
* loads js files
|
||||
* @param {string} directory the directory that contains the js files
|
||||
* @return {Array} an array of require()ed js files
|
||||
*/
|
||||
async function loadPlugins (directory) {
|
||||
const plugins = []
|
||||
|
||||
for (const filename of await fs.readdir(directory)) {
|
||||
if (!filename.endsWith('.js')) continue
|
||||
|
||||
const filepath = path.join(directory, filename)
|
||||
|
||||
const plugin = require(filepath)
|
||||
|
||||
plugins.push(plugin)
|
||||
}
|
||||
|
||||
return plugins
|
||||
}
|
||||
|
||||
module.exports = loadPlugins
|
||||
@@ -1,39 +0,0 @@
|
||||
const instrumentMap = require('./instrument_map.js')
|
||||
const percussionMap = require('./percussion_map.js')
|
||||
|
||||
function convertNote (track, note) {
|
||||
let instrument = null
|
||||
|
||||
const instrumentList = instrumentMap[track.instrument.number]
|
||||
if (instrumentList != null) {
|
||||
for (const candidateInstrument of instrumentList) {
|
||||
if (note.midi >= candidateInstrument.offset && note.midi <= candidateInstrument.offset + 24) {
|
||||
instrument = candidateInstrument
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (instrument == null) return null
|
||||
|
||||
const pitch = note.midi - instrument.offset
|
||||
const time = Math.floor(note.time * 1000)
|
||||
|
||||
return { time, instrument: instrument.name, pitch, volume: note.velocity }
|
||||
}
|
||||
|
||||
function convertPercussionNote (track, note) {
|
||||
if (note.midi < percussionMap.length) {
|
||||
const mapEntry = percussionMap[note.midi]
|
||||
if (mapEntry == null) return
|
||||
|
||||
const { pitch, instrument } = mapEntry
|
||||
const time = Math.floor(note.time * 1000)
|
||||
|
||||
return { time, instrument: instrument.name, pitch, volume: note.velocity }
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
module.exports = { convertNote, convertPercussionNote }
|
||||
@@ -1,153 +0,0 @@
|
||||
const instruments = require('./instruments.json')
|
||||
|
||||
module.exports = [
|
||||
// Piano (harp bass bell)
|
||||
[instruments.harp, instruments.bass, instruments.bell], // Acoustic Grand Piano
|
||||
[instruments.harp, instruments.bass, instruments.bell], // Bright Acoustic Piano
|
||||
[instruments.bit, instruments.didgeridoo, instruments.bell], // Electric Grand Piano
|
||||
[instruments.harp, instruments.bass, instruments.bell], // Honky-tonk Piano
|
||||
[instruments.bit, instruments.didgeridoo, instruments.bell], // Electric Piano 1
|
||||
[instruments.bit, instruments.didgeridoo, instruments.bell], // Electric Piano 2
|
||||
[instruments.harp, instruments.bass, instruments.bell], // Harpsichord
|
||||
[instruments.harp, instruments.bass, instruments.bell], // Clavinet
|
||||
|
||||
// Chromatic Percussion (iron_xylophone xylophone bass)
|
||||
[instruments.iron_xylophone, instruments.bass, instruments.xylophone], // Celesta
|
||||
[instruments.iron_xylophone, instruments.bass, instruments.xylophone], // Glockenspiel
|
||||
[instruments.iron_xylophone, instruments.bass, instruments.xylophone], // Music Box
|
||||
[instruments.iron_xylophone, instruments.bass, instruments.xylophone], // Vibraphone
|
||||
[instruments.iron_xylophone, instruments.bass, instruments.xylophone], // Marimba
|
||||
[instruments.iron_xylophone, instruments.bass, instruments.xylophone], // Xylophone
|
||||
[instruments.iron_xylophone, instruments.bass, instruments.xylophone], // Tubular Bells
|
||||
[instruments.iron_xylophone, instruments.bass, instruments.xylophone], // Dulcimer
|
||||
|
||||
// Organ (bit didgeridoo bell)
|
||||
[instruments.didgeridoo, instruments.bit, instruments.xylophone], // Drawbar Organ
|
||||
[instruments.didgeridoo, instruments.bit, instruments.xylophone], // Percussive Organ
|
||||
[instruments.didgeridoo, instruments.bit, instruments.xylophone], // Rock Organ
|
||||
[instruments.didgeridoo, instruments.bit, instruments.xylophone], // Church Organ
|
||||
[instruments.didgeridoo, instruments.bit, instruments.xylophone], // Reed Organ
|
||||
[instruments.didgeridoo, instruments.bit, instruments.xylophone], // Accordian
|
||||
[instruments.didgeridoo, instruments.bit, instruments.xylophone], // Harmonica
|
||||
[instruments.didgeridoo, instruments.bit, instruments.xylophone], // Tango Accordian
|
||||
|
||||
// Guitar (bit didgeridoo bell)
|
||||
[instruments.guitar, instruments.harp, instruments.bass, instruments.bell], // Acoustic Guitar (nylon)
|
||||
[instruments.guitar, instruments.harp, instruments.bass, instruments.bell], // Acoustic Guitar (steel)
|
||||
[instruments.guitar, instruments.harp, instruments.bass, instruments.bell], // Electric Guitar (jazz)
|
||||
[instruments.guitar, instruments.harp, instruments.bass, instruments.bell], // Electric Guitar (clean)
|
||||
[instruments.guitar, instruments.harp, instruments.bass, instruments.bell], // Electric Guitar (muted)
|
||||
[instruments.didgeridoo, instruments.bit, instruments.xylophone], // Overdriven Guitar
|
||||
[instruments.didgeridoo, instruments.bit, instruments.xylophone], // Distortion Guitar
|
||||
[instruments.guitar, instruments.harp, instruments.bass, instruments.bell], // Guitar Harmonics
|
||||
|
||||
// Bass
|
||||
[instruments.bass, instruments.harp, instruments.bell], // Acoustic Bass
|
||||
[instruments.bass, instruments.harp, instruments.bell], // Electric Bass (finger)
|
||||
[instruments.bass, instruments.harp, instruments.bell], // Electric Bass (pick)
|
||||
[instruments.bass, instruments.harp, instruments.bell], // Fretless Bass
|
||||
[instruments.didgeridoo, instruments.bit, instruments.xylophone], // Slap Bass 1
|
||||
[instruments.didgeridoo, instruments.bit, instruments.xylophone], // Slap Bass 2
|
||||
[instruments.didgeridoo, instruments.bit, instruments.xylophone], // Synth Bass 1
|
||||
[instruments.didgeridoo, instruments.bit, instruments.xylophone], // Synth Bass 2
|
||||
|
||||
// Strings
|
||||
[instruments.flute, instruments.guitar, instruments.bass, instruments.bell], // Violin
|
||||
[instruments.flute, instruments.guitar, instruments.bass, instruments.bell], // Viola
|
||||
[instruments.flute, instruments.guitar, instruments.bass, instruments.bell], // Cello
|
||||
[instruments.flute, instruments.guitar, instruments.bass, instruments.bell], // Contrabass
|
||||
[instruments.bit, instruments.didgeridoo, instruments.bell], // Tremolo Strings
|
||||
[instruments.harp, instruments.bass, instruments.bell], // Pizzicato Strings
|
||||
[instruments.harp, instruments.bass, instruments.chime], // Orchestral Harp
|
||||
[instruments.harp, instruments.bass, instruments.bell], // Timpani
|
||||
|
||||
// Ensenble
|
||||
[instruments.harp, instruments.bass, instruments.bell], // String Ensemble 1
|
||||
[instruments.harp, instruments.bass, instruments.bell], // String Ensemble 2
|
||||
[instruments.harp, instruments.bass, instruments.bell], // Synth Strings 1
|
||||
[instruments.harp, instruments.bass, instruments.bell], // Synth Strings 2
|
||||
[instruments.harp, instruments.bass, instruments.bell], // Choir Aahs
|
||||
[instruments.harp, instruments.bass, instruments.bell], // Voice Oohs
|
||||
[instruments.harp, instruments.bass, instruments.bell], // Synth Choir
|
||||
[instruments.harp, instruments.bass, instruments.bell], // Orchestra Hit
|
||||
|
||||
// Brass
|
||||
[instruments.bit, instruments.didgeridoo, instruments.bell],
|
||||
[instruments.bit, instruments.didgeridoo, instruments.bell],
|
||||
[instruments.bit, instruments.didgeridoo, instruments.bell],
|
||||
[instruments.bit, instruments.didgeridoo, instruments.bell],
|
||||
[instruments.bit, instruments.didgeridoo, instruments.bell],
|
||||
[instruments.bit, instruments.didgeridoo, instruments.bell],
|
||||
[instruments.bit, instruments.didgeridoo, instruments.bell],
|
||||
[instruments.bit, instruments.didgeridoo, instruments.bell],
|
||||
|
||||
// Reed
|
||||
[instruments.flute, instruments.didgeridoo, instruments.iron_xylophone, instruments.bell],
|
||||
[instruments.flute, instruments.didgeridoo, instruments.iron_xylophone, instruments.bell],
|
||||
[instruments.flute, instruments.didgeridoo, instruments.iron_xylophone, instruments.bell],
|
||||
[instruments.flute, instruments.didgeridoo, instruments.iron_xylophone, instruments.bell],
|
||||
[instruments.flute, instruments.didgeridoo, instruments.iron_xylophone, instruments.bell],
|
||||
[instruments.flute, instruments.didgeridoo, instruments.iron_xylophone, instruments.bell],
|
||||
[instruments.flute, instruments.didgeridoo, instruments.iron_xylophone, instruments.bell],
|
||||
[instruments.flute, instruments.didgeridoo, instruments.iron_xylophone, instruments.bell],
|
||||
|
||||
// Pipe
|
||||
[instruments.flute, instruments.didgeridoo, instruments.iron_xylophone, instruments.bell],
|
||||
[instruments.flute, instruments.didgeridoo, instruments.iron_xylophone, instruments.bell],
|
||||
[instruments.flute, instruments.didgeridoo, instruments.iron_xylophone, instruments.bell],
|
||||
[instruments.flute, instruments.didgeridoo, instruments.iron_xylophone, instruments.bell],
|
||||
[instruments.flute, instruments.didgeridoo, instruments.iron_xylophone, instruments.bell],
|
||||
[instruments.flute, instruments.didgeridoo, instruments.iron_xylophone, instruments.bell],
|
||||
[instruments.flute, instruments.didgeridoo, instruments.iron_xylophone, instruments.bell],
|
||||
[instruments.flute, instruments.didgeridoo, instruments.iron_xylophone, instruments.bell],
|
||||
|
||||
// Synth Lead
|
||||
[instruments.harp, instruments.bass, instruments.bell],
|
||||
[instruments.harp, instruments.bass, instruments.bell],
|
||||
[instruments.harp, instruments.bass, instruments.bell],
|
||||
[instruments.harp, instruments.bass, instruments.bell],
|
||||
[instruments.harp, instruments.bass, instruments.bell],
|
||||
[instruments.harp, instruments.bass, instruments.bell],
|
||||
[instruments.harp, instruments.bass, instruments.bell],
|
||||
[instruments.harp, instruments.bass, instruments.bell],
|
||||
|
||||
// Synth Pad
|
||||
[instruments.harp, instruments.bass, instruments.bell],
|
||||
[instruments.harp, instruments.bass, instruments.bell],
|
||||
[instruments.harp, instruments.bass, instruments.bell],
|
||||
[instruments.harp, instruments.bass, instruments.bell],
|
||||
[instruments.harp, instruments.bass, instruments.bell],
|
||||
[instruments.harp, instruments.bass, instruments.bell],
|
||||
[instruments.harp, instruments.bass, instruments.bell],
|
||||
[instruments.harp, instruments.bass, instruments.bell],
|
||||
|
||||
// Synth Effects
|
||||
null,
|
||||
null,
|
||||
[instruments.bit, instruments.didgeridoo, instruments.bell],
|
||||
[instruments.harp, instruments.bass, instruments.bell],
|
||||
[instruments.harp, instruments.bass, instruments.bell],
|
||||
[instruments.harp, instruments.bass, instruments.bell],
|
||||
[instruments.harp, instruments.bass, instruments.bell],
|
||||
[instruments.harp, instruments.bass, instruments.bell],
|
||||
|
||||
// Ethnic
|
||||
[instruments.banjo, instruments.bass, instruments.bell],
|
||||
[instruments.banjo, instruments.bass, instruments.bell],
|
||||
[instruments.banjo, instruments.bass, instruments.bell],
|
||||
[instruments.banjo, instruments.bass, instruments.bell],
|
||||
[instruments.banjo, instruments.bass, instruments.bell],
|
||||
[instruments.harp, instruments.didgeridoo, instruments.bell],
|
||||
[instruments.harp, instruments.didgeridoo, instruments.bell],
|
||||
[instruments.harp, instruments.didgeridoo, instruments.bell],
|
||||
|
||||
// Percussive
|
||||
[instruments.iron_xylophone, instruments.bass, instruments.xylophone],
|
||||
[instruments.iron_xylophone, instruments.bass, instruments.xylophone],
|
||||
[instruments.iron_xylophone, instruments.bass, instruments.xylophone],
|
||||
[instruments.iron_xylophone, instruments.bass, instruments.xylophone],
|
||||
[instruments.iron_xylophone, instruments.bass, instruments.xylophone],
|
||||
[instruments.iron_xylophone, instruments.bass, instruments.xylophone],
|
||||
[instruments.iron_xylophone, instruments.bass, instruments.xylophone],
|
||||
[instruments.iron_xylophone, instruments.bass, instruments.xylophone]
|
||||
]
|
||||
@@ -1,82 +0,0 @@
|
||||
{
|
||||
"harp": {
|
||||
"id": 0,
|
||||
"name": "harp",
|
||||
"offset": 54
|
||||
},
|
||||
"basedrum": {
|
||||
"id": 1,
|
||||
"name": "basedrum",
|
||||
"offset": 0
|
||||
},
|
||||
"snare": {
|
||||
"id": 2,
|
||||
"name": "snare",
|
||||
"offset": 0
|
||||
},
|
||||
"hat": {
|
||||
"id": 3,
|
||||
"name": "hat",
|
||||
"offset": 0
|
||||
},
|
||||
"bass": {
|
||||
"id": 4,
|
||||
"name": "bass",
|
||||
"offset": 30
|
||||
},
|
||||
"flute": {
|
||||
"id": 5,
|
||||
"name": "flute",
|
||||
"offset": 66
|
||||
},
|
||||
"bell": {
|
||||
"id": 6,
|
||||
"name": "bell",
|
||||
"offset": 78
|
||||
},
|
||||
"guitar": {
|
||||
"id": 7,
|
||||
"name": "guitar",
|
||||
"offset": 42
|
||||
},
|
||||
"chime": {
|
||||
"id": 8,
|
||||
"name": "chime",
|
||||
"offset": 78
|
||||
},
|
||||
"xylophone": {
|
||||
"id": 9,
|
||||
"name": "xylophone",
|
||||
"offset": 78
|
||||
},
|
||||
"iron_xylophone": {
|
||||
"id": 10,
|
||||
"name": "iron_xylophone",
|
||||
"offset": 54
|
||||
},
|
||||
"cow_bell": {
|
||||
"id": 11,
|
||||
"name": "cow_bell",
|
||||
"offset": 66
|
||||
},
|
||||
"didgeridoo": {
|
||||
"id": 12,
|
||||
"name": "didgeridoo",
|
||||
"offset": 30
|
||||
},
|
||||
"bit": {
|
||||
"id": 13,
|
||||
"name": "bit",
|
||||
"offset": 54
|
||||
},
|
||||
"banjo": {
|
||||
"id": 14,
|
||||
"name": "banjo",
|
||||
"offset": 54
|
||||
},
|
||||
"pling": {
|
||||
"id": 15,
|
||||
"name": "pling",
|
||||
"offset": 54
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
|
||||
const { Midi } = require('@tonejs/midi')
|
||||
const { convertNote, convertPercussionNote } = require('./convert_note.js')
|
||||
|
||||
function convertMidi (midi) {
|
||||
if (!(midi instanceof Midi)) throw new TypeError('midi must be an instance of require(\'@tonejs/midi\').Midi')
|
||||
|
||||
let noteList = []
|
||||
for (const track of midi.tracks) {
|
||||
for (const note of track.notes) {
|
||||
const mcNote = (track.instrument.percussion ? convertPercussionNote : convertNote)(track, note)
|
||||
if (mcNote != null) {
|
||||
noteList.push(mcNote)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
noteList = noteList.sort((a, b) => a.time - b.time)
|
||||
|
||||
// It might be better to move some of this code to the converting loop (for performance reasons)
|
||||
let maxVolume = 0.001
|
||||
for (const note of noteList) {
|
||||
if (note.volume > maxVolume) maxVolume = note.volume
|
||||
}
|
||||
for (const note of noteList) {
|
||||
note.volume /= maxVolume
|
||||
}
|
||||
|
||||
let songLength = 0
|
||||
for (const note of noteList) {
|
||||
if (note.time > songLength) songLength = note.time
|
||||
}
|
||||
|
||||
return { name: midi.header.name, notes: noteList, loop: false, loopPosition: 0, length: songLength }
|
||||
}
|
||||
|
||||
module.exports = { convertMidi, convertNote, convertPercussionNote }
|
||||
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"main": "main.js"
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
const instruments = require('./instruments.json')
|
||||
|
||||
module.exports = [
|
||||
...new Array(35).fill(null), // offset
|
||||
{ pitch: 10, instrument: instruments.basedrum },
|
||||
{ pitch: 6, instrument: instruments.basedrum },
|
||||
{ pitch: 6, instrument: instruments.hat },
|
||||
{ pitch: 8, instrument: instruments.snare },
|
||||
{ pitch: 6, instrument: instruments.hat },
|
||||
{ pitch: 4, instrument: instruments.snare },
|
||||
{ pitch: 6, instrument: instruments.basedrum },
|
||||
{ pitch: 22, instrument: instruments.snare },
|
||||
{ pitch: 13, instrument: instruments.basedrum },
|
||||
{ pitch: 22, instrument: instruments.snare },
|
||||
{ pitch: 15, instrument: instruments.basedrum },
|
||||
{ pitch: 18, instrument: instruments.snare },
|
||||
{ pitch: 20, instrument: instruments.basedrum },
|
||||
{ pitch: 23, instrument: instruments.basedrum },
|
||||
{ pitch: 17, instrument: instruments.snare },
|
||||
{ pitch: 23, instrument: instruments.basedrum },
|
||||
{ pitch: 24, instrument: instruments.snare },
|
||||
{ pitch: 8, instrument: instruments.snare },
|
||||
{ pitch: 13, instrument: instruments.snare },
|
||||
{ pitch: 18, instrument: instruments.hat },
|
||||
{ pitch: 18, instrument: instruments.snare },
|
||||
{ pitch: 1, instrument: instruments.hat },
|
||||
{ pitch: 13, instrument: instruments.snare },
|
||||
{ pitch: 2, instrument: instruments.hat },
|
||||
{ pitch: 13, instrument: instruments.snare },
|
||||
{ pitch: 9, instrument: instruments.hat },
|
||||
{ pitch: 2, instrument: instruments.hat },
|
||||
{ pitch: 8, instrument: instruments.hat },
|
||||
{ pitch: 22, instrument: instruments.basedrum },
|
||||
{ pitch: 15, instrument: instruments.basedrum },
|
||||
{ pitch: 13, instrument: instruments.snare },
|
||||
{ pitch: 8, instrument: instruments.snare },
|
||||
{ pitch: 8, instrument: instruments.hat },
|
||||
{ pitch: 3, instrument: instruments.hat },
|
||||
{ pitch: 20, instrument: instruments.hat },
|
||||
{ pitch: 23, instrument: instruments.hat },
|
||||
{ pitch: 24, instrument: instruments.hat },
|
||||
{ pitch: 24, instrument: instruments.hat },
|
||||
{ pitch: 17, instrument: instruments.hat },
|
||||
{ pitch: 11, instrument: instruments.hat },
|
||||
{ pitch: 18, instrument: instruments.hat },
|
||||
{ pitch: 9, instrument: instruments.hat },
|
||||
{ pitch: 5, instrument: instruments.hat },
|
||||
{ pitch: 22, instrument: instruments.hat },
|
||||
{ pitch: 19, instrument: instruments.snare },
|
||||
{ pitch: 17, instrument: instruments.hat },
|
||||
{ pitch: 22, instrument: instruments.hat },
|
||||
{ pitch: 22, instrument: instruments.snare },
|
||||
{ pitch: 24, instrument: instruments.chime },
|
||||
{ pitch: 24, instrument: instruments.chime },
|
||||
{ pitch: 21, instrument: instruments.hat },
|
||||
{ pitch: 14, instrument: instruments.basedrum },
|
||||
{ pitch: 7, instrument: instruments.basedrum }
|
||||
]
|
||||
@@ -1,13 +0,0 @@
|
||||
/**
|
||||
* converts minecraft version to number (for example '1.19.2' will be 1.19)
|
||||
* @param {String} version
|
||||
* @return {Number} decimal number of the version you specified
|
||||
*/
|
||||
function minecraftVersionToNumber (version) {
|
||||
const versionArray = version.split('.')
|
||||
if (versionArray.length === 2) return Number(version)
|
||||
versionArray.pop()
|
||||
return Number(versionArray.join('.'))
|
||||
}
|
||||
|
||||
module.exports = minecraftVersionToNumber
|
||||
@@ -1,65 +0,0 @@
|
||||
const nbs = require('./nbs_file')
|
||||
const instrumentNames = [
|
||||
'harp',
|
||||
'bass',
|
||||
'basedrum',
|
||||
'snare',
|
||||
'hat',
|
||||
'guitar',
|
||||
'flute',
|
||||
'bell',
|
||||
'chime',
|
||||
'xylophone',
|
||||
'iron_xylophone',
|
||||
'cow_bell',
|
||||
'didgeridoo',
|
||||
'bit',
|
||||
'banjo',
|
||||
'pling'
|
||||
]
|
||||
|
||||
function convertNBS (buf) {
|
||||
const parsed = nbs.parse(buf)
|
||||
const song = {
|
||||
name: parsed.songName,
|
||||
notes: [],
|
||||
loop: false,
|
||||
loopPosition: 0,
|
||||
length: 0
|
||||
}
|
||||
if (parsed.loop > 0) {
|
||||
song.loop = true
|
||||
song.loopPosition = parsed.loopStartTick
|
||||
}
|
||||
for (const note of parsed.nbsNotes) {
|
||||
let instrument = note.instrument
|
||||
if (note.instrument < instrumentNames.length) {
|
||||
instrument = instrumentNames[note.instrument]
|
||||
} else continue
|
||||
|
||||
let key = note.key
|
||||
|
||||
while (key < 33) key += 12;
|
||||
while (key > 57) key -= 12;
|
||||
|
||||
const layerVolume = 100
|
||||
// will add layer volume later
|
||||
|
||||
const time = tickToMs(note.tick, parsed.tempo)
|
||||
song.length = Math.max(song.length, time)
|
||||
|
||||
song.notes.push({
|
||||
instrument,
|
||||
pitch: key - 33,
|
||||
volume: note.velocity * layerVolume / 10000,
|
||||
time
|
||||
})
|
||||
}
|
||||
return song
|
||||
}
|
||||
|
||||
function tickToMs (tick = 1, tempo) {
|
||||
return Math.floor(1000 * tick * 100 / tempo)
|
||||
}
|
||||
|
||||
module.exports = convertNBS
|
||||
@@ -1,157 +0,0 @@
|
||||
function parse (buffer) {
|
||||
let i = 0
|
||||
|
||||
let songLength = 0
|
||||
let format = 0
|
||||
let vanillaInstrumentCount = 0
|
||||
songLength = readShort()
|
||||
if (songLength === 0) {
|
||||
format = readByte()
|
||||
}
|
||||
|
||||
if (format >= 1) {
|
||||
vanillaInstrumentCount = readByte()
|
||||
}
|
||||
if (format >= 3) {
|
||||
songLength = readShort()
|
||||
}
|
||||
|
||||
const layerCount = readShort()
|
||||
const songName = readString()
|
||||
const songAuthor = readString()
|
||||
const songOriginalAuthor = readString()
|
||||
const songDescription = readString()
|
||||
const tempo = readShort()
|
||||
const autoSaving = readByte()
|
||||
const autoSavingDuration = readByte()
|
||||
const timeSignature = readByte()
|
||||
const minutesSpent = readInt()
|
||||
const leftClicks = readInt()
|
||||
const rightClicks = readInt()
|
||||
const blocksAdded = readInt()
|
||||
const blocksRemoved = readInt()
|
||||
const origFileName = readString()
|
||||
|
||||
let loop = 0
|
||||
let maxLoopCount = 0
|
||||
let loopStartTick = 0
|
||||
if (format >= 4) {
|
||||
loop = readByte()
|
||||
maxLoopCount = readByte()
|
||||
loopStartTick = readShort()
|
||||
}
|
||||
|
||||
const nbsNotes = []
|
||||
let tick = -1
|
||||
while (true) {
|
||||
const tickJumps = readShort()
|
||||
if (tickJumps === 0) break
|
||||
tick += tickJumps
|
||||
|
||||
let layer = -1
|
||||
while (true) {
|
||||
const layerJumps = readShort()
|
||||
if (layerJumps === 0) break
|
||||
layer += layerJumps
|
||||
const note = nbsNote()
|
||||
note.tick = tick
|
||||
note.layer = layer
|
||||
note.instrument = readByte()
|
||||
note.key = readByte()
|
||||
if (format >= 4) {
|
||||
note.velocity = readByte()
|
||||
note.panning = readByte()
|
||||
note.pitch = readShort()
|
||||
}
|
||||
nbsNotes.push(note)
|
||||
}
|
||||
}
|
||||
|
||||
const nbsLayers = []
|
||||
if (i <= buffer.length) {
|
||||
for (let j = 0; j < layerCount; j++) {
|
||||
const layer = nbsLayer()
|
||||
layer.name = readString()
|
||||
if (format >= 4) {
|
||||
layer.lock = readByte()
|
||||
}
|
||||
layer.volume = readByte()
|
||||
if (format >= 2) {
|
||||
layer.stereo = readByte()
|
||||
}
|
||||
nbsLayers.push(layer)
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
songLength,
|
||||
format,
|
||||
vanillaInstrumentCount,
|
||||
layerCount,
|
||||
songName,
|
||||
songAuthor,
|
||||
songOriginalAuthor,
|
||||
songDescription,
|
||||
tempo,
|
||||
autoSaving,
|
||||
autoSavingDuration,
|
||||
timeSignature,
|
||||
minutesSpent,
|
||||
leftClicks,
|
||||
rightClicks,
|
||||
blocksAdded,
|
||||
blocksRemoved,
|
||||
origFileName,
|
||||
loop,
|
||||
maxLoopCount,
|
||||
loopStartTick,
|
||||
nbsNotes,
|
||||
nbsLayers
|
||||
}
|
||||
|
||||
function readByte () {
|
||||
return buffer.readInt8(i++)
|
||||
}
|
||||
|
||||
function readShort () {
|
||||
const short = buffer.readInt16LE(i)
|
||||
i += 2
|
||||
return short
|
||||
}
|
||||
|
||||
function readInt () {
|
||||
const int = buffer.readInt32LE(i)
|
||||
i += 4
|
||||
return int
|
||||
}
|
||||
|
||||
function readString () {
|
||||
let length = readInt()
|
||||
let string = ''
|
||||
for (; length > 0; length--) string += String.fromCharCode(readByte())
|
||||
return string
|
||||
}
|
||||
}
|
||||
|
||||
function nbsNote () {
|
||||
return {
|
||||
tick: null,
|
||||
layer: null,
|
||||
instrument: null,
|
||||
key: null,
|
||||
velocity: 100,
|
||||
panning: 100,
|
||||
pitch: 0
|
||||
}
|
||||
}
|
||||
|
||||
function nbsLayer () {
|
||||
return {
|
||||
name: null,
|
||||
lock: 0,
|
||||
volume: null,
|
||||
stereo: 100
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { parse, nbsNote, nbsLayer }
|
||||
@@ -1,15 +0,0 @@
|
||||
const { instrumentsArray } = require('minecraft-data')('1.15.2') // chip hardcoding moment
|
||||
|
||||
function parseTXTSong (data) {
|
||||
let length = 0
|
||||
const notes = String(data).split(/\r\n|\r|\n/).map(line => {
|
||||
const [tick, pitch, instrument] = line.split(':').map(Number)
|
||||
if (tick === undefined || pitch === undefined || instrument === undefined) return undefined
|
||||
const time = tick * 50
|
||||
length = Math.max(length, time)
|
||||
return { time, pitch, instrument: instrumentsArray[instrument].name, volume: 1 }
|
||||
}).filter(note => note !== undefined)
|
||||
return { name: '', notes, loop: false, loopPosition: 0, length }
|
||||
}
|
||||
|
||||
module.exports = parseTXTSong
|
||||
@@ -1,17 +0,0 @@
|
||||
// TODO: Improve how messages are stringified
|
||||
const ChatMessage = require('prismarine-chat')('1.20.2')
|
||||
const stringify = message => new ChatMessage(message).toString()
|
||||
|
||||
class CommandError extends Error {
|
||||
constructor (message, filename, lineError) {
|
||||
super(stringify(message), filename, lineError)
|
||||
this.name = 'CommandError'
|
||||
this._message = message
|
||||
|
||||
}
|
||||
|
||||
get message () {
|
||||
return stringify(this._message)
|
||||
}
|
||||
}
|
||||
module.exports = CommandError
|
||||
@@ -1,18 +0,0 @@
|
||||
class CommandSource {
|
||||
constructor (player, sources, hash = false, discordMessageEvent = null, consoleOnly = sources) {
|
||||
this.player = player
|
||||
this.sources = sources
|
||||
this.hash = hash
|
||||
this.consoleOnly = consoleOnly
|
||||
this.discordMessageEvent = discordMessageEvent
|
||||
this.displayName = player
|
||||
}
|
||||
|
||||
sendFeedback () {}
|
||||
|
||||
sendError (message) {
|
||||
this.sendFeedback([{ text: '', color: 'red' }, message], false)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = CommandSource
|
||||
@@ -0,0 +1,661 @@
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
@@ -1,4 +0,0 @@
|
||||
# FNFBoyfriendBot-V4.0
|
||||
|
||||
|
||||
Final Build of v4.0 (v4.3.4) but not the final build of the Ultimate Foundation code base of FNFBoyfriendBot
|
||||
-6802
File diff suppressed because it is too large
Load Diff
@@ -1,144 +0,0 @@
|
||||
const mc = require('minecraft-protocol')
|
||||
const { EventEmitter } = require('node:events')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const util = require('node:util')
|
||||
console.log(`Starting ${process.env["buildstring"]} .......`)
|
||||
console.log(`Foundation: ${process.env["FoundationBuildString"]}`)
|
||||
console.log('this may take a few moments....')
|
||||
|
||||
function createBot(options = {}) {
|
||||
const bot = new EventEmitter()
|
||||
const rs = require('randomstring')
|
||||
// Set some default values in options
|
||||
let r = Math.floor(Math.random() * 255) + 1;
|
||||
options.host ??= 'localhost'
|
||||
options.username ??= 'FNFBoyfriendBot'
|
||||
options.hideErrors ??= false // HACK: Hide errors by default as a lazy fix to console being spammed with them
|
||||
options.console ??= true
|
||||
options.input ??= true
|
||||
|
||||
options.selfcare.unmuted ??= true
|
||||
|
||||
options.selfcare.vanished ??= true
|
||||
|
||||
options.selfcare.prefix ??= true
|
||||
|
||||
options.selfcare.skin ??= true
|
||||
|
||||
options.selfcare.cspy ??= true
|
||||
|
||||
options.selfcare.op ??= true
|
||||
|
||||
options.selfcare.gmc ??= true
|
||||
|
||||
options.selfcare.interval ??= 500
|
||||
|
||||
options.Core.core ??= true
|
||||
|
||||
options.commands.prefix ??= '!'
|
||||
|
||||
options.discord.commandPrefix ??= '!'
|
||||
|
||||
options.reconnectDelay ??= 1000
|
||||
|
||||
options.Core.customName ??= '@'
|
||||
|
||||
options.selfcare.username ??= true
|
||||
|
||||
options.selfcare.nickname ??= true
|
||||
|
||||
options.selfcare.god ??= true
|
||||
|
||||
options.selfcare.tptoggle ??= true
|
||||
bot.options = options
|
||||
|
||||
// Create our client object, put it on the bot, and register some events
|
||||
bot.on('init_client', client => {
|
||||
client.on('packet', (data, meta) => {
|
||||
bot.emit('packet', data, meta)
|
||||
bot.emit('packet.' + meta.name, data)
|
||||
})
|
||||
|
||||
client.on('login', async function (data) {
|
||||
|
||||
bot.uuid = client.uuid
|
||||
bot.username = client.username
|
||||
bot.entityId = data.entityId
|
||||
bot.host = bot.options.host
|
||||
bot.port = bot.options.port
|
||||
bot.buildstring = process.env['buildstring']
|
||||
bot.fbs = process.env['FoundationBuildString']
|
||||
bot.version = bot.options.version
|
||||
console.log(`Username: ${bot.username}`)
|
||||
console.log(`Host: ${bot.host}:${bot.port}`)
|
||||
console.log(`Minecraft java version: ${bot.version}`)
|
||||
})
|
||||
//bot.visibility = false
|
||||
client.on('end', reason => { bot.emit('end', reason)
|
||||
|
||||
})
|
||||
client.on('keep_alive', ({ keepAliveId }) => {
|
||||
bot.emit('keep_alive', { keepAliveId })
|
||||
})
|
||||
client.on('error', error => bot.emit('error', error), )
|
||||
|
||||
})
|
||||
|
||||
const buildstring = process.env['buildstring']
|
||||
|
||||
const client = options.client ?? mc.createClient(options)
|
||||
bot._client = client
|
||||
bot.emit('init_client', client)
|
||||
|
||||
bot.bots = options.bots ?? [bot]
|
||||
|
||||
// Modules
|
||||
bot.loadModule = module => module(bot, options)
|
||||
|
||||
for (const filename of fs.readdirSync(path.join(__dirname, 'modules'))) {
|
||||
try {
|
||||
const module = require(path.join(__dirname, 'modules', filename))
|
||||
bot.loadModule(module)
|
||||
//console.log(filename.length);
|
||||
} catch (error) {
|
||||
|
||||
console.error('\x1b[0m\x1b[91m[ERROR]: \x1b[0m\x1b[90mFailed to load module', filename, ':', error)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return bot
|
||||
}//path.join(__dirname, 'modules', filename)
|
||||
//path.join(amonger + 'FridayNightFunkinBoyfriendBot') !== path.join(amonger)
|
||||
//fs.stat
|
||||
const amonger = '../'
|
||||
if (fs.existsSync('../FridayNightFunkinBoyfriendBot') == false) {
|
||||
process.exit(1)
|
||||
}
|
||||
//path.join('') != fs. existsSync('~/FridayNightFunkinBoyfriendBot/index.js')
|
||||
|
||||
const modules = './modules';
|
||||
const util2 = './util';
|
||||
const CommandModules = './CommandModules';
|
||||
const commands = './commands';
|
||||
const chat = './chat'
|
||||
fs.readdir(util2, (err, files) => {
|
||||
console.log('Successfully loaded: ' + files.length + ' util files');
|
||||
});
|
||||
fs.readdir(modules, (err, files) => {
|
||||
console.log('Successfully loaded: ' + files.length + ' module files');
|
||||
});
|
||||
fs.readdir(commands, (err, files) => {
|
||||
console.log('Successfully loaded: ' + files.length + ' command files');
|
||||
});
|
||||
fs.readdir(CommandModules, (err, files) => {
|
||||
console.log('Successfully loaded: ' + files.length + ' CommandModule files');
|
||||
});
|
||||
fs.readdir(chat, (err, files) => {
|
||||
console.log('Successfully loaded: ' + files.length + ' chat files');
|
||||
});
|
||||
|
||||
// ABot username function mabe mabe
|
||||
|
||||
module.exports = createBot
|
||||
@@ -0,0 +1,62 @@
|
||||
version = "v9.0.0"
|
||||
group = "nitoribot"
|
||||
description = "NitoriBot"
|
||||
plugins {
|
||||
id("com.gradleup.shadow") version "9.2.2"
|
||||
kotlin("jvm") version "2.3.10"
|
||||
id("maven-publish")
|
||||
application
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvmToolchain(25)
|
||||
}
|
||||
|
||||
repositories {
|
||||
|
||||
mavenCentral()
|
||||
|
||||
maven("https://repo.opencollab.dev/maven-releases/")
|
||||
|
||||
maven("https://repo.opencollab.dev/maven-snapshots/")
|
||||
|
||||
maven("https://jitpack.io/")
|
||||
|
||||
maven("https://repo.opencollab.dev/main/")
|
||||
|
||||
maven("https://maven.maxhenkel.de/repository/public/")
|
||||
|
||||
// maven("https://libraries.minecraft.net")
|
||||
|
||||
/* maven("https://code.optmstc.dev/api/packages/kso/maven") {
|
||||
content {
|
||||
includeGroupAndSubgroups("land.chipmunk.code")
|
||||
}
|
||||
}*/
|
||||
|
||||
//maven("https://libraries.minecraft.net")
|
||||
|
||||
maven("https://code.chipmunk.land/api/packages/kaboomstandardsorganization/maven/")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("org.geysermc.mcprotocollib:protocol:26.2-SNAPSHOT")
|
||||
implementation("org.slf4j:slf4j-api:2.0.13")
|
||||
implementation("org.tinylog:slf4j-tinylog:2.7.0")
|
||||
implementation("org.tinylog:tinylog-impl:2.7.0")
|
||||
implementation("org.yaml:snakeyaml:2.2")
|
||||
implementation("net.kyori:adventure-text-serializer-ansi:4.26.1")
|
||||
implementation("net.kyori:adventure-text-serializer-plain:4.26.1")
|
||||
implementation("net.kyori:adventure-text-serializer-legacy:4.26.1")
|
||||
implementation("net.kyori:adventure-text-serializer-gson:4.26.1")
|
||||
implementation("net.dv8tion:JDA:6.4.1")
|
||||
implementation("de.connect2x.trixnity:trixnity-client:5.0.0")
|
||||
implementation("org.pircbotx:pircbotx:2.1")
|
||||
implementation("org.jline:jline:4.1.0")
|
||||
implementation("land.chipmunk.code.kaboomstandardsorganization.messaginglib:mcprotocollib:3.1.2")
|
||||
}
|
||||
|
||||
application {
|
||||
mainClass.set("land.chipmunk.parker2991.nitoribot.Main")
|
||||
}
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
function parseMessage (message, data, context) {
|
||||
if (message === null || typeof message !== 'object') return
|
||||
|
||||
if (message.with?.length < 2 || (message.translate !== 'chat.type.emote' && message.translate !== '%s %s')) return
|
||||
|
||||
const senderComponent = message.with[0]
|
||||
// wtf spam again - console.log(senderComponent)//wtf...
|
||||
//console.log(senderComponent)
|
||||
|
||||
const contents = message.with[1]
|
||||
// spam lol - console.log(contents)
|
||||
//console.log(contents)
|
||||
let sender
|
||||
|
||||
const hoverEvent = senderComponent.hoverEvent
|
||||
if (hoverEvent?.action === 'show_entity') {
|
||||
const id = hoverEvent.contents.id
|
||||
//
|
||||
sender = data.players.find(player => player.uuid === id)
|
||||
} else {
|
||||
const stringUsername = data.getMessageAsPrismarine(senderComponent).toString() // TypeError: data.getMessageAsPrismarine is not a function
|
||||
|
||||
sender = data.players.find(player => player.profile.name) //=== stringusername)
|
||||
}
|
||||
|
||||
if (!sender) return undefined
|
||||
|
||||
return { sender, contents, type: 'minecraft:chat', senderComponent }
|
||||
}
|
||||
|
||||
module.exports = parseMessage
|
||||
@@ -1,31 +0,0 @@
|
||||
function parseMessage (message, data, context) {
|
||||
if (message === null || typeof message !== 'object') return
|
||||
|
||||
if (message.with?.length < 2 || (message.translate !== 'chat.type.text' && message.translate !== '%s %s')) return
|
||||
|
||||
const senderComponent = message.with[0]
|
||||
// wtf spam again - console.log(senderComponent)//wtf...
|
||||
//console.log(senderComponent)
|
||||
|
||||
const contents = message.with[1]
|
||||
// spam lol - console.log(contents)
|
||||
//console.log(contents)
|
||||
let sender
|
||||
|
||||
const hoverEvent = senderComponent.hoverEvent
|
||||
if (hoverEvent?.action === 'show_entity') {
|
||||
const id = hoverEvent.contents.id
|
||||
//
|
||||
sender = data.players.find(player => player.uuid === id)
|
||||
} else {
|
||||
const stringUsername = data.getMessageAsPrismarine(senderComponent).toString() // TypeError: data.getMessageAsPrismarine is not a function
|
||||
|
||||
sender = data.players.find(player => player.profile.name) //=== stringusername)
|
||||
}
|
||||
|
||||
if (!sender) return undefined
|
||||
|
||||
return { sender, contents, type: 'minecraft:chat', senderComponent }
|
||||
}
|
||||
|
||||
module.exports = parseMessage
|
||||
@@ -1,35 +0,0 @@
|
||||
function parseMessage (message, data, context, bot) {
|
||||
try{
|
||||
if (message === null || typeof message !== 'object') return
|
||||
|
||||
if (message.with?.length < 3 || (message.translate !== '[%s] %s › %s' && message.translate !== '%s %s › %s')) return
|
||||
|
||||
const senderComponent = message.with[1]
|
||||
// wtf spam again -
|
||||
//console.log(senderComponent)//wtf...
|
||||
|
||||
|
||||
const contents = message.with[2]
|
||||
// spam lol - console.log(contents)
|
||||
let sender
|
||||
|
||||
const hoverEvent = senderComponent.hoverEvent
|
||||
// console.log(hoverEvent)
|
||||
if (hoverEvent?.action === 'show_entity') {
|
||||
const id = hoverEvent.contents.id
|
||||
//
|
||||
sender = data.players.find(player => player.uuid === id)
|
||||
} else {
|
||||
const stringUsername = data.getMessageAsPrismarine(senderComponent).toString() // TypeError: data.getMessageAsPrismarine is not a function
|
||||
|
||||
sender = data.players.find(player => player.profile.name) //=== stringusername)
|
||||
}
|
||||
|
||||
if (!sender) return null
|
||||
|
||||
return { sender, contents, type: 'minecraft:chat', senderComponent }
|
||||
}catch(e){
|
||||
console.error(e)
|
||||
}
|
||||
}
|
||||
module.exports = parseMessage
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user