Skip to content

Commit

Permalink
v1.3.0 🔥
Browse files Browse the repository at this point in the history
### Added
- Option to disable bot presence
- Support for Free Minecraft Hosting Provider server
- Player Count Channel feature
- Customize auto reply message and enable it
- Bot Info slash command
- Motd commands
- Set status commands
- Startup Basic Minecraft Server Info
- Anti Crash System
- Player List grouping

### Fixed

- Better English in config.js
- Typo in IP slash command description
- Auto Reply feature reply when a word inside another words
- Bot presence not working when disabled status message
- Bug with retrieving Bedrock data
- Fixed many bugs
### Removed
- !setstatus prefix commands
- channelId option in auto Change status
  • Loading branch information
NooberPro committed Jun 29, 2023
1 parent 193c0ef commit 9b0f0d3
Show file tree
Hide file tree
Showing 25 changed files with 800 additions and 454 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules/
package-lock.json
dev-config.js
dev-data.js
dev-data.js
nodemon.json
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ This bot code uses **node-mcstatus npm package** for getting status of Minecraft

## TO DO

- [ ] Better Documentation and Readme
- [x] Better Documentation and Readme
- [x] Auto changing statusCH message
- [x] Message Reply for (is server online?) like question
- [x] Add prefix commands
Expand All @@ -46,6 +46,6 @@ This bot code uses **node-mcstatus npm package** for getting status of Minecraft
- [x] Colorfull Console
- [ ] Player Avatar and Skin Command
- [ ] Embed Customization for translating
- [ ] Server and bot Uptime
- [x] Server and bot Uptime
- [ ] Add support for various languages (customize in config).
- [ ] Instruction for Bot hosting for free
142 changes: 88 additions & 54 deletions config.js
Original file line number Diff line number Diff line change
@@ -1,82 +1,116 @@
//Config Explaination: https://nooberpro.gitbook.io/minecraft-discord-bot/installation/config
// "MC" is referring to Minecraft in the comments for convenience.
module.exports = {
bot: {
token: 'your-bot-token-here', // Paste Your Bot's Token here
// Auto changing status message and activity presence.
token: 'your-bot-token-here',
// Auto changing status and activity for bot.
presence: {
enabled: true,
activity: 'Playing', // Options: Playing, Listening, Watching, Competing.
text: {
// Use {playeronline} for no. of players online and {playermax} for maximum players .
online: 'with {playeronline}/{playermax} players', // Custom text of your choice.
online: 'with {playeronline}/{playermax} players', // {playeronline} and {playermax} show number of online and max players.
offline: 'Server Offline', // Status text when the server is offline.
},
status: {
// online, idle, dnd (do not disturb), invisible are the options
online: 'online', // The status of the bot when mc server is Online.
offline: 'idle', // The status of the bot when mc server is Offline.
// Options: online, idle, dnd, invisible.
online: 'online', // Status when MC server is online.
offline: 'idle', // Status when MC server is offline.
},
activity: 'Playing', // Playing, Listening, Watching, Competing are the options. This comes before the status text.
},
},
mcserver: {
ip: 'demo.mcstatus.io', // Ip Address of your minecraft server like mc.hypixel.net
port: 25565, // Port of your minecraft server like 25565 for java and 19132 for bedrock.
type: 'java', // Type of minecraft server, "java" or "bedrock". Default is Java.
name: 'Demo Server', //Name of your Minecraft Server like Hypixel
version: 'Requires 1.8 - 1.20', // Version of your Minecraft server. You can put anything there. It will come in the embed
icon: 'https://i.imgur.com/f35CYQs.png', // Url of minecraft server icon. How? https://tinyurl.com/iconurl
site: 'https://nooberpro.gitbook.io', // Url of your minecraft server website or vote website. NOT REQUIRED.
ip: 'demo.mcstatus.io', // IP of MC server.
port: 25565, // Port number of MC server. Default Port - Java: 25565, Bedrock: 19132.
type: 'java', // Type of MC server: "java" or "bedrock". Use Query Port in Java for full Player List.
name: 'Demo Server', // Name of MC server.
version: 'Requires 1.8 - 1.20', // Version of MC server.
icon: 'https://i.imgur.com/6Msem8Q.png', // URL of MC server icon. How? https://tinyurl.com/iconurl
site: '', // URL of MC server/vote website like https://nooberpro.gitbook.io/ . To disable site it blank. NOT REQUIRED
},
infoReply: {
// If a message contains triggerWords then reply version,ip,site,status etc.
enabled: false,
triggerWords: {
version: ['version of the server?', 'version'],
ip: ['ip of the server', 'ip'],
site: ['website link', 'website', 'url', 'site'],
status: ['is server online?', 'is server down?', 'is server offline'],
},
},
// Setting for bot

// Settings for bot.
settings: {
autoChangeStatus: {
enabled: false,
updateInterval: 60, // Time Period between auto changing status in seconds like 60 = 1min. Recommend is above 60.
setstatus: true, // Enable if status message can be set by sending "!setstatus" in any channel.
channelId: '', //Enter channel ID or use "!setstatus" in any channel to set status. How? https://tinyurl.com/discordChannelId
},
// console-logging settings.
logging: {
inviteLink: true, // Logs invite link at bot's launch
statusMessageUpdate: false, // Logs every Status message update (pretty much like spam)
activityUpdate: false, // Logs every bot activity update (pretty much like spam)
errorLog: true, // Logs the errors if there any
inviteLink: true, // Log invite link at bot's launch.
debug: false, // Log status message and bot activity update. (pretty much like spam)
error: true, // Log any errors that occur.
serverInfo: true, // Log basic info about server and check if it is online at startup.
},
},
commands: {
slashCommands: true, // Enable slash(/) commands.
prefixCommands: {
enabled: true, // Enable normal prefix commands.
prefix: '!', // Prefix for normal commands.

// Features settings

// Automatically Updates the current status of a Mc server in a channel, in real time.
autoChangeStatus: {
enabled: false,
updateInterval: 60, // Time period between auto changing status in seconds, e.g. 60 = 1min. Recommended: above 60.
// These settings will be applied in (/) and prefix commands for status.
isOnlineCheck: true, // Useful for servers which uses free hosting providers like Aternos. Check if the server's max players is greater than 0.
},
// Shows the Player Count of MC server in channel's name
playerCountCH: {
enabled: true,
guildID: 'your-guild-id', // Server's ID for creating/editing channel stats.
// {playeronline} and {playermax} show number of online and max players.
onlineText: '{playeronline}/{playermax} Players playing.',
offlineText: 'Server is currently Offline', // The name set when MC server is offline.
},
autoReply: {
// If a message contains triggerWords, reply with appropriate server information.
enabled: false, // Disable the entire feature.
version: {
enabled: true,
triggerWords: ['version of the server?', 'version'],
// Use {version} to get the version in the config
replyText: "The server's version: **`{version}`**",
},
ip: {
enablePrefix: true, // Enable prefix commands for ip.
enableSlash: true, // Enable slash commands for ip.
},
players: {
enablePrefix: true, // Enable prefix commands for players.
enableSlash: true, // Enable slash commands for players.
enabled: true,
triggerWords: ['ip of the server', 'ip'],
// Use {ip} for ip and {port} for port.
replyText: '**IP: `{ip}`\nPort: `{port}`**',
},
site: {
enablePrefix: true, // Enable prefix commands for site.
enableSlash: true, // Enable slash commands for site.
enabled: true,
triggerWords: ['website link', 'website', 'url', 'site', 'vote url'],
// Use {site} for site
replyText: "The server's website link: **<{site}>**",
},

status: {
enablePrefix: true, // Enable prefix commands for status.
enableSlash: true, // Enable slash commands for status.
enabled: true,
triggerWords: [
'is server online?',
'is server offline',
'status of the server',
],
// Use {playerOnline} for players online no. and {playerMax} for players max no. Only work in onlineReply.
onlineReply:
"The server's current status is **🟢`ONLINE`** with **`{playerOnline}/{playerMax}`** players playing.",
offlineReply: "The server's current status is **🔴`OFFLINE`**.",
},
version: {
enablePrefix: true, // Enable prefix commands for version.
enableSlash: true, // Enable slash commands for version.
},

commands: {
slashCommands: {
enabled: true, // Enable slash(/) commands.
ip: true, // Enable ip slash command.
players: true, // Enable players slash command.
site: true, // Enable site slash command.
status: true, // Enable status slash command.
version: true, // Enable version slash command.
motd: true, // Enable motd slash command.
},
prefixCommands: {
enabled: true, // Enable normal prefix commands.
prefix: '!', // Prefix for normal command.
ip: true, // Enable ip prefix command.
players: true, // Enable players prefix command.
site: true, // Enable site prefix command.
status: true, // Enable status prefix command.
version: true, // Enable version prefix command.
motd: true, // Enable motd prefix command.
},
},
};
4 changes: 0 additions & 4 deletions data.json

This file was deleted.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"dependencies": {
"chalk": "^4.1.2",
"discord.js": "^14.11.0",
"djs-commander": "^0.0.45",
"node-mcstatus": "^1.0.2"
"djs-commander": "^0.0.50",
"node-mcstatus": "^1.1.0"
}
}
55 changes: 55 additions & 0 deletions src/commands/botInfo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('botinfo')
.setDescription('Sends the CPU, Memory Stats of the Bot.')
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
run: async ({ interaction, client }) => {
interaction.deferReply({
ephemeral: true,
});
try {
const reply = await interaction.fetchReply();
const ping = reply.createdTimestamp - interaction.createdTimestamp;
const os = require('os');
const process = require('node:process');
const cpuUsage = (os.loadavg()[0] / os.cpus().length).toFixed(2);
const memoryUsage = (
process.memoryUsage().heapUsed /
1024 /
1024
).toFixed(2);
const nodeVersion = process.version;
const uptimeSeconds = process.uptime();
const uptimeMinutes = Math.floor(uptimeSeconds / 60);
const uptimeHours = Math.floor(uptimeMinutes / 60);
const uptimeDays = Math.floor(uptimeHours / 24);
await interaction.editReply({
ephemeral: true,
embeds: [
{
author: {
name: client.user.tag,
icon_url: client.user.avatarURL(),
},
title: '**Bot Info and Stats**',
description: `**CPU Usage: \`${cpuUsage}%\`\nMemory Usage: \`${memoryUsage}MB\`\nNode.js Version: \`${nodeVersion}\`\nBot uptime: \`${uptimeDays}\` days, \`${
uptimeHours % 24
}\` hours, \`${uptimeMinutes % 60}\`, minutes, \`${Math.floor(
uptimeSeconds
)}\` seconds \n Ping: Client \`${ping}ms\` | Websocket: \`${
client.ws.ping
}ms\` **`,
},
],
});
} catch (error) {
interaction.editReply({
content: 'Error with getting Bot Info',
ephemeral: true,
});
const { getError } = require('../index');
console.log(getError(error, 'Slash command - Botinfo'));
}
},
};
4 changes: 2 additions & 2 deletions src/commands/ip.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ const { commands } = require('../../config');
module.exports = {
data: new SlashCommandBuilder()
.setName('ip')
.setDescription('Sends the Server Addrees of a Minecraft Server'),
.setDescription('Sends the Server Address of the Minecraft Server.'),
run: ({ interaction }) => {
interaction.reply({ embeds: [ipEmbed] });
},
deleted: !commands.ip.enableSlash || !commands.slashCommands, // Deletes the command from Discord
deleted: !commands.slashCommands.ip || !commands.slashCommands.enabled, // Deletes the command from Discord
};
23 changes: 23 additions & 0 deletions src/commands/motd.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const { SlashCommandBuilder } = require('discord.js');
const { motdEmbed } = require('../embeds');
const { commands } = require('../../config');

module.exports = {
data: new SlashCommandBuilder()
.setName('motd')
.setDescription("Sends the Minecraft Server's Message Of The Day (MOTD)."),

run: async ({ interaction }) => {
interaction.deferReply();
try {
interaction.editReply({ embeds: [await motdEmbed()] });
} catch (error) {
interaction.editReply({
content: 'Error with getting Message of the Day (MOTD)',
});
const { getError } = require('../index');
console.log(getError(error, 'Slash command - Botinfo'));
}
},
deleted: !commands.slashCommands.motd,
};
19 changes: 8 additions & 11 deletions src/commands/player.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
const { SlashCommandBuilder } = require('discord.js');
const { settings, commands } = require('../../config');
const { commands } = require('../../config');

module.exports = {
data: new SlashCommandBuilder()
.setName('players')
.setDescription('Sends the Player Online List.'),
.setDescription('Sends the online player details.'),
run: async ({ interaction }) => {
await interaction.channel.sendTyping();
await interaction.deferReply();
const { playerList } = require('../embeds');
try {
const playerEmbed = await playerList();
interaction.reply({ embeds: [playerEmbed] });
interaction.editReply({ content: '', embeds: [await playerList()] });
} catch (error) {
if (!settings.logging.errorLog) return;
console.error(
chalk.red(`Error with player command: `),
chalk.keyword('orange')(error.message)
);
interaction.editReply({ content: 'Error with getting Players' });
const { getError } = require('../index');
console.log(getError(error, 'Slash command - Player'));
}
},
deleted: !commands.players.enableSlash || !commands.slashCommands, // Deletes the command from Discord
deleted: !commands.slashCommands.players || !commands.slashCommands.enabled, // Deletes the command from Discord
};
Loading

0 comments on commit 9b0f0d3

Please sign in to comment.