update with eslint rules

This commit is contained in:
Mylloon 2022-07-20 12:33:06 +02:00
parent 261bc96788
commit a1924e411c
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
4 changed files with 18 additions and 14 deletions

View file

@ -4,7 +4,7 @@ import { Client } from 'discord.js';
import { readdir } from 'fs/promises';
export default async (client: Client) => {
const rest = new REST({ version: '9' }).setToken(client.token!);
const rest = new REST({ version: '9' }).setToken(client.token ?? '');
const command_categories = (await readdir('./src/commands'))
.filter(element => !element.endsWith('.js'));
@ -32,7 +32,7 @@ export default async (client: Client) => {
)
).flat(2);
return await rest.put(Routes.applicationCommands(client.user!.id), {
return await rest.put(Routes.applicationCommands(client.user?.id ?? ''), {
body: commands,
});
};

View file

@ -17,7 +17,7 @@ export default async (client: Client) => {
);
// Remove .js
let event_type_ext = event_file.split('.');
const event_type_ext = event_file.split('.');
if (event_type_ext.pop() !== 'js') {
throw `Unknown file in ${event_category}: ${event_file}`;
}

View file

@ -15,7 +15,7 @@ const run = async () => {
.then(async client => {
console.log('Client ✅');
await loadEvents(client)
.then(_ => console.log('Events ✅'))
.then(() => console.log('Events ✅'))
.catch(() => {
throw 'Events ❌';
});
@ -23,14 +23,14 @@ const run = async () => {
await client.login(client.config.token_discord);
await loadCommands(client)
.then(_ => console.log('Commands ✅'))
.then(() => console.log('Commands ✅'))
.catch(() => {
throw 'Commands ❌';
});
console.log(`Botanique "${client.user!.username}" ${client.config.version} started!`);
console.log(`Botanique "${client.user?.username}" ${client.config.version} started!`);
})
.catch(_ => {
.catch(() => {
throw 'Client ❌';
});
};

View file

@ -4,16 +4,20 @@ import { SlashCommandBuilder } from '@discordjs/builders';
const { version } = JSON.parse(readFileSync('./package.json').toString());
declare module "discord.js" {
declare module 'discord.js' {
// eslint-disable-next-line no-shadow
export interface Client {
config: {
version: any,
token_discord: any
version: string,
token_discord: string | undefined
},
commands: Collection<string, {
commands: Collection<
string,
{
data: SlashCommandBuilder,
interaction: (interaction: CommandInteraction, client: Client) => any
}>
interaction: (interaction: CommandInteraction, client: Client) => unknown
}
>
}
}