|
1 | 1 | ---
|
2 | 2 | title: '@commandkit/legacy'
|
3 | 3 | ---
|
| 4 | + |
| 5 | +:::danger |
| 6 | + |
| 7 | +This plugin is not recommended as we do not plan to continue |
| 8 | +supporting the legacy structure. We only recommend this if you're |
| 9 | +trying to incrementally upgrade your application. If you prefer the |
| 10 | +old way, you can use v0.1.10, but please note, that version is not |
| 11 | +actively maintained. |
| 12 | + |
| 13 | +::: |
| 14 | + |
| 15 | +The `@commandkit/legacy` plugin enables support for legacy command and |
| 16 | +event handlers. This is particularly useful when migrating from an |
| 17 | +older version of CommandKit or another framework, as it allows you to |
| 18 | +incrementally upgrade your application without requiring immediate |
| 19 | +major changes to your existing code. |
| 20 | + |
| 21 | +## Installation |
| 22 | + |
| 23 | +```sh npm2yarn |
| 24 | +npm install @commandkit/legacy |
| 25 | +``` |
| 26 | + |
| 27 | +## Usage |
| 28 | + |
| 29 | +Add the Legacy plugin to your CommandKit configuration: |
| 30 | + |
| 31 | +```js |
| 32 | +import { defineConfig } from 'commandkit'; |
| 33 | +import { legacy } from '@commandkit/legacy'; |
| 34 | + |
| 35 | +export default defineConfig({ |
| 36 | + plugins: [legacy()], |
| 37 | +}); |
| 38 | +``` |
| 39 | + |
| 40 | +## Features |
| 41 | + |
| 42 | +The Legacy plugin provides the following features: |
| 43 | + |
| 44 | +1. **Legacy Command Handler Support**: Enables support for older |
| 45 | + command handler formats, making migration easier. |
| 46 | + |
| 47 | +2. **Legacy Event Handler Support**: Allows you to continue using your |
| 48 | + existing event handler structure. |
| 49 | + |
| 50 | +3. **Legacy Validation Support**: Maintains compatibility with |
| 51 | + existing validation methods. |
| 52 | + |
| 53 | +4. **Hot Module Replacement (HMR)**: The plugin automatically enables |
| 54 | + HMR for legacy commands, events, and validations, improving the |
| 55 | + development experience by allowing you to see changes without |
| 56 | + restarting your bot. |
| 57 | + |
| 58 | +## Migration Strategy |
| 59 | + |
| 60 | +The Legacy plugin is designed as a transitional tool. While it allows |
| 61 | +you to continue using your existing code structure, it's recommended |
| 62 | +to gradually migrate your commands, events, and validators to the new |
| 63 | +CommandKit format over time. |
| 64 | + |
| 65 | +This approach enables you to: |
| 66 | + |
| 67 | +1. Upgrade your bot's framework immediately without breaking existing |
| 68 | + functionality |
| 69 | +2. Incrementally refactor your code at your own pace |
| 70 | +3. Take advantage of new CommandKit features for new commands while |
| 71 | + maintaining backward compatibility |
0 commit comments