mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 02:37:05 +02:00
feat: stats setup
This commit is contained in:
1 parent
5f3d42c690
commit
bf7993fa38
8 files changed
+74
-13
No files matched your search
@@ -1,3 +0,0 @@
|
||||
tasks:
|
||||
- init: yarn
|
||||
command: yarn start
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"client_id": "1097673957865443370",
|
||||
"client_id_dev": "1099063696015229078",
|
||||
"guild_id": "894784231677513819",
|
||||
"verify_channel": "909968131873726545",
|
||||
"verify_role": "909968395154358333",
|
||||
|
||||
@@ -9,8 +9,10 @@ import {
|
||||
} from 'discord.js';
|
||||
import { readdirSync } from 'fs';
|
||||
import discord from '../../discord.json' assert { type: 'json' };
|
||||
import getClientId from '../utilities/getClientId.js';
|
||||
|
||||
export interface CommandRegistry {
|
||||
disabled?: boolean;
|
||||
data: SlashCommandBuilder;
|
||||
execute: (interaction: Interaction) => void;
|
||||
}
|
||||
@@ -22,15 +24,18 @@ const rest = new REST().setToken(process.env.DISCORD_TOKEN!);
|
||||
|
||||
for (const file of commandFolders) {
|
||||
const command = (await import(`../commands/${file}`)) as CommandRegistry;
|
||||
commands.push(command.data.toJSON());
|
||||
commandCollection.set(command.data.name, command);
|
||||
|
||||
if (!command.disabled) {
|
||||
commands.push(command.data.toJSON());
|
||||
commandCollection.set(command.data.name, command);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
console.log(`Started refreshing ${commands.length} command(s).`);
|
||||
|
||||
const data = (await rest.put(
|
||||
Routes.applicationGuildCommands(discord.client_id, discord.guild_id),
|
||||
Routes.applicationGuildCommands(getClientId(), discord.guild_id),
|
||||
{ body: commands },
|
||||
)) as { length: number };
|
||||
|
||||
|
||||
@@ -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,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) =>
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
export const SERVERS = {
|
||||
com: 'North America',
|
||||
eu: 'Europe',
|
||||
asia: 'Asia',
|
||||
};
|
||||
+1
-2
@@ -1,5 +1,4 @@
|
||||
import { Client, GatewayIntentBits } from 'discord.js';
|
||||
import guildMemberAdd from './behaviors/guildMemberAdd.js';
|
||||
import interactionCreate from './behaviors/interactionCreate.js';
|
||||
import ready from './behaviors/ready.js';
|
||||
import tokenRequirements from './utilities/tokenRequirements.js';
|
||||
@@ -12,6 +11,6 @@ const client = new Client({
|
||||
|
||||
client.on('error', console.error);
|
||||
client.on('ready', ready);
|
||||
client.on('guildMemberAdd', guildMemberAdd);
|
||||
// client.on('guildMemberAdd', guildMemberAdd);
|
||||
client.on('interactionCreate', interactionCreate);
|
||||
client.login(process.env.DISCORD_TOKEN);
|
||||
@@ -0,0 +1,8 @@
|
||||
import { argv } from 'process';
|
||||
import discord from '../../discord.json' assert { type: 'json' };
|
||||
|
||||
const isDev = argv.includes('--dev');
|
||||
|
||||
export default function getClientId() {
|
||||
return isDev ? discord.client_id_dev : discord.client_id;
|
||||
}
|
||||
Reference in new issue
Block a user