fix: linter

This commit is contained in:
Skillz4Killz
2023-03-16 13:22:04 +00:00
parent 103310a8f4
commit 580206a6f5
12 changed files with 34 additions and 17 deletions
+2
View File
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-confusing-void-expression */
/* eslint-disable no-prototype-builtins */
/* eslint-disable @typescript-eslint/restrict-template-expressions */
/* eslint-disable @typescript-eslint/restrict-plus-operands */
@@ -2300,6 +2301,7 @@ export class Client extends EventEmitter {
// Typescript is not so good as we developers so we need this little utility function to help it out
// Taken from https://fettblog.eu/typescript-hasownproperty/
/** TS save way to check if a property exists in an object */
// eslint-disable-next-line @typescript-eslint/ban-types
hasProperty<T extends {}, Y extends PropertyKey = string, Z = unknown>(obj: T, prop: Y): obj is T & Record<Y, Z> {
return obj.hasOwnProperty(prop)
}
+4 -1
View File
@@ -54,7 +54,10 @@ export class RequestHandler {
this.client = client
this.discordeno = createRestManager({
token: this.client.token,
baseUrl: options.baseURL ?? this.client.options.proxyURL,
proxy : {
baseUrl: options.baseURL ?? this.client.options.proxyURL,
authorization: this.client.token,
}
})
this.userAgent = `DiscordBot (https://github.com/discordeno/discordeno, ${version})`
+3 -1
View File
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/consistent-indexed-object-style */
/* eslint-disable no-useless-call */
/* eslint-disable no-prototype-builtins */
/* eslint-disable @typescript-eslint/restrict-template-expressions */
@@ -5,7 +6,6 @@
/* eslint-disable @typescript-eslint/restrict-plus-operands */
/* eslint-disable @typescript-eslint/explicit-function-return-type */
import { DiscordenoShard, ShardState } from '@discordeno/gateway'
import type { DiscordGuildStickersUpdate, DiscordThreadMemberUpdate } from '@discordeno/types'
import {
ActivityTypes,
ChannelTypes,
@@ -25,6 +25,7 @@ import {
type DiscordGuildRoleCreate,
type DiscordGuildRoleDelete,
type DiscordGuildRoleUpdate,
type DiscordGuildStickersUpdate,
type DiscordInteraction,
type DiscordInviteCreate,
type DiscordInviteDelete,
@@ -41,6 +42,7 @@ import {
type DiscordStageInstance,
type DiscordThreadListSync,
type DiscordThreadMembersUpdate,
type DiscordThreadMemberUpdate,
type DiscordTypingStart,
type DiscordUnavailableGuild,
type DiscordUser,
+1
View File
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/consistent-indexed-object-style */
import type {
ActivityTypes,
ApplicationCommandOptionTypes,
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/class-literal-property-style */
/* eslint-disable @typescript-eslint/explicit-function-return-type */
/* eslint-disable @typescript-eslint/no-var-requires */
import { EventEmitter } from 'node:events'
+1
View File
@@ -20,6 +20,7 @@ class Bucket {
tokenLimit: number
tokens: number
reservedTokens: number
// eslint-disable-next-line @typescript-eslint/ban-types
_queue: Array<{ func: Function; priority: boolean }>
timeout: NodeJS.Timeout | null = null
@@ -26,5 +26,6 @@ module.exports = {
'@typescript-eslint/no-invalid-void-type': 'off',
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/no-misused-promises': 'off',
'@typescript-eslint/no-confusing-void-expression': 'off',
},
}
+6 -5
View File
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-confusing-void-expression */
import type {
AtLeastOne,
BigString,
@@ -112,7 +113,7 @@ export class DiscordenoShard {
close(code: number, reason: string): void {
if (this.socket?.readyState !== WebSocket.OPEN) return
return this.socket?.close(code, reason)
this.socket?.close(code, reason)
}
/** Connect the shard with the gateway and start heartbeating. This will not identify the shard to the gateway. */
@@ -601,7 +602,7 @@ export class DiscordenoShard {
options?: AtLeastOne<Omit<UpdateVoiceState, 'guildId' | 'channelId'>>,
): Promise<void> {
logger.debug(`[Shard] joinVoiceChannel guildId: ${guildId} channelId: ${channelId}`)
return await this.send({
await this.send({
op: GatewayOpcodes.VoiceStateUpdate,
d: {
guild_id: guildId.toString(),
@@ -620,7 +621,7 @@ export class DiscordenoShard {
*/
async editBotStatus(data: StatusUpdate): Promise<void> {
logger.debug(`[Shard] editBotStatus data: ${JSON.stringify(data)}`)
return await this.editShardStatus(data)
await this.editShardStatus(data)
}
/**
@@ -632,7 +633,7 @@ export class DiscordenoShard {
*/
async editShardStatus(data: StatusUpdate): Promise<void> {
logger.debug(`[Shard] editShardStatus shardId: ${this.id} -> data: ${JSON.stringify(data)}`)
return await this.send({
await this.send({
op: GatewayOpcodes.PresenceUpdate,
d: {
since: null,
@@ -731,7 +732,7 @@ export class DiscordenoShard {
*/
async leaveVoiceChannel(guildId: BigString): Promise<void> {
logger.debug(`[Shard] leaveVoiceChannel guildId: ${guildId} Shard ${this.id}`)
return await this.send({
await this.send({
op: GatewayOpcodes.VoiceStateUpdate,
d: {
guild_id: guildId.toString(),
+6 -5
View File
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-confusing-void-expression */
import type { AtLeastOne, BigString, Camelize, DiscordGetGatewayBot, DiscordMember, RequestGuildMembers } from '@discordeno/types'
import { Collection, delay, logger } from '@discordeno/utils'
import Shard from './Shard.js'
@@ -144,7 +145,7 @@ export function createGatewayManager(options: CreateGatewayManagerOptions): Gate
},
async tellWorkerToIdentify(workerId, shardId, bucketId) {
logger.debug(`[Gateway] tell worker to identify (${workerId}, ${shardId}, ${bucketId})`)
return await gateway.identify(shardId)
await gateway.identify(shardId)
},
async identify(shardId: number) {
let shard = this.shards.get(shardId)
@@ -164,7 +165,7 @@ export function createGatewayManager(options: CreateGatewayManagerOptions): Gate
},
events: options.events,
requestIdentify: async () => {
return await gateway.identify(shardId);
await gateway.identify(shardId);
},
shardIsReady: async () => {
logger.debug(`[Shard] Shard #${shardId} is ready`)
@@ -196,7 +197,7 @@ export function createGatewayManager(options: CreateGatewayManagerOptions): Gate
logger.debug(`[Gateway] kill shard (${shardId})`)
this.shards.delete(shardId)
return await shard.shutdown()
await shard.shutdown()
},
async requestIdentify(shardId: number) {
@@ -251,7 +252,7 @@ export function createGatewayManager(options: CreateGatewayManagerOptions): Gate
}
logger.debug(`[Gateway] editShardStatus shardId: ${shardId} -> data: ${JSON.stringify(data)}`)
return await shard.editShardStatus(data)
await shard.editShardStatus(data)
},
async requestMembers(guildId, options) {
@@ -273,7 +274,7 @@ export function createGatewayManager(options: CreateGatewayManagerOptions): Gate
}
logger.debug(`[Gateway] leaveVoiceChannel guildId: ${guildId} Shard ${shardId}`)
return await shard.leaveVoiceChannel(guildId)
await shard.leaveVoiceChannel(guildId)
},
}
+1
View File
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-confusing-void-expression */
/* eslint-disable @typescript-eslint/explicit-function-return-type */
import { bgBrightMagenta, black, bold, cyan, gray, italic, red, yellow } from './colors.js'
+1
View File
@@ -12,6 +12,7 @@ export async function delay(ms: number): Promise<void> {
// Typescript is not so good as we developers so we need this little utility function to help it out
// Taken from https://fettblog.eu/typescript-hasownproperty/
/** TS save way to check if a property exists in an object */
// eslint-disable-next-line @typescript-eslint/ban-types
export function hasProperty<T extends {}, Y extends PropertyKey = string>(obj: T, prop: Y): obj is T & Record<Y, unknown> {
// eslint-disable-next-line no-prototype-builtins
return obj.hasOwnProperty(prop)