From e287b845e9898b8c34c3d7a9f383666f318fe490 Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Tue, 12 Sep 2017 04:07:20 +0000 Subject: [PATCH] Better --- commands/avatar-edit/steam-now-playing.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/commands/avatar-edit/steam-now-playing.js b/commands/avatar-edit/steam-now-playing.js index cd50af1a..9bb32784 100644 --- a/commands/avatar-edit/steam-now-playing.js +++ b/commands/avatar-edit/steam-now-playing.js @@ -54,8 +54,10 @@ module.exports = class SteamNowPlayingCommand extends Command { ctx.fillStyle = '#90ba3c'; ctx.font = '10px Noto'; ctx.fillText(member.displayName, 63, 26); + let shorten; + if (ctx.measureText(game).width > 160) shorten = true; while (ctx.measureText(game).width > 160) game = game.substr(0, game.length - 1); - ctx.fillText(game, 63, 54); + ctx.fillText(shorten ? `${game}...` : game, 63, 54); return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'steam-now-playing.png' }] }); } catch (err) { return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);