diff --git a/commands/ip.js b/commands/ip.js index 2a5622d..6b420be 100644 --- a/commands/ip.js +++ b/commands/ip.js @@ -17,6 +17,6 @@ module.exports.run = async (bot, message, args) => { .setTitle((config.server.name ? config.server.name : message.guild.name) + ' IP:', icon) .setDescription(`\`${server.ip}\`:\`${server.port}\``) .setColor(config.embeds.color); - message.channel.send(ipEmbed); + message.channel.send({ embeds: [ipEmbed] }); } }; \ No newline at end of file diff --git a/commands/list.js b/commands/list.js index fe88941..9ebded4 100644 --- a/commands/list.js +++ b/commands/list.js @@ -29,14 +29,14 @@ module.exports.run = async (bot, message) => { { name: "Players", value: `**${response.onlinePlayers}**/**${response.maxPlayers}**` + (response.samplePlayers ? "\n\`\`\`" + response.samplePlayers.map(p => ` ${p.name} `).join('\n') + "\`\`\`":"") , inline: false }, ) .setColor(config.embeds.color) - message.channel.send(serverEmbed); + message.channel.send({ embeds: [serverEmbed] }); }) .catch((error) => { const errorEmbed = new Discord.MessageEmbed() .setAuthor(`${ip1}:${port1}`, 'https://www.planetminecraft.com/files/image/minecraft/project/2020/224/12627341-image_l.jpg') .setDescription(':x: **OFFLINE**') .setColor(config.embeds.error) - message.channel.send(errorEmbed); + message.channel.send({ embeds: [errorEmbed] }); throw error; }); diff --git a/commands/status.js b/commands/status.js index 4d10512..35f3135 100644 --- a/commands/status.js +++ b/commands/status.js @@ -22,11 +22,6 @@ module.exports.run = async (bot, message) => { if(server.type === 'java') { util.status(ip1, { port: port1 }) .then((response) => { - const favic = response.favicon - let icon = favic.split(`,`); - let imageStream = new Buffer.from(icon[1], 'base64'); - var attachment = new Discord.MessageAttachment(imageStream, 'logo.png'); - const description1 = response.description.descriptionText, description11 = description1.toString().replace(/\u00A7[0-9A-FK-OR]/ig, '') @@ -39,7 +34,6 @@ module.exports.run = async (bot, message) => { const version = versionAdvanced ? versionAdvanced : versionOriginal const serverEmbed = new Discord.MessageEmbed() - .attachFiles(attachment) .setAuthor(config.server.name ? config.server.name : message.guild.name, 'attachment://logo.png') .setDescription(`:white_check_mark: **ONLINE**`) .addFields( @@ -49,14 +43,14 @@ module.exports.run = async (bot, message) => { { name: "Players", value: `**${response.onlinePlayers}**/**${response.maxPlayers}**` , inline: true }, ) .setColor(config.embeds.color) - message.channel.send(serverEmbed); + message.channel.send({ embeds: [serverEmbed] }); }) .catch((error) => { const errorEmbed = new Discord.MessageEmbed() .setAuthor(`${ip1}:${port1}`, 'https://www.planetminecraft.com/files/image/minecraft/project/2020/224/12627341-image_l.jpg') .setDescription(':x: **OFFLINE**') .setColor(config.embeds.error) - message.channel.send(errorEmbed); + message.channel.send({ embeds: [errorEmbed] }); throw error; }); @@ -79,14 +73,14 @@ module.exports.run = async (bot, message) => { { name: "Players", value: `**${response.onlinePlayers}**/**${response.maxPlayers}**` , inline: true }, ) .setColor('#77fc03') - message.channel.send(serverEmbed); + message.channel.send({ embeds: [serverEmbed] }); }) .catch((error) => { const errorEmbed = new Discord.MessageEmbed() .setAuthor(config.server.name ? config.server.name : message.guild.name, icon) .setDescription(':x: **OFFLINE**') .setColor('#f53636') - message.channel.send(errorEmbed); + message.channel.send({ embeds: [errorEmbed] }); throw error; }); diff --git a/commands/test.js b/commands/test.js index d594ee6..9edd766 100644 --- a/commands/test.js +++ b/commands/test.js @@ -11,5 +11,5 @@ module.exports.config = { module.exports.run = async (bot, message) => { const { server, config } = bot - message.channel.send('Didn\'t you mean toast?') + message.channel.send({ content: 'Didn\'t you mean toast?' }); }; \ No newline at end of file diff --git a/commands/version.js b/commands/version.js index c3d4167..4aed462 100644 --- a/commands/version.js +++ b/commands/version.js @@ -39,5 +39,5 @@ module.exports.run = async (bot, message, args) => { .setTitle((config.server.name ? config.server.name : message.guild.name) + ' Version:', icon) .setDescription(`**${version}**`) .setColor(config.embeds.color); - message.channel.send(versionEmbed); + message.channel.send({ embeds: [versionEmbed] }); }; \ No newline at end of file diff --git a/commands/vote.js b/commands/vote.js index 9ba07eb..7e31222 100644 --- a/commands/vote.js +++ b/commands/vote.js @@ -19,6 +19,6 @@ module.exports.run = async (bot, message, args) => { .setTitle('Vote for ' + serverName, icon) .setDescription(`[Here](${server.vote}) you can vote for ${serverName}!`) .setColor(config.embeds.color); - message.channel.send(ipEmbed); + message.channel.send({ embeds: [ipEmbed] }); } }; \ No newline at end of file diff --git a/events/message.js b/events/messageCreate.js similarity index 81% rename from events/message.js rename to events/messageCreate.js index f943fd5..2890f5b 100644 --- a/events/message.js +++ b/events/messageCreate.js @@ -5,10 +5,9 @@ module.exports = async (bot, message) => { if(message.author.bot) return; if(message.channel.type === "dm") { if(message.content.includes('minecraft-bot version')) { - message.channel.startTyping(); + message.channel.sendTyping(); setTimeout(function(){ - message.channel.stopTyping(); - message.channel.send(version); + message.channel.send({ content: version }); }, ms('1,5s')); return; } @@ -28,8 +27,8 @@ module.exports = async (bot, message) => { if(config.votingCH.reactions.second) message.react(config.votingCH.reactions.second) message.react(config.votingCH.reactions.cancel) - const filter = (reaction, user) => reaction.emoji.name === config.votingCH.reactions.cancel && (user.id === message.author.id || message.guild.member(user.id).permissions.has("MANAGE_MESSAGES") && user.id !== bot.user.id); - const cancel = await message.createReactionCollector(filter, { time: ms(config.votingCH.time), max: 1 }) + const filter = (reaction, user) => reaction.emoji.name === config.votingCH.reactions.cancel && (user.id === message.author.id || message.guild.members.cache.get(user.id).permissions.has("MANAGE_MESSAGES") && user.id !== bot.user.id); + const cancel = await message.createReactionCollector({ filter, time: ms(config.votingCH.time), max: 1 }) cancel.on('collect', () => { message.reactions.removeAll() diff --git a/events/ready.js b/events/ready.js index 0ea6eb9..df7b402 100644 --- a/events/ready.js +++ b/events/ready.js @@ -41,7 +41,7 @@ module.exports = async (bot) => { { name: "INFO", value: `EDITION §\n\`${server.ip}\`:\`${server.port}\`` , inline: true } ) .setColor(config.embeds.color) - msg = await channel.send(serverEmbed) + msg = await channel.send({ embeds: [serverEmbed] }) } catch(err) { console.log(err)} console.log(`✅ Successfully sent status message to ${gr(channel.name)}!`) @@ -235,5 +235,5 @@ module.exports = async (bot) => { } } - console.log("✅ " + gr(bot.user.username) + " is now working") + console.log("✅ " + gr(bot.user.username) + " is now working with prefix " + gr(bot.prefix)) } \ No newline at end of file diff --git a/index.js b/index.js index 365fe0a..5bdcd6e 100644 --- a/index.js +++ b/index.js @@ -1,10 +1,11 @@ const Discord = require('discord.js'), fs = require('fs'), c = require('chalk'), -ms = require('ms') +ms = require('ms'), +Intents = Discord.Intents //Discord client - I like "bot" more, then "client" -const bot = new Discord.Client({disableEveryone: true}); +const bot = new Discord.Client({ intents: [ Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_INTEGRATIONS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_MESSAGE_REACTIONS, Intents.FLAGS.GUILD_MESSAGE_TYPING, Intents.FLAGS.GUILD_MEMBERS ] }); const config = require('./config'), activites = ['PLAYING', 'WATCHING', 'COMPETING', 'LISTENING'], //Supported activites, discord.js supports more (but I don't care) diff --git a/package.json b/package.json index 89d7494..eba4b6e 100644 --- a/package.json +++ b/package.json @@ -28,10 +28,10 @@ }, "homepage": "https://github.com/PetyXbron/minecraft-bot#readme", "dependencies": { - "chalk": "^4.1.1", - "discord.js": "^12.5.3", + "chalk": "^4.1.2", + "discord.js": "^13.2.0", "fs": "^0.0.1-security", - "minecraft-server-util": "^3.5.1", + "minecraft-server-util": "^3.7.2", "ms": "^2.1.3", "quick.db": "^7.1.3" }