feat(*): Add trim helper function

This commit is contained in:
Olly Nicholass
2021-01-15 11:18:49 +00:00
parent 513d0aebd8
commit 853b934607
+14
View File
@@ -16,4 +16,18 @@ module.exports = {
message.channel.send('There was a problem, sorry!');
}
},
// Trim a string to a specific character length
trim: function (Discord, logger, string, max) {
try {
if (string.length > max) {
return `${string.slice(0, max - 3)}...`;
}
else {
return string;
}
} catch (error) {
logger.error('Failed to trim selection', error);
message.channel.send('There was a problem, sorry!');
}
}
};