Setup
If you want to use the component handler with GCommands, just add componentDir
to GCommandsClient
const { GCommandsClient } = require("gcommands");
const { join } = require("path");
const client = new GCommandsClient({
...options,
loader: {
componentDir: join(__dirname, "components")
}
})
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
But if you only use the component handler, not GCommands, you have to import @gcommmands/components
const { GComponents } = require("@gcommands/components");
const { Client } = require("discord.js");
const { join } = require("path");
const client = new Client();
new GComponents(client, { dir: join(__dirname, "components") })
1
2
3
4
5
6
2
3
4
5
6
Then you just create a file in the components
folder or you can also create a category.
const { Component } = require('@gcommands/components');
module.exports = class extends Component {
constructor(client) {
super(client, {
name: 'hello',
type: 'BUTTON',
})
}
run(interaction, args) {
return interaction.reply('Hello!');
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13