diff --git a/src/commands/verify.ts b/src/commands/verify.ts index fc86ab7a4..f3a9bc37f 100644 --- a/src/commands/verify.ts +++ b/src/commands/verify.ts @@ -5,6 +5,7 @@ import { SlashCommandBuilder, } from 'discord.js'; import config from '../../config.json' assert { type: 'json' }; +import AccountList from '../types/accountList.js'; 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 players = (await fetch( `https://api.wotblitz.${server}/wotb/account/list/?application_id=${config.wargaming_application_id}&search=${ign}`, - ).then((response) => response.json())) as - | { - data: { nickname: string; account_id: number }[] | undefined; - } - | undefined; + ).then((response) => response.json())) as AccountList; if (players?.data?.[0].nickname === ign) { // good match diff --git a/src/index.ts b/src/index.ts index c888c24aa..151aa6b4e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,6 +8,7 @@ import { REST, Routes, SlashCommandBuilder, + TextChannel, } from 'discord.js'; import { readdirSync } from 'fs'; import config from '../config.json' assert { type: 'json' }; @@ -24,8 +25,11 @@ client.on('ready', (c) => { client.on('guildMemberAdd', async (member) => { console.log(`${member.user.tag} joined`); - //@ts-ignore - await member.guild.channels.cache.get(config.discord_verify_channel)?.send({ + await ( + member.guild.channels.cache.get( + config.discord_verify_channel, + ) as TextChannel + ).send({ embeds: [ new EmbedBuilder() .setColor('#8e3cf5') @@ -39,10 +43,11 @@ client.on('guildMemberAdd', async (member) => { ), ], }); - await member.guild.channels.cache - .get(config.discord_verify_channel) - //@ts-ignore - ?.send(member.toString()); + await ( + member.guild.channels.cache.get( + config.discord_verify_channel, + ) as TextChannel + ).send(member.toString()); }); export interface CommandRegistry { diff --git a/src/types/accountList.ts b/src/types/accountList.ts new file mode 100644 index 000000000..bfa8e23ed --- /dev/null +++ b/src/types/accountList.ts @@ -0,0 +1,7 @@ +type AccountList = + | { + data?: { nickname: string; account_id: number }[]; + } + | undefined; + +export default AccountList;