-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Working slash commands (https://support.discord.com/hc/en-us/articles/1500000368501-Slash-Commands-FAQ) - Created folder /slashes with all 5 working slash commands - Edited command handler to visual match with event handler - Edited bot invite link to have permission for creating new slash commands - Installed discord-api-types - Installed @discordjs/builders and /rest - Added interactionCreate event to listen for slash commands - Not important bug fixes - Updated readme.MD file with new "What can this bot do?" title - Sorted to-do list and added marking points
- Loading branch information
PetyXbronCZ
committed
Jan 28, 2022
1 parent
f1bf87d
commit c4501d8
Showing
14 changed files
with
573 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,66 @@ | ||
## [DOCUMENTATION HERE](https://petyxbron.gitbook.io/minecraft-bot/installation) | ||
## [DOCUMENTATION HERE 🔗](https://petyxbron.gitbook.io/minecraft-bot/installation) | ||
|
||
# Discord minecraft server bot | ||
### Get info about your minecraft server with this discord bot! | ||
# Custom Discord Minecraft bot | ||
### *Get info about your minecraft server with this discord bot!* | ||
|
||
This code could not be created without **Minecraft server util package** | ||
This code uses **Minecraft server util package** for getting status of Minecraft servers | ||
* minecraft-server-util package | ||
* [Github Repository](https://github.com/PassTheMayo/minecraft-server-util) | ||
* [npmjs package](https://www.npmjs.com/package/minecraft-server-util) | ||
* [Author Github Profile](https://github.com/PassTheMayo) | ||
|
||
## WHAT CAN THIS BOT DO? | ||
|
||
- **Fully customizable [config](config.js)** | ||
- Working **commands** with **custom prefix** + their **[slash commands]((https://support.discord.com/hc/en-us/articles/1500000368501-Slash-Commands-FAQ))** | ||
- `ip` command for getting IP address of server | ||
- `list` command for getting actual list of online players now | ||
- `status` command for getting simple and clear overview of server | ||
- `version` command for getting Minecraft version of server | ||
- `vote` command for getting vote link for voting for server on Minecraft server list | ||
- **Auto updating bot's status** with online and max players (setup in config with variables) | ||
|
||
 | ||
 | ||
- More Discord bot activites: `playing`, `listening`, `watching` and `competing` | ||
- **Poll/Voting channel** with reactions | ||
|
||
 | ||
- Custom responses for each command, editable in [config file](config.js) | ||
- **Auto updating status message** with player list | ||
|
||
 | ||
- **Random** RGB **color of command embeds** (each message another) | ||
|
||
 | ||
- **Clear colorful console** logging | ||
|
||
 | ||
|
||
## HOW TO USE & INSTALL | ||
|
||
### Go to our [documentation](https://petyxbron.gitbook.io/minecraft-bot/installation/install) and see. | ||
[](https://repl.it/github/PetyXbron/minecraft-bot) | ||
*Repl will not be updated for node v16.* | ||
*Repl will not be updated for node v16. (not needed with version [1.1.5](https://github.com/PetyXbron/minecraft-bot/commit/a14fe3024b561a2b5516fb2390431f6650afe8b9))* | ||
|
||
## TO DO | ||
|
||
* <s>Auto changing status message</s> | ||
* <s>Status command</s> | ||
* <s>IP address command</s> | ||
* <s>Minecraft version command</s> | ||
* <s>Player list command</s> | ||
* <s>Vote link command</s> | ||
* Poll/Voting command | ||
* <s>Poll/Voting channel with reactions</s> | ||
* AdminTeam applications | ||
* Slash commands | ||
* Send custom embed message command | ||
* Send custom message/announcement command | ||
* <s>Custom reply for ip, test and version command</s> | ||
* <s>Installation with repl.it</s> | ||
* Better test command variables (more process info - like uptime) | ||
* <s>More text languages (or custom)</s> | ||
* Create threads from every message in voting channel | ||
* <s>Bot status (activity) for players online number</s> | ||
* <s>Get invite link on bot start (available option in config)</s> | ||
- [x] <s>Auto changing status message</s> | ||
- [x] <s>Status command</s> | ||
- [x] <s>IP address command</s> | ||
- [x] <s>Minecraft version command</s> | ||
- [x] <s>Player list command</s> | ||
- [x] <s>Vote link command</s> | ||
- [x] <s>Poll/Voting channel with reactions</s> | ||
- [x] <s>Slash commands</s> | ||
- [x] <s>Custom reply for ip, test and version command</s> | ||
- [x] <s>Installation with repl.it</s> | ||
- [x] <s>More text languages (or custom)</s> | ||
- [x] <s>Bot status (activity) for players online number</s> | ||
- [x] <s>Get invite link on bot start (available option in config)</s> | ||
- [ ] Poll/Voting command | ||
- [ ] AdminTeam applications | ||
- [ ] Send custom embed message command | ||
- [ ] Send custom message/announcement command | ||
- [ ] Better test command variables (more process info - like uptime) | ||
- [ ] Create threads from every message in voting channel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = async (bot, interaction) => { | ||
if (!interaction.isCommand()) return; | ||
|
||
const command = bot.slashes.get(interaction.commandName); | ||
if(command) command.run(bot,interaction); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const { SlashCommandBuilder } = require('@discordjs/builders'); | ||
const Discord = require('discord.js'); | ||
|
||
module.exports = { | ||
data: new SlashCommandBuilder() | ||
.setName('ip') //Name of command - RENAME THE FILE TOO!!! | ||
.setDescription(`Sends the IP address of server`) //Description of command - you can change it :) | ||
}; | ||
|
||
module.exports.run = async (bot, interaction) => { | ||
const { server, config, text } = bot | ||
let icon = server.icon ? server.icon : interaction.guild.icon | ||
|
||
if(text.ip.title === "" || text.ip.description === "") { | ||
const ipEmbed = new Discord.MessageEmbed() | ||
.setAuthor({ name: config.server.name ? config.server.name : interaction.guild.name, iconURL: icon }) | ||
.setTitle("IP address:") | ||
.setDescription(`\`${server.ip}\`:\`${server.port}\``) | ||
.setColor(config.embeds.color); | ||
interaction.reply({ embeds: [ipEmbed] }); | ||
} else { | ||
text.ip.title = text.ip.title.replace('{serverIp}', server.ip) | ||
text.ip.title = text.ip.title.replace('{serverPort}', server.port) | ||
text.ip.title = text.ip.title.replace('{serverName}', config.server.name ? config.server.name : interaction.guild.name) | ||
text.ip.title = text.ip.title.replace('{voteLink}', config.server.vote) | ||
text.ip.title = text.ip.title.replace('{serverType}', config.server.type.charAt(0).toUpperCase() + config.server.type.slice(1)) | ||
|
||
text.ip.description = text.ip.description.replace('{serverIp}', server.ip) | ||
text.ip.description = text.ip.description.replace('{serverPort}', server.port) | ||
text.ip.description = text.ip.description.replace('{serverName}', config.server.name ? config.server.name : interaction.guild.name) | ||
text.ip.description = text.ip.description.replace('{voteLink}', config.server.vote) | ||
text.ip.description = text.ip.description.replace('{serverType}', config.server.type.charAt(0).toUpperCase() + config.server.type.slice(1)) | ||
|
||
const ipEmbed = new Discord.MessageEmbed() | ||
.setAuthor({ name: config.server.name ? config.server.name : interaction.guild.name, iconURL: icon }) | ||
.setTitle(text.ip.title) | ||
.setDescription(text.ip.description) | ||
.setColor(config.embeds.color); | ||
interaction.reply({ embeds: [ipEmbed] }); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
const { SlashCommandBuilder } = require('@discordjs/builders'); | ||
const util = require('minecraft-server-util'); | ||
const Discord = require('discord.js'); | ||
const c = require('chalk') | ||
|
||
module.exports = { | ||
data: new SlashCommandBuilder() | ||
.setName('list') //Name of command - RENAME THE FILE TOO!!! | ||
.setDescription('Sends the actual list of players online') //Description of command - you can change it :) | ||
}; | ||
|
||
module.exports.run = async (bot, interaction) => { | ||
const { server, config, text } = bot, | ||
warn = c.keyword('yellow').bold, | ||
warns = config.settings.warns | ||
|
||
if(!server.work) return | ||
|
||
let | ||
ip1 = server.ip, | ||
port1 = server.port, | ||
icon = server.icon ? server.icon : interaction.guild.icon | ||
|
||
if(server.type === 'java') { | ||
util.status(ip1, port1) | ||
.then((result) => { | ||
if (text.list.title === "" || text.list.description === "" || text.list.listFormat === "") { | ||
const trueList = result.players.sample ? "\n\`\`\`" + result.players.sample.map(p => ` ${p.name} `).join('\r\n') + "\`\`\`":"" | ||
|
||
const serverEmbed = new Discord.MessageEmbed() | ||
.setAuthor({ name: config.server.name ? config.server.name : interaction.guild.name, iconURL: icon }) | ||
.setTitle("Online player list:") | ||
.setDescription(`**${result.players.online}**/**${result.players.max}**` + trueList) | ||
.setColor(config.embeds.color) | ||
interaction.reply({ embeds: [serverEmbed] }); | ||
} else { | ||
text.list.title = text.list.title.replace('{serverIp}', server.ip) | ||
text.list.title = text.list.title.replace('{serverPort}', server.port) | ||
text.list.title = text.list.title.replace('{serverName}', config.server.name ? config.server.name : interaction.guild.name) | ||
text.list.title = text.list.title.replace('{voteLink}', config.server.vote) | ||
text.list.title = text.list.title.replace('{serverType}', config.server.type.charAt(0).toUpperCase() + config.server.type.slice(1)) | ||
text.list.title = text.list.title.replace('{playersOnline}', result.players.online) | ||
text.list.title = text.list.title.replace('{playersMax}', result.players.max) | ||
|
||
text.list.description = text.list.description.replace('{serverIp}', server.ip) | ||
text.list.description = text.list.description.replace('{serverPort}', server.port) | ||
text.list.description = text.list.description.replace('{serverName}', config.server.name ? config.server.name : interaction.guild.name) | ||
text.list.description = text.list.description.replace('{voteLink}', config.server.vote) | ||
text.list.description = text.list.description.replace('{serverType}', config.server.type.charAt(0).toUpperCase() + config.server.type.slice(1)) | ||
text.list.description = text.list.description.replace('{playersOnline}', result.players.online) | ||
text.list.description = text.list.description.replace('{playersMax}', result.players.max) | ||
|
||
if (result.players.sample) { | ||
var trueList = text.list.listFormat.replace('{playersList}', result.players.sample.map(p => ` ${p.name} `).join('\r\n')) | ||
} | ||
|
||
const serverEmbed = new Discord.MessageEmbed() | ||
.setAuthor({ name: config.server.name ? config.server.name : interaction.guild.name, iconURL: icon }) | ||
.setTitle(text.list.title) | ||
.setDescription(text.list.description + (trueList ? `\n${trueList}` : "")) | ||
.setColor(config.embeds.color) | ||
interaction.reply({ embeds: [serverEmbed] }); | ||
} | ||
}) | ||
.catch((error) => { | ||
if (text.list.title === "" || text.list.description === "" || text.list.listFormat === "") { | ||
const errorEmbed = new Discord.MessageEmbed() | ||
.setAuthor({ name: config.server.name ? config.server.name : interaction.guild.name, iconURL: icon }) | ||
.setTitle("Online player list:") | ||
.setDescription(`:x: **OFFLINE**\n\n:information_source: \`${server.ip}\`:\`${server.port}\``) | ||
.setColor(config.embeds.error) | ||
interaction.reply({ embeds: [errorEmbed] }); | ||
} else { | ||
text.list.title = text.list.title.replace('{serverIp}', server.ip) | ||
text.list.title = text.list.title.replace('{serverPort}', server.port) | ||
text.list.title = text.list.title.replace('{serverName}', config.server.name ? config.server.name : interaction.guild.name) | ||
text.list.title = text.list.title.replace('{voteLink}', config.server.vote) | ||
text.list.title = text.list.title.replace('{serverType}', config.server.type.charAt(0).toUpperCase() + config.server.type.slice(1)) | ||
|
||
const errorEmbed = new Discord.MessageEmbed() | ||
.setAuthor({ name: config.server.name ? config.server.name : interaction.guild.name, iconURL: icon }) | ||
.setTitle("Online player list:") | ||
.setDescription(`:x: **OFFLINE**\n\n:information_source: \`${server.ip}\`:\`${server.port}\``) | ||
.setColor(config.embeds.error) | ||
interaction.reply({ embeds: [errorEmbed] }); | ||
} | ||
|
||
if (warns) console.log(warn(`Error when using command ${module.exports.config.name}! Error:\n`) + error) | ||
}); | ||
} else { | ||
//Doesn't work for bedrock edition, sorry. | ||
interaction.reply({ content: 'Sorry, but this function is not working for Bedrock servers.' }) | ||
} | ||
|
||
}; |
Oops, something went wrong.