Skip to content

Commit

Permalink
Added emojis (#111)
Browse files Browse the repository at this point in the history
* Added emojis

* removed whitespace
  • Loading branch information
Kr0nox authored May 19, 2023
1 parent ec39027 commit a7337fb
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions modules/mensa/mensaParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ export function buildMensaEmbed(foodPlan: CanteenLine[]): EmbedBuilder {
for (const line of foodPlan) {
if (line.meals.length > 0) {
const content = line.meals.map(e => {
let emoji = getClassificationEmoji(e.classifiers);
emoji += emoji != '' ? ' ' : '';
if (e.price !== "") {
return `${e.name} (${e.price})`;
return `${emoji}${e.name} (${e.price})`;
} else {
return `_${e.name}_`;
return `${emoji} _${e.name}_`;
}
}).join("\n");
embed.addFields({name: line.name, value: content, inline: true});
Expand All @@ -45,3 +47,28 @@ export function buildMensaEmbed(foodPlan: CanteenLine[]): EmbedBuilder {

return embed;
}

/**
* Generates the emoji representation of the given classifiers of a meal
*
* @param classification Classifiers of meal
* @returns Emoji of the classifiers
*/
function getClassificationEmoji(classification: string[]): string {
if (classification.length == 0) {
return '';
}
if (classification.includes('VG')) {
return ':ear_of_rice:';
}
if (classification.includes('VEG')) {
return ':carrot:';
}
if (classification.includes('S') || classification[0].startsWith('S')) {
return ':pig:';
}
if (classification.includes('R') || classification[0].startsWith('R')) {
return ':cow:';
}
return '';
}

0 comments on commit a7337fb

Please sign in to comment.