Clean ups

This commit is contained in:
Daniel Odendahl Jr
2018-09-05 16:55:11 +00:00
parent 3d76d81e48
commit e8ff1af28c
21 changed files with 40 additions and 47 deletions
+5 -3
View File
@@ -88,9 +88,11 @@ module.exports = class CanvasUtil {
}
static shortenText(ctx, text, maxWidth) {
let shorten;
if (ctx.measureText(text).width > maxWidth) shorten = true;
while (ctx.measureText(text).width > maxWidth) text = text.substr(0, text.length - 1);
let shorten = false;
while (ctx.measureText(text).width > maxWidth) {
if (!shorten) shorten = true;
text = text.substr(0, text.length - 1);
}
return shorten ? `${text}...` : text;
}
};
+3 -3
View File
@@ -60,7 +60,7 @@ module.exports = class Util {
static today(timeZone) {
const now = new Date();
if (timeZone) now.setUTCHours(now.getUTCHours() + timeZone);
if (timeZone) now.setUTCHours(timeZone);
now.setHours(0);
now.setMinutes(0);
now.setSeconds(0);
@@ -74,13 +74,13 @@ module.exports = class Util {
return today;
}
static async awaitPlayers(msg, max, min, { text = 'join game', time = 30000, dmCheck = false } = {}) {
static async awaitPlayers(msg, max, min, { time = 30000, dmCheck = false } = {}) {
const joined = [];
joined.push(msg.author.id);
const filter = res => {
if (res.author.bot) return false;
if (joined.includes(res.author.id)) return false;
if (res.content.toLowerCase() !== text.toLowerCase()) return false;
if (res.content.toLowerCase() !== 'join game') return false;
joined.push(res.author.id);
res.react(SUCCESS_EMOJI_ID || '✅').catch(() => null);
return true;