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):
import { Listener } from '@sapphire/framework';

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

export class ExampleListener extends Listener {
public run() {
const { client } = container;
// rest of your code
}
}