Allow bot owner to delete custom commands
This commit is contained in:
parent
b07418e03c
commit
b872e88f85
2 changed files with 7 additions and 7 deletions
|
@ -17,7 +17,7 @@ module.exports = {
|
||||||
"<prefix>custom list - list all custom commands",
|
"<prefix>custom list - list all custom commands",
|
||||||
"<prefix>custom variables - list all variables you can use"
|
"<prefix>custom variables - list all variables you can use"
|
||||||
],
|
],
|
||||||
execute({message, args, client, prefix}) {
|
execute({message, args, client, prefix, owners}) {
|
||||||
const customPath = './data/customCommands.json';
|
const customPath = './data/customCommands.json';
|
||||||
if(!fs.existsSync(customPath)){
|
if(!fs.existsSync(customPath)){
|
||||||
fs.writeFileSync(customPath,"[]")
|
fs.writeFileSync(customPath,"[]")
|
||||||
|
@ -36,7 +36,7 @@ module.exports = {
|
||||||
break;
|
break;
|
||||||
case "remove":
|
case "remove":
|
||||||
case "delete":
|
case "delete":
|
||||||
sendText = deleteCustomCommand(customName, message.author.id);
|
sendText = deleteCustomCommand(customName, message.author.id, owners);
|
||||||
break;
|
break;
|
||||||
case "owner":
|
case "owner":
|
||||||
let author = getOwnerOfCustomCommand(customName);
|
let author = getOwnerOfCustomCommand(customName);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
module.exports = function(customName, author){
|
module.exports = function(customName, author, owners){
|
||||||
const customPath = './data/customCommands.json';
|
const customPath = './data/customCommands.json';
|
||||||
let sendText = "This custom command does not exist.";
|
let sendText = "This custom command does not exist.";
|
||||||
let json = fs.readFileSync(customPath, 'utf8');
|
let json = fs.readFileSync(customPath, 'utf8');
|
||||||
|
@ -7,10 +7,10 @@ module.exports = function(customName, author){
|
||||||
let index = 0;
|
let index = 0;
|
||||||
customCommands.forEach(function (customCommand) {
|
customCommands.forEach(function (customCommand) {
|
||||||
if (customCommand.customName === customName) {
|
if (customCommand.customName === customName) {
|
||||||
if(customCommand.author === author){
|
if(customCommand.author === author || owners.indexOf(author.toString()) != -1 ){
|
||||||
customCommands.splice(index, 1)
|
customCommands.splice(index, 1)
|
||||||
sendText = `The custom command "${customName}" has been deleted.`
|
sendText = `The custom command "${customName}" has been deleted.`
|
||||||
fs.writeFileSync(customPath, JSON.stringify(customCommands, null, 4))
|
fs.writeFileSync(customPath, JSON.stringify(customCommands, null, 4))
|
||||||
}else {
|
}else {
|
||||||
sendText = "You do not own this custom command.\nOnly the one who created the custom command can delete it."
|
sendText = "You do not own this custom command.\nOnly the one who created the custom command can delete it."
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue