Add fallback fonts

This commit is contained in:
Dragon Fire
2021-02-21 15:53:14 -05:00
parent 8b9ac4dabe
commit 4d5a8a8a22
5 changed files with 13 additions and 8 deletions
+3 -1
View File
@@ -9,6 +9,7 @@ module.exports = class FontArgumentType extends ArgumentType {
validate(value) {
const choice = value.toLowerCase();
let found = this.client.fonts.filter(font => {
if (font.isFallback) return false;
if (font.isVariant) return false;
if (font.name.toLowerCase().includes(choice)) return true;
if (font.filenameNoExt.toLowerCase().includes(choice)) return true;
@@ -24,13 +25,14 @@ module.exports = class FontArgumentType extends ArgumentType {
if (foundExact.size === 1) return true;
if (foundExact.size > 0) found = foundExact;
return found.size <= 15
? `${disambiguation(found.map(font => escapeMarkdown(font.name)), 'fonts', null)}\n`
? `${disambiguation(found.map(font => escapeMarkdown(font.filenameNoExt)), 'fonts', null)}\n`
: 'Multiple fonts found. Please be more specific.';
}
parse(value) {
const choice = value.toLowerCase();
const found = this.client.fonts.filter(font => {
if (font.isFallback) return false;
if (font.isVariant) return false;
if (font.name.toLowerCase().includes(choice)) return true;
if (font.filenameNoExt.toLowerCase().includes(choice)) return true;