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

Fix 14.15 Breaking Changes on SlashCommandBuilder #50

Merged
merged 3 commits into from
May 9, 2024
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
4 changes: 2 additions & 2 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
},
"dependencies": {
"@reciple/core": "^8.1.4",
"discord.js": "^14.14.1",
"discord.js": "^14.15.2",
"reciple": "^8.1.4"
},
"devDependencies": {
"@types/node": "^20.12.7",
"@types/node": "^20.12.11",
"nodemon": "^3.0.2"
}
}
332 changes: 159 additions & 173 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"docs": "rimraf -g ./packages/*/docs/docs.json && lerna run docs"
},
"devDependencies": {
"@types/node": "^20.12.7",
"@types/node": "^20.12.11",
"lerna": "^8.1.2",
"rimraf": "^5.0.5",
"typescript": "^5.4.5"
Expand Down
6 changes: 3 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@
"@sapphire/shapeshift": "^3.9.7",
"fallout-utility": "^2.8.0",
"lodash": "^4.17.21",
"semver": "^7.6.0",
"semver": "^7.6.1",
"ts-mixer": "^6.0.4"
},
"devDependencies": {
"@types/lodash": "^4.17.0",
"@types/lodash": "^4.17.1",
"@types/semver": "^7.5.8",
"discord.js": "^14.14.1"
"discord.js": "^14.15.2"
},
"peerDependencies": {
"discord.js": "^14.9.0"
Expand Down
24 changes: 12 additions & 12 deletions packages/core/src/classes/builders/SlashCommandBuilder.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { ApplicationCommandType, Awaitable, ChatInputCommandInteraction, isJSONEncodable, JSONEncodable, SlashCommandBuilder as DiscordJsSlashCommandBuilder, SharedSlashCommandOptions, RESTPostAPIChatInputApplicationCommandsJSONBody, SlashCommandSubcommandGroupBuilder, SlashCommandSubcommandBuilder, SlashCommandAttachmentOption, SlashCommandBooleanOption, SlashCommandChannelOption, SlashCommandIntegerOption, SlashCommandMentionableOption, SlashCommandNumberOption, SlashCommandRoleOption, SlashCommandStringOption, SlashCommandUserOption, ApplicationCommandOptionType, ApplicationCommandOptionAllowedChannelTypes, PermissionResolvable, PermissionsBitField } from 'discord.js';
import { Awaitable, ChatInputCommandInteraction, JSONEncodable, SlashCommandBuilder as DiscordJsSlashCommandBuilder, RESTPostAPIChatInputApplicationCommandsJSONBody, ApplicationCommandType, SharedSlashCommandOptions, ApplicationCommandOptionType, SlashCommandStringOption, SlashCommandIntegerOption, SlashCommandBooleanOption, SlashCommandUserOption, SlashCommandChannelOption, ApplicationCommandOptionAllowedChannelTypes, SlashCommandRoleOption, SlashCommandMentionableOption, SlashCommandNumberOption, SlashCommandAttachmentOption, SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder, isJSONEncodable, PermissionsBitField, PermissionResolvable } from 'discord.js';
import { AnyNonSubcommandSlashCommandOptionBuilder, AnySlashCommandOptionBuilder, AnySlashCommandOptionData, CommandHaltData } from '../../types/structures';
import { BaseCommandBuilder, BaseCommandBuilderData } from './BaseCommandBuilder';
import { CommandHaltReason, CommandType } from '../../types/constants';
import { RecipleClient } from '../structures/RecipleClient';
import { CooldownData } from '../structures/Cooldown';
import { Mixin } from 'ts-mixer';
import { CooldownData } from '../structures/Cooldown';

export interface SlashCommandExecuteData {
type: CommandType.SlashCommand;
Expand Down Expand Up @@ -37,30 +37,30 @@ export interface SlashCommandBuilder extends DiscordJsSlashCommandBuilder, BaseC
addSubcommandGroup(input: SlashCommandSubcommandGroupBuilder|((subcommandGroup: SlashCommandSubcommandGroupBuilder) => SlashCommandSubcommandGroupBuilder)): Omit<this, SlashCommandBuilderNonSubcommandAddOptionMethods>;
addSubcommand(input: SlashCommandSubcommandBuilder|((subcommandGroup: SlashCommandSubcommandBuilder) => SlashCommandSubcommandBuilder)): Omit<this, SlashCommandBuilderNonSubcommandAddOptionMethods>;

addBooleanOption(input: SlashCommandBooleanOption|((builder: SlashCommandBooleanOption) => SlashCommandBooleanOption)): Omit<this, SlashCommandBuilderSubcommandAddOptionMethods>;
addUserOption(input: SlashCommandUserOption|((builder: SlashCommandUserOption) => SlashCommandUserOption)): Omit<this, SlashCommandBuilderSubcommandAddOptionMethods>;
addChannelOption(input: SlashCommandChannelOption|((builder: SlashCommandChannelOption) => SlashCommandChannelOption)): Omit<this, SlashCommandBuilderSubcommandAddOptionMethods>;
addRoleOption(input: SlashCommandRoleOption|((builder: SlashCommandRoleOption) => SlashCommandRoleOption)): Omit<this, SlashCommandBuilderSubcommandAddOptionMethods>;
addAttachmentOption(input: SlashCommandAttachmentOption|((builder: SlashCommandAttachmentOption) => SlashCommandAttachmentOption)): Omit<this, SlashCommandBuilderSubcommandAddOptionMethods>;
addMentionableOption(input: SlashCommandMentionableOption|((builder: SlashCommandMentionableOption) => SlashCommandMentionableOption)): Omit<this, SlashCommandBuilderSubcommandAddOptionMethods>;
addBooleanOption(input: SlashCommandBooleanOption|((builder: SlashCommandBooleanOption) => SlashCommandBooleanOption)): SharedSlashCommandOptions<any> & Omit<this, SlashCommandBuilderSubcommandAddOptionMethods>;
addUserOption(input: SlashCommandUserOption|((builder: SlashCommandUserOption) => SlashCommandUserOption)): SharedSlashCommandOptions<any> & Omit<this, SlashCommandBuilderSubcommandAddOptionMethods>;
addChannelOption(input: SlashCommandChannelOption|((builder: SlashCommandChannelOption) => SlashCommandChannelOption)): SharedSlashCommandOptions<any> & Omit<this, SlashCommandBuilderSubcommandAddOptionMethods>;
addRoleOption(input: SlashCommandRoleOption|((builder: SlashCommandRoleOption) => SlashCommandRoleOption)): SharedSlashCommandOptions<any> & Omit<this, SlashCommandBuilderSubcommandAddOptionMethods>;
addAttachmentOption(input: SlashCommandAttachmentOption|((builder: SlashCommandAttachmentOption) => SlashCommandAttachmentOption)): SharedSlashCommandOptions<any> & Omit<this, SlashCommandBuilderSubcommandAddOptionMethods>;
addMentionableOption(input: SlashCommandMentionableOption|((builder: SlashCommandMentionableOption) => SlashCommandMentionableOption)): SharedSlashCommandOptions<any> & Omit<this, SlashCommandBuilderSubcommandAddOptionMethods>;
addStringOption(input:
| SlashCommandStringOption
| Omit<SlashCommandStringOption, 'setAutocomplete'>
| Omit<SlashCommandStringOption, 'addChoices'>
| ((builder: SlashCommandStringOption) => SlashCommandStringOption | Omit<SlashCommandStringOption, 'setAutocomplete'> | Omit<SlashCommandStringOption, 'addChoices'>)
): Omit<this, SlashCommandBuilderSubcommandAddOptionMethods>;
): SharedSlashCommandOptions<any> & Omit<this, SlashCommandBuilderSubcommandAddOptionMethods>;
addIntegerOption(input:
| SlashCommandIntegerOption
| Omit<SlashCommandIntegerOption, 'setAutocomplete'>
| Omit<SlashCommandIntegerOption, 'addChoices'>
| ((builder: SlashCommandIntegerOption) => SlashCommandIntegerOption | Omit<SlashCommandIntegerOption, 'setAutocomplete'> | Omit<SlashCommandIntegerOption, 'addChoices'>)
): Omit<this, SlashCommandBuilderSubcommandAddOptionMethods>;
): SharedSlashCommandOptions<any> & Omit<this, SlashCommandBuilderSubcommandAddOptionMethods>;
addNumberOption(input:
| SlashCommandNumberOption
| Omit<SlashCommandNumberOption, 'setAutocomplete'>
| Omit<SlashCommandNumberOption, 'addChoices'>
| ((builder: SlashCommandNumberOption) => SlashCommandNumberOption | Omit<SlashCommandNumberOption, 'setAutocomplete'> | Omit<SlashCommandNumberOption, 'addChoices'>)
): Omit<this, SlashCommandBuilderSubcommandAddOptionMethods>;
): SharedSlashCommandOptions<any> & Omit<this, SlashCommandBuilderSubcommandAddOptionMethods>;
}

export class SlashCommandBuilder extends Mixin(DiscordJsSlashCommandBuilder, BaseCommandBuilder) {
Expand Down Expand Up @@ -105,7 +105,7 @@ export class SlashCommandBuilder extends Mixin(DiscordJsSlashCommandBuilder, Bas
}
}

public static addOption<Builder extends SharedSlashCommandOptions>(builder: Builder, option: AnySlashCommandOptionBuilder): Builder {
public static addOption<Builder extends SharedSlashCommandOptions<any>>(builder: Builder, option: AnySlashCommandOptionBuilder): Builder {
if (option instanceof SlashCommandAttachmentOption) {
builder.addAttachmentOption(option);
} else if (option instanceof SlashCommandBooleanOption) {
Expand Down
4 changes: 2 additions & 2 deletions packages/create-reciple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
},
"devDependencies": {
"@reciple/core": "^8.3.2",
"@types/node": "^20.12.7",
"discord.js": "^14.14.1",
"@types/node": "^20.12.11",
"discord.js": "^14.15.2",
"nodemon": "^3.1.0",
"reciple": "^8.3.2",
"rimraf": "^5.0.5",
Expand Down
4 changes: 2 additions & 2 deletions packages/docgen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
"access": "public"
},
"dependencies": {
"@discordjs/collection": "^2.0.0",
"@discordjs/collection": "^2.1.0",
"@reciple/utils": "^8.2.1",
"commander": "^12.0.0",
"typedoc": "^0.25.13",
"typedoc-json-parser": "^9.0.1"
"typedoc-json-parser": "^10.0.0"
}
}
4 changes: 2 additions & 2 deletions packages/reciple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@
"globby": "^14.0.1",
"micromatch": "^4.0.5",
"prompts": "^2.4.2",
"semver": "^7.6.0"
"semver": "^7.6.1"
},
"devDependencies": {
"@reciple/core": "^8.3.2",
"@types/micromatch": "^4.0.7",
"@types/semver": "^7.5.8",
"discord.js": "^14.14.1"
"discord.js": "^14.15.2"
},
"peerDependencies": {
"@reciple/core": "^8.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/update-checker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
},
"dependencies": {
"package-json": "^10.0.0",
"semver": "^7.6.0"
"semver": "^7.6.1"
},
"devDependencies": {
"@types/semver": "^7.5.8"
Expand Down
4 changes: 2 additions & 2 deletions packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
"access": "public"
},
"dependencies": {
"@discordjs/collection": "^2.0.0",
"@discordjs/collection": "^2.1.0",
"discord-api-types": "^0.37.83",
"dotenv": "^16.4.5",
"fallout-utility": "^2.8.0"
},
"devDependencies": {
"discord.js": "^14.14.1"
"discord.js": "^14.15.2"
}
}
6 changes: 3 additions & 3 deletions packages/utils/src/classes/ImageBase64Resolver.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Base64Resolvable, BufferResolvable, DiscordjsError, DiscordjsErrorCodes, DiscordjsTypeError, ResolvedFile } from 'discord.js';
import { Base64Resolvable, BufferResolvable, DiscordjsErrorCodes, ResolvedFile } from 'discord.js';
import { readFile, stat } from 'node:fs/promises';
import path from 'node:path';

Expand Down Expand Up @@ -41,10 +41,10 @@ export class ImageBase64 {
const file = path.resolve(resource);
const stats = await stat(file);

if (!stats.isFile()) throw new DiscordjsError(DiscordjsErrorCodes.FileNotFound, file);
if (!stats.isFile()) throw new Error(DiscordjsErrorCodes.FileNotFound, { cause: file });
return { data: await readFile(file) };
}

throw new DiscordjsTypeError(DiscordjsErrorCodes.ReqResourceType);
throw new Error(DiscordjsErrorCodes.ReqResourceType);
}
}
Loading