Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: dep update #1082

Merged
merged 4 commits into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@
"dev": "docusaurus start"
},
"dependencies": {
"@docusaurus/core": "^3.5.2",
"@docusaurus/preset-classic": "^3.5.2",
"@docusaurus/remark-plugin-npm2yarn": "^3.5.2",
"@docusaurus/theme-search-algolia": "^3.5.2",
"@mdx-js/react": "^3.0.1",
"@docusaurus/core": "^3.7.0",
"@docusaurus/preset-classic": "^3.7.0",
"@docusaurus/remark-plugin-npm2yarn": "^3.7.0",
"@docusaurus/theme-search-algolia": "^3.7.0",
"@mdx-js/react": "^3.1.0",
"@svgr/webpack": "^8.1.0",
"ansi-regex": "^6.0.1",
"clsx": "^2.1.1",
"file-loader": "^6.2.0",
"nth-check": "^2.1.1",
"prism-react-renderer": "^2.4.0",
"prism-react-renderer": "^2.4.1",
"react": "^18.3.1",
"trim": "^1.0.1",
"typescript": "^5.6.2",
"typescript": "^5.7.3",
"url-loader": "^4.1.1"
},
"browserslist": {
Expand Down
30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,25 +42,25 @@
},
"devDependencies": {
"@changesets/changelog-github": "^0.5.0",
"@changesets/cli": "^2.27.8",
"@commitlint/cli": "^19.5.0",
"@commitlint/config-angular": "^19.5.0",
"@eslint/js": "^9.10.0",
"@changesets/cli": "^2.27.12",
"@commitlint/cli": "^19.6.1",
"@commitlint/config-angular": "^19.7.0",
"@eslint/js": "^9.19.0",
"@types/eslint__js": "^8.42.3",
"eslint": "^9.10.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint": "^9.19.0",
"eslint-config-prettier": "^10.0.1",
"eslint-plugin-prettier": "^5.2.3",
"eslint-plugin-simple-import-sort": "^12.1.1",
"husky": "^9.1.6",
"is-ci": "^3.0.1",
"husky": "^9.1.7",
"is-ci": "^4.1.0",
"minipass": "^7.1.2",
"prettier": "^3.3.3",
"tsup": "^8.2.4",
"prettier": "^3.4.2",
"tsup": "^8.3.6",
"tsx": "^4.19.2",
"turbo": "^2.1.1",
"typedoc": "^0.26.7",
"typescript": "^5.6.2",
"typescript-eslint": "^8.5.0"
"turbo": "^2.3.4",
"typedoc": "^0.27.6",
"typescript": "^5.7.3",
"typescript-eslint": "^8.21.0"
},
"engines": {
"node": ">=16.0.0",
Expand Down
10 changes: 5 additions & 5 deletions packages/create-discordx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@
"build": "tsup src/index.ts --format esm --dts"
},
"dependencies": {
"axios": "^1.7.7",
"axios": "^1.7.9",
"boxen": "^8.0.1",
"chalk": "^5.3.0",
"chalk": "^5.4.1",
"is-installed-globally": "^1.0.0",
"ora": "^8.1.0",
"ora": "^8.1.1",
"prompts": "^2.4.2",
"rimraf": "^6.0.1",
"tar": "^7.4.3",
"typescript": "5.6.2",
"typescript": "5.7.3",
"update-check": "^1.5.4",
"validate-npm-package-name": "^5.0.1"
"validate-npm-package-name": "^6.0.0"
},
"engines": {
"node": ">=16.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/di/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"typedi": "^0.10.0"
},
"devDependencies": {
"typescript": "5.6.2"
"typescript": "5.7.3"
},
"engines": {
"node": ">=16.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/di/src/logic/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
* -------------------------------------------------------------------------------------------------------
*/
export * from "./AbstractConfigurableDependencyInjector.js";
export * from "./IDependencyRegistryEngine.js";
export type * from "./IDependencyRegistryEngine.js";
export * from "./impl/index.js";
8 changes: 4 additions & 4 deletions packages/discordx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@
},
"devDependencies": {
"@discordx/importer": "workspace:^",
"@types/jest": "^29.5.12",
"@types/lodash": "^4.17.7",
"discord.js": "^14.16.2",
"@types/jest": "^29.5.14",
"@types/lodash": "^4.17.14",
"discord.js": "^14.17.3",
"jest": "^29.7.0",
"reflect-metadata": "^0.2.2",
"ts-jest": "^29.2.5",
"ts-jest-resolver": "^2.0.1",
"typescript": "^5.6.2"
"typescript": "^5.7.3"
},
"peerDependencies": {
"discord.js": ">=14 || ^14.0.0-dev"
Expand Down
29 changes: 12 additions & 17 deletions packages/discordx/src/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import {
InteractionType,
} from "discord.js";
import escapeRegExp from "lodash/escapeRegExp.js";
import isArray from "lodash/isArray.js";

import type {
ApplicationCommandDataEx,
Expand All @@ -49,7 +48,6 @@ import type {
GuardFunction,
IGuild,
ILogger,
IPrefix,
IPrefixResolver,
ISimpleCommandByName,
ITriggerEventData,
Expand All @@ -63,6 +61,7 @@ import {
SimpleCommandMessage,
SimpleCommandOptionType,
SimpleCommandParseType,
toStringArray,
} from "./index.js";

/**
Expand Down Expand Up @@ -1179,12 +1178,13 @@ export class Client extends ClientJS {
*
* @returns
*/
async getMessagePrefix(message: Message): Promise<IPrefix> {
async getMessagePrefix(message: Message): Promise<string[]> {
if (typeof this.prefix !== "function") {
return isArray(this.prefix) ? [...this.prefix] : [this.prefix];
return toStringArray(this.prefix);
}

return [...(await this.prefix(message))];
const prefix = await this.prefix(message);
return toStringArray(prefix);
}

/**
Expand All @@ -1197,15 +1197,19 @@ export class Client extends ClientJS {
* @returns
*/
async parseCommand(
prefix: IPrefix,
message: Message,
caseSensitive = false,
): Promise<SimpleCommandParseType | SimpleCommandMessage> {
/**
* Get prefix for message
*/
const prefix = await this.getMessagePrefix(message);

/**
* Get a regular expression for the prefix by combining unique simple command prefixes.
*/
const prefixRegex = RegExp(
`^(${[...prefix, ...this.simpleCommandMappedPrefix]
`^(${toStringArray(prefix, Array.from(this.simpleCommandMappedPrefix))
.map((pfx) => escapeRegExp(pfx))
.join("|")})`,
);
Expand Down Expand Up @@ -1288,19 +1292,10 @@ export class Client extends ClientJS {
message: Message,
caseSensitive?: boolean,
): Promise<unknown> {
/**
* Get prefix for message
*/
const prefix = await this.getMessagePrefix(message);

/**
* Parse command
*/
const command = await this.parseCommand(
prefix,
message,
caseSensitive ?? false,
);
const command = await this.parseCommand(message, caseSensitive ?? false);

/**
* Return if the message is not a command
Expand Down
3 changes: 2 additions & 1 deletion packages/discordx/src/logic/metadata/MetadataStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
DOn,
DReaction,
DSimpleCommand,
toStringArray,
} from "../../index.js";

/**
Expand Down Expand Up @@ -399,7 +400,7 @@ export class MetadataStorage {
* Save the customized prefix within the mapped prefix set.
*/
if (cmd.prefix) {
[...cmd.prefix].forEach((pfx) =>
toStringArray(cmd.prefix).forEach((pfx) =>
this._simpleCommandMappedPrefix.add(pfx),
);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/discordx/src/types/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
* Licensed under the Apache License. See License.txt in the project root for license information.
* -------------------------------------------------------------------------------------------------------
*/
export * from "./ClientOptions.js";
export * from "./common.js";
export type * from "./ClientOptions.js";
export type * from "./common.js";
export * from "./literal.js";
4 changes: 2 additions & 2 deletions packages/discordx/src/types/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Licensed under the Apache License. See License.txt in the project root for license information.
* -------------------------------------------------------------------------------------------------------
*/
export * from "./common.js";
export type * from "./common.js";
export * from "./enum.js";
export * from "./simple command.js";
export * from "./slash.js";
export type * from "./slash.js";
11 changes: 11 additions & 0 deletions packages/discordx/src/util/common.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Converts the provided arguments into a single flat array of strings.
* Accepts multiple arguments, each of which can be a string or an array of strings.
* If an argument is a string, it is wrapped in an array. If it is an array, it is flattened.
*
* @param {...(string | string[])[]} input - One or more strings or arrays of strings.
* @returns {string[]} A flat array of strings.
*/
export function toStringArray(...input: (string | string[])[]): string[] {
return input.flatMap((item) => (Array.isArray(item) ? item : [item]));
}
1 change: 1 addition & 0 deletions packages/discordx/src/util/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Licensed under the Apache License. See License.txt in the project root for license information.
* -------------------------------------------------------------------------------------------------------
*/
export * from "./common.js";
export * from "./comparison.js";
export * from "./resolve-guilds.js";
export * from "./slash-name-validator.js";
14 changes: 7 additions & 7 deletions packages/discordx/tests/simple-command.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ describe("Commands", () => {

it("Should execute simple command", async () => {
const sampleMessage = { content: "!add 2~+~4" } as Message;
const parsedCommand = await client.parseCommand("!", sampleMessage);
const parsedCommand = await client.parseCommand(sampleMessage);
const response = await client.executeCommand(sampleMessage);
expect(response).toEqual(["!add", ["+", 6], parsedCommand, true]);
});
Expand All @@ -174,21 +174,21 @@ describe("Commands", () => {

it("Should execute simple command with space", async () => {
const sampleMessage = { content: "!add plus" } as Message;
const parsedCommand = await client.parseCommand("!", sampleMessage);
const parsedCommand = await client.parseCommand(sampleMessage);
const response = await client.executeCommand(sampleMessage);
expect(response).toEqual(["!add plus", [], parsedCommand, true]);
});

it("Should execute simple command with uppercase names", async () => {
const sampleMessage = { content: "!findSource" } as Message;
const parsedCommand = await client.parseCommand("!", sampleMessage);
const parsedCommand = await client.parseCommand(sampleMessage);
const response = await client.executeCommand(sampleMessage);
expect(response).toEqual(["!findSource", [1], parsedCommand, true]);
});

it("Should execute simple command with two spaces", async () => {
const sampleMessage = { content: "!add plus second car" } as Message;
const parsedCommand = await client.parseCommand("!", sampleMessage);
const parsedCommand = await client.parseCommand(sampleMessage);
const response = await client.executeCommand(sampleMessage);
expect(response).toEqual([
"!add plus second",
Expand All @@ -200,7 +200,7 @@ describe("Commands", () => {

it("Should execute simple command aliases", async () => {
const sampleMessage = { content: "!add2 2~+~4" } as Message;
const parsedCommand = await client.parseCommand("!", sampleMessage);
const parsedCommand = await client.parseCommand(sampleMessage);
const response = await client.executeCommand(sampleMessage);
expect(response).toEqual(["!add", ["+", 6], parsedCommand, true]);
});
Expand All @@ -216,7 +216,7 @@ describe("Commands", () => {
const results = await Promise.all(
contents.map(async (content) => {
const sampleMessage = { content } as Message;
const parsedCommand = await client.parseCommand("!", sampleMessage);
const parsedCommand = await client.parseCommand(sampleMessage);
const response = await client.executeCommand(sampleMessage);
return { parsedCommand, response };
}),
Expand All @@ -236,7 +236,7 @@ describe("Commands", () => {
const sampleMessage = {
content: "!ban 123 99 'ban reason test' cars",
} as Message;
const parsedCommand = await client.parseCommand("!", sampleMessage);
const parsedCommand = await client.parseCommand(sampleMessage);
const response = await client.executeCommand(sampleMessage);
expect(response).toEqual([
"!ban",
Expand Down
4 changes: 2 additions & 2 deletions packages/importer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@
"build": "tsup src/index.ts --format cjs,esm --dts"
},
"dependencies": {
"glob": "^11.0.0"
"glob": "^11.0.1"
},
"devDependencies": {
"typescript": "5.6.2"
"typescript": "5.7.3"
},
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion packages/internal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"build:typedoc": "npx typedoc src/index.ts --out ../../docs/static/api/internal"
},
"devDependencies": {
"typescript": "5.6.2"
"typescript": "5.7.3"
},
"engines": {
"node": ">=16.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/internal/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
* -------------------------------------------------------------------------------------------------------
*/
export * from "./decorator/index.js";
export * from "./types/decorators.js";
export type * from "./types/decorators.js";
4 changes: 2 additions & 2 deletions packages/lava-player/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
"ws": "^8.18.0"
},
"devDependencies": {
"@types/ws": "^8.5.12",
"typescript": "5.6.2"
"@types/ws": "^8.5.14",
"typescript": "5.7.3"
},
"engines": {
"node": ">=16.0.0",
Expand Down
1 change: 0 additions & 1 deletion packages/lava-player/src/core/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export class Connection<T extends BaseNode = BaseNode> {

let pk: any;
try {
// eslint-disable-next-line @typescript-eslint/no-base-to-string
pk = JSON.parse(d.toString());
} catch (e) {
this.node.emit("error", e);
Expand Down
2 changes: 1 addition & 1 deletion packages/lava-player/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Licensed under the Apache License. See License.txt in the project root for license information.
* -------------------------------------------------------------------------------------------------------
*/
export * from "./node.js";
export type * from "./node.js";
export * from "./op.js";
export * from "./player.js";
export * from "./rest.js";
Expand Down
6 changes: 3 additions & 3 deletions packages/lava-queue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@
},
"devDependencies": {
"@discordx/lava-player": "workspace:^",
"@types/lodash": "^4.17.7",
"discord.js": "^14.16.2",
"typescript": "5.6.2"
"@types/lodash": "^4.17.14",
"discord.js": "^14.17.3",
"typescript": "5.7.3"
},
"peerDependencies": {
"@discordx/lava-player": ">=2.1.3",
Expand Down
Loading
Loading