mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 03:59:50 +02:00
feat: markdownEscape
This commit is contained in:
1 parent
01b5ec9bc2
commit
5ef1f87236
11 files changed
+75
-26
No files matched your search
@@ -11,8 +11,12 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/node": "^18.15.11",
|
"@types/node": "^18.15.11",
|
||||||
"discord.js": "^14.9.0",
|
"discord.js": "^14.9.0",
|
||||||
|
"markdown-escape": "^2.0.0",
|
||||||
"node-fetch": "^3.3.1",
|
"node-fetch": "^3.3.1",
|
||||||
"typescript": "^5.0.4",
|
"typescript": "^5.0.4",
|
||||||
"vite-node": "^0.30.1"
|
"vite-node": "^0.30.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/markdown-escape": "^1.1.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
||||||
|
import markdownEscape from 'markdown-escape';
|
||||||
import { CommandRegistry } from '../behaviors/interactionCreate.js';
|
import { CommandRegistry } from '../behaviors/interactionCreate.js';
|
||||||
import { NEGATIVE_COLOR, POSITIVE_COLOR } from '../constants/colors.js';
|
import { NEGATIVE_COLOR, POSITIVE_COLOR } from '../constants/colors.js';
|
||||||
import { BlitzServer } from '../constants/servers.js';
|
import { BlitzServer } from '../constants/servers.js';
|
||||||
@@ -108,7 +109,7 @@ export default {
|
|||||||
poweredByBlitzStars(
|
poweredByBlitzStars(
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setTitle(
|
.setTitle(
|
||||||
`${data.nickname} is ${
|
`${markdownEscape(data.nickname)} is ${
|
||||||
eligible ? '' : 'not '
|
eligible ? '' : 'not '
|
||||||
}eligible for ${CLANS[clan].name}`,
|
}eligible for ${CLANS[clan].name}`,
|
||||||
)
|
)
|
||||||
@@ -116,10 +117,14 @@ export default {
|
|||||||
.setDescription(
|
.setDescription(
|
||||||
`${
|
`${
|
||||||
eligible
|
eligible
|
||||||
? `${data.nickname} meets all the requirements set for ${CLANS[clan].name}.`
|
? `${markdownEscape(
|
||||||
: `${data.nickname}'s shortcomings for ${
|
data.nickname,
|
||||||
|
)} meets all the requirements set for ${
|
||||||
CLANS[clan].name
|
CLANS[clan].name
|
||||||
} (${
|
}.`
|
||||||
|
: `${markdownEscape(
|
||||||
|
data.nickname,
|
||||||
|
)}'s shortcomings for ${CLANS[clan].name} (${
|
||||||
clan === 'sklld' ? '30 days stats' : 'career stats'
|
clan === 'sklld' ? '30 days stats' : 'career stats'
|
||||||
}):\n\n${issues.join('\n')}`
|
}):\n\n${issues.join('\n')}`
|
||||||
}\n\n${blitzLinks(data)}`,
|
}\n\n${blitzLinks(data)}`,
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
||||||
|
import markdownEscape from 'markdown-escape';
|
||||||
import { CommandRegistry } from '../behaviors/interactionCreate.js';
|
import { CommandRegistry } from '../behaviors/interactionCreate.js';
|
||||||
import { NEGATIVE_COLOR, POSITIVE_COLOR } from '../constants/colors.js';
|
import { NEGATIVE_COLOR, POSITIVE_COLOR } from '../constants/colors.js';
|
||||||
import { BlitzServer } from '../constants/servers.js';
|
import { BlitzServer } from '../constants/servers.js';
|
||||||
@@ -68,7 +69,9 @@ export default {
|
|||||||
.sort((a, b) => b[1] - a[1])
|
.sort((a, b) => b[1] - a[1])
|
||||||
.map(([nickname, inactiveDays]) => {
|
.map(([nickname, inactiveDays]) => {
|
||||||
const days = Math.floor(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;
|
const hasInactiveMembers = inactiveInfo.length > 0;
|
||||||
|
|
||||||
@@ -80,8 +83,8 @@ export default {
|
|||||||
)
|
)
|
||||||
.setTitle(
|
.setTitle(
|
||||||
hasInactiveMembers
|
hasInactiveMembers
|
||||||
? `${clan.name}'s inactive members`
|
? `${markdownEscape(clan.name)}'s inactive members`
|
||||||
: `No inactive members in ${clan.name}`,
|
: `No inactive members in ${markdownEscape(clan.name)}`,
|
||||||
)
|
)
|
||||||
.setDescription(
|
.setDescription(
|
||||||
hasInactiveMembers
|
hasInactiveMembers
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
||||||
|
import markdownEscape from 'markdown-escape';
|
||||||
import { CommandRegistry } from '../behaviors/interactionCreate.js';
|
import { CommandRegistry } from '../behaviors/interactionCreate.js';
|
||||||
import { SKILLED_COLOR } from '../constants/colors.js';
|
import { SKILLED_COLOR } from '../constants/colors.js';
|
||||||
import { Players } from '../types/players.js';
|
import { Players } from '../types/players.js';
|
||||||
@@ -38,12 +39,14 @@ export default {
|
|||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setColor(SKILLED_COLOR)
|
.setColor(SKILLED_COLOR)
|
||||||
.setTitle(`Player search results for "${name}"`)
|
.setTitle(`Player search results for "${markdownEscape(name)}"`)
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`\`\`\`${
|
`\`\`\`${
|
||||||
players.length === 0
|
players.length === 0
|
||||||
? 'No players found.'
|
? 'No players found.'
|
||||||
: players.map((player) => player.nickname).join('\n')
|
: players
|
||||||
|
.map((player) => markdownEscape(player.nickname))
|
||||||
|
.join('\n')
|
||||||
}\`\`\``,
|
}\`\`\``,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
||||||
|
import markdownEscape from 'markdown-escape';
|
||||||
import { CommandRegistry } from '../behaviors/interactionCreate.js';
|
import { CommandRegistry } from '../behaviors/interactionCreate.js';
|
||||||
import { SKILLED_COLOR } from '../constants/colors.js';
|
import { SKILLED_COLOR } from '../constants/colors.js';
|
||||||
import { BlitzServer } from '../constants/servers.js';
|
import { BlitzServer } from '../constants/servers.js';
|
||||||
@@ -55,7 +56,7 @@ export default {
|
|||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setColor(SKILLED_COLOR)
|
.setColor(SKILLED_COLOR)
|
||||||
.setTitle(
|
.setTitle(
|
||||||
`${data.nickname}'s ${
|
`${markdownEscape(data.nickname)}'s ${
|
||||||
period === 'career' ? period : `${period} day`
|
period === 'career' ? period : `${period} day`
|
||||||
} stats`,
|
} stats`,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
||||||
|
import markdownEscape from 'markdown-escape';
|
||||||
import { CommandRegistry } from '../behaviors/interactionCreate.js';
|
import { CommandRegistry } from '../behaviors/interactionCreate.js';
|
||||||
import { SKILLED_COLOR } from '../constants/colors.js';
|
import { SKILLED_COLOR } from '../constants/colors.js';
|
||||||
import { BlitzServer } from '../constants/servers.js';
|
import { BlitzServer } from '../constants/servers.js';
|
||||||
@@ -68,20 +69,20 @@ export default {
|
|||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setTitle(
|
.setTitle(
|
||||||
`${account.nickname}'s owned ${
|
`${markdownEscape(account.nickname)}'s owned ${
|
||||||
tier === null ? '' : `tier ${tier} `
|
tier === null ? '' : `tier ${tier} `
|
||||||
}tanks`,
|
}tanks`,
|
||||||
)
|
)
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`${
|
`${
|
||||||
tanks.length === 0
|
tanks.length === 0
|
||||||
? `No tanks found for player in tier ${tier}`
|
? `No tanks found in tier ${tier}`
|
||||||
: tanks
|
: tanks
|
||||||
.map(
|
.map(
|
||||||
(tank) =>
|
(tank) =>
|
||||||
`${TANK_TYPE_EMOJIS[tank.type]} ${tank.name} ${
|
`${TANK_TYPE_EMOJIS[tank.type]} ${markdownEscape(
|
||||||
tank.is_premium ? '⭐' : ''
|
tank.name,
|
||||||
}${
|
)} ${tank.is_premium ? '⭐' : ''}${
|
||||||
COMP_TANKS.includes(tank.tank_id) ? '🏆' : ''
|
COMP_TANKS.includes(tank.tank_id) ? '🏆' : ''
|
||||||
}`,
|
}`,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
|
||||||
|
import markdownEscape from 'markdown-escape';
|
||||||
import discord from '../../discord.json' assert { type: 'json' };
|
import discord from '../../discord.json' assert { type: 'json' };
|
||||||
import { CommandRegistry } from '../behaviors/interactionCreate.js';
|
import { CommandRegistry } from '../behaviors/interactionCreate.js';
|
||||||
import { NEGATIVE_COLOR, POSITIVE_COLOR } from '../constants/colors.js';
|
import { NEGATIVE_COLOR, POSITIVE_COLOR } from '../constants/colors.js';
|
||||||
@@ -52,7 +53,9 @@ export default {
|
|||||||
.setColor(POSITIVE_COLOR)
|
.setColor(POSITIVE_COLOR)
|
||||||
.setTitle(`${interaction.user.username} is verified`)
|
.setTitle(`${interaction.user.username} is verified`)
|
||||||
.setDescription(
|
.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: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setColor(NEGATIVE_COLOR)
|
.setColor(NEGATIVE_COLOR)
|
||||||
.setTitle(`${interaction.user.username} failed to verify`)
|
.setTitle(
|
||||||
|
`${markdownEscape(
|
||||||
|
interaction.user.username,
|
||||||
|
)} failed to verify`,
|
||||||
|
)
|
||||||
.setDescription(
|
.setDescription(
|
||||||
'I may not have the permission to change your nickname.',
|
'I may not have the permission to change your nickname.',
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import {
|
|||||||
ChatInputCommandInteraction,
|
ChatInputCommandInteraction,
|
||||||
EmbedBuilder,
|
EmbedBuilder,
|
||||||
} from 'discord.js';
|
} from 'discord.js';
|
||||||
|
import markdownEscape from 'markdown-escape';
|
||||||
import { NEGATIVE_COLOR } from '../constants/colors.js';
|
import { NEGATIVE_COLOR } from '../constants/colors.js';
|
||||||
import { BLITZ_SERVERS, BlitzServer } from '../constants/servers.js';
|
import { BLITZ_SERVERS, BlitzServer } from '../constants/servers.js';
|
||||||
import { Player, Players } from '../types/players.js';
|
import { Player, Players } from '../types/players.js';
|
||||||
@@ -21,7 +22,10 @@ export default async function getBlitzAccount(
|
|||||||
`https://api.wotblitz.${server}/wotb/account/list/?application_id=${args['wargaming-application-id']}&search=${name}`,
|
`https://api.wotblitz.${server}/wotb/account/list/?application_id=${args['wargaming-application-id']}&search=${name}`,
|
||||||
interaction,
|
interaction,
|
||||||
async (players) => {
|
async (players) => {
|
||||||
if (players.length > 0 && players[0].nickname === name) {
|
if (
|
||||||
|
players.length > 0 &&
|
||||||
|
players[0].nickname.toLowerCase() === name.toLowerCase()
|
||||||
|
) {
|
||||||
callback(players[0]);
|
callback(players[0]);
|
||||||
} else {
|
} else {
|
||||||
// no exact match
|
// no exact match
|
||||||
@@ -31,7 +35,9 @@ export default async function getBlitzAccount(
|
|||||||
.setColor(NEGATIVE_COLOR)
|
.setColor(NEGATIVE_COLOR)
|
||||||
.setTitle(`Account not found`)
|
.setTitle(`Account not found`)
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`I couldn't find "${name}" in the ${serverName} server. I found ${
|
`I couldn't find "${markdownEscape(
|
||||||
|
name,
|
||||||
|
)}" in the ${serverName} server. I found ${
|
||||||
players
|
players
|
||||||
? players.length < 100
|
? players.length < 100
|
||||||
? players.length
|
? players.length
|
||||||
@@ -41,9 +47,9 @@ export default async function getBlitzAccount(
|
|||||||
players?.length !== 1 ? 's' : ''
|
players?.length !== 1 ? 's' : ''
|
||||||
}. ${
|
}. ${
|
||||||
players && players.length > 0
|
players && players.length > 0
|
||||||
? `Did you mean "${players[0].nickname}"? `
|
? `Did you mean "${markdownEscape(players[0].nickname)}"? `
|
||||||
: ''
|
: ''
|
||||||
}Re-run the command, don't make typos, and capitalize correctly.`,
|
}Re-run the command and don't make typos.`,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import {
|
|||||||
ChatInputCommandInteraction,
|
ChatInputCommandInteraction,
|
||||||
EmbedBuilder,
|
EmbedBuilder,
|
||||||
} from 'discord.js';
|
} from 'discord.js';
|
||||||
|
import markdownEscape from 'markdown-escape';
|
||||||
import fetch from 'node-fetch';
|
import fetch from 'node-fetch';
|
||||||
import { NEGATIVE_COLOR } from '../constants/colors.js';
|
import { NEGATIVE_COLOR } from '../constants/colors.js';
|
||||||
import { PlayerStatistics } from '../types/statistics.js';
|
import { PlayerStatistics } from '../types/statistics.js';
|
||||||
@@ -20,7 +21,9 @@ export default async function getBlitzStarsAccount(
|
|||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setTitle('No data to display')
|
.setTitle('No data to display')
|
||||||
.setDescription(`${name} is not tracked by BlitzStars.`)
|
.setDescription(
|
||||||
|
`${markdownEscape(name)} is not tracked by BlitzStars.`,
|
||||||
|
)
|
||||||
.setColor(NEGATIVE_COLOR),
|
.setColor(NEGATIVE_COLOR),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import {
|
|||||||
ChatInputCommandInteraction,
|
ChatInputCommandInteraction,
|
||||||
EmbedBuilder,
|
EmbedBuilder,
|
||||||
} from 'discord.js';
|
} from 'discord.js';
|
||||||
|
import markdownEscape from 'markdown-escape';
|
||||||
import { NEGATIVE_COLOR } from '../constants/colors.js';
|
import { NEGATIVE_COLOR } from '../constants/colors.js';
|
||||||
import { BLITZ_SERVERS, BlitzServer } from '../constants/servers.js';
|
import { BLITZ_SERVERS, BlitzServer } from '../constants/servers.js';
|
||||||
import { Clan, ClanList } from '../types/clanList.js';
|
import { Clan, ClanList } from '../types/clanList.js';
|
||||||
@@ -23,7 +24,8 @@ export default async function getClan(
|
|||||||
async (clans) => {
|
async (clans) => {
|
||||||
if (
|
if (
|
||||||
clans.length > 0 &&
|
clans.length > 0 &&
|
||||||
(clans[0].name === name || clans[0].tag === name.toUpperCase())
|
(clans[0].name.toLowerCase() === name.toLowerCase() ||
|
||||||
|
clans[0].tag.toLowerCase() === name.toLowerCase())
|
||||||
) {
|
) {
|
||||||
callback(clans[0]);
|
callback(clans[0]);
|
||||||
} else {
|
} else {
|
||||||
@@ -34,13 +36,17 @@ export default async function getClan(
|
|||||||
.setColor(NEGATIVE_COLOR)
|
.setColor(NEGATIVE_COLOR)
|
||||||
.setTitle(`Clan not found`)
|
.setTitle(`Clan not found`)
|
||||||
.setDescription(
|
.setDescription(
|
||||||
`I couldn't find "${name}" in the ${serverName} server. I found ${
|
`I couldn't find "${markdownEscape(
|
||||||
|
name,
|
||||||
|
)}" in the ${serverName} server. I found ${
|
||||||
clans ? (clans.length < 100 ? clans.length : 'over 100') : 0
|
clans ? (clans.length < 100 ? clans.length : 'over 100') : 0
|
||||||
} similarly spelled clan${clans?.length !== 1 ? 's' : ''}. ${
|
} similarly spelled clan${clans?.length !== 1 ? 's' : ''}. ${
|
||||||
clans && clans.length > 0
|
clans && clans.length > 0
|
||||||
? `Did you mean "${clans[0].name}" or "${clans[0].tag}"? `
|
? `Did you mean "${markdownEscape(
|
||||||
|
clans[0].name,
|
||||||
|
)}" or "${markdownEscape(clans[0].tag)}"? `
|
||||||
: ''
|
: ''
|
||||||
}Re-run the command, don't make typos, and capitalize correctly.`,
|
}Re-run the command, don't make typos.`,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -179,6 +179,11 @@
|
|||||||
resolved "https://registry.npmjs.org/@tokenizer/token/-/token-0.3.0.tgz"
|
resolved "https://registry.npmjs.org/@tokenizer/token/-/token-0.3.0.tgz"
|
||||||
integrity sha512-OvjF+z51L3ov0OyAU0duzsYuvO01PH7x4t6DJx+guahgTnBHkhJdG7soQeTSFLWN3efnHyibZ4Z8l2EuWwJN3A==
|
integrity sha512-OvjF+z51L3ov0OyAU0duzsYuvO01PH7x4t6DJx+guahgTnBHkhJdG7soQeTSFLWN3efnHyibZ4Z8l2EuWwJN3A==
|
||||||
|
|
||||||
|
"@types/markdown-escape@^1.1.0":
|
||||||
|
version "1.1.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/markdown-escape/-/markdown-escape-1.1.0.tgz#8bd940d6701880eb7229467542c029bc05a7b22f"
|
||||||
|
integrity sha512-bJZh73L6fSt8MmTON/btR8hiKRipoIoPfLO41lxr6l65QXdG1rwUjR8Hu5xU7XYHBwKHiJZ+sTQ8L2TKkQrBpw==
|
||||||
|
|
||||||
"@types/node@*", "@types/node@^18.15.11":
|
"@types/node@*", "@types/node@^18.15.11":
|
||||||
version "18.15.11"
|
version "18.15.11"
|
||||||
resolved "https://registry.npmjs.org/@types/node/-/node-18.15.11.tgz"
|
resolved "https://registry.npmjs.org/@types/node/-/node-18.15.11.tgz"
|
||||||
@@ -331,6 +336,11 @@ lodash@^4.17.21:
|
|||||||
resolved "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz"
|
resolved "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz"
|
||||||
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
|
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
|
||||||
|
|
||||||
|
markdown-escape@^2.0.0:
|
||||||
|
version "2.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/markdown-escape/-/markdown-escape-2.0.0.tgz#44484d30d7845b91575c77fd8898f23a0a6f890c"
|
||||||
|
integrity sha512-Trz4v0+XWlwy68LJIyw3bLbsJiC8XAbRCKF9DbEtZjyndKOGVx6n+wNB0VfoRmY2LKboQLeniap3xrb6LGSJ8A==
|
||||||
|
|
||||||
mlly@^1.1.1, mlly@^1.2.0:
|
mlly@^1.1.1, mlly@^1.2.0:
|
||||||
version "1.2.0"
|
version "1.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/mlly/-/mlly-1.2.0.tgz#f0f6c2fc8d2d12ea6907cd869066689b5031b613"
|
resolved "https://registry.yarnpkg.com/mlly/-/mlly-1.2.0.tgz#f0f6c2fc8d2d12ea6907cd869066689b5031b613"
|
||||||
|
|||||||
Reference in new issue
Block a user