Skip to content

Commit

Permalink
v1
Browse files Browse the repository at this point in the history
  • Loading branch information
Aplex2723 committed Jan 25, 2022
1 parent f68ec3d commit cbedc8f
Show file tree
Hide file tree
Showing 37 changed files with 1,449 additions and 1,258 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
node_modules/

json.sqlite
config.json
17 changes: 8 additions & 9 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const fs = require("fs");
const Discord = require("discord.js");
const client = new Discord.Client({partials: ["GUILD_MEMBER"], intents: ["GUILDS", "GUILD_MESSAGES", "GUILD_MEMBERS", "DIRECT_MESSAGES", "GUILD_PRESENCES"], fetchAllMembers: true });
const client = new Discord.Client({partials: ["GUILD_MEMBER"], intents: ["GUILDS", "GUILD_MESSAGES", "GUILD_MEMBERS", "DIRECT_MESSAGES", "GUILD_PRESENCES", "GUILD_MESSAGE_REACTIONS"], fetchAllMembers: true });

if (!fs.existsSync("./config.json")) {
console.log("config.json not found");
Expand All @@ -22,15 +22,14 @@ fs.readdir("./events/", (err, files) => {
});

client.commands = new Discord.Collection();
client.aliases = new Discord.Collection();

fs.readdir("./commands/", (err, files) => {
if (err) return console.error(err);
files.forEach(file => {
if (!file.endsWith(".js")) return;
let props = require(`./commands/${file}`);
let commandName = file.split(".")[0];
client.commands.set(commandName, props);
});
["commandHandler"].forEach(x => require(`./helpers/${x}`)(client));

client.categories = fs.readdirSync("./commands/");

["commandHandler"].forEach(handler => {
require(`./helpers/${handler}`)(client);
});

client.login(client.config.token);
72 changes: 0 additions & 72 deletions commands/ban.js

This file was deleted.

102 changes: 51 additions & 51 deletions commands/botinfo.js → commands/misc/botinfo.js
Original file line number Diff line number Diff line change
@@ -1,52 +1,52 @@
const os = require('os');
const { MessageEmbed } = require('discord.js');
exports.run = async (client, message) => {
let delay = ms => new Promise(res => setTimeout(res, ms));

function cpuaverage() {
var totalIdle = 0, totalTick = 0;
var cpus = os.cpus();
for (var i = 0, len = cpus.length; i < len; i++) {
var cpu = cpus[i];
for (type in cpu.times) {
totalTick += cpu.times[type];
}
totalIdle += cpu.times.idle;
}
return { idle: totalIdle / cpus.length, total: totalTick / cpus.length };
}

async function msg() {
var startMeasure = cpuaverage();
await delay(100);
var endMeasure = cpuaverage();
var percentagecpu = 100 - ~~(100 * (endMeasure.idle - startMeasure.idle) / (endMeasure.total - startMeasure.total));

let emb = new MessageEmbed()
.setTitle("Bot Info")
.setColor(client.color)
.setThumbnail(client.thumbnail)
.addField("Bot's memory usage [" + ((process.memoryUsage().heapUsed / os.totalmem()) * 100).toFixed(2) + "%]", (process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2) + " MB / " + (((os.totalmem() / 1024) / 1024) / 1024).toFixed(2) + " GB", true)
.addField("Cpu usage [" + percentagecpu + "%]", (process.cpuUsage().user / 1024 / 1024).toFixed(2) + " MB | " + os.cpus().length + (os.cpus().length === 1 ? " Core" : " Cores"), true)
.addField("\u200b", "\u200b", true)
.addField("Mem usage [" + Math.floor(((os.totalmem() - os.freemem()) / os.totalmem()) * 100) + "%]", ((((os.totalmem() - os.freemem()) / 1024) / 1024) / 1024).toFixed(2) + " GB / " + (((os.totalmem() / 1024) / 1024) / 1024).toFixed(2) + " GB", true)
.addField("Node Js version", process.versions.node, true)
.addField("\u200b", "\u200b", true)
.addField("Platform", process.platform.replace(/win32/g, "Windows"), true)
.addField("Architecture", os.arch(), true)
.addField("\u200b", "\u200b", true)
.addField("Bot's Uptime", client.function.timeformat(client.uptime / 1000), false)
.setFooter(client.footer)
message.channel.send({ embeds: [emb] });
}

if (client.config.ownerid)
if (message.author.id === client.config.ownerid) msg();
else message.channel.send('```css\nThis command is locked for owner```');
else msg();
};

exports.conf = {
aliases: ['binfo'],
permissions: ['SEND_MESSAGES', 'EMBED_LINKS']
const os = require('os');
const moment = require('moment');
const { MessageEmbed } = require('discord.js');
exports.run = async (client, message) => {
let delay = ms => new Promise(res => setTimeout(res, ms));

function cpuaverage() {
var totalIdle = 0, totalTick = 0;
var cpus = os.cpus();
for (var i = 0, len = cpus.length; i < len; i++) {
var cpu = cpus[i];
for (type in cpu.times) {
totalTick += cpu.times[type];
}
totalIdle += cpu.times.idle;
}
return { idle: totalIdle / cpus.length, total: totalTick / cpus.length };
}

async function msg() {
var startMeasure = cpuaverage();
await delay(100);
var endMeasure = cpuaverage();
var percentagecpu = 100 - ~~(100 * (endMeasure.idle - startMeasure.idle) / (endMeasure.total - startMeasure.total));

let emb = new MessageEmbed()
.setTitle("Bot Information")
.setColor("#fffff")
.addField("Bot's memory usage [" + ((process.memoryUsage().heapUsed / os.totalmem()) * 100).toFixed(2) + "%]", (process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2) + " MB / " + (((os.totalmem() / 1024) / 1024) / 1024).toFixed(2) + " GB", true)
.addField("Cpu usage [" + percentagecpu + "%]", (process.cpuUsage().user / 1024 / 1024).toFixed(2) + " MB | " + os.cpus().length + (os.cpus().length === 1 ? " Core" : " Cores"), true)
.addField("\u200b", "\u200b", true)
.addField("Mem usage [" + Math.floor(((os.totalmem() - os.freemem()) / os.totalmem()) * 100) + "%]", ((((os.totalmem() - os.freemem()) / 1024) / 1024) / 1024).toFixed(2) + " GB / " + (((os.totalmem() / 1024) / 1024) / 1024).toFixed(2) + " GB", true)
.addField("Node Js version", process.versions.node, true)
.addField("\u200b", "\u200b", true)
.addField("Platform", process.platform.replace(/win32/g, "Windows"), true)
.addField("Architecture", os.arch(), true)
.addField("\u200b", "\u200b", true)
.addField("Bot's Uptime", client.function.timeformat(client.uptime / 1000), false)
.setFooter(moment().format('MMMM Do YYYY, h:mm:ss a'))
message.channel.send({ embeds: [emb] });
}

if (client.config.ownerid)
if (message.author.id === client.config.ownerid) msg();
else message.channel.send('```css\nThis command is locked for owner```');
else msg();
};

exports.conf = {
aliases: ['binfo'],
permissions: ['SEND_MESSAGES', 'EMBED_LINKS']
};
100 changes: 50 additions & 50 deletions commands/help.js → commands/misc/help.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
const { MessageEmbed } = require('discord.js');
exports.run = async (client, message, args) => {
if (args[0] && !isNaN(args[0])) return message.channel.send("Command name cannot be a number");
if (!args[0]) args[0] = 'none';

switch (args[0].toLowerCase()) {
case ('ban'):
message.channel.send("```css\n" + client.config.prefix + "ban <Page Number>\nAlias: " + client.config.prefix + "s```");
break;
case ('serverinfo'):
message.channel.send("```css\n" + client.config.prefix + "serverinfo <Serial Number from Status command>\nAlias: " + client.config.prefix + "sinfo```");
break;
case ('kick'):
message.channel.send("```css\n" + client.config.prefix + "kick <Serverid | ip:port | Serial No. from Status command> <page number>\nAlias: " + client.config.prefix + "p, " + client.config.prefix + "scoreboard```");
break;
case ('mute'):
message.channel.send("```css\n" + client.config.prefix + "mute <name of the player | xuid of the player>\nAlias: " + client.config.prefix + "f```");
break;
case ('warn'):
message.channel.send("```css\n" + client.config.prefix + "warn <client id from " + client.config.webfronturl + ">\nAlias: none```");
break;
case ('logs'):
message.channel.send("```css\n" + client.config.prefix + "logs\nMethod: Your id and password for " + client.config.webfronturl + " will be asked in DM```");
break;
case ('invite'):
message.channel.send("```css\n" + client.config.prefix + "invite\nAlias: none```");
break;
case ('profile'):
message.channel.send("```css\n" + client.config.prefix + "profile <Serverid | ip:port | Serial No. from Status command> <!help>\nAlias: " + client.config.prefix + "e```");
break;
case ('botinfo'):
message.channel.send("```css\n" + client.config.prefix + "botinfo\nAlias: " + client.config.prefix + "binfo```");
break;
case ('ping'):
message.channel.send("```css\n" + client.config.prefix + "ping\nAlias: none```");
break;
default:
const emc = new MessageEmbed()
.setTitle('Help')
.setColor(client.color)
.setThumbnail(client.thumbnail)
.setDescription("🔸 `" + client.config.prefix + "ban` - Shows all iw4m admin server's status\n" + "🔹 `" + client.config.prefix + "serverinfo` - Shows info about given server number\n" + "🔸 `" + client.config.prefix + "kick` - Shows player scoreboard for the given server\n" + "🔹 `" + client.config.prefix + "mute` - Shows name, iw4m client id and xuid of found clients\n" + "🔸 `" + client.config.prefix + "warn` - Shows all stats about the player\n" + "🔹 `" + client.config.prefix + "logs` - Asks you for login info in dm\n" + "🔸 `" + client.config.prefix + "invite` - Deletes your login and logs you out\n" + "🔹 `" + client.config.prefix + "profile` - profiles the command in the given server\n" + "🔹 `" + client.config.prefix + "botinfo` - Shows bot's overall status\n" + "🔸 `" + client.config.prefix + "ping` - Shows bot's latency to discord\n" + "```Use " + client.config.prefix + "help <command name> or " + client.config.prefix + "h <command name> to get more info about the command```")
.setFooter(client.footer);
message.channel.send({ embeds: [emc] });
}
};

exports.conf = {
aliases: ['h'],
permissions: ['SEND_MESSAGES', 'EMBED_LINKS']
const { MessageEmbed } = require('discord.js');
exports.run = async (client, message, args) => {
if (args[0] && !isNaN(args[0])) return message.channel.send("Command name cannot be a number");
if (!args[0]) args[0] = 'none';

switch (args[0].toLowerCase()) {
case ('ban'):
message.channel.send("```css\n" + client.config.prefix + "ban <Page Number>\nAlias: " + client.config.prefix + "s```");
break;
case ('serverinfo'):
message.channel.send("```css\n" + client.config.prefix + "serverinfo <Serial Number from Status command>\nAlias: " + client.config.prefix + "sinfo```");
break;
case ('kick'):
message.channel.send("```css\n" + client.config.prefix + "kick <Serverid | ip:port | Serial No. from Status command> <page number>\nAlias: " + client.config.prefix + "p, " + client.config.prefix + "scoreboard```");
break;
case ('mute'):
message.channel.send("```css\n" + client.config.prefix + "mute <name of the player | xuid of the player>\nAlias: " + client.config.prefix + "f```");
break;
case ('warn'):
message.channel.send("```css\n" + client.config.prefix + "warn <client id from " + client.config.webfronturl + ">\nAlias: none```");
break;
case ('logs'):
message.channel.send("```css\n" + client.config.prefix + "logs\nMethod: Your id and password for " + client.config.webfronturl + " will be asked in DM```");
break;
case ('invite'):
message.channel.send("```css\n" + client.config.prefix + "invite\nAlias: none```");
break;
case ('profile'):
message.channel.send("```css\n" + client.config.prefix + "profile <Serverid | ip:port | Serial No. from Status command> <!help>\nAlias: " + client.config.prefix + "e```");
break;
case ('botinfo'):
message.channel.send("```css\n" + client.config.prefix + "botinfo\nAlias: " + client.config.prefix + "binfo```");
break;
case ('ping'):
message.channel.send("```css\n" + client.config.prefix + "ping\nAlias: none```");
break;
default:
const emc = new MessageEmbed()
.setTitle('Help')
.setColor(client.color)
.setThumbnail(client.thumbnail)
.setDescription("🔸 `" + client.config.prefix + "ban` - Shows all iw4m admin server's status\n" + "🔹 `" + client.config.prefix + "serverinfo` - Shows info about given server number\n" + "🔸 `" + client.config.prefix + "kick` - Shows player scoreboard for the given server\n" + "🔹 `" + client.config.prefix + "mute` - Shows name, iw4m client id and xuid of found clients\n" + "🔸 `" + client.config.prefix + "warn` - Shows all stats about the player\n" + "🔹 `" + client.config.prefix + "logs` - Asks you for login info in dm\n" + "🔸 `" + client.config.prefix + "invite` - Deletes your login and logs you out\n" + "🔹 `" + client.config.prefix + "profile` - profiles the command in the given server\n" + "🔹 `" + client.config.prefix + "botinfo` - Shows bot's overall status\n" + "🔸 `" + client.config.prefix + "ping` - Shows bot's latency to discord\n" + "```Use " + client.config.prefix + "help <command name> or " + client.config.prefix + "h <command name> to get more info about the command```")
.setFooter(client.footer);
message.channel.send({ embeds: [emc] });
}
};

exports.conf = {
aliases: ['h'],
permissions: ['SEND_MESSAGES', 'EMBED_LINKS']
};
22 changes: 11 additions & 11 deletions commands/ping.js → commands/misc/ping.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const { MessageEmbed } = require('discord.js');
exports.run = (client, message) => {
const embed = new MessageEmbed()
.setTitle('🌐 Your ping is: ' + Math.floor(client.ws.ping) + 'ms')
.setColor(client.color)
message.channel.send({ embeds: [embed] });
};

exports.conf = {
aliases: [],
permissions: ['SEND_MESSAGES', 'EMBED_LINKS']
const { MessageEmbed } = require('discord.js');
exports.run = (client, message) => {
const embed = new MessageEmbed()
.setTitle('🌐 Your ping is: ' + Math.floor(client.ws.ping) + 'ms')
.setColor(client.color)
message.channel.send({ embeds: [embed] });
};

exports.conf = {
aliases: [],
permissions: ['SEND_MESSAGES', 'EMBED_LINKS']
};
Loading

0 comments on commit cbedc8f

Please sign in to comment.