Skip to content

Commit

Permalink
chore(builders): add attachment option tests
Browse files Browse the repository at this point in the history
  • Loading branch information
amitojsingh366 authored and iCrawl committed Feb 13, 2022
1 parent de84599 commit a1f7191
Show file tree
Hide file tree
Showing 10 changed files with 720 additions and 678 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
},
"homepage": "https://discord.js.org",
"devDependencies": {
"@commitlint/cli": "^16.1.0",
"@commitlint/config-angular": "^16.0.0",
"@commitlint/cli": "^16.2.1",
"@commitlint/config-angular": "^16.2.1",
"@favware/npm-deprecate": "^1.0.4",
"conventional-changelog-cli": "^2.2.2",
"husky": "^7.0.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
SlashCommandMentionableOption,
SlashCommandNumberOption,
SlashCommandRoleOption,
SlashCommandAttachmentOption,
SlashCommandStringOption,
SlashCommandSubcommandBuilder,
SlashCommandSubcommandGroupBuilder,
Expand All @@ -25,6 +26,7 @@ const getBooleanOption = () => new SlashCommandBooleanOption().setName('owo').se
const getUserOption = () => new SlashCommandUserOption().setName('owo').setDescription('Testing 123');
const getChannelOption = () => new SlashCommandChannelOption().setName('owo').setDescription('Testing 123');
const getRoleOption = () => new SlashCommandRoleOption().setName('owo').setDescription('Testing 123');
const getAttachmentOption = () => new SlashCommandAttachmentOption().setName('owo').setDescription('Testing 123');
const getMentionableOption = () => new SlashCommandMentionableOption().setName('owo').setDescription('Testing 123');
const getSubcommandGroup = () => new SlashCommandSubcommandGroupBuilder().setName('owo').setDescription('Testing 123');
const getSubcommand = () => new SlashCommandSubcommandBuilder().setName('owo').setDescription('Testing 123');
Expand Down Expand Up @@ -286,6 +288,8 @@ describe('Slash Commands', () => {

expect(() => getBuilder().addRoleOption(getRoleOption())).not.toThrowError();

expect(() => getBuilder().addAttachmentOption(getAttachmentOption())).not.toThrowError();

expect(() => getBuilder().addMentionableOption(getMentionableOption())).not.toThrowError();
});

Expand Down
20 changes: 10 additions & 10 deletions packages/builders/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,27 +52,27 @@
"homepage": "https://discord.js.org",
"dependencies": {
"@sindresorhus/is": "^4.4.0",
"discord-api-types": "^0.26.1",
"discord-api-types": "^0.27.0",
"ts-mixer": "^6.0.0",
"tslib": "^2.3.1",
"zod": "^3.11.6"
},
"devDependencies": {
"@babel/core": "^7.17.0",
"@babel/plugin-proposal-decorators": "^7.17.0",
"@babel/core": "^7.17.2",
"@babel/plugin-proposal-decorators": "^7.17.2",
"@babel/preset-env": "^7.16.11",
"@babel/preset-typescript": "^7.16.5",
"@babel/preset-typescript": "^7.16.7",
"@discordjs/ts-docgen": "^0.3.4",
"@types/jest": "^27.0.3",
"@types/node": "^16.11.6",
"@typescript-eslint/eslint-plugin": "^5.10.2",
"@typescript-eslint/parser": "^5.10.2",
"@types/jest": "^27.4.0",
"@types/node": "^16.11.24",
"@typescript-eslint/eslint-plugin": "^5.11.0",
"@typescript-eslint/parser": "^5.11.0",
"babel-plugin-transform-typescript-metadata": "^0.3.2",
"eslint": "^8.8.0",
"eslint": "^8.9.0",
"eslint-config-marine": "^9.3.2",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"jest": "^27.4.7",
"jest": "^27.5.1",
"prettier": "^2.5.1",
"tsup": "^5.11.13",
"typedoc": "^0.22.11",
Expand Down
4 changes: 2 additions & 2 deletions packages/builders/src/components/ActionRow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class ActionRow<T extends ActionRowComponent = ActionRowComponent> implem
public readonly components: T[] = [];
public readonly type = ComponentType.ActionRow;

public constructor(data?: APIActionRowComponent & { type?: ComponentType.ActionRow }) {
public constructor(data?: APIActionRowComponent<T> & { type?: ComponentType.ActionRow }) {
this.components = (data?.components.map(createComponent) ?? []) as T[];
}

Expand All @@ -39,7 +39,7 @@ export class ActionRow<T extends ActionRowComponent = ActionRowComponent> implem
return this;
}

public toJSON(): APIActionRowComponent {
public toJSON(): APIActionRowComponent<T> {
return {
...this,
components: this.components.map((component) => component.toJSON()),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { ApplicationCommandOptionType } from 'discord-api-types/v9';
import { SlashCommandOptionBase } from '../mixins/CommandOptionBase';
import { APIApplicationCommandAttachmentOption, ApplicationCommandOptionType } from 'discord-api-types/v9';
import { ApplicationCommandOptionBase } from '../mixins/ApplicationCommandOptionBase';

export class SlashCommandAttachmentOption extends SlashCommandOptionBase {
export class SlashCommandAttachmentOption extends ApplicationCommandOptionBase {
public override readonly type = ApplicationCommandOptionType.Attachment as const;

public constructor() {
super(ApplicationCommandOptionType.Attachment);
public toJSON(): APIApplicationCommandAttachmentOption {
this.runRequiredValidations();

return { ...this };
}
}
}
16 changes: 8 additions & 8 deletions packages/collection/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,19 @@
},
"homepage": "https://discord.js.org",
"devDependencies": {
"@babel/core": "^7.17.0",
"@babel/core": "^7.17.2",
"@babel/preset-env": "^7.16.11",
"@babel/preset-typescript": "^7.16.5",
"@babel/preset-typescript": "^7.16.7",
"@discordjs/ts-docgen": "^0.3.4",
"@types/jest": "^27.0.3",
"@types/node": "^16.11.6",
"@typescript-eslint/eslint-plugin": "^5.10.2",
"@typescript-eslint/parser": "^5.10.2",
"eslint": "^8.8.0",
"@types/jest": "^27.4.0",
"@types/node": "^16.11.24",
"@typescript-eslint/eslint-plugin": "^5.11.0",
"@typescript-eslint/parser": "^5.11.0",
"eslint": "^8.9.0",
"eslint-config-marine": "^9.3.2",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"jest": "^27.4.7",
"jest": "^27.5.1",
"prettier": "^2.5.1",
"tsup": "^5.11.13",
"typedoc": "^0.22.11",
Expand Down
12 changes: 6 additions & 6 deletions packages/discord.js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,23 @@
"@discordjs/rest": "workspace:^",
"@sapphire/snowflake": "^3.1.0",
"@types/ws": "^8.2.2",
"discord-api-types": "^0.26.1",
"discord-api-types": "^0.27.0",
"node-fetch": "^2.6.7",
"ws": "^8.4.2"
"ws": "^8.5.0"
},
"devDependencies": {
"@discordjs/docgen": "^0.11.0",
"@types/node": "^16.11.12",
"@types/node": "^16.11.24",
"dtslint": "^4.2.1",
"eslint": "^8.8.0",
"eslint": "^8.9.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-prettier": "^4.0.0",
"husky": "^7.0.4",
"is-ci": "^3.0.1",
"jest": "^27.4.7",
"jest": "^27.5.1",
"prettier": "^2.5.1",
"tsd": "^0.19.0",
"tsd": "^0.19.1",
"tslint": "^6.1.3",
"typescript": "^4.5.5"
},
Expand Down
14 changes: 7 additions & 7 deletions packages/rest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,27 +53,27 @@
"@sapphire/async-queue": "^1.2.0",
"@sapphire/snowflake": "^3.1.0",
"@types/node-fetch": "^2.5.12",
"discord-api-types": "^0.26.1",
"discord-api-types": "^0.27.0",
"form-data": "^4.0.0",
"node-fetch": "^2.6.7",
"tslib": "^2.3.1"
},
"devDependencies": {
"@babel/core": "^7.17.0",
"@babel/plugin-proposal-decorators": "^7.17.0",
"@babel/core": "^7.17.2",
"@babel/plugin-proposal-decorators": "^7.17.2",
"@babel/preset-env": "^7.16.11",
"@babel/preset-typescript": "^7.16.7",
"@discordjs/ts-docgen": "^0.3.4",
"@types/jest": "^27.4.0",
"@typescript-eslint/eslint-plugin": "^5.10.2",
"@typescript-eslint/parser": "^5.10.2",
"@typescript-eslint/eslint-plugin": "^5.11.0",
"@typescript-eslint/parser": "^5.11.0",
"babel-plugin-const-enum": "^1.2.0",
"babel-plugin-transform-typescript-metadata": "^0.3.2",
"eslint": "^8.8.0",
"eslint": "^8.9.0",
"eslint-config-marine": "^9.3.2",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"jest": "^27.4.7",
"jest": "^27.5.1",
"nock": "^13.2.4",
"prettier": "^2.5.1",
"tsup": "^5.11.13",
Expand Down
26 changes: 13 additions & 13 deletions packages/voice/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,30 +49,30 @@
},
"homepage": "https://discord.js.org",
"dependencies": {
"@types/ws": "^8.2.0",
"discord-api-types": "^0.26.1",
"@types/ws": "^8.2.2",
"discord-api-types": "^0.27.0",
"prism-media": "^1.3.2",
"tiny-typed-emitter": "^2.1.0",
"tslib": "^2.3.1",
"ws": "^8.4.2"
"ws": "^8.5.0"
},
"devDependencies": {
"@babel/core": "^7.17.0",
"@babel/core": "^7.17.2",
"@babel/preset-env": "^7.16.11",
"@babel/preset-typescript": "^7.16.0",
"@discordjs/ts-docgen": "^0.3.2",
"@types/jest": "^27.0.2",
"@types/node": "^16.11.7",
"@typescript-eslint/eslint-plugin": "^5.10.2",
"@typescript-eslint/parser": "^5.10.2",
"eslint": "^8.8.0",
"@babel/preset-typescript": "^7.16.7",
"@discordjs/ts-docgen": "^0.3.4",
"@types/jest": "^27.4.0",
"@types/node": "^16.11.24",
"@typescript-eslint/eslint-plugin": "^5.11.0",
"@typescript-eslint/parser": "^5.11.0",
"eslint": "^8.9.0",
"eslint-config-marine": "^9.3.2",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"jest": "^27.4.7",
"jest": "^27.5.1",
"jest-websocket-mock": "^2.3.0",
"mock-socket": "^9.1.2",
"prettier": "^2.4.1",
"prettier": "^2.5.1",
"tsup": "^5.11.13",
"tweetnacl": "^1.0.3",
"typedoc": "^0.22.11",
Expand Down

0 comments on commit a1f7191

Please sign in to comment.