# Basic Plugin

## Step 1

We need a separate file for your own plugin, let's make one! say, `MyPlugin.js` this should come under the directory name `plugins` .\
\
Now we import the plugin class to model our plugin from `#disclosure/Plugin`&#x20;

```javascript
import { Plugin } from '#disclosure/Plugin';
```

## Step 2

We create our custom plugin class extended from the Plugin class and then set it as the default export.

```javascript
// ..

export default class MyPlugin extends Plugin {

}
```

## Step 3

We pass the plugin's metadata into this class so disclosure can destructure it and recognize it as a valid plugin

```javascript
// ..

export default class MyPlugin extends Plugin {
    constructor(client: any) {
        super(client, {
	    metadata: {
                name: 'MyPlugin',
                description: 'My Awesome Plugin',
		version: '1.0.0',
		author: ['YourNameHere'],
            },
            configuration: {},
	});
    }
}

// ..
```

## Step 4

All ready! Now we can use various functions available to this class, for example, the `onLoad` event for slash commands.

```javascript
// ..

    onLoad() {
        this.addCommand(
            (builder) =>
                builder
                    .setName('ping')
                    .setDescription('Simple Ping Command.'),
	    (interaction) => {
                interaction.reply(`Pong!`);
	    },
        );
    }

// ..
```

That's it! start your bot application to try it out.

## Resulting Code

```javascript
import { Plugin } from '#disclosure/Plugin';

export default class MyPlugin extends Plugin {
    constructor(client: any) {
        super(client, {
	    metadata: {
                name: 'MyPlugin',
                description: 'My Awesome Plugin',
		version: '1.0.0',
		author: ['YourNameHere'],
            },
            configuration: {},
	});
    }

    onLoad() {
        this.addCommand(
            (builder) =>
                builder
                    .setName('ping')
                    .setDescription('Simple Ping Command.'),
	    (interaction) => {
                interaction.reply(`Pong!`);
	    },
        );
    }
}
```
