Skip to content

Commit

Permalink
Update channelCreation.js
Browse files Browse the repository at this point in the history
Updated internal notes!
  • Loading branch information
SaladCoder committed Jan 16, 2021
1 parent 45a95e1 commit 4d3f5ac
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/events/commands/channelCreation.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,49 @@ module.exports = {
const type = args[1].toLowerCase();
const property = args[2];

// Check the member type remove
// Check we have all 3 args for this command
if (args.length !== 3) return message.reply(intLang('commands.channelCreation._errors.wrongOption', discord.prefix));

// Load our Config file for later reading and writing
const configFile = JSON.parse(fs.readFileSync(`${__dirname}/../../config/config.json`, 'utf8'));

switch(type){
case 'slots':

// Convert to a number for comparison
const slots = Number(property);

// If the Number given is the same as the config file, we return making the planet greener
if (slots === configFile.channelTemplate.channelSlots) return message.reply(intLang('commands.channelCreation.slots.failed.slotsNotUpdated'));

// Check if a number was given for arg slots
if (typeof slots === 'number') {

// Check if the range is not above 99 and not below 1, else return
if (!slots > 99 || !slots < 1) configFile.channelTemplate.channelSlots = slots;
else return message.reply(intLang('commands.channelCreation.slots._errors.slotsIncorrectValue'));
}
break;
case 'lock':

// If the option [true/false] given is the same as the config file, we return making the planet more greener :D
if (property === configFile.channelTemplate.lockStatus) return message.reply(intLang('commands.channelCreation.lock.failed.lockNotUpdated'));

// Check if we was given a string
if (typeof property === 'string') {

// Straight forward if statement, if anything other than [true/false] given, return
if (property === 'true' || property === 'false') configFile.channelTemplate.lockStatus = property.toLowerCase();
else return message.reply(intLang('commands.channelCreation.lock._errors.lockIncorrectType'));
}
break;
default:

// if any of the options given do not equal slots or lock, return here
return message.reply(intLang('commands.channelCreation._errors.wrongOption', discord.prefix));
}

// Write to file our new Channel ID for the log dumps
// Write to file if any changes are accepted
fs.writeFile(`${__dirname}/../../config/config.json`, JSON.stringify(configFile, null, "\t"), error => {
if (error) return logger.error(intLang('commands.channelCreation.failed.unableToWriteFile', error)+ ' [0004]');

Expand Down

0 comments on commit 4d3f5ac

Please sign in to comment.