Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: Snazzah/slash-create
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.5.0
Choose a base ref
...
head repository: Snazzah/slash-create
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v4.0.0
Choose a head ref
  • 8 commits
  • 46 files changed
  • 4 contributors

Commits on Aug 12, 2021

  1. Copy the full SHA
    34ea78e View commit details

Commits on Aug 14, 2021

  1. Copy the full SHA
    42adca2 View commit details
  2. chore(deps): expose yarn.lock

    closes #95
    Snazzah committed Aug 14, 2021
    Copy the full SHA
    3dfaced View commit details

Commits on Aug 16, 2021

  1. refactor: expose a lot of typings (#96)

    * refactor: expose a lot of typings
    
    * chore: fix line
    
    * chore: fix line
    
    * chore(lint): add bigint global
    
    Co-authored-by: Snazzah <[email protected]>
    fdasfsafsa and Snazzah authored Aug 16, 2021
    Copy the full SHA
    9d3f4a3 View commit details
  2. Copy the full SHA
    cba3060 View commit details
  3. patch(MessageInteraction): remove message reference on delete (#97)

    * patch(MessageInteraction): unref message state if  message is removed
    
    * method still returns empty string
    
    * patch: replace <req>.then with await <req>
    
    * ci: eslint (add correct endings and spacing)
    sudojunior authored Aug 16, 2021
    Copy the full SHA
    2096810 View commit details
  4. chore: remove deprecations

    Snazzah committed Aug 16, 2021
    Copy the full SHA
    6e5a7de View commit details
  5. release: v4.0.0

    Snazzah committed Aug 16, 2021
    Copy the full SHA
    0886ccd View commit details
Showing with 3,122 additions and 719 deletions.
  1. +1 −1 .github/workflows/lint.yml
  2. +0 −1 .gitignore
  3. +18 −1 CHANGELOG.md
  4. +1 −1 README.md
  5. +1 −1 package.json
  6. +3 −3 src/api.ts
  7. +64 −62 src/command.ts
  8. +9 −22 src/constants.ts
  9. +105 −105 src/creator.ts
  10. +1 −3 src/errors/DiscordHTTPError.ts
  11. +1 −3 src/errors/DiscordRESTError.ts
  12. +33 −138 src/index.ts
  13. +43 −45 src/server.ts
  14. +4 −6 src/servers/azure.ts
  15. +3 −5 src/servers/express.ts
  16. +3 −5 src/servers/fastify.ts
  17. +2 −4 src/servers/gateway.ts
  18. +4 −6 src/servers/gcf.ts
  19. +4 −6 src/servers/lambda.ts
  20. +2 −4 src/structures/channel.ts
  21. +9 −9 src/structures/interfaces/commandContext.ts
  22. +7 −9 src/structures/interfaces/componentContext.ts
  23. +47 −57 src/structures/interfaces/messageInteraction.ts
  24. +4 −6 src/structures/member.ts
  25. +117 −110 src/structures/message.ts
  26. +3 −7 src/structures/permissions.ts
  27. +3 −5 src/structures/resolvedMember.ts
  28. +2 −4 src/structures/role.ts
  29. +3 −5 src/structures/user.ts
  30. +3 −5 src/structures/userFlags.ts
  31. +17 −17 src/util.ts
  32. +2 −3 src/util/bitfield.ts
  33. +7 −7 src/util/lambdaHeaders.ts
  34. +1 −3 src/util/multipartData.ts
  35. +15 −17 src/util/requestHandler.ts
  36. +10 −12 src/util/sequentialBucket.ts
  37. +3 −5 src/util/typedEmitter.ts
  38. +3 −3 test/__util__/commands.ts
  39. +1 −1 test/__util__/constants.ts
  40. +4 −4 test/creator.ts
  41. +1 −1 test/structures/interfaces/commandContext.ts
  42. +2 −2 test/structures/interfaces/componentContext.ts
  43. +2 −2 test/structures/interfaces/messageInteraction.ts
  44. +2 −2 test/structures/message.ts
  45. +1 −1 test/structures/user.ts
  46. +2,551 −0 yarn.lock
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ on:
- ".eslintrc.*"
- ".prettierrc"
- ".github/workflows/lint.yml"
pull_request:
pull_request_target:
branches:
- "*"
- "!docs"
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Packages
node_modules/
yarn.lock

# Log files
logs/
19 changes: 18 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -5,6 +5,22 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [4.0.0] - 2021-08-16
### Removed:
- **ApplicationCommandOption:** removed deprecated `default` option
- Reorder the required options instead.
- **Permissions:** removed `MANAGE_EMOJIS` permission in favor of`MANAGE_EMOJIS_AND_STICKERS`
- **types:** removed `CommandOption` type
- **types:** removed `FollowUpMessageOptions` in favor of `MessageOptions`
### Changed:
- **types:** `RequestHandler` -> `ServerRequestHandler`
- **types:** `TypedEmitter` -> `TypedEventEmitter`
- **Permissions/UserFlags:** `FLAGS` constants from Permissions and UserFlags are hidden
- **index:** Almost everything is now properly exported to index
- All files are no longer using `default` for exporting
### Fixed:
- **MessageInteractionContext:** Deleting the original message de-references the message ID from the context ([#97](https://github.com/Snazzah/slash-create/pull/97))
- **ComponentContext:** Remove partial message parsing
## [3.5.0] - 2021-08-11
### Changed:
- **Permissions:** `MANAGE_EMOJIS` is now `MANAGE_EMOJIS_AND_STICKERS`, making the former deprecated.
@@ -292,7 +308,7 @@ This release features mostly completed documentation and changes to the packages
## [0.1.0] - 2020-12-15
- Initial release.

[Unreleased]: https://github.com/Snazzah/slash-create/compare/v3.5.0...HEAD
[Unreleased]: https://github.com/Snazzah/slash-create/compare/v4.0.0...HEAD
[0.1.0]: https://github.com/Snazzah/slash-create/releases/tag/v0.1.0
[0.2.0]: https://github.com/Snazzah/slash-create/compare/v0.1.0...v0.2.0
[1.0.0]: https://github.com/Snazzah/slash-create/compare/v0.2.0...v1.0.0
@@ -322,3 +338,4 @@ This release features mostly completed documentation and changes to the packages
[3.4.2]: https://github.com/Snazzah/slash-create/compare/v3.4.1...v3.4.2
[3.4.3]: https://github.com/Snazzah/slash-create/compare/v3.4.2...v3.4.3
[3.5.0]: https://github.com/Snazzah/slash-create/compare/v3.4.3...v3.5.0
[4.0.0]: https://github.com/Snazzah/slash-create/compare/v3.5.0...v4.0.0
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -57,7 +57,7 @@ In order to use a specific webserver, you will need to install the dependency as
- [Creating commands](https://slash-create.js.org/#/docs/main/latest/examples/command)

## Useful Links
- [**Discord Documentation on Slash Commands**](https://discord.com/developers/docs/interactions/slash-commands)
- [**Discord Documentation on Application Commands**](https://discord.com/developers/docs/interactions/application-commands)
- [Website](https://slash-create.js.org/) ([source](https://github.com/Snazzah/slash-create-website))
- [Documentation](https://slash-create.js.org/#/docs/main/latest/general/welcome)
- [Commands Template](https://github.com/Snazzah/slash-create-template)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "slash-create",
"version": "3.5.0",
"version": "4.0.0",
"description": "Creator and handler for Discord's slash commands",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
6 changes: 3 additions & 3 deletions src/api.ts
Original file line number Diff line number Diff line change
@@ -7,10 +7,10 @@ import {
PartialApplicationCommand,
PartialApplicationCommandPermissions
} from './constants';
import SlashCreator from './creator';
import { SlashCreator } from './creator';

/** The API handler for {@link SlashCreator}. */
class SlashCreatorAPI {
export class SlashCreatorAPI {
/** The parent creator. */
private readonly _creator: SlashCreator;

@@ -150,4 +150,4 @@ class SlashCreatorAPI {
}
}

export default SlashCreatorAPI;
export const API = SlashCreatorAPI;
126 changes: 64 additions & 62 deletions src/command.ts
Original file line number Diff line number Diff line change
@@ -5,71 +5,12 @@ import {
PartialApplicationCommand,
PermissionNames
} from './constants';
import CommandContext from './structures/interfaces/commandContext';
import SlashCreator from './creator';
import { CommandContext } from './structures/interfaces/commandContext';
import { SlashCreator } from './creator';
import { oneLine, validateOptions } from './util';

/** The options for a {@link SlashCommand}. */
export interface SlashCommandOptions {
/** The type of command this is. Defaults to chat input, or a regular slash command. */
type?: ApplicationCommandType;
/** The name of the command. */
name: string;
/** The description of the command. */
description?: string;
/** The guild ID(s) that this command will be assigned to. */
guildIDs?: string | string[];
/** The required permission(s) for this command. */
requiredPermissions?: Array<string>;
/** The command's options. */
options?: ApplicationCommandOption[];
/** The throttling options for the command. */
throttling?: ThrottlingOptions;
/** Whether this command is used for unknown commands. */
unknown?: boolean;
/** Whether responses from this command should defer ephemeral messages. */
deferEphemeral?: boolean;
/** Whether to enable this command for everyone by default. `true` by default. */
defaultPermission?: boolean;
/** The command permissions per guild */
permissions?: CommandPermissions;
}

/**
* The command permission for a {@link SlashCommand}.
* The object is a guild ID mapped to an array of {@link ApplicationCommandPermissions}.
* @example
* {
* '<guild_id>': [
* {
* type: ApplicationCommandPermissionType.USER,
* id: '<user_id>',
* permission: true
* }
* ]
* }
*/
export interface CommandPermissions {
[guildID: string]: ApplicationCommandPermissions[];
}

/** The throttling options for a {@link SlashCommand}. */
export interface ThrottlingOptions {
/** Maximum number of usages of the command allowed in the time frame. */
usages: number;
/** Amount of time to count the usages of the command within (in seconds). */
duration: number;
}

/** @private */
export interface ThrottleObject {
start: number;
usages: number;
timeout: any;
}

/** Represents a Discord slash command. */
export default class SlashCommand {
export class SlashCommand {
/** The command's name. */
readonly commandName: string;
/** The type of command this is. */
@@ -331,3 +272,64 @@ export default class SlashCommand {
}
}
}

export const Command = SlashCommand;

/** The options for a {@link SlashCommand}. */
export interface SlashCommandOptions {
/** The type of command this is. Defaults to chat input, or a regular slash command. */
type?: ApplicationCommandType;
/** The name of the command. */
name: string;
/** The description of the command. */
description?: string;
/** The guild ID(s) that this command will be assigned to. */
guildIDs?: string | string[];
/** The required permission(s) for this command. */
requiredPermissions?: Array<string>;
/** The command's options. */
options?: ApplicationCommandOption[];
/** The throttling options for the command. */
throttling?: ThrottlingOptions;
/** Whether this command is used for unknown commands. */
unknown?: boolean;
/** Whether responses from this command should defer ephemeral messages. */
deferEphemeral?: boolean;
/** Whether to enable this command for everyone by default. `true` by default. */
defaultPermission?: boolean;
/** The command permissions per guild */
permissions?: CommandPermissions;
}

/**
* The command permission for a {@link SlashCommand}.
* The object is a guild ID mapped to an array of {@link ApplicationCommandPermissions}.
* @example
* {
* '<guild_id>': [
* {
* type: ApplicationCommandPermissionType.USER,
* id: '<user_id>',
* permission: true
* }
* ]
* }
*/
export interface CommandPermissions {
[guildID: string]: ApplicationCommandPermissions[];
}

/** The throttling options for a {@link SlashCommand}. */
export interface ThrottlingOptions {
/** Maximum number of usages of the command allowed in the time frame. */
usages: number;
/** Amount of time to count the usages of the command within (in seconds). */
duration: number;
}

/** @private */
export interface ThrottleObject {
start: number;
usages: number;
timeout: any;
}
31 changes: 9 additions & 22 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { IncomingMessage } from 'http';
import SlashCommand from './command';
import CommandContext from './structures/interfaces/commandContext';
import SlashCreator from './creator';
import { SlashCommand } from './command';
import { CommandContext } from './structures/interfaces/commandContext';
import { SlashCreator } from './creator';
import { RespondFunction, TransformedRequest } from './server';
import ComponentContext from './structures/interfaces/componentContext';
import { ComponentContext } from './structures/interfaces/componentContext';
import { MessageData } from './structures/message';
import { version } from '../package.json';

export const VERSION: string = version;

export const API_VERSION = 8;
export const INTERACTION_VERSION = 1;
@@ -129,11 +132,6 @@ export interface ApplicationCommandOptionBase {
name: string;
/** The description of the option. */
description: string;
/**
* The first required option the user has to complete.
* @deprecated Reorder the required options instead.
*/
default?: boolean;
/** Whether the parameter is required. */
required?: boolean;
}
@@ -294,7 +292,7 @@ export interface DMMessageComponentRequestData {
version: 1;
type: InteractionType.MESSAGE_COMPONENT;
token: string;
message: MessageData | PartialMessage;
message: MessageData;
id: string;
channel_id: string;
user: CommandUser;
@@ -313,7 +311,7 @@ export interface GuildMessageComponentRequestData {
version: 1;
type: InteractionType.MESSAGE_COMPONENT;
token: string;
message: MessageData | PartialMessage;
message: MessageData;
id: string;
channel_id: string;
guild_id: string;
@@ -407,17 +405,6 @@ export type AnyCommandOption =
| CommandBooleanOption
| CommandSubcommandOption;

/**
* @private
* @deprecated
*/
export interface CommandOption {
/** The name for the option. */
name: string;
type?: CommandOptionType;
value?: string | number | boolean;
}

/** @private */
export interface CommandStringOption {
/** The name for the option. */
Loading