mirror of
https://github.com/jcreek/MupBot.git
synced 2026-07-12 18:33:44 +00:00
feat(*): Add trim helper function
This commit is contained in:
+14
@@ -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!');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user