Skip to content

Commit

Permalink
Use OR instead of null coalescing
Browse files Browse the repository at this point in the history
Null coalescing requires Node >14. Fixes #26
  • Loading branch information
Kalissaac committed Mar 18, 2021
1 parent b4a0e09 commit 0db3fce
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/commands/match.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,9 +458,9 @@ const edit = async (message, GLOBALS) => {
if (editedValue.toLowerCase() === 'any') {
matchInformation.map = CONSTANTS.MAPS[Math.floor(Math.random() * Math.floor(CONSTANTS.MAPS.length))]
} else if (CONSTANTS.MAPS.includes(editedValue.toLowerCase())) {
matchInformation.map = CONSTANTS.MAPS.find(e => e === editedValue.toLowerCase()) ?? editedValue.toLowerCase()
matchInformation.map = CONSTANTS.MAPS.find(e => e === editedValue.toLowerCase()) || editedValue.toLowerCase()
} else {
return userMessage.reply('please give a valid map!').then(msg => msg.delete({ timeout: 5000 }))
return message.reply('please give a valid map!').then(msg => msg.delete({ timeout: 5000 }))
}
matchEmbed.fields[2].value = CONSTANTS.capitalizeFirstLetter(matchInformation.map)
matchEmbed.setThumbnail(CONSTANTS.MAPS_THUMBNAILS[matchInformation.map])
Expand Down
4 changes: 2 additions & 2 deletions src/services/matchCreation.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ const handleMatchCreation = async (matchRecord, userMessage, GLOBALS) => {
matchRecord.creationInformation.map = CONSTANTS.MAPS[Math.floor(Math.random() * Math.floor(CONSTANTS.MAPS.length))]
break
} else if (CONSTANTS.MAPS.includes(content)) {
matchRecord.creationInformation.map = CONSTANTS.MAPS.find(e => e === content) ?? content
matchRecord.creationInformation.map = CONSTANTS.MAPS.find(e => e === content) || content
break
} else {
return userMessage.reply('please give a valid map!').then(msg => msg.delete({ timeout: 5000 }))
}
}
case 6: {
if (CONSTANTS.GAME_MODES.includes(content)) {
matchRecord.creationInformation.mode = CONSTANTS.GAME_MODES.find(e => e === content) ?? content
matchRecord.creationInformation.mode = CONSTANTS.GAME_MODES.find(e => e === content) || content
break
} else {
return userMessage.reply('please give a valid game mode!').then(msg => msg.delete({ timeout: 5000 }))
Expand Down

0 comments on commit 0db3fce

Please sign in to comment.