Skip to content

Commit

Permalink
Updated to Discord.js v13
Browse files Browse the repository at this point in the history
  • Loading branch information
PetyXbron authored Oct 28, 2021
2 parents a14fe30 + ae6ad3a commit dcbdb15
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 28 deletions.
2 changes: 1 addition & 1 deletion commands/ip.js
Original file line number Diff line number Diff line change
Expand Up @@ -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] });
}
};
4 changes: 2 additions & 2 deletions commands/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand Down
14 changes: 4 additions & 10 deletions commands/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, '')
Expand All @@ -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(
Expand All @@ -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;
});
Expand All @@ -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;
});
Expand Down
2 changes: 1 addition & 1 deletion commands/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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?' });
};
2 changes: 1 addition & 1 deletion commands/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -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] });
};
2 changes: 1 addition & 1 deletion commands/vote.js
Original file line number Diff line number Diff line change
Expand Up @@ -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] });
}
};
9 changes: 4 additions & 5 deletions events/message.js → events/messageCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions events/ready.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)}!`)
Expand Down Expand Up @@ -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))
}
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down

0 comments on commit dcbdb15

Please sign in to comment.