Skip to content

Commit

Permalink
feat: support new options structure !!BREAKING CHANGES (#12)
Browse files Browse the repository at this point in the history
* feat: support new options structure

Introduce a new structure for the manager's options
Fixes #10

* docs: update example's options & remove some errorMessages

* fix: options not being stored in the manager

* refactor: use string enum

* fix: import ErrorMessage should be default

* fix: typo

* chore: properly increase package version

Due to breaking changes in this new version, a major release is necessary

* use coma instead of semicolon

* chore: add build workflow

* fix: properly export ErrorMessages enum
  • Loading branch information
HunteRoi authored Mar 17, 2023
1 parent 1418c36 commit 40e149e
Show file tree
Hide file tree
Showing 45 changed files with 872 additions and 857 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Build

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:
concurrency: ci-${{ github.ref }}

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x]

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- run: yarn install --frozen-lockfile
- run: yarn build
104 changes: 5 additions & 99 deletions BREAKING_CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,105 +1,11 @@
# Breaking Changes

## Support for Discord.js v14
## Rework of the entire options parameter

The entire library has been ported to djs v14.
The option parameter is now fully supporting different guilds. The changes made are structural but some renaming also occured.

## MailboxManager class
It is strongly advised to revise the entire options you are passing to the manager and restructure it with the new type accessible [here](./src/types/ManagerOptions.ts).

The mailbox manager becomes a real tickets manager. It now only handles user tickets.

## Format Title parameter

The `options#formatTitle` method does not take the id as a parameter anymore, but directly relies on a [Ticket](./src/types/Ticket.ts) instance.

```ts
// before
function formatTitle(id: string): string {
return `Ticket ${id}`;
}

// after
function formatTitle(ticket: Ticket, guild: Guild): string {
return `Ticket ${ticket.id} - ${guild.name}`;
}
```

## ticketDelete event disappears

This event was initially created to let the user know a ticket has been internally deleted but this information should not be shared outside the system through a different event than `ticketClose`.
It has thus been removed.

## loggingOptions#format Changes

The format function supposed to format each message of a ticket has changed. The whole signature actually got updated:
```ts
// before

loggingOptions: {
...
format: (message: Message) => `${message.author.username} sent: ${message.cleanContent}`,
...
}

// after
loggingOptions: {
...
generateLogEntry: (ticketContent: TicketContent) => `${ticketContent.author.username} sent: ${ticketContent.cleanContent}`,
...
}
```

## loggingOptions#showNames Rename

The `showName` property of the logging options has been renamed to `showSenderNames` for more clarity on its meaning.

## options#closeTicketAfter Unit Change

The `closeTicketAfter` was initially in seconds. It is now in milliseconds.

## options#closeTicketAfter Rename

The `closeTicketAfter` property of the options has been renamed to `closeTicketAfterInMilliseconds` for more clarity on its unit.

## options#notAllowedToPing Removal

The `notAllowedToPing` property of the options has been removed. You should handle this using your client's options (property is called `allowedMentions`).

## options#autoReplyMessage Removal

The `autoReplyMessage` property of the options has been removed. You should use `ticketCreate` event to handle such side-effect.

## options#replyMessageInFooter Removal

The `replyMessageInFooter` property of the options has been removed. The footer is forced.

## options#ticketClose Removal

The `ticketClose` property of the options has been removed. You should use `ticketClose` event to handle such side-effect.

## embedOptions#send Removal

The `send` property of the embed options has been removed. Once an EmbedOptions object is found, the embed feature is used instead of standard messages.

## options#deleteReplies Removal

The `deleteReplies` property of the options has been removed. It actually is misleading to end users (staff members responding to messages).
If you want to still use it, you can perform the same action through the `replySent` event.

## replyDelete event disappears

This event was initially created to let the user know a replt has been deleted but the deletion behaviour has ben removed so thus event has no purpose anymore.
It has thus been removed.

## options#sendToRecipient Removal

The `sendToRecipient` property of the options has been removed. Indeed, users have the fundamental right to receive and keep a copy of the conversation with anyone.

## options#mailboxChannel Removal

The `mailboxChannel` property has been removed in profit of a `mailboxChannels` property to enable the management of several guilds by a single manager.

## options#loggingOptions#channel Removal

The `channel` property of the `loggingOptions` property has been removed in profit of a `channels` property to enable the management of several guilds by a single manager.
## Error messages have now error codes

The error messages now have error codes from 001 to 0006. You can inspect these directly [in the source code](./src/ErrorMessages.ts).
20 changes: 4 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,29 +47,17 @@ manager.on(MailboxManagerEvents.ticketLog, (ticket: Ticket) => {});

manager.on(MailboxManagerEvents.ticketClose, (ticket: Ticket) => {});

manager.on(
MailboxManagerEvents.ticketForceClose,
(ticket: Ticket, user: User | PartialUser) => {}
);
manager.on(MailboxManagerEvents.ticketForceClose, (ticket: Ticket, user: User | PartialUser) => {});

manager.on(MailboxManagerEvents.ticketDelete, (ticket: Ticket) => {});

manager.on(
MailboxManagerEvents.replySent,
(message: Message, answer: Message) => {}
);
manager.on(MailboxManagerEvents.replySent, (message: Message, answer: Message) => {});

manager.on(MailboxManagerEvents.replyDelete, (message: Message) => {});

manager.on(
MailboxManagerEvents.threadCreate,
(ticket: Ticket, thread: ThreadChannel) => {}
);
manager.on(MailboxManagerEvents.threadCreate, (ticket: Ticket, thread: ThreadChannel) => {});

manager.on(
MailboxManagerEvents.threadArchive,
(ticket: Ticket, thread: ThreadChannel) => {}
);
manager.on(MailboxManagerEvents.threadArchive, (ticket: Ticket, thread: ThreadChannel) => {});
```

## Contribution
Expand Down
2 changes: 1 addition & 1 deletion docs/api-docs/assets/search.js

Large diffs are not rendered by default.

Loading

0 comments on commit 40e149e

Please sign in to comment.