forked from Ubaid7/Discord.JS-V12-Bot-Tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
165 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,67 @@ | ||
const { MessageEmbed } = require('discord.js') | ||
const os = require('os') // npm i os | ||
const ms = require('ms') // npm i ms | ||
const moment = require('moment') // npm i moment | ||
const cpuStat = require('cpu-stat') // npm i cpu-stat | ||
const db = require('quick.db') // npm i quick.db // Optional | ||
|
||
module.exports = (client) => { | ||
client.on('message', message => { | ||
const prefix = db.fetch(`prefix_${message.guild.id}`) // Or Just Do const { prefix } = require('../../../config.json') | ||
if(message.content.toLowerCase() === `${prefix}bot-info` || message.content.toLowerCase() === `${prefix}bi`) { | ||
|
||
// For Status Of Bot | ||
const status = { | ||
online: '🟢:- Online', | ||
idle: '🟡:- Idle', | ||
dnd: '🔴:- DND', | ||
offline: '⚫:- Offline' | ||
} | ||
// UpTime Of Bot | ||
const days = Math.floor(client.uptime / 86400000) | ||
const hours = Math.floor(client.uptime / 3600000) % 24 // 1 Day = 24 Hours | ||
const minutes = Math.floor(client.uptime / 60000) % 60 // 1 Hour = 60 Minutes | ||
const seconds = Math.floor(client.uptime / 1000) % 60 // 1 Minute = 60 Seconds | ||
|
||
// Other Stats | ||
cpuStat.usagePercent(function(error, percent) { | ||
if(error) return message.reply(error) | ||
const memoryusage = formatBytes(process.memoryUsage().heapUsed) // Memory Usage | ||
const node = process.version // NodeJS Version | ||
const CPU = percent.toFixed(2) // CPU Usage | ||
const CPUModel = os.cpus()[0].model // PC Model | ||
const cores = os.cpus().length // Cores | ||
|
||
const embed = new MessageEmbed() | ||
.setAuthor(client.user.username, client.user.displayAvatarURL()) | ||
.setTimestamp() | ||
.setColor('RANDOM') | ||
.addField('Name', client.user.username, true) | ||
.addField('ID', client.user.id, true) | ||
.addField('Status', `${status[client.presence.status]}`) | ||
.addField('Craeted At', moment.utc(client.user.createdAt).format('LLLL')) | ||
.addField('Added To Server', moment.utc(client.joinedAt).format('LLLL')) | ||
.addField('Servers', client.guilds.cache.size, true) | ||
.addField('Members In All Server', client.users.cache.size, true) | ||
.addField('Channels In All Server', client.channels.cache.size.toLocaleString()) | ||
.addField('UpTime', `\`${days}\` Days \`${hours}\` Hours \`${minutes}\` Minutes \`${seconds}\` Seconds`) | ||
.addField('Node Verison', node, true) | ||
.addField('Memery Usage', memoryusage, true) | ||
.addField('CPU USage', `${CPU}%`, true) | ||
.addField('CPU Model', CPUModel) | ||
.addField('Cores', cores, true) | ||
message.channel.send(embed) | ||
}) | ||
|
||
// For Memory In MB, GB.... | ||
function formatBytes(a, b) { | ||
let c = 1024 // 1 GB = 1024 MB | ||
d = b || 2 | ||
e = ['B', 'KB', 'MB', 'GB', 'TB'] | ||
f = Math.floor(Math.log(a) / Math.log(c)) | ||
|
||
return parseFloat((a / Math.pow(c, f)).toFixed(d)) + '' + e[f] | ||
} | ||
} | ||
}) | ||
} |
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,39 @@ | ||
const { MessageEmbed } = require("discord.js") | ||
|
||
module.exports = { | ||
commands: ['serverinfo', 'server-info', 'si'], // You Can Keep Any Name | ||
description: 'Gives Info About A Server', // Optional | ||
|
||
callback: (message, args) => { | ||
|
||
const { guild } = message | ||
const icon = message.guild.iconURL() // Icon Of Server | ||
const roles = message.guild.roles.cache.map(e => e.toString()) // Roles Of Server | ||
const emojis = message.guild.emojis.cache.map(e => e.toString()) // Emojis Of Server | ||
const emojicount = message.guild.emojis.cache | ||
const members = message.guild.members.cache // Members In Server | ||
const create = message.guild.createdAt.toLocaleDateString() // Server Create Date | ||
|
||
const embed = new MessageEmbed() | ||
.setColor('RANDOM') | ||
.setTitle('Server Info') | ||
.setThumbnail(`${icon}`) | ||
.addField('Server Onwer:-', guild.owner) | ||
.addField('Server ID:-', guild.id) | ||
.addField('Server Creation Date:-', create) | ||
.addField('Boost Count:-', guild.premiumSubscriptionCount) | ||
.addField('Boost Level:-', guild.premiumTier) | ||
// You Can Add Any Emoji | ||
.addField('Member Count:-', `${members.size}\n${members.filter(member => !member.user.bot).size}(Human)\n${members.filter(member => member.user.bot).size}(BOT)`) | ||
.addField('Mmeber Stats:-', `${guild.members.cache.filter(member => member.presence.status == 'online').size}:-🟢\n${guild.members.cache.filter(member => member.presence.status == 'idle').size}:-🟡\n${guild.members.cache.filter(member => member.presence.status == 'dnd').size}:-🔴\n${guild.members.cache.filter(member => member.presence.status == 'offline').size}:-⚫\n`) | ||
.addField('Highest Role:-', guild.roles.highest) | ||
.addField('Roles:-', `${roles}`, true) // <true> Means All Roles Will Come In Line | ||
.addField('Emoji Count:-', `${emojicount.size}\n${emojicount.filter(emoji => !emoji.animated).size}(Non Animated)\n${emojicount.filter(emoji => emoji.animated).size}(Animated)`) | ||
.addField('Emojis:-', `${emojis}`, true) // <true> Means All Emojis Will Come In Line // This Will All Emojis Of Server | ||
// You Can Add Any Emoji | ||
.addField('Server Stats:-', `${guild.channels.cache.filter(channel => channel.type == 'text').size}⌨️\n${guild.channels.cache.filter(channel => channel.type == 'voice').size}🔈\n${guild.channels.cache.filter(channel => channel.type == 'news').size}📢\n${guild.channels.cache.filter(channel => channel.type == 'category').size}📁`) | ||
.setFooter('Server Info', icon) | ||
// Add More Fields If You Want, I Have Added Main One's | ||
message.channel.send(embed) | ||
} | ||
} |
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,25 @@ | ||
const { MessageEmbed } = require('discord.js') | ||
const db = require('quick.db') // For Prefix | ||
|
||
module.exports = (client) => { | ||
client.on('message', message => { | ||
const prefix = db.fetch(`prefix_${message.guild.id}`) | ||
if(message.content.toLowerCase() === `${prefix}uptime` || message.content.toLowerCase() === `${prefix}bot-uptime`) { | ||
const days = Math.floor(client.uptime / 86400000) | ||
const hours = Math.floor(client.uptime / 3600000) % 24 // 1 Day = 24 Hours | ||
const minutes = Math.floor(client.uptime / 60000) % 60 // 1 Hour = 60 Minutes | ||
const seconds = Math.floor(client.uptime / 1000) % 60 // 1 Minute = 60 Seconds | ||
|
||
// Send As Embed | ||
const embed = new MessageEmbed() | ||
.setAuthor(`${client.user.username}`, client.user.displayAvatarURL({ dynamic: true })) | ||
.setTimestamp() | ||
.setColor('RANDOM') | ||
.setDescription(` | ||
My Uptime Is:- | ||
\`${days}\` Days \`${hours}\` Hours \`${minutes}\` Minutes \`${seconds}\` Seconds | ||
`) | ||
message.channel.send(embed) | ||
} | ||
}) | ||
} |
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 +1,34 @@ | ||
|
||
const { MessageEmbed } = require('discord.js') | ||
const moment = require('moment') // npm i moment | ||
moment.locale('ENG') | ||
|
||
module.exports ={ | ||
commands: ['userinfo', 'user-info', 'ui', 'memberinfo', 'member-info', 'mi'], // You Can Keep Any Name | ||
description: 'Shows User Info About A User or Pinged User.', // Optional | ||
|
||
callback: (message, args) => { | ||
|
||
const member = message.mentions.members.first() || message.guild.members.cache.find(member => member.user.username.toLowerCase() === args.join(" ").toLowerCase()) || message.guild.members.cache.get(args[0]) || message.guild.members.cache.find(member => member.displayName.toLowerCase() === args.join(" ").toLowerCase()) || message.member | ||
// For Status Of User, We Will Use Emoji To Look Nice | ||
const status = { | ||
online: '🟢:- Online', | ||
idle: '🟡:- Idle', | ||
dnd: '🔴:- DND', | ||
offline: '⚫:- Offline' | ||
} | ||
|
||
const embed = new MessageEmbed() | ||
.setColor('RANDOM') | ||
.setTitle(`User Info Of ${member.user.username}`, member.user.displayAvatarURL()) | ||
.setThumbnail(member.user.displayAvatarURL({dynamic: true, size: 512})) | ||
.addField('<a:Right:805663924267384852> **User-Name**', `${member.user.username}#${member.user.discriminator}`) // We Use Emojis Also | ||
.addField('<a:Right:805663924267384852> **User ID**', `${member.id}`) | ||
.addField('<a:Right:805663924267384852> **Status**', `${status[member.presence.status]}`) | ||
.addField('<a:Right:805663924267384852> **Account Created**', `${moment.utc(member.user.createdAt).format('LLLL')}`) | ||
.addField('<a:Right:805663924267384852> **Joined Server**', `${moment.utc(member.joinedAt).format('LLLL')}`) | ||
.addField('<a:Right:805663924267384852> **VC**', member.voice.channel ? member.voice.channel.name + `(${member.voice.channel.id})` : 'Not In A VC') | ||
.addField('<a:Right:805663924267384852> **Roles**', `${member.roles.cache.map(role => role.toString())}`, true) | ||
// Add More Fields If Want | ||
message.channel.send(embed) | ||
} | ||
} |