feat: stats setup

This commit is contained in:
TresAbhi committed 2023-04-22 01:58:42 +00:00
1 parent 5f3d42c690
commit bf7993fa38
8 files changed
+74 -13

No files matched your search

+45
View File
@@ -0,0 +1,45 @@
import {
CacheType,
ChatInputCommandInteraction,
SlashCommandBuilder,
} from 'discord.js';
import { SERVERS } from '../constants/servers.js';
export async function execute(
interaction: ChatInputCommandInteraction<CacheType>,
) {
interaction.reply('YOU SUCK MORON GO PLAY ROBLOX');
}
export const data = new SlashCommandBuilder()
.setName('stats')
.setDescription("Gets the user's in-game statistics")
.addStringOption((option) =>
option
.setName('server')
.setDescription('The Blitz server you are in')
.addChoices(
{ name: SERVERS.com, value: 'com' },
{ name: SERVERS.eu, value: 'eu' },
{ name: SERVERS.asia, value: 'asia' },
)
.setRequired(true),
)
.addStringOption((option) =>
option
.setName('ign')
.setDescription('The username you use in Blitz')
.setRequired(true),
)
.addStringOption((option) =>
option
.setName('period')
.setDescription('The last number of days of stats')
.setChoices(
{ name: '30 Days', value: '30' },
{ name: '60 Days', value: '60' },
{ name: '90 Days', value: '90' },
{ name: 'Career', value: 'career' },
)
.setRequired(true),
);
+6 -5
View File
@@ -6,16 +6,17 @@ import {
} from 'discord.js';
import fetch from 'node-fetch';
import discord from '../../discord.json' assert { type: 'json' };
import { SERVERS } from '../constants/servers.js';
import AccountList from '../types/accountList.js';
const SERVER_NAMES = { com: 'North America', eu: 'Europe', asia: 'Asia' };
export const disabled = true;
export async function execute(
interaction: ChatInputCommandInteraction<CacheType>,
) {
const ign = interaction.options.getString('ign')!;
const server = interaction.options.getString('server')!;
const serverName = SERVER_NAMES[server as keyof typeof SERVER_NAMES];
const serverName = SERVERS[server as keyof typeof SERVERS];
const players = (await fetch(
`https://api.wotblitz.${server}/wotb/account/list/?application_id=${process.env.WARGAMING_APPLICATION_ID}&search=${ign}`,
).then((response) => response.json())) as AccountList;
@@ -102,9 +103,9 @@ export const data = new SlashCommandBuilder()
.setDescription('The Blitz server you are in')
.setRequired(true)
.addChoices(
{ name: SERVER_NAMES.com, value: 'com' },
{ name: SERVER_NAMES.eu, value: 'eu' },
{ name: SERVER_NAMES.asia, value: 'asia' },
{ name: SERVERS.com, value: 'com' },
{ name: SERVERS.eu, value: 'eu' },
{ name: SERVERS.asia, value: 'asia' },
),
)
.addStringOption((option) =>