mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
feat: username inferring from discord nickname
This commit is contained in:
1 parent
f4bc66658b
commit
db881f44d4
17 files changed
+55
-41
No files matched your search
@@ -13,7 +13,7 @@ const executionStart = new Date().getTime();
|
||||
|
||||
export default {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
|
||||
@@ -11,7 +11,7 @@ import { client } from '../index.js';
|
||||
|
||||
export default {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
|
||||
@@ -15,7 +15,7 @@ const DEFAULT_THRESHOLD = 7;
|
||||
|
||||
export default {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
|
||||
@@ -36,7 +36,7 @@ const COMP_TANKS = [
|
||||
|
||||
export default {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
@@ -54,8 +54,7 @@ export default {
|
||||
|
||||
async execute(interaction) {
|
||||
const tier = interaction.options.getInteger('tier')!;
|
||||
const name = interaction.options.getString('username')!;
|
||||
const account = await getBlitzAccount(interaction, name);
|
||||
const account = await getBlitzAccount(interaction);
|
||||
const { id, server } = account;
|
||||
const accountInfo = await getWargamingResponse<AccountInfo>(
|
||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${args['wargaming-application-id']}&account_id=${id}`,
|
||||
|
||||
@@ -17,7 +17,7 @@ type SortBy = 'name' | 'count';
|
||||
|
||||
export default {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
@@ -36,8 +36,7 @@ export default {
|
||||
|
||||
async execute(interaction) {
|
||||
const sortBy = (interaction.options.getString('sort') ?? 'name') as SortBy;
|
||||
const name = interaction.options.getString('username')!;
|
||||
const account = await getBlitzAccount(interaction, name);
|
||||
const account = await getBlitzAccount(interaction);
|
||||
const { id, server } = account;
|
||||
const accounts = await getWargamingResponse<AccountInfo>(
|
||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${args['wargaming-application-id']}&account_id=${id}`,
|
||||
|
||||
@@ -13,7 +13,7 @@ import { AccountInfo } from '../types/accountInfo.js';
|
||||
|
||||
export default {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
@@ -22,8 +22,7 @@ export default {
|
||||
.addStringOption(addUsernameOption),
|
||||
|
||||
async execute(interaction) {
|
||||
const name = interaction.options.getString('username')!;
|
||||
const account = await getBlitzAccount(interaction, name);
|
||||
const account = await getBlitzAccount(interaction);
|
||||
const { id, server } = account;
|
||||
const accounts = await getWargamingResponse<AccountInfo>(
|
||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${args['wargaming-application-id']}&account_id=${id}`,
|
||||
|
||||
@@ -12,7 +12,7 @@ import { ClanList } from '../types/clanList.js';
|
||||
|
||||
export default {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
|
||||
@@ -2,7 +2,7 @@ import { SlashCommandBuilder } from 'discord.js';
|
||||
import markdownEscape from 'markdown-escape';
|
||||
import { BLITZ_SERVERS, BlitzServer } from '../constants/servers.js';
|
||||
import getWargamingResponse from '../core/blitz/getWargamingResponse.js';
|
||||
import { usernameRegex } from '../core/blitz/listAccountsPanServer.js';
|
||||
import { usernamePattern } from '../core/blitz/listAccountsPanServer.js';
|
||||
import cmdName from '../core/interaction/cmdName.js';
|
||||
import infoEmbed from '../core/interaction/infoEmbed.js';
|
||||
import addServerChoices from '../core/options/addServerChoices.js';
|
||||
@@ -13,7 +13,7 @@ import { AccountList } from '../types/accountList.js';
|
||||
|
||||
export default {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
@@ -21,7 +21,7 @@ export default {
|
||||
.setDescription('Search players in a Blitz server')
|
||||
.addStringOption(addServerChoices)
|
||||
.addStringOption((option) =>
|
||||
addUsernameOption(option).setAutocomplete(false),
|
||||
addUsernameOption(option).setAutocomplete(false).setRequired(true),
|
||||
)
|
||||
.addIntegerOption((option) =>
|
||||
option
|
||||
@@ -36,7 +36,7 @@ export default {
|
||||
const name = interaction.options.getString('username')!;
|
||||
const limit = interaction.options.getInteger('limit') ?? 25;
|
||||
const trimmedSearch = name.trim();
|
||||
const players = usernameRegex.test(trimmedSearch)
|
||||
const players = usernamePattern.test(trimmedSearch)
|
||||
? await getWargamingResponse<AccountList>(
|
||||
`https://api.wotblitz.${server}/wotb/account/list/?application_id=${
|
||||
args['wargaming-application-id']
|
||||
|
||||
@@ -9,7 +9,7 @@ import { CommandRegistry } from '../events/interactionCreate.js';
|
||||
|
||||
export default {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
|
||||
@@ -40,7 +40,7 @@ import { PlayerClanData } from '../types/playerClanData.js';
|
||||
|
||||
export default {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
@@ -51,8 +51,7 @@ export default {
|
||||
|
||||
async execute(interaction) {
|
||||
const period = interaction.options.getString('period') as StatPeriod;
|
||||
const username = interaction.options.getString('username')!;
|
||||
const blitzAccount = await getBlitzAccount(interaction, username);
|
||||
const blitzAccount = await getBlitzAccount(interaction);
|
||||
const { id, server } = blitzAccount;
|
||||
const accountInfo = await getWargamingResponse<AccountInfo>(
|
||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${args['wargaming-application-id']}&account_id=${id}`,
|
||||
|
||||
@@ -40,7 +40,7 @@ import { AccountInfo, AllStats } from '../types/accountInfo.js';
|
||||
|
||||
export default {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
@@ -56,8 +56,7 @@ export default {
|
||||
interaction.options.getString('tank')!,
|
||||
);
|
||||
const period = interaction.options.getString('period') as StatPeriod;
|
||||
const username = interaction.options.getString('username')!;
|
||||
const blitzAccount = await getBlitzAccount(interaction, username);
|
||||
const blitzAccount = await getBlitzAccount(interaction);
|
||||
const { id, server } = blitzAccount;
|
||||
const accountInfo = await getWargamingResponse<AccountInfo>(
|
||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${args['wargaming-application-id']}&account_id=${id}`,
|
||||
|
||||
@@ -32,7 +32,7 @@ import { PlayerClanData } from '../types/playerClanData.js';
|
||||
|
||||
export default {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
@@ -41,9 +41,7 @@ export default {
|
||||
.addStringOption(addUsernameOption),
|
||||
|
||||
async execute(interaction) {
|
||||
const username = interaction.options.getString('username')!;
|
||||
const blitzAccount = await getBlitzAccount(interaction, username);
|
||||
const { id, server } = blitzAccount;
|
||||
const { id, server } = await getBlitzAccount(interaction);
|
||||
const tankStatsOverTime = await getTankStatsOverTime(
|
||||
interaction,
|
||||
server,
|
||||
|
||||
@@ -14,17 +14,16 @@ import { PlayerClanData } from '../types/playerClanData.js';
|
||||
|
||||
export default {
|
||||
inProduction: true,
|
||||
inDevelopment: false,
|
||||
inDevelopment: true,
|
||||
inPublic: true,
|
||||
|
||||
command: new SlashCommandBuilder()
|
||||
.setName(cmdName('verify'))
|
||||
.setDescription("Set's the user's username to their in-game name")
|
||||
.addStringOption(addUsernameOption),
|
||||
.addStringOption((option) => addUsernameOption(option).setRequired(true)),
|
||||
|
||||
async execute(interaction) {
|
||||
const name = interaction.options.getString('username')!;
|
||||
const blitzAccount = await getBlitzAccount(interaction, name);
|
||||
const blitzAccount = await getBlitzAccount(interaction);
|
||||
const { id, server } = blitzAccount;
|
||||
const accountInfo = await getWargamingResponse<AccountInfo>(
|
||||
`https://api.wotblitz.${server}/wotb/account/info/?application_id=${args['wargaming-application-id']}&account_id=${id}`,
|
||||
@@ -118,7 +117,7 @@ export default {
|
||||
.setColor(NEGATIVE_COLOR)
|
||||
.setTitle(`${interaction.user.username} failed to verify`)
|
||||
.setDescription(
|
||||
"I can't change your nickname because you have higher permissions than me.",
|
||||
"I can't change your nickname because you have higher permissions than me. Try setting your nickname to your Blitz username manually.",
|
||||
),
|
||||
],
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user