Move custom command files into own directory

This commit is contained in:
SileNce5k 2022-04-05 16:36:32 +02:00
parent e6bf4045ed
commit 4e41a035ed
No known key found for this signature in database
GPG key ID: C507260E7F2583AD
9 changed files with 8 additions and 8 deletions

View file

@ -0,0 +1,20 @@
const fs = require('fs')
module.exports = function(customName, author, newCustomMessage){
const customPath = './data/customCommands.json';
let sendText = "This custom command does not exist.";
let json = fs.readFileSync(customPath, 'utf8');
let customCommands = JSON.parse(json)
customCommands.forEach(function (customCommand) {
if (customCommand.customName === customName) {
if(customCommand.author === author){
customCommand.customMessage = newCustomMessage;
fs.writeFileSync(customPath, JSON.stringify(customCommands, null, 4))
sendText = `${customName} has been updated.`;
}else {
sendText = "You do not own this custom command.\nOnly the one who created the custom command can edit it."
}
}
});
return sendText;
}