@reaxion/utils
Version:
Core utilities for Reaxion: channels, threads, roles, categories
27 lines (25 loc) • 776 B
JavaScript
/**
* Registry for storing global client reference
*/
let clientInstance = null;
/**
* Register the Discord client instance to be used by all @reaxion utilities
* @param {Object} client Discord.js client instance
*/
export function registerClient(client) {
if (!client || typeof client !== 'object') {
throw new Error('Invalid Discord client provided to registerClient');
}
clientInstance = client;
}
/**
* Get the registered Discord client instance
* @returns {Object} The client instance
* @throws {Error} If no client has been registered
*/
export function getClient() {
if (!clientInstance) {
throw new Error('No Discord client registered. Call registerClient() before using utilities.');
}
return clientInstance;
}