chore: Migrate ESLint and prettier to Biome (#3634)

* Migrate eslint and prettier to biomejs

This does NOT include examples/bigbot as it has its own formatter

* Update to biome 1.8.0

* Readd dotenv dev dependency to rest

During a merge it got lost
This commit is contained in:
Fleny
2024-07-13 20:05:02 +02:00
committed by GitHub
parent 7b3bd76c82
commit 919474069d
132 changed files with 722 additions and 4993 deletions

View File

@@ -17,7 +17,7 @@
// Configure properties specific to VS Code.
"vscode": {
// Add the IDs of extensions you want installed when the container is created.
"extensions": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode"]
"extensions": ["biomejs.biome"]
}
},

View File

@@ -1,5 +0,0 @@
{
"root": true,
// This tells ESLint to load the config from the package `eslint-config-discordeno`
"extends": ["discordeno"]
}

View File

@@ -1,7 +0,0 @@
{
"trailingComma": "all",
"useTabs": false,
"singleQuote": true,
"semi": false,
"printWidth": 150
}

View File

@@ -1,3 +1,3 @@
{
"recommendations": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode"]
"recommendations": ["biomejs.biome"]
}

12
.vscode/settings.json vendored
View File

@@ -2,38 +2,36 @@
"editor.tabSize": 2,
"editor.formatOnSave": true,
"editor.formatOnPaste": true,
"editor.codeActionsOnSave": ["source.organizeImports", "source.fixAll.eslint"],
"eslint.validate": ["typescript", "javascript"],
"editor.codeActionsOnSave": ["source.organizeImports.biome", "source.fixAll.biome"],
"files.associations": {
"*.ts": "typescript",
"*.js": "javascript"
},
"typescript.tsdk": "node_modules\\typescript\\lib",
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.defaultFormatter": "biomejs.biome",
"editor.quickSuggestions": {
"strings": true
},
"editor.suggest.insertMode": "replace"
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.defaultFormatter": "biomejs.biome",
"editor.quickSuggestions": {
"strings": true
},
"editor.suggest.insertMode": "replace"
},
"[yaml]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.insertSpaces": true,
"editor.tabSize": 2,
"editor.autoIndent": "advanced",
"diffEditor.ignoreTrimWhitespace": false
},
"[javascript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
"editor.defaultFormatter": "biomejs.biome"
},
"[typescript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
"editor.defaultFormatter": "biomejs.biome"
}
}

View File

@@ -1,5 +1,4 @@
await import(`https://raw.githubusercontent.com/discordeno/discordeno/benchies/benchmarksResult/data.js`)
const commitSha = await Deno.readTextFile('./sha')
const results = JSON.parse(await Deno.readTextFile('./data.json'))
interface BenchmarksData {

61
biome.jsonc Normal file
View File

@@ -0,0 +1,61 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.0/schema.json",
"formatter": {
"enabled": true,
"formatWithErrors": false,
"indentStyle": "space",
"indentWidth": 2,
"lineEnding": "lf",
"lineWidth": 150
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": false,
"correctness": {
"noUnusedVariables": "error"
},
"style": {
"noNamespace": "error",
"noNonNullAssertion": "off",
"useConsistentArrayType": {
"level": "error",
"options": { "syntax": "shorthand" }
}
}
}
},
"javascript": {
"formatter": {
"trailingCommas": "all",
"semicolons": "asNeeded",
"quoteStyle": "single"
}
},
"json": {
"parser": {
"allowComments": true,
"allowTrailingCommas": true
}
},
"files": {
"ignore": [
"node_modules",
// Ignore turbo and docusaurus cache/stuff
".docusaurus",
".turbo",
// Remove the yarn script as it is minified
".yarn",
// Ignore build outputs
"bunTestsDist",
"build",
"coverage",
"denoTestsDist",
"dist"
],
"ignoreUnknown": true
}
}

View File

@@ -1,6 +1,6 @@
import fastifyMultipart from '@fastify/multipart'
import fastifyEnv from '@fastify/env'
import fastifyHelmet from '@fastify/helmet'
import fastifyMultipart from '@fastify/multipart'
import fastify, { type FastifyInstance } from 'fastify'
export const buildFastifyApp = async (): Promise<FastifyInstance> => {

View File

@@ -1,5 +1,5 @@
import { type RequestMethods, createRestManager } from '@discordeno/rest'
import type { MultipartFile, MultipartValue } from '@fastify/multipart'
import { createRestManager, type RequestMethods } from '@discordeno/rest'
import { buildFastifyApp } from './fastify.js'
const app = await buildFastifyApp()
@@ -13,7 +13,7 @@ const discordRestManager = createRestManager({
token: app.config.DISCORD_TOKEN,
})
app.get('/timecheck', async (request, reply) => {
app.get('/timecheck', async (_request, reply) => {
reply.status(200).send({
message: Date.now(),
})

View File

@@ -1,4 +1,4 @@
import { createBot, Intents, LogDepth, type logger as discordenoLogger } from '@discordeno/bot'
import { Intents, LogDepth, createBot, type logger as discordenoLogger } from '@discordeno/bot'
import { createProxyCache } from 'dd-cache-proxy'
import { configs } from './config.js'

View File

@@ -1,4 +1,4 @@
import { Collection, type ApplicationCommandOption, type ApplicationCommandTypes, type Interaction } from '@discordeno/bot'
import { type ApplicationCommandOption, type ApplicationCommandTypes, Collection, type Interaction } from '@discordeno/bot'
export const commands = new Collection<string, Command>()

View File

@@ -1,4 +1,4 @@
import { ApplicationCommandOptionTypes, ApplicationCommandTypes, createEmbeds, Permissions, type Member, type User } from '@discordeno/bot'
import { ApplicationCommandOptionTypes, ApplicationCommandTypes, type Member, Permissions, type User, createEmbeds } from '@discordeno/bot'
import { bot } from '../bot.js'
import { createCommand } from '../commands.js'
import { calculateMemberPermissions } from '../utils/permissions.js'

View File

@@ -1,5 +1,5 @@
import { logger } from '@discordeno/bot'
import { readdir } from 'node:fs/promises'
import { logger } from '@discordeno/bot'
export default async function importDirectory(folder: string): Promise<void> {
const files = await readdir(folder, { recursive: true })

View File

@@ -1,5 +1,5 @@
import { BitwisePermissionFlags, type Guild, type Member } from '@discordeno/bot'
import assert from 'node:assert'
import { BitwisePermissionFlags, type Guild, type Member } from '@discordeno/bot'
export async function calculateMemberPermissions(guild: Guild, member: Member): Promise<bigint> {
if (member.id === guild.ownerId) return 8n

View File

@@ -1,4 +1,4 @@
import { Collection, type ApplicationCommandOption, type ApplicationCommandTypes, type Interaction } from '@discordeno/bot'
import { type ApplicationCommandOption, type ApplicationCommandTypes, Collection, type Interaction } from '@discordeno/bot'
export const commands = new Collection<string, Command>()

View File

@@ -1,4 +1,4 @@
import { ApplicationCommandOptionTypes, hasProperty, type Guild } from '@discordeno/bot'
import { ApplicationCommandOptionTypes, type Guild, hasProperty } from '@discordeno/bot'
import chalk from 'chalk'
import { bot } from '../bot.js'
import { commands } from '../commands.js'

View File

@@ -1,14 +1,14 @@
import { hasProperty, type Bot, type CreateApplicationCommand, type Guild } from '@discordeno/bot'
import { type Bot, type CreateApplicationCommand, type Guild, hasProperty } from '@discordeno/bot'
import { bot } from '../bot.js'
import { commands, type SubCommand, type SubCommandGroup } from '../commands.js'
import { type SubCommand, type SubCommandGroup, commands } from '../commands.js'
import { createLogger } from './logger.js'
const logger = createLogger({ name: 'Helpers' })
/** This function will update all commands, or the defined scope */
export async function updateCommands(scope?: 'Guild' | 'Global'): Promise<void> {
const globalCommands: Array<MakeRequired<CreateApplicationCommand, 'name'>> = []
const perGuildCommands: Array<MakeRequired<CreateApplicationCommand, 'name'>> = []
const globalCommands: MakeRequired<CreateApplicationCommand, 'name'>[] = []
const perGuildCommands: MakeRequired<CreateApplicationCommand, 'name'>[] = []
for (const command of commands.values()) {
if (command.scope === 'Guild') {
@@ -44,7 +44,7 @@ export async function updateCommands(scope?: 'Guild' | 'Global'): Promise<void>
/** Update commands for a guild */
export async function updateGuildCommands(bot: Bot, guild: Guild): Promise<void> {
const perGuildCommands: Array<MakeRequired<CreateApplicationCommand, 'name'>> = []
const perGuildCommands: MakeRequired<CreateApplicationCommand, 'name'>[] = []
for (const command of commands.values()) {
if (command.scope === 'Guild') {

View File

@@ -1,4 +1,4 @@
import { Collection, LogDepth, createBot, type Bot, type logger } from '@discordeno/bot'
import { type Bot, Collection, LogDepth, createBot, type logger } from '@discordeno/bot'
import { DISCORD_TOKEN, GATEWAY_AUTHORIZATION, GATEWAY_INTENTS, GATEWAY_URL, REST_AUTHORIZATION, REST_URL } from '../config.js'
import type { ManagerGetShardInfoFromGuildId, ShardInfo, WorkerPresencesUpdate, WorkerShardPayload } from '../gateway/worker/types.js'
import type { Command } from './commands.js'

View File

@@ -1,4 +1,4 @@
import { InteractionTypes, LogLevels, commandOptionsParser, type Interaction, type logger } from '@discordeno/bot'
import { type Interaction, InteractionTypes, LogLevels, commandOptionsParser, type logger } from '@discordeno/bot'
import chalk from 'chalk'
import { bot } from '../../bot.js'
@@ -48,6 +48,5 @@ function logCommand(
const command = `Command${autocomplete}: ${chalk.bgYellow.black(commandName || 'Unknown')} - ${chalk.bgBlack(typeColor)}`
const user = chalk.bgGreen.black(`@${interaction.user.username} (${interaction.user.id})`)
const guild = chalk.bgMagenta.black(interaction.guildId ? `guildId: ${interaction.guildId}` : 'DM')
;(bot.logger as typeof logger).log(logLevel, `${command} - By ${user} in ${guild}`, ...restArgs)
}

View File

@@ -1,5 +1,5 @@
import { createEmbeds } from '@discordeno/bot'
import { inspect } from 'node:util'
import { createEmbeds } from '@discordeno/bot'
import { BUGS_ERRORS_REPORT_WEBHOOK } from '../../config.js'
import { bot } from '../bot.js'
import { webhookURLToIDAndToken } from '../utils/webhook.js'

View File

@@ -1,6 +1,6 @@
import { join as joinPath } from 'node:path'
import type { DiscordGatewayPayload, GatewayDispatchEventNames } from '@discordeno/bot'
import { connect as connectAmqp } from 'amqplib'
import { join as joinPath } from 'node:path'
import {
EVENT_HANDLER_HOST,
EVENT_HANDLER_PORT,

View File

@@ -1,5 +1,5 @@
import { createGatewayManager, createLogger, createRestManager, LogDepth } from '@discordeno/bot'
import type { Worker } from 'node:worker_threads'
import { LogDepth, createGatewayManager, createLogger, createRestManager } from '@discordeno/bot'
import { DISCORD_TOKEN, GATEWAY_INTENTS, REST_AUTHORIZATION, REST_URL, SHARDS_PER_WORKER, TOTAL_SHARDS, TOTAL_WORKERS } from '../config.js'
import { createWorker } from './worker/createWorker.js'
import type { WorkerMessage } from './worker/types.js'

View File

@@ -1,8 +1,8 @@
import { createLogger, DiscordenoShard, GatewayOpcodes, LogDepth } from '@discordeno/bot'
import { connect as connectAmqp, type Channel as amqpChannel } from 'amqplib'
import assert from 'node:assert'
import { createHash } from 'node:crypto'
import { workerData as _workerData, parentPort } from 'node:worker_threads'
import { DiscordenoShard, GatewayOpcodes, LogDepth, createLogger } from '@discordeno/bot'
import { type Channel as amqpChannel, connect as connectAmqp } from 'amqplib'
import { promiseWithResolvers } from '../../util.js'
import type { ManagerMessage, WorkerCreateData, WorkerMessage } from './types.js'

View File

@@ -1,4 +1,4 @@
import { createLogger, createRestManager, LogDepth } from '@discordeno/bot'
import { LogDepth, createLogger, createRestManager } from '@discordeno/bot'
import { DISCORD_TOKEN } from '../config.js'
import { setupRestAnalyticsHooks } from './influx.js'

View File

@@ -1,4 +1,4 @@
import { Collection, Intents, createBot, type Bot } from '@discordeno/bot'
import { type Bot, Collection, Intents, createBot } from '@discordeno/bot'
import { configs } from './config.js'
import type { Command } from './types/commands.js'

View File

@@ -1,12 +1,12 @@
import {
DiscordInteractionContextType,
MessageComponentTypes,
TextStyles,
type ActionRow,
type ButtonComponent,
DiscordInteractionContextType,
type Interaction,
MessageComponentTypes,
type Role,
type SelectMenuComponent,
TextStyles,
} from '@discordeno/bot'
import { ApplicationCommandOptionTypes, ButtonStyles } from '@discordeno/types'
import ItemCollector from '../collector.js'

View File

@@ -1,4 +1,4 @@
import { InteractionTypes, MessageComponentTypes, commandOptionsParser, type EventHandlers, type Interaction } from '@discordeno/bot'
import { type EventHandlers, type Interaction, InteractionTypes, MessageComponentTypes, commandOptionsParser } from '@discordeno/bot'
import type ItemCollector from '../collector.js'
import commands from '../commands/index.js'

View File

@@ -3,9 +3,7 @@
"version": "19.0.0-alpha.1",
"private": true,
"type": "module",
"workspaces": [
"packages/*"
],
"workspaces": ["packages/*"],
"scripts": {
"build": "turbo run build --no-daemon",
"build:watch": "echo \"Starting build in watch mode...\" && chokidar \"packages/**/*.ts\" --ignore \"packages/**/dist/**/*.d.ts\" -c \"yarn run build && yarn run build:type\"",
@@ -13,7 +11,7 @@
"build:type": "turbo run build:type --no-daemon",
"dev": "turbo run dev --parallel --no-daemon",
"fmt": "turbo run fmt --no-daemon",
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"format": "biome format --write",
"lint": "turbo run lint --no-daemon",
"prepare": "husky",
"release-build": "turbo run release-build --no-daemon",
@@ -28,12 +26,10 @@
"test:unit-coverage": "turbo run test:unit-coverage --no-daemon"
},
"devDependencies": {
"@biomejs/biome": "^1.8.0",
"chokidar-cli": "^3.0.0",
"eslint": "^8.57.0",
"eslint-config-discordeno": "*",
"husky": "^9.0.11",
"lint-staged": "^15.2.7",
"prettier": "^3.3.3",
"turbo": "^1.11.3",
"typedoc": "^0.26.4",
"typedoc-plugin-markdown": "^4.1.2",
@@ -43,9 +39,7 @@
"node": ">=18.0.0"
},
"lint-staged": {
"*.{js,jsx,ts,tsx,md,html,css}": "yarn run prettier --ignore-unknown --write",
"!(website)/**/*.{js,ts,tsx}": "yarn run eslint --fix --config ./packages/eslint-config-discordeno/index.js --resolve-plugins-relative-to .",
"website/**/*.{js,ts,tsx}": "yarn run eslint --fix --config ./website/.eslintrc.yml --resolve-plugins-relative-to ./website"
"*": "yarn biome check --no-errors-on-unmatched --write"
},
"packageManager": "yarn@4.0.2"
}

View File

@@ -16,8 +16,8 @@
"scripts": {
"build:type": "tsc --declaration --emitDeclarationOnly --declarationDir dist/types",
"release-build": "yarn build && yarn build:type",
"fmt": "eslint --fix \"src/**/*.ts*\"",
"lint": "eslint \"src/**/*.ts*\"",
"fmt": "biome format --write",
"lint": "biome lint --write",
"build": "swc src --strip-leading-paths --delete-dir-on-start --out-dir dist && node ../../scripts/fixBenchExtension.js",
"build-message": "swc src/generateMessage.ts --strip-leading-paths -C sourceMaps=false --out-dir ../../scripts && node ../../scripts/fixBenchExtension.js",
"bench": "node dist/index.js"
@@ -31,12 +31,11 @@
"benchmark": "^2.1.4"
},
"devDependencies": {
"@biomejs/biome": "^1.8.0",
"@swc/cli": "^0.4.0",
"@swc/core": "^1.4.2",
"@types/benchmark": "^2.1.5",
"@types/node": "^20.14.10",
"eslint": "^8.57.0",
"eslint-config-discordeno": "*",
"ts-node": "^10.9.2",
"tsconfig": "*",
"typescript": "^5.5.3"

View File

@@ -1,4 +1,4 @@
import { createBot, snakeToCamelCase, type Bot } from '@discordeno/bot'
import { type Bot, createBot, snakeToCamelCase } from '@discordeno/bot'
import { events as dbEvents } from '../utils/db.js'
import { memoryBenchmark } from '../utils/memoryBenchmark.js'

View File

@@ -1,6 +1,8 @@
import {
ApplicationFlags,
type Bot,
ButtonStyles,
type DiscordMessage,
InteractionTypes,
MemberToggles,
MessageActivityTypes,
@@ -13,8 +15,6 @@ import {
UserFlags,
createBot,
iconHashToBigInt,
type Bot,
type DiscordMessage,
} from '@discordeno/bot'
import { memoryBenchmark } from '../utils/memoryBenchmark.js'
@@ -390,7 +390,6 @@ function oldtransformMessage(bot: Bot, payload: DiscordMessage): any {
// UNTRANSFORMED STUFF HERE
content: payload.content ?? '',
isFromBot: payload.author.bot ?? false,
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
tag: `${payload.author.username}#${payload.author.discriminator}`,
timestamp: Date.parse(payload.timestamp),
editedTimestamp: payload.edited_timestamp ? Date.parse(payload.edited_timestamp) : undefined,
@@ -483,7 +482,7 @@ await memoryBenchmark(
(object, event: DiscordMessage) => object.cache.push(oldtransformMessage(bot, event)),
// function specify how to add event to the object/ run the object
[...new Array(MESSAGE_SIZE)].map(
(i) =>
() =>
({
activity: {
party_id: 'party_id',

View File

@@ -1,6 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
import type { DiscordGatewayPayload } from '@discordeno/types'
import fs from 'node:fs/promises'
import type { DiscordGatewayPayload } from '@discordeno/types'
export const events: Array<{
shardId: number

View File

@@ -14,7 +14,6 @@ export async function memoryBenchmark<O, E>(
const stages = ['start', 'loaded', 'end', 'cached'] as const
const typesOfMemUsages = ['rss', 'heapUsed', 'heapTotal'] as const
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
async function runTest(object: O) {
// Determine memory stats now before touching anything
const results: {

View File

@@ -18,8 +18,8 @@
"build": "swc src --strip-leading-paths --delete-dir-on-start src --out-dir dist/esm && swc --strip-leading-paths --delete-dir-on-start src --out-dir dist/cjs -C module.type=commonjs && node ../../scripts/fixCjsExtension.js",
"build:type": "tsc --declaration --emitDeclarationOnly --declarationDir dist/types",
"release-build": "yarn build && yarn build:type",
"fmt": "eslint --fix \"src/**/*.ts*\"",
"lint": "eslint \"src/**/*.ts*\"",
"fmt": "biome format --write",
"lint": "biome lint --write",
"test:unit-coverage": "c8 mocha --no-warnings 'tests/unit/**/*.spec.ts'",
"test:unit": "c8 --r lcov mocha --no-warnings 'tests/unit/**/*.spec.ts' && node ../../scripts/coveragePathFixing.js discordeno",
"test:deno-unit": "swc tests --strip-leading-paths --delete-dir-on-start --out-dir denoTestsDist && node ../../scripts/fixDenoTestExtension.js && deno test -A --import-map ../../denoImportMap.json denoTestsDist/unit",
@@ -35,6 +35,7 @@
"@discordeno/utils": "19.0.0-beta.1"
},
"devDependencies": {
"@biomejs/biome": "^1.8.0",
"@swc/cli": "^0.4.0",
"@swc/core": "^1.4.2",
"@types/chai": "^4.3.16",
@@ -43,8 +44,6 @@
"@types/sinon": "^17.0.3",
"c8": "^9.1.0",
"chai": "^5.1.1",
"eslint": "^8.57.0",
"eslint-config-discordeno": "*",
"mocha": "^10.5.1",
"sinon": "^18.0.0",
"ts-node": "^10.9.2",

View File

@@ -3,10 +3,10 @@ import { ShardSocketCloseCodes, createGatewayManager } from '@discordeno/gateway
import type { CreateRestManagerOptions, RestManager } from '@discordeno/rest'
import { createRestManager } from '@discordeno/rest'
import type { BigString, DiscordGatewayPayload, DiscordReady, GatewayIntents } from '@discordeno/types'
import { createLogger, getBotIdFromToken, type Collection, type logger } from '@discordeno/utils'
import { type Collection, createLogger, getBotIdFromToken, type logger } from '@discordeno/utils'
import { createBotGatewayHandlers } from './handlers.js'
import { createBotHelpers, type BotHelpers } from './helpers.js'
import { createTransformers, type Transformers } from './transformers.js'
import { type BotHelpers, createBotHelpers } from './helpers.js'
import { type Transformers, createTransformers } from './transformers.js'
import type { ApplicationCommandPermission } from './transformers/applicationCommandPermission.js'
import type { AuditLogEntry } from './transformers/auditLogEntry.js'
import type { AutoModerationActionExecution } from './transformers/automodActionExecution.js'

View File

@@ -1,6 +1,6 @@
import type { Bot, DiscordChannel, DiscordGatewayPayload } from '../../index.js'
export async function handleChannelCreate(bot: Bot, payload: DiscordGatewayPayload, shardId: number): Promise<void> {
export async function handleChannelCreate(bot: Bot, payload: DiscordGatewayPayload, _shardId: number): Promise<void> {
if (!bot.events.channelCreate) return
const data = payload.d as DiscordChannel

View File

@@ -1,7 +1,7 @@
import type { DiscordGatewayPayload, DiscordThreadMembersUpdate } from '@discordeno/types'
import type { Bot } from '../../index.js'
export async function handleThreadMembersUpdate(bot: Bot, data: DiscordGatewayPayload, shardId: number): Promise<void> {
export async function handleThreadMembersUpdate(bot: Bot, data: DiscordGatewayPayload, _shardId: number): Promise<void> {
if (!bot.events.threadMembersUpdate) return
const payload = data.d as DiscordThreadMembersUpdate

View File

@@ -1,7 +1,7 @@
import type { DiscordGatewayPayload, DiscordThreadMemberUpdate } from '@discordeno/types'
import type { Bot } from '../../index.js'
export async function handleThreadMemberUpdate(bot: Bot, data: DiscordGatewayPayload, shardId: number): Promise<void> {
export async function handleThreadMemberUpdate(bot: Bot, data: DiscordGatewayPayload, _shardId: number): Promise<void> {
if (!bot.events.threadMemberUpdate) return
const payload = data.d as DiscordThreadMemberUpdate

View File

@@ -1,6 +1,6 @@
import type { Bot, DiscordGatewayPayload, DiscordGuildStickersUpdate } from '../../index.js'
export async function handleGuildStickersUpdate(bot: Bot, data: DiscordGatewayPayload, shardId: number): Promise<void> {
export async function handleGuildStickersUpdate(bot: Bot, data: DiscordGatewayPayload, _shardId: number): Promise<void> {
if (!bot.events.guildStickersUpdate) return
const payload = data.d as DiscordGuildStickersUpdate

View File

@@ -2,7 +2,7 @@ import type { DiscordAutoModerationActionExecution, DiscordGatewayPayload } from
import type { Bot } from '../../../bot.js'
/** Requires the MANAGE_GUILD permission. */
export async function handleAutoModerationActionExecution(bot: Bot, data: DiscordGatewayPayload, shardId: number): Promise<void> {
export async function handleAutoModerationActionExecution(bot: Bot, data: DiscordGatewayPayload, _shardId: number): Promise<void> {
if (!bot.events.automodActionExecution) return
const payload = data.d as DiscordAutoModerationActionExecution

View File

@@ -2,7 +2,7 @@ import type { DiscordAutoModerationRule, DiscordGatewayPayload } from '@discorde
import type { Bot } from '../../../bot.js'
/** Requires the MANAGE_GUILD permission. */
export async function handleAutoModerationRuleCreate(bot: Bot, data: DiscordGatewayPayload, shardId: number): Promise<void> {
export async function handleAutoModerationRuleCreate(bot: Bot, data: DiscordGatewayPayload, _shardId: number): Promise<void> {
if (!bot.events.automodRuleCreate) return
const payload = data.d as DiscordAutoModerationRule

View File

@@ -2,7 +2,7 @@ import type { DiscordAutoModerationRule, DiscordGatewayPayload } from '@discorde
import type { Bot } from '../../../bot.js'
/** Requires the MANAGE_GUILD permission. */
export async function handleAutoModerationRuleDelete(bot: Bot, data: DiscordGatewayPayload, shardId: number): Promise<void> {
export async function handleAutoModerationRuleDelete(bot: Bot, data: DiscordGatewayPayload, _shardId: number): Promise<void> {
if (!bot.events.automodRuleDelete) return
const payload = data.d as DiscordAutoModerationRule

View File

@@ -2,7 +2,7 @@ import type { DiscordAutoModerationRule, DiscordGatewayPayload } from '@discorde
import type { Bot } from '../../../bot.js'
/** Requires the MANAGE_GUILD permission. */
export async function handleAutoModerationRuleUpdate(bot: Bot, data: DiscordGatewayPayload, shardId: number): Promise<void> {
export async function handleAutoModerationRuleUpdate(bot: Bot, data: DiscordGatewayPayload, _shardId: number): Promise<void> {
if (!bot.events.automodRuleUpdate) return
const payload = data.d as DiscordAutoModerationRule

View File

@@ -1,7 +1,7 @@
import type { DiscordGatewayPayload, DiscordScheduledEvent } from '@discordeno/types'
import type { Bot } from '../../../bot.js'
export async function handleGuildScheduledEventCreate(bot: Bot, data: DiscordGatewayPayload, shardId: number): Promise<void> {
export async function handleGuildScheduledEventCreate(bot: Bot, data: DiscordGatewayPayload, _shardId: number): Promise<void> {
if (!bot.events.scheduledEventCreate) return
const payload = data.d as DiscordScheduledEvent

View File

@@ -1,6 +1,6 @@
import type { Bot, DiscordGatewayPayload, DiscordGuildApplicationCommandPermissions } from '../../index.js'
export async function handleApplicationCommandPermissionsUpdate(bot: Bot, data: DiscordGatewayPayload, shardId: number): Promise<void> {
export async function handleApplicationCommandPermissionsUpdate(bot: Bot, data: DiscordGatewayPayload, _shardId: number): Promise<void> {
if (!bot.events.applicationCommandPermissionsUpdate) return
const payload = data.d as DiscordGuildApplicationCommandPermissions

View File

@@ -1,7 +1,7 @@
import type { DiscordGatewayPayload, DiscordWebhookUpdate } from '@discordeno/types'
import type { Bot } from '../../index.js'
export async function handleWebhooksUpdate(bot: Bot, data: DiscordGatewayPayload, shardId: number): Promise<void> {
export async function handleWebhooksUpdate(bot: Bot, data: DiscordGatewayPayload, _shardId: number): Promise<void> {
if (!bot.events.webhooksUpdate) return
const payload = data.d as DiscordWebhookUpdate

View File

@@ -69,8 +69,8 @@ import type {
GetInvite,
GetMessagesOptions,
GetReactions,
GetScheduledEvents,
GetScheduledEventUsers,
GetScheduledEvents,
GetUserGuilds,
GetWebhookMessageOptions,
InteractionCallbackData,

View File

@@ -14,7 +14,7 @@ export type Optionalize<T> = T extends object
? T extends unknown[]
? number extends T['length']
? T[number] extends object
? Array<OptionalizeAux<T[number]>>
? OptionalizeAux<T[number]>[]
: T
: Partial<T>
: OptionalizeAux<T>

View File

@@ -55,25 +55,26 @@ import type {
DiscordWelcomeScreen,
} from '@discordeno/types'
import { logger } from '@discordeno/utils'
import { bigintToSnowflake, snowflakeToBigint, type Bot } from './index.js'
import { transformActivity, type Activity } from './transformers/activity.js'
import { transformApplication, type Application } from './transformers/application.js'
import { transformApplicationCommand, type ApplicationCommand } from './transformers/applicationCommand.js'
import { transformApplicationCommandOption, type ApplicationCommandOption } from './transformers/applicationCommandOption.js'
import { transformApplicationCommandOptionChoice, type ApplicationCommandOptionChoice } from './transformers/applicationCommandOptionChoice.js'
import { transformApplicationCommandPermission, type ApplicationCommandPermission } from './transformers/applicationCommandPermission.js'
import { transformAttachment, type Attachment } from './transformers/attachment.js'
import { transformAuditLogEntry, type AuditLogEntry } from './transformers/auditLogEntry.js'
import { transformAutoModerationActionExecution, type AutoModerationActionExecution } from './transformers/automodActionExecution.js'
import { transformAutoModerationRule, type AutoModerationRule } from './transformers/automodRule.js'
import { transformChannel, transformForumTag, type Channel, type ForumTag } from './transformers/channel.js'
import { transformComponent, type Component } from './transformers/component.js'
import { transformEmbed, type Embed } from './transformers/embed.js'
import { transformDefaultReactionEmoji, transformEmoji, type DefaultReactionEmoji, type Emoji } from './transformers/emoji.js'
import { transformEntitlement, type Entitlement } from './transformers/entitlement.js'
import { transformGatewayBot, type GetGatewayBot } from './transformers/gatewayBot.js'
import { transformGuild, type Guild } from './transformers/guild.js'
import { type Bot, bigintToSnowflake, snowflakeToBigint } from './index.js'
import { type Activity, transformActivity } from './transformers/activity.js'
import { type Application, transformApplication } from './transformers/application.js'
import { type ApplicationCommand, transformApplicationCommand } from './transformers/applicationCommand.js'
import { type ApplicationCommandOption, transformApplicationCommandOption } from './transformers/applicationCommandOption.js'
import { type ApplicationCommandOptionChoice, transformApplicationCommandOptionChoice } from './transformers/applicationCommandOptionChoice.js'
import { type ApplicationCommandPermission, transformApplicationCommandPermission } from './transformers/applicationCommandPermission.js'
import { type Attachment, transformAttachment } from './transformers/attachment.js'
import { type AuditLogEntry, transformAuditLogEntry } from './transformers/auditLogEntry.js'
import { type AutoModerationActionExecution, transformAutoModerationActionExecution } from './transformers/automodActionExecution.js'
import { type AutoModerationRule, transformAutoModerationRule } from './transformers/automodRule.js'
import { type Channel, type ForumTag, transformChannel, transformForumTag } from './transformers/channel.js'
import { type Component, transformComponent } from './transformers/component.js'
import { type Embed, transformEmbed } from './transformers/embed.js'
import { type DefaultReactionEmoji, type Emoji, transformDefaultReactionEmoji, transformEmoji } from './transformers/emoji.js'
import { type Entitlement, transformEntitlement } from './transformers/entitlement.js'
import { type GetGatewayBot, transformGatewayBot } from './transformers/gatewayBot.js'
import { type Guild, transformGuild } from './transformers/guild.js'
import {
type AvatarDecorationData,
transformActivityToDiscordActivity,
transformApplicationCommandOptionChoiceToDiscordApplicationCommandOptionChoice,
transformApplicationCommandOptionToDiscordApplicationCommandOption,
@@ -86,47 +87,46 @@ import {
transformMemberToDiscordMember,
transformTeamToDiscordTeam,
transformUserToDiscordUser,
type AvatarDecorationData,
} from './transformers/index.js'
import { transformIntegration, type Integration } from './transformers/integration.js'
import { transformInteraction, transformInteractionDataOption, type Interaction, type InteractionDataOption } from './transformers/interaction.js'
import { transformInvite, type Invite } from './transformers/invite.js'
import { transformMember, type Member } from './transformers/member.js'
import { type Integration, transformIntegration } from './transformers/integration.js'
import { type Interaction, type InteractionDataOption, transformInteraction, transformInteractionDataOption } from './transformers/interaction.js'
import { type Invite, transformInvite } from './transformers/invite.js'
import { type Member, transformMember } from './transformers/member.js'
import {
transformMessage,
transformMessageCall,
transformMessageInteractionMetadata,
type Message,
type MessageCall,
type MessageInteractionMetadata,
transformMessage,
transformMessageCall,
transformMessageInteractionMetadata,
} from './transformers/message.js'
import { transformGuildOnboarding, type GuildOnboarding } from './transformers/onboarding.js'
import { transformPoll, transformPollMedia, type Poll, type PollMedia } from './transformers/poll.js'
import { transformPresence, type PresenceUpdate } from './transformers/presence.js'
import { type GuildOnboarding, transformGuildOnboarding } from './transformers/onboarding.js'
import { type Poll, type PollMedia, transformPoll, transformPollMedia } from './transformers/poll.js'
import { type PresenceUpdate, transformPresence } from './transformers/presence.js'
import { transformAllowedMentionsToDiscordAllowedMentions } from './transformers/reverse/allowedMentions.js'
import { transformCreateApplicationCommandToDiscordCreateApplicationCommand } from './transformers/reverse/createApplicationCommand.js'
import { transformInteractionResponseToDiscordInteractionResponse } from './transformers/reverse/interactionResponse.js'
import { transformRole, type Role } from './transformers/role.js'
import { transformScheduledEvent, type ScheduledEvent } from './transformers/scheduledEvent.js'
import { transformSku, type Sku } from './transformers/sku.js'
import { transformStageInstance, type StageInstance } from './transformers/stageInstance.js'
import { transformInviteStageInstance, type InviteStageInstance } from './transformers/stageInviteInstance.js'
import { transformSticker, transformStickerPack, type Sticker, type StickerPack } from './transformers/sticker.js'
import { transformTeam, type Team } from './transformers/team.js'
import { transformTemplate, type Template } from './transformers/template.js'
import { type Role, transformRole } from './transformers/role.js'
import { type ScheduledEvent, transformScheduledEvent } from './transformers/scheduledEvent.js'
import { type Sku, transformSku } from './transformers/sku.js'
import { type StageInstance, transformStageInstance } from './transformers/stageInstance.js'
import { type InviteStageInstance, transformInviteStageInstance } from './transformers/stageInviteInstance.js'
import { type Sticker, type StickerPack, transformSticker, transformStickerPack } from './transformers/sticker.js'
import { type Team, transformTeam } from './transformers/team.js'
import { type Template, transformTemplate } from './transformers/template.js'
import {
transformThreadMember,
transformThreadMemberGuildCreate,
type ThreadMember,
type ThreadMemberGuildCreate,
transformThreadMember,
transformThreadMemberGuildCreate,
} from './transformers/threadMember.js'
import { transformUser, type User } from './transformers/user.js'
import { transformVoiceRegion, type VoiceRegion } from './transformers/voiceRegion.js'
import { transformVoiceState, type VoiceState } from './transformers/voiceState.js'
import { transformWebhook, type Webhook } from './transformers/webhook.js'
import { transformWelcomeScreen, type WelcomeScreen } from './transformers/welcomeScreen.js'
import { transformWidget, type GuildWidget } from './transformers/widget.js'
import { transformWidgetSettings, type GuildWidgetSettings } from './transformers/widgetSettings.js'
import { type User, transformUser } from './transformers/user.js'
import { type VoiceRegion, transformVoiceRegion } from './transformers/voiceRegion.js'
import { type VoiceState, transformVoiceState } from './transformers/voiceState.js'
import { type Webhook, transformWebhook } from './transformers/webhook.js'
import { type WelcomeScreen, transformWelcomeScreen } from './transformers/welcomeScreen.js'
import { type GuildWidget, transformWidget } from './transformers/widget.js'
import { type GuildWidgetSettings, transformWidgetSettings } from './transformers/widgetSettings.js'
import type { BotInteractionResponse, DiscordComponent, DiscordInteractionResponse, DiscordThreadMemberGuildCreate } from './typings.js'
export interface Transformers {
@@ -689,154 +689,154 @@ export function createTransformers(options: Partial<Transformers>, opts?: Create
return {
customizers: {
channel(bot, payload, channel) {
channel(_bot, _payload, channel) {
return channel
},
forumTag(bot, payload, forumTag) {
forumTag(_bot, _payload, forumTag) {
return forumTag
},
interaction(bot, payload, interaction) {
interaction(_bot, _payload, interaction) {
return interaction
},
member(bot, payload, member) {
member(_bot, _payload, member) {
return member
},
message(bot, payload, message) {
message(_bot, _payload, message) {
return message
},
messageInteractionMetadata(bot, payload, metadata) {
messageInteractionMetadata(_bot, _payload, metadata) {
return metadata
},
messageCall(bot, payload, call) {
messageCall(_bot, _payload, call) {
return call
},
role(bot, payload, role) {
role(_bot, _payload, role) {
return role
},
user(bot, payload, user) {
user(_bot, _payload, user) {
return user
},
activity(bot, payload, activity) {
activity(_bot, _payload, activity) {
return activity
},
application(bot, payload, application) {
application(_bot, _payload, application) {
return application
},
applicationCommand(bot, payload, applicationCommand) {
applicationCommand(_bot, _payload, applicationCommand) {
return applicationCommand
},
applicationCommandOption(bot, payload, applicationCommandOption) {
applicationCommandOption(_bot, _payload, applicationCommandOption) {
return applicationCommandOption
},
applicationCommandOptionChoice(bot, payload, applicationCommandOptionChoice) {
applicationCommandOptionChoice(_bot, _payload, applicationCommandOptionChoice) {
return applicationCommandOptionChoice
},
applicationCommandPermission(bot, payload, applicationCommandPermission) {
applicationCommandPermission(_bot, _payload, applicationCommandPermission) {
return applicationCommandPermission
},
attachment(bot, payload, attachment) {
attachment(_bot, _payload, attachment) {
return attachment
},
auditLogEntry(bot, payload, auditLogEntry) {
auditLogEntry(_bot, _payload, auditLogEntry) {
return auditLogEntry
},
automodActionExecution(bot, payload, automodActionExecution) {
automodActionExecution(_bot, _payload, automodActionExecution) {
return automodActionExecution
},
automodRule(bot, payload, automodRule) {
automodRule(_bot, _payload, automodRule) {
return automodRule
},
component(bot, payload, component) {
component(_bot, _payload, component) {
return component
},
embed(bot, payload, embed) {
embed(_bot, _payload, embed) {
return embed
},
emoji(bot, payload, emoji) {
emoji(_bot, _payload, emoji) {
return emoji
},
defaultReactionEmoji(bot, payload, defaultReactionEmoji) {
defaultReactionEmoji(_bot, _payload, defaultReactionEmoji) {
return defaultReactionEmoji
},
guild(bot, payload, guild) {
guild(_bot, _payload, guild) {
return guild
},
integration(bot, payload, integration) {
integration(_bot, _payload, integration) {
return integration
},
interactionDataOptions(bot, payload, interactionDataOptions) {
interactionDataOptions(_bot, _payload, interactionDataOptions) {
return interactionDataOptions
},
invite(bot, payload, invite) {
invite(_bot, _payload, invite) {
return invite
},
presence(bot, payload, presence) {
presence(_bot, _payload, presence) {
return presence
},
scheduledEvent(bot, payload, scheduledEvent) {
scheduledEvent(_bot, _payload, scheduledEvent) {
return scheduledEvent
},
stageInstance(bot, payload, stageInstance) {
stageInstance(_bot, _payload, stageInstance) {
return stageInstance
},
inviteStageInstance(bot, payload, inviteStageInstance) {
inviteStageInstance(_bot, _payload, inviteStageInstance) {
return inviteStageInstance
},
sticker(bot, payload, sticker) {
sticker(_bot, _payload, sticker) {
return sticker
},
stickerPack(bot, payload, stickerPack) {
stickerPack(_bot, _payload, stickerPack) {
return stickerPack
},
team(bot, payload, team) {
team(_bot, _payload, team) {
return team
},
template(bot, payload, template) {
template(_bot, _payload, template) {
return template
},
threadMember(bot, payload, threadMember) {
threadMember(_bot, _payload, threadMember) {
return threadMember
},
threadMemberGuildCreate(bot, payload, threadMemberGuildCreate) {
threadMemberGuildCreate(_bot, _payload, threadMemberGuildCreate) {
return threadMemberGuildCreate
},
voiceRegion(bot, payload, voiceRegion) {
voiceRegion(_bot, _payload, voiceRegion) {
return voiceRegion
},
voiceState(bot, payload, voiceState) {
voiceState(_bot, _payload, voiceState) {
return voiceState
},
gatewayBot(bot, payload, getGatewayBot) {
gatewayBot(_bot, _payload, getGatewayBot) {
return getGatewayBot
},
webhook(bot, payload, webhook) {
webhook(_bot, _payload, webhook) {
return webhook
},
welcomeScreen(bot, payload, welcomeScreen) {
welcomeScreen(_bot, _payload, welcomeScreen) {
return welcomeScreen
},
widget(bot, payload, widget) {
widget(_bot, _payload, widget) {
return widget
},
widgetSettings(bot, payload, widgetSettings) {
widgetSettings(_bot, _payload, widgetSettings) {
return widgetSettings
},
guildOnboarding(bot, payload, onboarding) {
guildOnboarding(_bot, _payload, onboarding) {
return onboarding
},
entitlement(bot, payload, entitlement) {
entitlement(_bot, _payload, entitlement) {
return entitlement
},
sku(bot, payload, sku) {
sku(_bot, _payload, sku) {
return sku
},
poll(bot, payload, poll) {
poll(_bot, _payload, poll) {
return poll
},
pollMedia(bot, payload, pollMedia) {
pollMedia(_bot, _payload, pollMedia) {
return pollMedia
},
avatarDecorationData(bot, payload, avatarDecorationData) {
avatarDecorationData(_bot, _payload, avatarDecorationData) {
return avatarDecorationData
},
},

View File

@@ -1,14 +1,14 @@
import {
DiscordApplicationIntegrationType,
iconHashToBigInt,
type ApplicationFlags,
type Bot,
type DiscordApplication,
DiscordApplicationIntegrationType,
type DiscordUser,
type Guild,
type OAuth2Scope,
type Team,
type User,
iconHashToBigInt,
} from '../index.js'
export function transformApplication(bot: Bot, payload: { application: DiscordApplication; shardId: number }): Application {

View File

@@ -1,5 +1,5 @@
import type { AuditLogEvents, DiscordAuditLogEntry, OverwriteTypes } from '@discordeno/types'
import { iconHashToBigInt, type Bot } from '../index.js'
import { type Bot, iconHashToBigInt } from '../index.js'
export function transformAuditLogEntry(bot: Bot, payload: DiscordAuditLogEntry): AuditLogEntry {
const auditLogEntry = {

View File

@@ -1,4 +1,4 @@
import { iconHashToBigInt, type Bot, type DiscordAvatarDecorationData } from '../index.js'
import { type Bot, type DiscordAvatarDecorationData, iconHashToBigInt } from '../index.js'
export function transformAvatarDecorationData(bot: Bot, payload: DiscordAvatarDecorationData): AvatarDecorationData {
const data = {} as AvatarDecorationData

View File

@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
import type {
BigString,
ChannelTypes,
@@ -9,7 +8,7 @@ import type {
SortOrderTypes,
VideoQualityModes,
} from '@discordeno/types'
import { calculatePermissions, iconHashToBigInt, type Bot, type DefaultReactionEmoji, type ThreadMember, type User } from '../index.js'
import { type Bot, type DefaultReactionEmoji, type ThreadMember, type User, calculatePermissions, iconHashToBigInt } from '../index.js'
import { Permissions } from './toggles/Permissions.js'
import { ChannelToggles } from './toggles/channel.js'

View File

@@ -1,5 +1,5 @@
import type { DiscordIntegrationCreateUpdate, IntegrationExpireBehaviors, OAuth2Scope } from '@discordeno/types'
import { iconHashToBigInt, type Bot, type User } from '../index.js'
import { type Bot, type User, iconHashToBigInt } from '../index.js'
export function transformIntegration(bot: Bot, payload: DiscordIntegrationCreateUpdate): Integration {
const integration = {

View File

@@ -1,7 +1,4 @@
import {
InteractionResponseTypes,
InteractionTypes,
MessageFlags,
type ApplicationCommandOptionTypes,
type ApplicationCommandTypes,
type BigString,
@@ -9,14 +6,17 @@ import {
type DiscordInteraction,
type DiscordInteractionDataOption,
type InteractionCallbackData,
InteractionResponseTypes,
InteractionTypes,
type MessageComponentTypes,
MessageFlags,
} from '@discordeno/types'
import { Collection } from '@discordeno/utils'
import {
DiscordApplicationIntegrationType,
type Bot,
type Channel,
type Component,
DiscordApplicationIntegrationType,
type DiscordChannel,
type DiscordInteractionContextType,
type Guild,
@@ -286,7 +286,7 @@ export function transformInteractionDataResolved(bot: Bot, resolved: DiscordInte
if (resolved.messages) {
transformed.messages = new Collection(
Object.entries(resolved.messages).map(([id, value]) => {
Object.entries(resolved.messages).map(([_id, value]) => {
const message: Message = bot.transformers.message(bot, value)
return [message.id, message]
}),
@@ -295,7 +295,7 @@ export function transformInteractionDataResolved(bot: Bot, resolved: DiscordInte
if (resolved.users) {
transformed.users = new Collection(
Object.entries(resolved.users).map(([id, value]) => {
Object.entries(resolved.users).map(([_id, value]) => {
const user = bot.transformers.user(bot, value)
return [user.id, user]
}),
@@ -313,7 +313,7 @@ export function transformInteractionDataResolved(bot: Bot, resolved: DiscordInte
if (guildId && resolved.roles) {
transformed.roles = new Collection(
Object.entries(resolved.roles).map(([id, value]) => {
Object.entries(resolved.roles).map(([_id, value]) => {
const role = bot.transformers.role(bot, { role: value, guildId })
return [role.id, role]
}),

View File

@@ -1,5 +1,5 @@
import type { DiscordApplication, DiscordInviteCreate, DiscordInviteMetadata, DiscordInviteType } from '@discordeno/types'
import { isInviteWithMetadata, type Application, type Bot, type ScheduledEvent, type User } from '../index.js'
import { type Application, type Bot, type ScheduledEvent, type User, isInviteWithMetadata } from '../index.js'
import type { InviteStageInstance } from './stageInviteInstance.js'
export function transformInvite(bot: Bot, payload: { invite: DiscordInviteCreate | DiscordInviteMetadata; shardId: number }): Invite {

View File

@@ -1,16 +1,16 @@
import {
DiscordApplicationIntegrationType,
MessageFlags,
type DiscordMessage,
type DiscordMessageCall,
type DiscordMessageInteractionMetadata,
type InteractionTypes,
type MessageActivityTypes,
MessageFlags,
type MessageTypes,
type StickerFormatTypes,
} from '@discordeno/types'
import { CHANNEL_MENTION_REGEX } from '../constants.js'
import { snowflakeToTimestamp, type Bot, type Poll } from '../index.js'
import { type Bot, type Poll, snowflakeToTimestamp } from '../index.js'
import type { Attachment } from './attachment.js'
import type { Channel } from './channel.js'
import type { Component } from './component.js'

View File

@@ -1,4 +1,4 @@
import { PresenceStatus, type DiscordPresenceUpdate } from '@discordeno/types'
import { type DiscordPresenceUpdate, PresenceStatus } from '@discordeno/types'
import type { Activity, Bot, User } from '../index.js'
export function transformPresence(bot: Bot, payload: DiscordPresenceUpdate): PresenceUpdate {

View File

@@ -1,7 +1,7 @@
import type { Bot, DiscordActivity } from '../../index.js'
import type { Activity } from '../activity.js'
export function transformActivityToDiscordActivity(bot: Bot, payload: Activity): DiscordActivity {
export function transformActivityToDiscordActivity(_bot: Bot, payload: Activity): DiscordActivity {
return {
name: payload.name,
type: payload.type,

View File

@@ -1,6 +1,6 @@
import type { AllowedMentions, Bot, DiscordAllowedMentions } from '../../index.js'
export function transformAllowedMentionsToDiscordAllowedMentions(bot: Bot, mentions: AllowedMentions): DiscordAllowedMentions {
export function transformAllowedMentionsToDiscordAllowedMentions(_bot: Bot, mentions: AllowedMentions): DiscordAllowedMentions {
return {
parse: mentions.parse,
replied_user: mentions.repliedUser,

View File

@@ -1,4 +1,4 @@
import { iconBigintToHash, type Bot, type DiscordApplication } from '../../index.js'
import { type Bot, type DiscordApplication, iconBigintToHash } from '../../index.js'
import type { Application } from '../application.js'
export function transformApplicationToDiscordApplication(bot: Bot, payload: Application): DiscordApplication {

View File

@@ -2,7 +2,7 @@ import type { Bot, Camelize, DiscordApplicationCommandOptionChoice } from '../..
import type { ApplicationCommandOptionChoice } from '../applicationCommandOptionChoice.js'
export function transformApplicationCommandOptionChoiceToDiscordApplicationCommandOptionChoice(
bot: Bot,
_bot: Bot,
payload: ApplicationCommandOptionChoice | Camelize<DiscordApplicationCommandOptionChoice>,
): DiscordApplicationCommandOptionChoice {
return {

View File

@@ -1,5 +1,5 @@
import type { DiscordAuditLogEntry } from '@discordeno/types'
import { iconBigintToHash, type Bot } from '../../index.js'
import { type Bot, iconBigintToHash } from '../../index.js'
import type { AuditLogEntry } from '../auditLogEntry.js'
export function transformAuditLogEntryToDiscordAuditLogEntry(bot: Bot, payload: AuditLogEntry): DiscordAuditLogEntry {

View File

@@ -2,7 +2,7 @@ import type { DiscordEmbed } from '@discordeno/types'
import type { Bot } from '../../index.js'
import type { Embed } from '../embed.js'
export function transformEmbedToDiscordEmbed(bot: Bot, payload: Embed): DiscordEmbed {
export function transformEmbedToDiscordEmbed(_bot: Bot, payload: Embed): DiscordEmbed {
return {
title: payload.title,
type: payload.type,

View File

@@ -4,7 +4,7 @@ import type { Bot } from '../../bot.js'
import type { Member } from '../member.js'
import type { User } from '../user.js'
export function transformUserToDiscordUser(bot: Bot, payload: User): DiscordUser {
export function transformUserToDiscordUser(_bot: Bot, payload: User): DiscordUser {
return {
id: payload.id.toString(),
username: payload.username,

View File

@@ -1,4 +1,4 @@
import { PresenceStatus, type DiscordPresenceUpdate } from '@discordeno/types'
import { type DiscordPresenceUpdate, PresenceStatus } from '@discordeno/types'
import type { Bot } from '../../index.js'
import type { PresenceUpdate } from '../presence.js'

View File

@@ -1,5 +1,5 @@
import type { DiscordTeam } from '@discordeno/types'
import { iconBigintToHash, type Bot } from '../../index.js'
import { type Bot, iconBigintToHash } from '../../index.js'
import type { Team } from '../team.js'
export function transformTeamToDiscordTeam(bot: Bot, payload: Team): DiscordTeam {

View File

@@ -2,7 +2,7 @@ import type { DiscordGuildWidgetSettings } from '@discordeno/types'
import type { Bot } from '../../index.js'
import type { GuildWidgetSettings } from '../widgetSettings.js'
export function transformWidgetSettingsToDiscordWidgetSettings(bot: Bot, payload: GuildWidgetSettings): DiscordGuildWidgetSettings {
export function transformWidgetSettingsToDiscordWidgetSettings(_bot: Bot, payload: GuildWidgetSettings): DiscordGuildWidgetSettings {
return {
enabled: payload.enabled,
channel_id: payload.channelId ?? null,

View File

@@ -1,5 +1,5 @@
import type { BigString, DiscordRole, RoleFlags } from '@discordeno/types'
import { iconHashToBigInt, type Bot } from '../index.js'
import { type Bot, iconHashToBigInt } from '../index.js'
import { Permissions } from './toggles/Permissions.js'
import { RoleToggles } from './toggles/role.js'

View File

@@ -5,7 +5,7 @@ import type {
ScheduledEventPrivacyLevel,
ScheduledEventStatus,
} from '@discordeno/types'
import { iconHashToBigInt, type Bot, type User } from '../index.js'
import { type Bot, type User, iconHashToBigInt } from '../index.js'
export function transformScheduledEvent(bot: Bot, payload: DiscordScheduledEvent): ScheduledEvent {
const props = bot.transformers.desiredProperties.scheduledEvent

View File

@@ -24,7 +24,7 @@ export function transformInviteStageInstance(bot: Bot, payload: DiscordInviteSta
export interface InviteStageInstance {
/** The members speaking in the Stage */
members: Array<Partial<Member>>
members: Partial<Member>[]
/** The number of users in the Stage */
participantCount: number
/** The number of users speaking in the Stage */

View File

@@ -1,5 +1,5 @@
import type { DiscordTeam, DiscordTeamMemberRole, TeamMembershipStates } from '@discordeno/types'
import { iconHashToBigInt, type Bot, type User } from '../index.js'
import { type Bot, type User, iconHashToBigInt } from '../index.js'
export function transformTeam(bot: Bot, payload: DiscordTeam): Team {
const id = bot.transformers.snowflake(payload.id)

View File

@@ -1,4 +1,4 @@
import { type PermissionStrings, BitwisePermissionFlags } from '@discordeno/types'
import { BitwisePermissionFlags, type PermissionStrings } from '@discordeno/types'
import { ToggleBitfieldBigint } from './ToggleBitfield.js'
export class Permissions extends ToggleBitfieldBigint {

View File

@@ -1,4 +1,4 @@
import { GuildFeatures, type DiscordGuild } from '@discordeno/types'
import { type DiscordGuild, GuildFeatures } from '@discordeno/types'
import { ToggleBitfieldBigint } from './ToggleBitfield.js'
const featureNames = [

View File

@@ -1,10 +1,9 @@
import type { DiscordUser, PremiumTypes } from '@discordeno/types'
import { iconHashToBigInt } from '@discordeno/utils'
import { ToggleBitfield, UserToggles, type AvatarDecorationData, type Bot } from '../index.js'
import { type AvatarDecorationData, type Bot, ToggleBitfield, UserToggles } from '../index.js'
const baseUser: Partial<User> & BaseUser = {
get tag() {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
return `${this.username}#${this.discriminator}`
},
get bot() {

View File

@@ -1,5 +1,5 @@
import type { DiscordWebhook, WebhookTypes } from '@discordeno/types'
import { iconHashToBigInt, type Bot, type Channel, type Guild, type User } from '../index.js'
import { type Bot, type Channel, type Guild, type User, iconHashToBigInt } from '../index.js'
export function transformWebhook(bot: Bot, payload: DiscordWebhook): Webhook {
const props = bot.transformers.desiredProperties.webhook

View File

@@ -1,5 +1,5 @@
import type { DiscordGuildWidget } from '@discordeno/types'
import { iconHashToBigInt, type Bot } from '../index.js'
import { type Bot, iconHashToBigInt } from '../index.js'
export function transformWidget(bot: Bot, payload: DiscordGuildWidget): GuildWidget {
const widget = {

View File

@@ -1,6 +1,6 @@
import {
ApplicationCommandTypes,
type AllowedMentions,
ApplicationCommandTypes,
type ButtonStyles,
type ChannelTypes,
type CreateApplicationCommand,

View File

@@ -19,8 +19,8 @@
"build": "swc src --strip-leading-paths --delete-dir-on-start src --out-dir dist/esm && swc --strip-leading-paths --delete-dir-on-start src --out-dir dist/cjs -C module.type=commonjs && node ../../scripts/fixCjsExtension.js",
"build:type": "tsc --declaration --emitDeclarationOnly --declarationDir dist/types",
"release-build": "yarn build && yarn build:type",
"fmt": "eslint --fix \"src/**/*.ts*\"",
"lint": "eslint \"src/**/*.ts*\"",
"fmt": "biome format --write",
"lint": "biome lint --write",
"test:unit-coverage": "c8 mocha --no-warnings 'tests/**/*.spec.ts'",
"test:unit": "c8 --r lcov mocha --no-warnings 'tests/**/*.spec.ts' && node ../../scripts/coveragePathFixing.js discordeno",
"test:deno-unit": "swc --strip-leading-paths tests --delete-dir-on-start --out-dir denoTestsDist && node ../../scripts/fixDenoTestExtension.js && deno test -A --import-map ../../denoImportMap.json denoTestsDist",
@@ -37,6 +37,7 @@
"commander": "^12.1.0"
},
"devDependencies": {
"@biomejs/biome": "^1.8.0",
"@swc/cli": "^0.4.0",
"@swc/core": "^1.4.2",
"@types/chai": "^4.3.16",
@@ -45,8 +46,6 @@
"@types/sinon": "^17.0.3",
"c8": "^9.1.0",
"chai": "^5.1.1",
"eslint": "^8.57.0",
"eslint-config-discordeno": "*",
"mocha": "^10.5.1",
"sinon": "^18.0.0",
"ts-node": "^10.9.2",

View File

@@ -1,31 +0,0 @@
module.exports = {
env: {
es2022: true,
node: true,
},
extends: ['standard-with-typescript', 'plugin:prettier/recommended', 'plugin:require-extensions/recommended'],
overrides: [
{
files: ['*.spec.ts'],
rules: {
'@typescript-eslint/no-unused-expressions': 'off',
},
},
],
plugins: ['require-extensions'],
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: ['./tsconfig.json'],
},
rules: {
'@typescript-eslint/strict-boolean-expressions': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/consistent-type-assertions': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@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',
},
}

View File

@@ -1,23 +0,0 @@
{
"name": "eslint-config-discordeno",
"version": "0.0.0",
"main": "index.js",
"license": "MIT",
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^7.1.1",
"@typescript-eslint/parser": "^7.16.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "9.1.0",
"eslint-config-standard-with-typescript": "^43.0.1",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-n": "^17.9.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-require-extensions": "^0.1.3",
"prettier": "^3.3.3",
"typescript": "^5.5.3"
},
"publishConfig": {
"access": "public"
}
}

View File

@@ -18,8 +18,8 @@
"build": "swc src --strip-leading-paths --delete-dir-on-start src --out-dir dist/esm && swc --strip-leading-paths --delete-dir-on-start src --out-dir dist/cjs -C module.type=commonjs && node ../../scripts/fixCjsExtension.js",
"build:type": "tsc --declaration --emitDeclarationOnly --declarationDir dist/types",
"release-build": "yarn build && yarn build:type",
"fmt": "eslint --fix \"src/**/*.ts*\"",
"lint": "eslint \"src/**/*.ts*\"",
"fmt": "biome format --write",
"lint": "biome lint --write",
"test:unit-coverage": "c8 mocha --no-warnings 'tests/unit/**/*.spec.ts'",
"test:unit": "c8 --r lcov mocha --no-warnings 'tests/unit/**/*.spec.ts' && node ../../scripts/coveragePathFixing.js gateway",
"test:deno-unit": "swc --strip-leading-paths tests --delete-dir-on-start --out-dir denoTestsDist && node ../../scripts/fixDenoTestExtension.js && deno test -A --import-map ../../denoImportMap.json denoTestsDist/unit",
@@ -34,6 +34,7 @@
"ws": "^8.18.0"
},
"devDependencies": {
"@biomejs/biome": "^1.8.0",
"@swc/cli": "^0.4.0",
"@swc/core": "^1.4.2",
"@types/chai": "^4.3.16",
@@ -43,8 +44,6 @@
"@types/ws": "^8.5.10",
"c8": "^9.1.0",
"chai": "^5.1.1",
"eslint": "^8.57.0",
"eslint-config-discordeno": "*",
"mocha": "^10.5.1",
"sinon": "^18.0.0",
"ts-node": "^10.9.2",

View File

@@ -1,8 +1,7 @@
/* eslint-disable @typescript-eslint/no-confusing-void-expression */
import { inflateSync } from 'node:zlib'
import type { DiscordGatewayPayload, DiscordHello, DiscordReady } from '@discordeno/types'
import { GatewayCloseEventCodes, GatewayOpcodes } from '@discordeno/types'
import { LeakyBucket, camelize, delay, logger } from '@discordeno/utils'
import { inflateSync } from 'node:zlib'
import NodeWebSocket from 'ws'
import type { BotStatusUpdate, ShardEvents, ShardGatewayConfig, ShardHeart, ShardSocketRequest } from './types.js'
import { ShardSocketCloseCodes, ShardState } from './types.js'
@@ -214,10 +213,7 @@ export class DiscordenoShard {
this.logger.debug(`[Gateway] Resuming Shard #${this.id}, before connecting`)
// Before we can resume, we need to create a new connection with Discord's gateway.
await this.connect()
this.logger.debug(
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
`[Gateway] Resuming Shard #${this.id}, after connecting. ${this.sessionId} | ${this.previousSequenceNumber}`,
)
this.logger.debug(`[Gateway] Resuming Shard #${this.id}, after connecting. ${this.sessionId} | ${this.previousSequenceNumber}`)
this.send(
{
@@ -494,7 +490,6 @@ export class DiscordenoShard {
* Passing the shard's id there to make it easier for the dev to use this function.
*/
async makePresence(): Promise<BotStatusUpdate | undefined> {
// eslint-disable-next-line no-useless-return
return
}

View File

@@ -1,18 +1,17 @@
/* eslint-disable @typescript-eslint/no-confusing-void-expression */
import {
GatewayIntents,
GatewayOpcodes,
type AtLeastOne,
type BigString,
type Camelize,
type DiscordGetGatewayBot,
type DiscordMemberWithUser,
type DiscordReady,
GatewayIntents,
GatewayOpcodes,
type RequestGuildMembers,
} from '@discordeno/types'
import { Collection, delay, logger } from '@discordeno/utils'
import Shard from './Shard.js'
import { ShardSocketCloseCodes, type ShardEvents, type ShardSocketRequest, type StatusUpdate, type UpdateVoiceState } from './types.js'
import { type ShardEvents, ShardSocketCloseCodes, type ShardSocketRequest, type StatusUpdate, type UpdateVoiceState } from './types.js'
export function createGatewayManager(options: CreateGatewayManagerOptions): GatewayManager {
const connectionOptions = options.connection ?? {
@@ -282,7 +281,6 @@ export function createGatewayManager(options: CreateGatewayManagerOptions): Gate
for (const bucket of gateway.buckets.values()) {
for (const worker of bucket.workers.values()) {
// eslint-disable-next-line @typescript-eslint/require-array-sort-compare
worker.queue = worker.queue.sort((a, b) => a - b)
}
}
@@ -390,7 +388,7 @@ export function createGatewayManager(options: CreateGatewayManagerOptions): Gate
this.shards.delete(shardId)
await shard.shutdown()
},
async requestIdentify(shardId: number) {
async requestIdentify(_shardId: number) {
gateway.logger.debug(`[Gateway] requesting identify`)
// const bucket = gateway.buckets.get(shardId % gateway.connection.sessionStartLimit.maxConcurrency)
// if (!bucket) return

View File

@@ -173,7 +173,7 @@ export interface StatusUpdate {
// /** Unix time (in milliseconds) of when the client went idle, or null if the client is not idle */
// since: number | null;
/** The user's activities */
activities?: Camelize<Array<Omit<DiscordActivity, 'created_at'>>>
activities?: Camelize<Omit<DiscordActivity, 'created_at'>[]>
/** The user's new status */
status: keyof typeof PresenceStatus
// /** Whether or not the client is afk */

View File

@@ -1,6 +1,6 @@
import { Intents } from '@discordeno/types'
import uWS from 'uWebSockets.js'
import { ShardSocketCloseCodes, createGatewayManager, type GatewayManager } from '../../src/index.js'
import { type GatewayManager, ShardSocketCloseCodes, createGatewayManager } from '../../src/index.js'
/**
* This value needs to be AT LEAST `1017`
@@ -36,8 +36,8 @@ async function createUws(options: {
closing?: boolean
}): Promise<{ port: number; uwsToken: uWS.us_listen_socket }> {
options.onOpen ??= () => {}
options.onMessage ??= (message: any) => {}
options.onClose ??= (code: number, message: string) => {}
options.onMessage ??= (_message: any) => {}
options.onClose ??= (_code: number, _message: string) => {}
options.closing ??= false
return await new Promise<{ port: number; uwsToken: uWS.us_listen_socket }>((resolve, reject) => {
@@ -64,7 +64,7 @@ async function createUws(options: {
)
options.onOpen!()
},
message: async (ws, message, isBinary) => {
message: async (ws, message, _isBinary) => {
const msg = JSON.parse(Buffer.from(message).toString())
options.onMessage!(msg)
if (msg.op === 1) {
@@ -116,7 +116,7 @@ async function createUws(options: {
// resume
}
},
close: (ws, code, message) => {
close: (_ws, code, message) => {
const msg = Buffer.from(message).toString()
options.onClose!(code, msg)
},

View File

@@ -18,8 +18,8 @@
"build": "swc src --strip-leading-paths --delete-dir-on-start src --out-dir dist/esm && swc --strip-leading-paths --delete-dir-on-start src --out-dir dist/cjs -C module.type=commonjs && node ../../scripts/fixCjsExtension.js",
"build:type": "tsc --declaration --emitDeclarationOnly --declarationDir dist/types",
"release-build": "yarn build && yarn build:type",
"fmt": "eslint --fix \"src/**/*.ts*\"",
"lint": "eslint \"src/**/*.ts*\"",
"fmt": "biome format --write",
"lint": "biome lint --write",
"test:unit-coverage": "c8 mocha --no-warnings 'tests/unit/**/*.spec.ts'",
"test:unit": "c8 --r lcov mocha --no-warnings 'tests/unit/**/*.spec.ts' && node ../../scripts/coveragePathFixing.js rest",
"test:deno-unit": "swc tests --strip-leading-paths --delete-dir-on-start --out-dir denoTestsDist && node ../../scripts/fixDenoTestExtension.js && deno test -A --import-map ../../denoImportMap.json denoTestsDist/unit",
@@ -34,6 +34,7 @@
"@discordeno/utils": "19.0.0-beta.1"
},
"devDependencies": {
"@biomejs/biome": "^1.8.0",
"@swc/cli": "^0.4.0",
"@swc/core": "^1.4.2",
"@types/chai": "^4.3.16",
@@ -45,8 +46,6 @@
"chai": "^5.1.1",
"chai-as-promised": "^7.1.1",
"dotenv": "^16.4.5",
"eslint": "^8.57.0",
"eslint-config-discordeno": "*",
"mocha": "^10.5.1",
"sinon": "^18.0.0",
"ts-node": "^10.9.2",

View File

@@ -35,7 +35,6 @@ export function createInvalidRequestBucket(options: InvalidRequestBucketOptions)
},
waitUntilRequestAvailable: async function () {
// eslint-disable-next-line no-async-promise-executor
return await new Promise(async (resolve) => {
// If whatever amount of requests is left is more than the safety margin, allow the request
if (bucket.isRequestAllowed()) {

View File

@@ -1,13 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
import { Buffer } from 'node:buffer'
import { calculateBits, camelize, camelToSnakeCase, delay, getBotIdFromToken, logger, processReactionString, urlToBase64 } from '@discordeno/utils'
import { createInvalidRequestBucket } from './invalidBucket.js'
import { Queue } from './queue.js'
import {
InteractionResponseTypes,
type BigString,
type Camelize,
type DiscordAccessTokenResponse,
@@ -55,9 +47,13 @@ import {
type DiscordVoiceRegion,
type DiscordWebhook,
type DiscordWelcomeScreen,
InteractionResponseTypes,
type MfaLevels,
type ModifyGuildTemplate,
} from '@discordeno/types'
import { calculateBits, camelToSnakeCase, camelize, delay, getBotIdFromToken, logger, processReactionString, urlToBase64 } from '@discordeno/utils'
import { createInvalidRequestBucket } from './invalidBucket.js'
import { Queue } from './queue.js'
import { createRoutes } from './routes.js'
import type { CreateRequestBodyOptions, CreateRestManagerOptions, MakeRequestOptions, RestManager, SendRequestOptions } from './types.js'
@@ -545,7 +541,6 @@ export function createRestManager(options: CreateRestManagerOptions): RestManage
const error = new Error()
error.message = 'Failed to send request to discord.'
// eslint-disable-next-line no-async-promise-executor
return await new Promise(async (resolve, reject) => {
const payload: SendRequestOptions = {
route,

View File

@@ -57,7 +57,6 @@ export class Queue {
/** Pauses the execution until a request is allowed to be made. */
async waitUntilRequestAvailable(): Promise<void> {
// eslint-disable-next-line no-async-promise-executor
return await new Promise(async (resolve) => {
// If whatever amount of requests is left is more than the safety margin, allow the request
if (this.isRequestAllowed()) {

View File

@@ -82,9 +82,7 @@ export function createRoutes(): RestRoutes {
let url = `/channels/${channelId}/messages/${messageId}/reactions/${encodeURIComponent(emoji)}?`
if (options) {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
if (options.after) url += `after=${options.after}`
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
if (options.limit) url += `&limit=${options.limit}`
}
@@ -182,7 +180,6 @@ export function createRoutes(): RestRoutes {
if (options.before) {
url += `before=${new Date(options.before).toISOString()}`
}
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
if (options.limit) url += `&limit=${options.limit}`
}
@@ -195,7 +192,6 @@ export function createRoutes(): RestRoutes {
if (options.before) {
url += `before=${new Date(options.before).toISOString()}`
}
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
if (options.limit) url += `&limit=${options.limit}`
}
@@ -208,7 +204,6 @@ export function createRoutes(): RestRoutes {
if (options.before) {
url += `before=${new Date(options.before).toISOString()}`
}
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
if (options.limit) url += `&limit=${options.limit}`
}
@@ -246,13 +241,9 @@ export function createRoutes(): RestRoutes {
let url = '/users/@me/guilds?'
if (options) {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
if (options.after) url += `after=${options.after}`
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
if (options.before) url += `&before=${options.before}`
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
if (options.limit) url += `&limit=${options.limit}`
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
if (options.withCounts) url += `&with_counts=${options.withCounts}`
}
@@ -262,15 +253,10 @@ export function createRoutes(): RestRoutes {
let url = `/guilds/${guildId}/audit-logs?`
if (options) {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
if (options.actionType) url += `action_type=${options.actionType}`
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
if (options.before) url += `&before=${options.before}`
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
if (options.after) url += `&after=${options.after}`
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
if (options.limit) url += `&limit=${options.limit}`
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
if (options.userId) url += `&user_id=${options.userId}`
}
@@ -315,15 +301,11 @@ export function createRoutes(): RestRoutes {
let url = `/guilds/${guildId}/scheduled-events/${eventId}/users?`
if (options) {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
if (options.limit !== undefined) url += `limit=${options.limit}`
if (options.withMember !== undefined) {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
url += `&with_member=${options.withMember.toString()}`
}
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
if (options.after !== undefined) url += `&after=${options.after}`
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
if (options.before !== undefined) url += `&before=${options.before}`
}
@@ -350,15 +332,12 @@ export function createRoutes(): RestRoutes {
if (options) {
if (options.withCounts !== undefined) {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
url += `with_counts=${options.withCounts.toString()}`
}
if (options.withExpiration !== undefined) {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
url += `&with_expiration=${options.withExpiration.toString()}`
}
if (options.scheduledEventId) {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
url += `&guild_scheduled_event_id=${options.scheduledEventId}`
}
}
@@ -379,11 +358,8 @@ export function createRoutes(): RestRoutes {
let url = `/guilds/${guildId}/bans?`
if (options) {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
if (options.limit) url += `limit=${options.limit}`
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
if (options.after) url += `&after=${options.after}`
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
if (options.before) url += `&before=${options.before}`
}
@@ -405,9 +381,7 @@ export function createRoutes(): RestRoutes {
let url = `/guilds/${guildId}/members?`
if (options !== undefined) {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
if (options.limit) url += `limit=${options.limit}`
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
if (options.after) url += `&after=${options.after}`
}
@@ -426,13 +400,10 @@ export function createRoutes(): RestRoutes {
let url = `/guilds/${guildId}/prune?`
if (options) {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
if (options.days) url += `days=${options.days}`
if (Array.isArray(options.includeRoles)) {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
url += `&include_roles=${options.includeRoles.join(',')}`
} else if (options.includeRoles) {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
url += `&include_roles=${options.includeRoles}`
}
}
@@ -448,13 +419,10 @@ export function createRoutes(): RestRoutes {
let url = `/guilds/${guildId}/prune?`
if (options) {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
if (options.days) url += `days=${options.days}`
if (Array.isArray(options.includeRoles)) {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
url += `&include_roles=${options.includeRoles.join(',')}`
} else if (options.includeRoles) {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
url += `&include_roles=${options.includeRoles}`
}
}

View File

@@ -110,8 +110,6 @@ import type {
GetScheduledEvents,
GetUserGuilds,
GetWebhookMessageOptions,
// Type is required for typedoc
// eslint-disable-next-line @typescript-eslint/no-unused-vars
GuildFeatures,
InteractionCallbackData,
InteractionResponse,
@@ -126,11 +124,7 @@ import type {
ModifyGuildTemplate,
ModifyRolePositions,
ModifyWebhook,
// Type is required for typedoc
// eslint-disable-next-line @typescript-eslint/no-unused-vars
ScheduledEventEntityType,
// Type is required for typedoc
// eslint-disable-next-line @typescript-eslint/no-unused-vars
ScheduledEventStatus,
SearchMembers,
StartThreadWithMessage,

View File

@@ -45,7 +45,6 @@ describe('Get a user from the api', () => {
})
it('With an invalid user id', async () => {
// eslint-disable-next-line @typescript-eslint/await-thenable
await expect(rest.getUser('123')).eventually.throws
})
})

View File

@@ -2,8 +2,5 @@
"name": "tsconfig",
"version": "0.0.0",
"private": true,
"files": [
"base.json",
"test.json"
]
"files": ["base.json", "test.json"]
}

View File

@@ -6,7 +6,7 @@
"incremental": false,
"tsBuildInfoFile": null,
"rootDir": null,
"outDir": null,
"outDir": null
},
"include": ["${configDir}"],
"include": ["${configDir}"]
}

View File

@@ -18,8 +18,8 @@
"build": "swc src --strip-leading-paths --delete-dir-on-start src --out-dir dist/esm && swc --strip-leading-paths --delete-dir-on-start src --out-dir dist/cjs -C module.type=commonjs && node ../../scripts/fixCjsExtension.js",
"build:type": "tsc --declaration --emitDeclarationOnly --declarationDir dist/types",
"release-build": "yarn build && yarn build:type",
"fmt": "eslint --fix \"src/**/*.ts*\"",
"lint": "eslint \"src/**/*.ts*\"",
"fmt": "biome format --write",
"lint": "biome lint --write",
"test:unit-coverage": "c8 mocha --no-warnings 'tests/**/*.spec.ts'",
"test:unit": "c8 --r lcov mocha --no-warnings 'tests/**/*.spec.ts' && node ../../scripts/coveragePathFixing.js utils",
"test:deno-unit": "swc tests --strip-leading-paths --delete-dir-on-start -C jsc.minify.mangle=false --out-dir denoTestsDist && node ../../scripts/fixDenoTestExtension.js && deno test -A --import-map ../../denoImportMap.json denoTestsDist",
@@ -27,13 +27,12 @@
"test:type": "tsc --noEmit"
},
"devDependencies": {
"@biomejs/biome": "^1.8.0",
"@swc/cli": "^0.4.0",
"@swc/core": "^1.4.2",
"@types/mocha": "^10.0.7",
"@types/node": "^20.14.10",
"c8": "^9.1.0",
"eslint": "^8.57.0",
"eslint-config-discordeno": "*",
"mocha": "^10.5.1",
"ts-node": "^10.9.2",
"tsconfig": "*",

View File

@@ -498,7 +498,7 @@ export interface DiscordConnection {
/** whether the connection is revoked */
revoked?: boolean
/** an array of partial server integrations */
integrations?: Array<Partial<DiscordIntegration>>
integrations?: Partial<DiscordIntegration>[]
/** whether the connection is verified */
verified: boolean
/** whether friend sync is enabled for this connection */
@@ -879,7 +879,7 @@ export interface DiscordGuild {
/** When this guild was joined at */
joined_at?: string
/** States of members currently in voice channels; lacks the guild_id key */
voice_states?: Array<Omit<DiscordVoiceState, 'guildId'>>
voice_states?: Omit<DiscordVoiceState, 'guildId'>[]
/** Users in the guild */
members?: DiscordMember[]
/** Channels in the guild */
@@ -887,7 +887,7 @@ export interface DiscordGuild {
/** All active threads in the guild that the current user has permission to view */
threads?: DiscordChannel[]
/** Presences of the members in the guild, will only include non-offline members if the size is greater than large threshold */
presences?: Array<Partial<DiscordPresenceUpdate>>
presences?: Partial<DiscordPresenceUpdate>[]
/** Banner hash */
banner: string | null
/** The preferred locale of a Community guild; used in server discovery and notices from Discord; defaults to "en-US" */
@@ -1922,7 +1922,7 @@ export interface DiscordAuditLog {
/** List of audit log entries, sorted from most to least recent */
audit_log_entries: DiscordAuditLogEntry[]
/** List of partial integration objects */
integrations: Array<Partial<DiscordIntegration>>
integrations: Partial<DiscordIntegration>[]
/**
* List of threads found in the audit log.
* Threads referenced in `THREAD_CREATE` and `THREAD_UPDATE` events are included in the threads map since archived threads might not be kept in memory by clients.
@@ -2187,8 +2187,8 @@ export type DiscordAuditLogChange =
| 'communication_disabled_until'
}
| {
new_value: Array<Partial<DiscordRole>>
old_value?: Array<Partial<DiscordRole>>
new_value: Partial<DiscordRole>[]
old_value?: Partial<DiscordRole>[]
key: '$add' | '$remove'
}
| {
@@ -2408,7 +2408,7 @@ export enum DiscordInviteType {
export interface DiscordInviteStageInstance {
/** The members speaking in the Stage */
members: Array<Partial<DiscordMember>>
members: Partial<DiscordMember>[]
/** The number of users in the Stage */
participant_count: number
/** The number of users speaking in the Stage */

View File

@@ -58,7 +58,7 @@ export interface CreateMessageOptions {
/** true if this is a TTS message */
tts?: boolean
/** Embedded `rich` content (up to 6000 characters) */
embeds?: Array<Camelize<DiscordEmbed>>
embeds?: Camelize<DiscordEmbed>[]
/** Allowed mentions for the message */
allowedMentions?: AllowedMentions
/** Include to make your message a reply */
@@ -507,7 +507,7 @@ export interface InteractionCallbackData {
/** True if this is a TTS message */
tts?: boolean
/** Embedded `rich` content (up to 6000 characters) */
embeds?: Array<Camelize<DiscordEmbed>>
embeds?: Camelize<DiscordEmbed>[]
/** Allowed mentions for the message */
allowedMentions?: AllowedMentions
/** The contents of the files being sent */
@@ -771,7 +771,7 @@ export interface ExecuteWebhook {
/** The contents of the files being sent */
files?: FileContent[]
/** Embedded `rich` content */
embeds?: Array<Camelize<DiscordEmbed>>
embeds?: Camelize<DiscordEmbed>[]
/** Allowed mentions for the message */
allowedMentions?: AllowedMentions
/** the components to include with the message */
@@ -802,7 +802,7 @@ export interface CreateForumPostWithMessage {
/** The message contents (up to 2000 characters) */
content?: string
/** Embedded `rich` content (up to 6000 characters) */
embeds?: Array<Camelize<DiscordEmbed>>
embeds?: Camelize<DiscordEmbed>[]
/** Allowed mentions for the message */
allowedMentions?: AllowedMentions
/** The components you would like to have sent in this message */
@@ -999,7 +999,7 @@ export interface EditMessage {
/** The new message contents (up to 2000 characters) */
content?: string | null
/** Embedded `rich` content (up to 6000 characters) */
embeds?: Array<Camelize<DiscordEmbed>> | null
embeds?: Camelize<DiscordEmbed>[] | null
/** Edit the flags of the message (only `SUPPRESS_EMBEDS` can currently be set/unset) */
flags?: MessageFlags | null
/** The contents of the files being sent/edited */
@@ -1007,7 +1007,7 @@ export interface EditMessage {
/** Allowed mentions for the message */
allowedMentions?: AllowedMentions
/** When specified (adding new attachments), attachments which are not provided in this list will be removed. */
attachments?: Array<Camelize<DiscordAttachment>>
attachments?: Camelize<DiscordAttachment>[]
/** The components you would like to have sent in this message */
components?: MessageComponents
}
@@ -1045,7 +1045,7 @@ export interface CreateGuild {
/** New guild roles (first role is the everyone role) */
roles?: Camelize<DiscordRole[]>
/** New guild's channels */
channels?: Array<Partial<Camelize<DiscordChannel>>>
channels?: Partial<Camelize<DiscordChannel>>[]
/** Id for afk channel */
afkChannelId?: string
/** Afk timeout in seconds */
@@ -1269,7 +1269,7 @@ export interface BeginGuildPrune {
/** https://discord.com/developers/docs/resources/guild#modify-guild-onboarding-json-params */
export interface EditGuildOnboarding {
/** Prompts shown during onboarding and in customize community */
prompts: Array<Camelize<DiscordGuildOnboardingPrompt>>
prompts: Camelize<DiscordGuildOnboardingPrompt>[]
/** Channel IDs that members get opted into automatically */
defaultChannelIds: BigString[]
/** Whether onboarding is enabled in the guild */
@@ -1357,7 +1357,7 @@ export interface CreatePoll {
/** The question of the poll. Only `text` is supported. */
question: Camelize<DiscordPollMedia>
/** Each of the answers available in the poll, up to 10 */
answers: Array<Omit<Camelize<DiscordPollAnswer>, 'answerId'>>
answers: Omit<Camelize<DiscordPollAnswer>, 'answerId'>[]
/**
* Number of hours the poll should be open for
*

View File

@@ -1120,16 +1120,16 @@ export type CamelCase<S extends string> = S extends `${infer T}_${infer U}` ? `$
export type SnakeCase<S extends string> = S extends `${infer T}${infer U}` ? `${T extends Lowercase<T> ? '' : '_'}${Lowercase<T>}${SnakeCase<U>}` : S
export type Camelize<T> = T extends any[]
? T extends Array<Record<any, any>>
? Array<Camelize<T[number]>>
? T extends Record<any, any>[]
? Camelize<T[number]>[]
: T
: T extends Record<any, any>
? { [K in keyof T as CamelCase<K & string>]: Camelize<T[K]> }
: T
export type Snakelize<T> = T extends any[]
? T extends Array<Record<any, any>>
? Array<Snakelize<T[number]>>
? T extends Record<any, any>[]
? Snakelize<T[number]>[]
: T
: T extends Record<any, any>
? { [K in keyof T as SnakeCase<K & string>]: Snakelize<T[K]> }

View File

@@ -18,8 +18,8 @@
"build": "swc src --strip-leading-paths --delete-dir-on-start src --out-dir dist/esm && swc --strip-leading-paths --delete-dir-on-start src --out-dir dist/cjs -C module.type=commonjs && node ../../scripts/fixCjsExtension.js",
"build:type": "tsc --skipDefaultLibCheck --declaration --emitDeclarationOnly --declarationDir dist/types",
"release-build": "yarn build && yarn build:type",
"fmt": "eslint --fix \"src/**/*.ts*\"",
"lint": "eslint \"src/**/*.ts*\"",
"fmt": "biome format --write",
"lint": "biome lint --write",
"test:unit-coverage": "c8 mocha --no-warnings 'tests/**/*.spec.ts'",
"test:unit": "c8 --r lcov mocha --no-warnings 'tests/**/*.spec.ts' && node ../../scripts/coveragePathFixing.js utils",
"test:deno-unit": "swc tests --strip-leading-paths --delete-dir-on-start -C jsc.minify.mangle=false --out-dir denoTestsDist && node ../../scripts/fixDenoTestExtension.js && deno test -A --import-map ../../denoImportMap.json denoTestsDist",
@@ -32,6 +32,7 @@
"@discordeno/types": "19.0.0-beta.1"
},
"devDependencies": {
"@biomejs/biome": "^1.8.0",
"@swc/cli": "^0.4.0",
"@swc/core": "^1.4.2",
"@types/chai": "^4.3.16",
@@ -40,8 +41,6 @@
"@types/sinon": "^17.0.3",
"c8": "^9.1.0",
"chai": "^5.1.1",
"eslint": "^8.57.0",
"eslint-config-discordeno": "*",
"mocha": "^10.5.1",
"sinon": "^18.0.0",
"ts-node": "^10.9.2",

Some files were not shown because too many files have changed in this diff Show More