feat: markdownEscape

This commit is contained in:
TresAbhi committed 2023-05-06 17:45:43 +00:00
1 parent 01b5ec9bc2
commit 5ef1f87236
11 files changed
+75 -26

No files matched your search

+9 -4
View File
@@ -1,4 +1,5 @@
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
import markdownEscape from 'markdown-escape';
import { CommandRegistry } from '../behaviors/interactionCreate.js';
import { NEGATIVE_COLOR, POSITIVE_COLOR } from '../constants/colors.js';
import { BlitzServer } from '../constants/servers.js';
@@ -108,7 +109,7 @@ export default {
poweredByBlitzStars(
new EmbedBuilder()
.setTitle(
`${data.nickname} is ${
`${markdownEscape(data.nickname)} is ${
eligible ? '' : 'not '
}eligible for ${CLANS[clan].name}`,
)
@@ -116,10 +117,14 @@ export default {
.setDescription(
`${
eligible
? `${data.nickname} meets all the requirements set for ${CLANS[clan].name}.`
: `${data.nickname}'s shortcomings for ${
? `${markdownEscape(
data.nickname,
)} meets all the requirements set for ${
CLANS[clan].name
} (${
}.`
: `${markdownEscape(
data.nickname,
)}'s shortcomings for ${CLANS[clan].name} (${
clan === 'sklld' ? '30 days stats' : 'career stats'
}):\n\n${issues.join('\n')}`
}\n\n${blitzLinks(data)}`,
+6 -3
View File
@@ -1,4 +1,5 @@
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
import markdownEscape from 'markdown-escape';
import { CommandRegistry } from '../behaviors/interactionCreate.js';
import { NEGATIVE_COLOR, POSITIVE_COLOR } from '../constants/colors.js';
import { BlitzServer } from '../constants/servers.js';
@@ -68,7 +69,9 @@ export default {
.sort((a, b) => b[1] - a[1])
.map(([nickname, inactiveDays]) => {
const days = Math.floor(inactiveDays);
return `**${nickname}**: ${days} day${days === 1 ? '' : 's'}`;
return `**${markdownEscape(nickname)}**: ${days} day${
days === 1 ? '' : 's'
}`;
});
const hasInactiveMembers = inactiveInfo.length > 0;
@@ -80,8 +83,8 @@ export default {
)
.setTitle(
hasInactiveMembers
? `${clan.name}'s inactive members`
: `No inactive members in ${clan.name}`,
? `${markdownEscape(clan.name)}'s inactive members`
: `No inactive members in ${markdownEscape(clan.name)}`,
)
.setDescription(
hasInactiveMembers
+5 -2
View File
@@ -1,4 +1,5 @@
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
import markdownEscape from 'markdown-escape';
import { CommandRegistry } from '../behaviors/interactionCreate.js';
import { SKILLED_COLOR } from '../constants/colors.js';
import { Players } from '../types/players.js';
@@ -38,12 +39,14 @@ export default {
embeds: [
new EmbedBuilder()
.setColor(SKILLED_COLOR)
.setTitle(`Player search results for "${name}"`)
.setTitle(`Player search results for "${markdownEscape(name)}"`)
.setDescription(
`\`\`\`${
players.length === 0
? 'No players found.'
: players.map((player) => player.nickname).join('\n')
: players
.map((player) => markdownEscape(player.nickname))
.join('\n')
}\`\`\``,
),
],
+2 -1
View File
@@ -1,4 +1,5 @@
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
import markdownEscape from 'markdown-escape';
import { CommandRegistry } from '../behaviors/interactionCreate.js';
import { SKILLED_COLOR } from '../constants/colors.js';
import { BlitzServer } from '../constants/servers.js';
@@ -55,7 +56,7 @@ export default {
new EmbedBuilder()
.setColor(SKILLED_COLOR)
.setTitle(
`${data.nickname}'s ${
`${markdownEscape(data.nickname)}'s ${
period === 'career' ? period : `${period} day`
} stats`,
)
+6 -5
View File
@@ -1,4 +1,5 @@
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
import markdownEscape from 'markdown-escape';
import { CommandRegistry } from '../behaviors/interactionCreate.js';
import { SKILLED_COLOR } from '../constants/colors.js';
import { BlitzServer } from '../constants/servers.js';
@@ -68,20 +69,20 @@ export default {
embeds: [
new EmbedBuilder()
.setTitle(
`${account.nickname}'s owned ${
`${markdownEscape(account.nickname)}'s owned ${
tier === null ? '' : `tier ${tier} `
}tanks`,
)
.setDescription(
`${
tanks.length === 0
? `No tanks found for player in tier ${tier}`
? `No tanks found in tier ${tier}`
: tanks
.map(
(tank) =>
`${TANK_TYPE_EMOJIS[tank.type]} ${tank.name} ${
tank.is_premium ? '⭐' : ''
}${
`${TANK_TYPE_EMOJIS[tank.type]} ${markdownEscape(
tank.name,
)} ${tank.is_premium ? '⭐' : ''}${
COMP_TANKS.includes(tank.tank_id) ? '🏆' : ''
}`,
)
+9 -2
View File
@@ -1,4 +1,5 @@
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
import markdownEscape from 'markdown-escape';
import discord from '../../discord.json' assert { type: 'json' };
import { CommandRegistry } from '../behaviors/interactionCreate.js';
import { NEGATIVE_COLOR, POSITIVE_COLOR } from '../constants/colors.js';
@@ -52,7 +53,9 @@ export default {
.setColor(POSITIVE_COLOR)
.setTitle(`${interaction.user.username} is verified`)
.setDescription(
`The user is now verified as ${name}${clanTag}`,
`The user is now verified as ${markdownEscape(
name,
)}${markdownEscape(clanTag)}`,
),
],
});
@@ -66,7 +69,11 @@ export default {
embeds: [
new EmbedBuilder()
.setColor(NEGATIVE_COLOR)
.setTitle(`${interaction.user.username} failed to verify`)
.setTitle(
`${markdownEscape(
interaction.user.username,
)} failed to verify`,
)
.setDescription(
'I may not have the permission to change your nickname.',
),