Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubaid7 authored May 6, 2021
1 parent 318fa92 commit 68a12ce
Show file tree
Hide file tree
Showing 4 changed files with 165 additions and 1 deletion.
67 changes: 67 additions & 0 deletions Episode 40/commands/Main-Commands/Info/bot-info.js
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]
}
}
})
}
39 changes: 39 additions & 0 deletions Episode 40/commands/Main-Commands/Info/server-info.js
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)
}
}
25 changes: 25 additions & 0 deletions Episode 40/commands/Main-Commands/Info/uptime.js
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)
}
})
}
35 changes: 34 additions & 1 deletion Episode 40/commands/Main-Commands/Info/user-info.js
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)
}
}

0 comments on commit 68a12ce

Please sign in to comment.