Skip to content

Commit

Permalink
feat(*): update to discord.js v13.7.0 (#431)
Browse files Browse the repository at this point in the history
Co-authored-by: Jeroen Claassens <support@favware.tech>
  • Loading branch information
vladfrangu and favna committed May 15, 2022
1 parent bf1374b commit b2d34bd
Show file tree
Hide file tree
Showing 16 changed files with 1,427 additions and 1,568 deletions.
5 changes: 5 additions & 0 deletions .cliff-jumperrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: framework
packagePath: .
org: sapphire
monoRepo: false
commitMessageTemplate: 'chore(release): release {{new-version}}'
11 changes: 6 additions & 5 deletions .github/workflows/continuous-delivery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,19 @@ jobs:
with:
node-version: 16
cache: yarn
registry-url: https://registry.npmjs.org/
registry-url: https://registry.yarnpkg.com/
- name: Install Dependencies
run: yarn --immutable
- name: Bump Version & Publish
run: |
# Resolve the tag to be used. "next" for push events, "pr-{prNumber}" for dispatch events.
TAG=$([[ ${{ github.event_name }} == 'push' ]] && echo 'next' || echo 'pr-${{ github.event.inputs.prNumber }}')
# Bump the version
yarn standard-version --skip.commit --skip.tag --prerelease "${TAG}.$(git rev-parse --verify --short HEAD)"
yarn config set npmAuthToken ${NODE_AUTH_TOKEN}
yarn config set npmPublishRegistry "https://registry.yarnpkg.com"
# Publish to NPM
npm publish --tag ${TAG} || true
yarn bump --preid "${TAG}.$(git rev-parse --verify --short HEAD)"
yarn npm publish --tag ${TAG}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
785 changes: 0 additions & 785 deletions .yarn/releases/yarn-3.2.0.cjs

This file was deleted.

786 changes: 786 additions & 0 deletions .yarn/releases/yarn-3.2.1.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: '@yarnpkg/plugin-interactive-tools'

yarnPath: .yarn/releases/yarn-3.2.0.cjs
yarnPath: .yarn/releases/yarn-3.2.1.cjs
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changelog

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
All notable changes to this project will be documented in this file.

## [2.4.0](https://github.com/sapphiredev/framework/compare/v2.3.0...v2.4.0) (2022-02-05)

Expand Down
64 changes: 64 additions & 0 deletions cliff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
[changelog]
header = """
# Changelog
All notable changes to this project will be documented in this file.\n
"""
body = """
{% if version %}\
# [{{ version | trim_start_matches(pat="v") }}]\
{% if previous %}\
{% if previous.version %}\
(https://github.com/sapphiredev/framework/compare/{{ previous.version }}...{{ version }})\
{% else %}
(https://github.com/sapphiredev/framework/tree/{{ version }})\
{% endif %}\
{% endif %} \
- ({{ timestamp | date(format="%Y-%m-%d") }})
{% else %}\
# [unreleased]
{% endif %}\
{% for group, commits in commits | group_by(attribute="group") %}
## {{ group | upper_first }}
{% for commit in commits %}
- {% if commit.scope %}\
**{{commit.scope}}:** \
{% endif %}\
{{ commit.message | upper_first }} ([{{ commit.id | truncate(length=7, end="") }}](https://github.com/sapphiredev/framework/commit/{{ commit.id }}))\
{% if commit.breaking %}\
\n\n {% raw %} {% endraw %} ### 💥 Breaking Changes:\n \
{% for breakingChange in commit.footers %}\
{% raw %} {% endraw %} - {{ breakingChange }}\n\
{% endfor %}\
{% endif %}\
{% endfor %}
{% endfor %}\n
"""
trim = true
footer = ""

[git]
conventional_commits = true
filter_unconventional = true
commit_parsers = [
{ message = "^feat", group = "🚀 Features"},
{ message = "^fix", group = "🐛 Bug Fixes"},
{ message = "^docs", group = "📝 Documentation"},
{ message = "^perf", group = "🏃 Performance"},
{ message = "^refactor", group = "🏠 Refactor"},
{ message = "^typings", group = "⌨️ Typings"},
{ message = "^types", group = "⌨️ Typings"},
{ message = ".*deprecated", body = ".*deprecated", group = "🚨 Deprecation"},
{ message = "^revert", skip = true},
{ message = "^style", group = "🪞 Styling"},
{ message = "^test", group = "🧪 Testing"},
{ message = "^chore", skip = true},
{ message = "^ci", skip = true},
{ message = "^build", skip = true},
{ body = ".*security", group = "🛡️ Security"},
]
filter_commits = true
tag_pattern = "v[0-9]*"
ignore_tags = ""
topo_order = false
sort_commits = "newest"
40 changes: 21 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,24 @@
"license": "MIT",
"scripts": {
"lint": "eslint src tests scripts --ext mjs,ts --fix",
"format": "prettier --write {src,tests,scripts}/**/*.ts",
"format": "prettier --write \"{src,tests,scripts}/**/*.ts\"",
"docs": "typedoc",
"test": "jest",
"test:watch": "jest --watch",
"update": "yarn up \"*\" -i",
"update": "yarn upgrade-interactive",
"clean": "node scripts/clean-dist.mjs",
"build": "tsc -b src && rollup -c scripts/rollup.bundle.ts && gen-esm-wrapper dist/index.js dist/index.mjs",
"watch": "tsc -b src -w",
"sversion": "standard-version",
"commit": "git-cz",
"cz": "git-cz",
"prepublishOnly": "rollup-type-bundler -v -e url events",
"prepare": "husky install .github/husky"
"bump": "cliff-jumper",
"check-update": "cliff-jumper --dry-run",
"postinstall": "husky install .github/husky",
"prepack": "rollup-type-bundler -v -e url events && pinst --disable",
"postpack": "pinst --enable"
},
"dependencies": {
"@sapphire/discord-utilities": "^2.10.3",
"@sapphire/discord.js-utilities": "^4.10.0",
"@sapphire/pieces": "^3.3.1",
"@sapphire/discord.js-utilities": "^4.11.0",
"@sapphire/pieces": "^3.3.3",
"@sapphire/ratelimits": "^2.4.4",
"@sapphire/result": "^1.1.1",
"@sapphire/stopwatch": "^1.4.1",
Expand All @@ -39,32 +39,33 @@
"tslib": "^2.4.0"
},
"devDependencies": {
"@commitlint/cli": "^16.2.4",
"@commitlint/cli": "^16.3.0",
"@commitlint/config-conventional": "^16.2.4",
"@favware/cliff-jumper": "^1.8.0",
"@favware/npm-deprecate": "^1.0.4",
"@favware/rollup-type-bundler": "^1.0.7",
"@sapphire/eslint-config": "^4.3.4",
"@sapphire/eslint-config": "^4.3.5",
"@sapphire/prettier-config": "^1.4.3",
"@sapphire/ts-config": "^3.3.4",
"@types/jest": "^27.5.0",
"@types/node": "^17.0.31",
"@types/jest": "^27.5.1",
"@types/node": "^17.0.33",
"@types/ws": "^8.5.3",
"@typescript-eslint/eslint-plugin": "^5.23.0",
"@typescript-eslint/parser": "^5.23.0",
"cz-conventional-changelog": "^3.3.0",
"discord.js": "^13.6.0",
"discord.js": "^13.7.0",
"eslint": "^8.15.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.0.0",
"gen-esm-wrapper": "^1.1.3",
"husky": "^8.0.1",
"jest": "^28.1.0",
"lint-staged": "^12.4.1",
"pinst": "^3.0.0",
"prettier": "^2.6.2",
"pretty-quick": "^3.1.3",
"rollup": "^2.72.1",
"rollup": "^2.73.0",
"rollup-plugin-version-injector": "^1.3.3",
"standard-version": "^9.3.2",
"ts-jest": "^28.0.2",
"typedoc": "^0.22.15",
"typedoc-plugin-djs-links": "^1.0.4",
Expand All @@ -76,8 +77,9 @@
"url": "git+https://github.com/sapphiredev/framework.git"
},
"files": [
"dist",
"!dist/*.tsbuildinfo"
"dist/**/*.js*",
"dist/**/*.mjs*",
"dist/**/*.d*"
],
"engines": {
"node": ">=16.6.0",
Expand Down Expand Up @@ -117,5 +119,5 @@
"minimist": "^1.2.6"
},
"prettier": "@sapphire/prettier-config",
"packageManager": "yarn@3.2.0"
"packageManager": "yarn@3.2.1"
}
21 changes: 18 additions & 3 deletions src/lib/structures/Command.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { AliasPiece, AliasPieceJSON, AliasStore, PieceContext } from '@sapphire/pieces';
import { Awaitable, isNullish, NonNullObject } from '@sapphire/utilities';
import type { LocalizationMap } from 'discord-api-types/v9';
import {
AutocompleteInteraction,
CommandInteraction,
Expand Down Expand Up @@ -236,7 +237,13 @@ export class Command<PreParseReturn = Args, O extends Command.Options = Command.
builder.setDefaultPermission(this.chatInputCommandOptions.defaultPermission!);
}

return builder;
if (this.chatInputCommandOptions.nameLocalizations) {
builder.setNameLocalizations(this.chatInputCommandOptions.nameLocalizations);
}

if (this.chatInputCommandOptions.descriptionLocalizations) {
builder.setDescriptionLocalizations(this.chatInputCommandOptions.descriptionLocalizations);
}
},
{
behaviorWhenNotIdentical: this.chatInputCommandOptions.behaviorWhenNotIdentical,
Expand Down Expand Up @@ -270,7 +277,7 @@ export class Command<PreParseReturn = Args, O extends Command.Options = Command.
}

/**
* Type-guard that ensures the command supports handling autocompletes by checking if the handler for it is present
* Type-guard that ensures the command supports handling autocomplete interactions by checking if the handler for it is present
*/
public supportsAutocompleteInteractions(): this is AutocompleteCommand {
return Reflect.has(this, 'autocompleteRun');
Expand Down Expand Up @@ -763,11 +770,19 @@ export interface CommandChatInputRegisterShortcut {
*
* :::warn
*
* This will be deprecated in the future for Discord's new permission system
* This will be deprecated in the future for Discord's new permission system.
*
* :::
*/
defaultPermission?: boolean;
/**
* Sets the `nameLocalizations` for the chat input command
*/
nameLocalizations?: LocalizationMap;
/**
* Sets the `descriptionLocalizations` for the chat input command
*/
descriptionLocalizations?: LocalizationMap;
}

export interface MessageCommandContext extends Record<PropertyKey, unknown> {
Expand Down
1 change: 1 addition & 0 deletions src/lib/structures/InteractionHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export const enum InteractionHandlerTypes {
// Specifically focused types
Button = 'BUTTON',
SelectMenu = 'SELECT_MENU',
ModalSubmit = 'MODAL_SUBMIT',

// More free-falling handlers, for 1 shared handler between buttons and select menus (someone will have a use for this >,>)
MessageComponent = 'MESSAGE_COMPONENT',
Expand Down
1 change: 1 addition & 0 deletions src/lib/structures/InteractionHandlerStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export class InteractionHandlerStore extends Store<InteractionHandler> {
export const InteractionHandlerFilters = new Map<InteractionHandlerTypes, (interaction: Interaction) => boolean>([
[InteractionHandlerTypes.Button, (interaction) => interaction.isButton()],
[InteractionHandlerTypes.SelectMenu, (interaction) => interaction.isSelectMenu()],
[InteractionHandlerTypes.ModalSubmit, (interaction) => interaction.isModalSubmit()],

[InteractionHandlerTypes.MessageComponent, (interaction) => interaction.isMessageComponent()],
[InteractionHandlerTypes.Autocomplete, (Interaction) => Interaction.isAutocomplete()]
Expand Down
13 changes: 4 additions & 9 deletions src/lib/utils/application-commands/ApplicationCommandRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,7 @@ export class ApplicationCommandRegistry {
| SlashCommandSubcommandsOnlyBuilder
| SlashCommandOptionsOnlyBuilder
| Omit<SlashCommandBuilder, 'addSubcommand' | 'addSubcommandGroup'>
| ((
builder: SlashCommandBuilder
) =>
| SlashCommandBuilder
| SlashCommandSubcommandsOnlyBuilder
| SlashCommandOptionsOnlyBuilder
| Omit<SlashCommandBuilder, 'addSubcommand' | 'addSubcommandGroup'>),
| ((builder: SlashCommandBuilder) => unknown),
options?: ApplicationCommandRegistryRegisterOptions
) {
const builtData = normalizeChatInputCommand(command);
Expand All @@ -80,7 +74,7 @@ export class ApplicationCommandRegistry {
| UserApplicationCommandData
| MessageApplicationCommandData
| ContextMenuCommandBuilder
| ((builder: ContextMenuCommandBuilder) => ContextMenuCommandBuilder),
| ((builder: ContextMenuCommandBuilder) => unknown),
options?: ApplicationCommandRegistryRegisterOptions
) {
const builtData = normalizeContextMenuCommand(command);
Expand Down Expand Up @@ -405,6 +399,7 @@ export class ApplicationCommandRegistry {
guildId?: string
) {
try {
// @ts-expect-error Currently there's a discord-api-types version clash between builders and discord.js
const result = await commandsManager.create(apiData, guildId);

this.info(
Expand Down Expand Up @@ -467,7 +462,7 @@ export namespace ApplicationCommandRegistry {
registerCommandIfMissing?: boolean;
/**
* Specifies what we should do when the command is present, but not identical with the data you provided
* @default `ApplicationCommandRegistries.getDefaultBehaviorWhenNotIdentical`
* @default `ApplicationCommandRegistries.getDefaultBehaviorWhenNotIdentical()`
*/
behaviorWhenNotIdentical?: RegisterBehavior;
/**
Expand Down
Loading

0 comments on commit b2d34bd

Please sign in to comment.