Skip to content

Commit

Permalink
refactor: reduce indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
zapteryx committed Dec 2, 2022
1 parent 76dd1d3 commit 6c60cd4
Showing 1 changed file with 28 additions and 32 deletions.
60 changes: 28 additions & 32 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,42 +85,38 @@ rl.on('line', async (input): Promise<void> => {
console.log('Guild not found.');
break;
}
if (!['stay', 'autolyrics'].includes(feature)) {
console.log('Available features: stay, autolyrics');
break;
}
let featureName = '';
switch (feature) {
case 'stay':
case 'autolyrics': {
let featureName = '';
switch (feature) {
case 'stay':
featureName = '24/7';
break;
case 'autolyrics':
featureName = 'Auto Lyrics';
}
if (!settings.features[feature].whitelist) {
console.log(
`The ${featureName} whitelist is not enabled.`,
);
break;
}
const whitelisted = !(await data.guild.get<boolean>(
guildId,
`features.${feature}.whitelisted`,
));
await data.guild.set(
guildId,
`features.${feature}.whitelisted`,
whitelisted,
);
console.log(
`${whitelisted ? 'Added' : 'Removed'} ${guild.name} ${
whitelisted ? 'to' : 'from'
} the ${featureName} whitelist.`,
);
featureName = '24/7';
break;
}
default:
console.log('Available features: stay, autolyrics');
case 'autolyrics':
featureName = 'Auto Lyrics';
}
if (
!settings.features[feature as 'stay' | 'autolyrics'].whitelist
) {
console.log(`The ${featureName} whitelist is not enabled.`);
break;
}
const whitelisted = !(await data.guild.get<boolean>(
guildId,
`features.${feature}.whitelisted`,
));
await data.guild.set(
guildId,
`features.${feature}.whitelisted`,
whitelisted,
);
console.log(
`${whitelisted ? 'Added' : 'Removed'} ${guild.name} ${
whitelisted ? 'to' : 'from'
} the ${featureName} whitelist.`,
);
break;
}
case 'eval': {
Expand Down

0 comments on commit 6c60cd4

Please sign in to comment.