-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### 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
Showing
25 changed files
with
800 additions
and
454 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,4 +1,5 @@ | ||
node_modules/ | ||
package-lock.json | ||
dev-config.js | ||
dev-data.js | ||
dev-data.js | ||
nodemon.json |
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 |
---|---|---|
@@ -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. | ||
}, | ||
}, | ||
}; |
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,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')); | ||
} | ||
}, | ||
}; |
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,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, | ||
}; |
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,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 | ||
}; |
Oops, something went wrong.