feat: type cleanup

This commit is contained in:
TresAbhi committed 2023-04-20 13:26:05 +00:00
1 parent 9f12f82485
commit 0e37d0479a
3 files changed
+20 -11

No files matched your search

+2 -5
View File
@@ -5,6 +5,7 @@ import {
SlashCommandBuilder, SlashCommandBuilder,
} from 'discord.js'; } from 'discord.js';
import config from '../../config.json' assert { type: 'json' }; import config from '../../config.json' assert { type: 'json' };
import AccountList from '../types/accountList.js';
const SERVER_NAMES = { com: 'North America', eu: 'Europe', asia: 'Asia' }; const SERVER_NAMES = { com: 'North America', eu: 'Europe', asia: 'Asia' };
@@ -16,11 +17,7 @@ export async function execute(
const serverName = SERVER_NAMES[server as keyof typeof SERVER_NAMES]; const serverName = SERVER_NAMES[server as keyof typeof SERVER_NAMES];
const players = (await fetch( const players = (await fetch(
`https://api.wotblitz.${server}/wotb/account/list/?application_id=${config.wargaming_application_id}&search=${ign}`, `https://api.wotblitz.${server}/wotb/account/list/?application_id=${config.wargaming_application_id}&search=${ign}`,
).then((response) => response.json())) as ).then((response) => response.json())) as AccountList;
| {
data: { nickname: string; account_id: number }[] | undefined;
}
| undefined;
if (players?.data?.[0].nickname === ign) { if (players?.data?.[0].nickname === ign) {
// good match // good match
+11 -6
View File
@@ -8,6 +8,7 @@ import {
REST, REST,
Routes, Routes,
SlashCommandBuilder, SlashCommandBuilder,
TextChannel,
} from 'discord.js'; } from 'discord.js';
import { readdirSync } from 'fs'; import { readdirSync } from 'fs';
import config from '../config.json' assert { type: 'json' }; import config from '../config.json' assert { type: 'json' };
@@ -24,8 +25,11 @@ client.on('ready', (c) => {
client.on('guildMemberAdd', async (member) => { client.on('guildMemberAdd', async (member) => {
console.log(`${member.user.tag} joined`); console.log(`${member.user.tag} joined`);
//@ts-ignore await (
await member.guild.channels.cache.get(config.discord_verify_channel)?.send({ member.guild.channels.cache.get(
config.discord_verify_channel,
) as TextChannel
).send({
embeds: [ embeds: [
new EmbedBuilder() new EmbedBuilder()
.setColor('#8e3cf5') .setColor('#8e3cf5')
@@ -39,10 +43,11 @@ client.on('guildMemberAdd', async (member) => {
), ),
], ],
}); });
await member.guild.channels.cache await (
.get(config.discord_verify_channel) member.guild.channels.cache.get(
//@ts-ignore config.discord_verify_channel,
?.send(member.toString()); ) as TextChannel
).send(member.toString());
}); });
export interface CommandRegistry { export interface CommandRegistry {
+7
View File
@@ -0,0 +1,7 @@
type AccountList =
| {
data?: { nickname: string; account_id: number }[];
}
| undefined;
export default AccountList;