From 5c89dd00dbc7b91dec2828c41525f17732cd1a20 Mon Sep 17 00:00:00 2001 From: Behzad Rabiei Date: Thu, 24 Oct 2024 14:26:46 +0400 Subject: [PATCH] bot: format the code --- bot/src/database/services/channel.service.ts | 16 ++-------- .../database/services/guildMember.service.ts | 23 +-------------- bot/src/database/services/rawInfo.service.ts | 29 ++----------------- bot/src/database/services/role.service.ts | 16 ++-------- bot/src/index.ts | 2 +- 5 files changed, 8 insertions(+), 78 deletions(-) diff --git a/bot/src/database/services/channel.service.ts b/bot/src/database/services/channel.service.ts index d46c3506..573ffebe 100644 --- a/bot/src/database/services/channel.service.ts +++ b/bot/src/database/services/channel.service.ts @@ -26,13 +26,7 @@ async function createChannel( ): Promise { try { return await connection.models.Channel.create(channel) - // eslint-disable-next-line @typescript-eslint/no-explicit-any - } catch (error: any) { - // if (error.code === 11000) { - // logger.warn({ database: connection.name, channel_id: channel.channelId }, 'Failed to create duplicate channel'); - // return null; - // } - // logger.error({ database: connection.name, channel_id: channel.channelId, error }, 'Failed to create channel'); + } catch (error) { return null } } @@ -51,13 +45,7 @@ async function createChannels( return await connection.models.Channel.insertMany(channels, { ordered: false, }) - // eslint-disable-next-line @typescript-eslint/no-explicit-any - } catch (error: any) { - // if (error.code === 11000) { - // logger.warn({ database: connection.name }, 'Failed to create duplicate channels'); - // return []; - // } - // logger.error({ database: connection.name, error }, 'Failed to create channels'); + } catch (error) { return [] } } diff --git a/bot/src/database/services/guildMember.service.ts b/bot/src/database/services/guildMember.service.ts index a409a1ed..e8075783 100644 --- a/bot/src/database/services/guildMember.service.ts +++ b/bot/src/database/services/guildMember.service.ts @@ -20,23 +20,7 @@ async function createGuildMember( ): Promise { try { return await connection.models.GuildMember.create(guildMember) - // eslint-disable-next-line @typescript-eslint/no-explicit-any - } catch (error: any) { - // if (error.code === 11000) { - // logger.warn( - // { database: connection.name, guild_member_id: guildMember.discordId }, - // 'Failed to create duplicate guild member', - // ); - // return null; - // } - // logger.error( - // { - // database: connection.name, - // guild_member_id: guildMember.discordId, - // error, - // }, - // 'Failed to create guild member', - // ); + } catch (error) { return null } } @@ -57,11 +41,6 @@ async function createGuildMembers( }) // eslint-disable-next-line @typescript-eslint/no-explicit-any } catch (error: any) { - // if (error.code === 11000) { - // logger.warn({ database: connection.name }, 'Failed to create duplicate guild members'); - // return []; - // } - // logger.error({ database: connection.name, error }, 'Failed to create guild members'); return [] } } diff --git a/bot/src/database/services/rawInfo.service.ts b/bot/src/database/services/rawInfo.service.ts index bbdeab1f..d35ae7b1 100644 --- a/bot/src/database/services/rawInfo.service.ts +++ b/bot/src/database/services/rawInfo.service.ts @@ -16,27 +16,7 @@ async function createRawInfo( ): Promise { try { return await connection.models.RawInfo.create(rawInfo) - // eslint-disable-next-line @typescript-eslint/no-explicit-any - } catch (error: any) { - // if (error.code === 11000) { - // logger.warn( - // { - // database: connection.name, - // channel_id: rawInfo.channelId, - // message_id: rawInfo.messageId, - // }, - // 'Failed to create duplicate rawInfo', - // ); - // return null; - // } - // logger.error( - // { - // database: connection.name, - // channel_id: rawInfo.channelId, - // message_id: rawInfo.messageId, - // }, - // 'Failed to create rawInfo', - // ); + } catch (error) { return null } } @@ -55,12 +35,7 @@ async function createRawInfos( return await connection.models.RawInfo.insertMany(rawInfos, { ordered: false, }) - // eslint-disable-next-line @typescript-eslint/no-explicit-any - } catch (error: any) { - // if (error.code === 11000) { - // logger.warn({ database: connection.name }, 'Failed to create duplicate rawInfos'); - // return []; - // } + } catch (error) { logger.error( { database: connection.name, error }, 'Failed to create rawInfos' diff --git a/bot/src/database/services/role.service.ts b/bot/src/database/services/role.service.ts index ebc58b0c..1b3943b0 100644 --- a/bot/src/database/services/role.service.ts +++ b/bot/src/database/services/role.service.ts @@ -21,13 +21,7 @@ async function createRole( ): Promise { try { return await connection.models.Role.create(role) - // eslint-disable-next-line @typescript-eslint/no-explicit-any - } catch (error: any) { - // if (error.code === 11000) { - // logger.warn({ database: connection.name, role_id: role.roleId }, 'Failed to create duplicate role'); - // return null; - // } - // logger.error({ database: connection.name, role_id: role.roleId, error }, 'Failed to create role'); + } catch (error) { return null } } @@ -46,13 +40,7 @@ async function createRoles( return await connection.models.Role.insertMany(roles, { ordered: false, }) - // eslint-disable-next-line @typescript-eslint/no-explicit-any - } catch (error: any) { - // if (error.code === 11000) { - // logger.warn({ database: connection.name }, 'Failed to create duplicate roles'); - // return []; - // } - // logger.error({ database: connection.name, error }, 'Failed to create roles'); + } catch (error) { return [] } } diff --git a/bot/src/index.ts b/bot/src/index.ts index 8345971d..ad3c7855 100644 --- a/bot/src/index.ts +++ b/bot/src/index.ts @@ -34,5 +34,5 @@ async function app(): Promise { } app().catch((error) => { - logger.fatal(error, 'Failed To start the application!!!!!') + logger.fatal(error, 'Failed To start the application!') })