forked from afspiegeling/NitoriBot
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
229f4c5664 | ||
|
|
37e19521a4 |
+34
-16
@@ -1,6 +1,8 @@
|
||||
const mc = require('minecraft-protocol');
|
||||
const { EventEmitter } = require('events');
|
||||
EventEmitter.defaultMaxListeners = 200;
|
||||
const ChatMessage = require("prismarine-chat");
|
||||
EventEmitter.defaultMaxListeners = Infinity;
|
||||
let disconnectCount = 0;
|
||||
|
||||
function createBot(options = {}, config) {
|
||||
const bot = new EventEmitter();
|
||||
@@ -23,27 +25,43 @@ function createBot(options = {}, config) {
|
||||
bot.username = client.username;
|
||||
})
|
||||
|
||||
client.on('disconnect', data => {
|
||||
bot.emit("clientDisconnect", data.reason);
|
||||
})
|
||||
client.on("disconnect", (data) => {
|
||||
bot.console.warn(`${ChatMessage(bot._client.version).fromNotch("§8[§bClient Reconnect§8]§r")?.toAnsi()} ${ChatMessage(bot._client.version).fromNotch(data.reason)?.toAnsi()}`);
|
||||
bot?.discord?.channel?.send(ChatMessage(bot._client.version).fromNotch(data.reason)?.toString());
|
||||
});
|
||||
|
||||
client.on('end', reason => {
|
||||
bot.emit('end', reason);
|
||||
})
|
||||
client.on("end", (reason) => {
|
||||
bot.emit("end", reason);
|
||||
disconnectCount++;
|
||||
});
|
||||
|
||||
client.on('error', error => {
|
||||
bot.emit('clientDisconnect', error.toString());
|
||||
})
|
||||
client.on("error", (error) => {
|
||||
try {
|
||||
if (disconnectCount === 10) {
|
||||
bot.console.info("stopped logging disconnect messages for now...");
|
||||
bot?.discord?.channel?.send("stopped logging disconnect messages for now...");
|
||||
return;
|
||||
} else if (disconnectCount > 10) {
|
||||
return;
|
||||
} else {
|
||||
bot.console.warn(ChatMessage(bot._client.version).fromNotch(`§8[§bClient Reconnect§8]§r ${error.toString()}`)?.toAnsi());
|
||||
bot?.discord?.channel?.send(error.toString());
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e.stack);
|
||||
}
|
||||
});
|
||||
|
||||
client.on("keep_alive", ({ keepAliveId }) => {
|
||||
})
|
||||
|
||||
client.on('kick_disconnect', (data) => {
|
||||
bot.emit("clientDisconnect", data.reason)
|
||||
})
|
||||
client.on("kick_disconnect", (data) => {
|
||||
bot.console.warn(`${ChatMessage(bot._client.version).fromNotch("§8[§bClient Reconnect§8]§r")?.toAnsi()} ${ChatMessage(bot._client.version).fromNotch(data.reason)?.toAnsi()}`);
|
||||
bot?.discord?.channel?.send(ChatMessage(bot._client.version).fromNotch(data.reason)?.toString());
|
||||
});
|
||||
|
||||
process.on("uncaughtException", (e) => {
|
||||
});
|
||||
|
||||
client.on("success", () => {
|
||||
disconnectCount = 0;
|
||||
});
|
||||
})
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@ module.exports = {
|
||||
const bot = context.bot
|
||||
const args = context.arguments;
|
||||
const source = context.source;
|
||||
const config = context.config;
|
||||
|
||||
if (!args && !args[0] && !args[1] && !args[2] && !args[3]) return;
|
||||
switch (args[0]?.toLowerCase()) {
|
||||
case "server":
|
||||
|
||||
@@ -44,6 +44,7 @@ module.exports = {
|
||||
const bot = context.bot;
|
||||
const args = context.arguments;
|
||||
const fixansi = context.fixansi;
|
||||
const config = context.config;
|
||||
|
||||
let component = [];
|
||||
|
||||
@@ -59,7 +60,7 @@ module.exports = {
|
||||
if (e.toString() === "pageError: TypeError: Cannot read properties of undefined (reading 'pages')") {
|
||||
bot?.discord?.message?.reply('Article not found!');
|
||||
} else {
|
||||
bot?.discord?.message?.reply(`${e.toString()}`);
|
||||
bot?.discord?.message?.reply(`${e.stack}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,8 @@ module.exports = {
|
||||
const event = bot?.discord?.message
|
||||
const roles = event?.member?.roles?.cache
|
||||
const source = context.source;
|
||||
const config = context.config;
|
||||
|
||||
if (roles?.some(role => role.name === `${config.discord.roles.trusted}`)) {
|
||||
bot.discord.message.reply('Valid trusted user')
|
||||
bot.chat.message(`Valid trusted user [${bot.discord.message.member.user.username}]`)
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"buildstring": {
|
||||
"build": "2200",
|
||||
"build": "2205",
|
||||
"codename": "",
|
||||
"version": "v7.0.5",
|
||||
"version": "v7.0.6",
|
||||
"url": "https://code.chipmunk.land/Parker2991/FridayNightFunkinBoyfriendBot.git"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,28 +34,7 @@ for (const options of config.bots) {
|
||||
bots.push(bot);
|
||||
bot.bots = bots;
|
||||
require('./util/loadModules')(bot, options, config, discordClient);
|
||||
|
||||
let disconnectCount = 0;
|
||||
bot.console.readlineInterface(rl);
|
||||
|
||||
bot.on('clientDisconnect', (data) => {
|
||||
try {
|
||||
disconnectCount++
|
||||
|
||||
if (disconnectCount === 10) {
|
||||
bot.console.info('stopped logging disconnect messages for now...');
|
||||
bot?.discord?.channel?.send('stopped logging disconnect messages for now...');
|
||||
return;
|
||||
} else if (disconnectCount > 10) {
|
||||
return;
|
||||
} else {
|
||||
bot.console.warn(bot.getMessageAsPrismarine(`§8[§bClient Reconnect§8]§r ${data}`)?.toAnsi())
|
||||
bot?.discord?.channel?.send(data.toString());
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e.stack);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
discordClient.on('messageCreate', (message) => {
|
||||
|
||||
+1
-1
@@ -83,7 +83,7 @@ function inject (context) {
|
||||
return
|
||||
}
|
||||
|
||||
if (message.translate === "advMode.notAllowed" || message?.translate?.startsWith("قيادة المجموعة")) return;
|
||||
if (message.translate === "advMode.notAllowed") return;
|
||||
|
||||
bot.emit('message', message);
|
||||
|
||||
|
||||
@@ -50,11 +50,11 @@ function inject (context) {
|
||||
present: true,
|
||||
itemId: bot.registry.itemsByName.repeating_command_block.id,
|
||||
itemCount: 1,
|
||||
nbtData: nbt.comp({
|
||||
/* nbtData: nbt.comp({
|
||||
BlockEntityTag: nbt.comp({
|
||||
CustomName: nbt.string(JSON.stringify(config.core.itemName))
|
||||
})
|
||||
})
|
||||
})*/
|
||||
}
|
||||
});
|
||||
|
||||
@@ -185,11 +185,11 @@ function inject (context) {
|
||||
present: true,
|
||||
itemId: bot.registry.itemsByName.repeating_command_block.id,
|
||||
itemCount: 1,
|
||||
nbtData: nbt.comp({
|
||||
/* nbtData: nbt.comp({
|
||||
BlockEntityTag: nbt.comp({
|
||||
CustomName: nbt.string(JSON.stringify(config.core.itemName))
|
||||
})
|
||||
})
|
||||
})*/
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ async function inject (context) {
|
||||
}
|
||||
}
|
||||
|
||||
cmdMgrUtil(bot, command, args, source);
|
||||
cmdMgrUtil(bot, command, args, source, config);
|
||||
|
||||
return command?.execute({ bot, source, arguments: args, config, discordClient });
|
||||
} catch (error) {
|
||||
@@ -82,7 +82,7 @@ async function inject (context) {
|
||||
throw new CommandError(`Unknown Command: ${commandName}`);
|
||||
}
|
||||
|
||||
cmdMgrUtil(bot, command, args, source);
|
||||
cmdMgrUtil(bot, command, args, source, config);
|
||||
|
||||
if (!command?.discordExecute) {
|
||||
throw new CommandError(`${command.data.name} command is not supported in discord!`);
|
||||
@@ -93,7 +93,7 @@ async function inject (context) {
|
||||
if (error instanceof CommandError) {
|
||||
bot?.discord?.message?.reply(`${bot.getMessageAsPrismarine(error._message)}`);
|
||||
} else {
|
||||
bot?.discord?.message?.reply(`\`\`\`${error}\`\`\``);
|
||||
bot?.discord?.message?.reply(`\`\`\`${error.stack}\`\`\``);
|
||||
bot?.console?.warn(error.stack);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,12 +6,15 @@ function inject (context) {
|
||||
const config = context.config;
|
||||
const discordClient = context.discordClient;
|
||||
const options = context.options;
|
||||
if (!options?.channelId) {
|
||||
if (!options.channelId) {
|
||||
bot.discord = {
|
||||
invite: config.discord?.invite
|
||||
invite: config.discord?.invite,
|
||||
client: discordClient,
|
||||
prefix: config.discord.prefix
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
bot.discord = {
|
||||
client: discordClient,
|
||||
channel: undefined,
|
||||
|
||||
@@ -88,9 +88,7 @@ function inject (context) {
|
||||
setTimeout(() => {
|
||||
positionCount--
|
||||
if (positionCount > 4) {
|
||||
bot.core.run('sudo * icu stop');
|
||||
} if (permissionLevel < 2 || gameMode !== 1) {
|
||||
bot._client.end('anti icu :3');
|
||||
bot._client.end('anti icu')
|
||||
}
|
||||
}, 1000)
|
||||
})
|
||||
@@ -116,7 +114,7 @@ function inject (context) {
|
||||
if (permissionLevel < 2) bot.chat.command('op @s[type=player]');
|
||||
else if (gameMode !== 1) bot.chat.command('minecraft:gamemode creative');
|
||||
else if (username) bot.chat.command(`username ${bot._client.username}`)
|
||||
else if (nickname) bot.chat.command(`nick off`)
|
||||
// else if (nickname) bot.chat.command(`nick off`)
|
||||
else if (!prefix) bot.chat.command(`prefix &8[&bPrefix&8: &3${config.prefixes[0]}&8]`);
|
||||
else if (!vanished && bot.vanished) bot.core.run(`essentials:vanish ${bot._client.username} on`);
|
||||
else if (!commandSpy) bot.core.run(`commandspy ${bot.uuid} on`);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const CommandError = require('./command_error');
|
||||
module.exports = (bot, command, args, source) => {
|
||||
module.exports = (bot, command, args, source, config) => {
|
||||
const event = bot.discord.message;
|
||||
const roles = event?.member?.roles?.cache;
|
||||
switch (command?.data?.trustLevel) {
|
||||
|
||||
Reference in New Issue
Block a user