-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
6 changed files
with
118 additions
and
17 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 |
---|---|---|
|
@@ -3,4 +3,5 @@ Token.js | |
package-lock.json | ||
json.sqlite | ||
DeveloperFolder | ||
.vscode | ||
.vscode | ||
docs |
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
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,47 @@ | ||
const BotConfiguration = require("../../BotConfiguration.js"); | ||
const { Command } = require("discord.js-commando"); | ||
const BotData = require("../../BotData.js"); | ||
const discord = require("discord.js"); | ||
const db = require("quick.db"); | ||
const os = require('os'); | ||
|
||
module.exports = class PerformanceCommand extends Command { | ||
constructor(client) { | ||
super(client, { | ||
name: 'pf', | ||
group: 'bot', | ||
memberName: 'pf', | ||
description: `Performance command for the bot!`, | ||
}); | ||
} | ||
|
||
run(message, args) { | ||
if (message.guild === null){ | ||
message.reply(DMMessage); | ||
return; | ||
} | ||
if (!message.member.hasPermission("MANAGE_MESSAGES")){ | ||
const PermissionErrorMessage = new discord.MessageEmbed() | ||
.setColor("#FF0000") | ||
.setDescription(`${PermissionError}`) | ||
message.channel.send(PermissionErrorMessage).then(message => { | ||
message.delete({timeout: 10000}) | ||
}); | ||
return; | ||
} | ||
|
||
var usedMemory = os.totalmem() -os.freemem(), totalMemory = os.totalmem(); | ||
var getpercentage = ((usedMemory/totalMemory) * 100).toFixed(2) + '%' | ||
|
||
const PerformanceMessage = new discord.MessageEmbed() | ||
.setTimestamp() | ||
.setColor("#d3d3d3") | ||
.setTitle("Bot Performance") | ||
.setDescription(` | ||
**Used RAM:** ${getpercentage} | ||
**RAM:** ${(usedMemory/ Math.pow(1024, 3)).toFixed(2)} | ||
**Ping:** ${Date.now() - message.createdTimestamp} ms | ||
`) | ||
message.channel.send(PerformanceMessage); | ||
} | ||
}; |
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,57 @@ | ||
const { Command, CommandoClient } = require("discord.js-commando"); | ||
const BotConfiguration = require("../../BotConfiguration.js"); | ||
const BotData = require("../../BotData.js"); | ||
const token = require("../../Token.js"); | ||
const discord = require("discord.js"); | ||
const client = new CommandoClient(); | ||
const db = require("quick.db"); | ||
const chalk = require("chalk"); | ||
|
||
module.exports = class PowerCommand extends Command { | ||
constructor(client) { | ||
super(client, { | ||
name: 'power', | ||
group: 'bot', | ||
memberName: 'power', | ||
description: `Power commands for the bot.`, | ||
}); | ||
} | ||
|
||
run(message, args) { | ||
if (message.guild === null){ | ||
message.reply(DMMessage); | ||
return; | ||
} | ||
if(!message.member.hasPermission("ADMINISTRATOR")){ | ||
const PermissionErrorMessage = new discord.MessageEmbed() | ||
.setColor("#FF0000") | ||
.setDescription(`${PermissionError}`) | ||
message.channel.send(PermissionErrorMessage).then(message => { | ||
message.delete({timeout: 10000}) | ||
}); | ||
return; | ||
} | ||
let words = args.split(' '); | ||
let PowerAction = words.slice(0).join(' '); | ||
if (!PowerAction) return message.reply(":warning: Do you want to restart or shutdown the bot? Ex: -power <restart or shutdown>").then(message => { | ||
message.delete({timeout: 10000}); | ||
}); | ||
|
||
if (PowerAction == "restart"){ | ||
console.log(chalk.red(`${message.author.tag} Restarted the bot!`)); | ||
message.channel.send("Restarting Bot..."); | ||
client.destroy().then(() => { | ||
client.login(key); | ||
}); | ||
message.channel.send(`The bot is back online!`); | ||
} | ||
if (PowerAction == "shutdown"){ | ||
console.log(chalk.red(`${message.author.tag} Shut down the bot!`)); | ||
message.channel.send(`Shutting down bot...`).then(message => { | ||
message.channel.send("The bot is now offline.").then(() => { | ||
process.exit(); | ||
}); | ||
}); | ||
} | ||
} | ||
}; |
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