Skip to main content

Accessing the client in pieces

There are multiple ways to access the client in pieces:

  1. By accessing container from this, if you're extending a Sapphire Piece (commands, listeners, etc):
const { Listener } = require('@sapphire/framework');

class ExampleListener extends Listener {
run() {
const { client } = this.container;
// rest of your code
}
}
module.exports = {
ExampleListener
};
  1. By importing container from the framework:
const { container, Listener } = require('@sapphire/framework');

class ExampleListener extends Listener {
run() {
const { client } = container;
// rest of your code
}
}
module.exports = {
ExampleListener
};