webpresence
Version:
Discord Rich Presence for websites - Show your browsing activity in Discord
227 lines (224 loc) • 6.01 kB
TypeScript
declare const runtimeConfig: {
userPreferences: {
prefixText: string;
disabledSites: string[];
alwaysEnabledSites: string[];
continuousTimer: boolean;
};
discord: {
clientId: string;
reconnectAttempts: number;
maxReconnectAttempts: number;
};
server: {
port: number;
activityTimeout: number;
inactiveCheckInterval: number;
};
presence: {
enabled: boolean;
defaultPrefix: string;
creditText: string;
buttons: {
label: string;
url: string;
}[];
largeImageKey: string;
smallImageKey: string;
smallImageText: string;
browserIcons: {
chrome: {
iconKey: string;
text: string;
};
firefox: {
iconKey: string;
text: string;
};
default: {
iconKey: string;
text: string;
};
};
};
};
declare const config: {
get: () => {
userPreferences: {
prefixText: string;
disabledSites: string[];
alwaysEnabledSites: string[];
continuousTimer: boolean;
};
discord: {
clientId: string;
reconnectAttempts: number;
maxReconnectAttempts: number;
};
server: {
port: number;
activityTimeout: number;
inactiveCheckInterval: number;
};
presence: {
enabled: boolean;
defaultPrefix: string;
creditText: string;
buttons: {
label: string;
url: string;
}[];
largeImageKey: string;
smallImageKey: string;
smallImageText: string;
browserIcons: {
chrome: {
iconKey: string;
text: string;
};
firefox: {
iconKey: string;
text: string;
};
default: {
iconKey: string;
text: string;
};
};
};
};
getDiscord: () => {
clientId: string;
reconnectAttempts: number;
maxReconnectAttempts: number;
};
getServer: () => {
port: number;
activityTimeout: number;
inactiveCheckInterval: number;
};
getPresence: () => {
enabled: boolean;
defaultPrefix: string;
creditText: string;
buttons: {
label: string;
url: string;
}[];
largeImageKey: string;
smallImageKey: string;
smallImageText: string;
browserIcons: {
chrome: {
iconKey: string;
text: string;
};
firefox: {
iconKey: string;
text: string;
};
default: {
iconKey: string;
text: string;
};
};
};
getUserPreferences: () => {
prefixText: string;
disabledSites: string[];
alwaysEnabledSites: string[];
continuousTimer: boolean;
};
updateUserPreferences: (preferences: Partial<typeof runtimeConfig.userPreferences>) => {
prefixText: string;
disabledSites: string[];
alwaysEnabledSites: string[];
continuousTimer: boolean;
};
resetUserPreferences: () => {
prefixText: string;
disabledSites: string[];
alwaysEnabledSites: string[];
continuousTimer: boolean;
};
};
/**
* Check if a port is in use
* @param port The port to check
* @returns A promise that resolves to true if the port is in use, false otherwise
*/
declare function checkPortInUse(port: number): Promise<boolean>;
/**
* Start the Web Presence server
* @param options Optional configuration options
* @returns A promise that resolves when the server is started
*/
declare function startServer(options?: {
port?: number;
skipDiscord?: boolean;
}): Promise<{
success: boolean;
port: number;
error?: undefined;
} | {
success: boolean;
port: number;
error: string;
}>;
/**
* Stop the Web Presence server
* @returns A promise that resolves when the server is stopped
*/
declare function stopServer(): Promise<{
success: boolean;
}>;
/**
* Check if the server is running
* @param options Optional configuration options
* @returns True if the server is running, false otherwise
*/
declare function isServerRunning(options?: {
checkPort?: boolean;
checkApi?: boolean;
}): boolean;
/**
* Get the current server status
* @param options Optional configuration options
* @returns An object with server status information
*/
declare function getServerStatus(options?: {
checkPort?: boolean;
checkApi?: boolean;
checkDaemon?: boolean;
}): {
running: boolean;
port: number | null;
discordConnected: boolean;
presenceEnabled: boolean;
daemonRunning: boolean;
preferences: {
prefixText: string;
disabledSites: string[];
alwaysEnabledSites: string[];
continuousTimer: boolean;
};
};
/**
* Toggle Discord presence
* @param enabled Whether to enable or disable presence
* @returns A promise that resolves with the new presence state
*/
declare function togglePresence(enabled?: boolean): Promise<{
success: boolean;
enabled: any;
}>;
/**
* Update user preferences
* @param preferences User preferences to update
* @returns A promise that resolves with the updated preferences
*/
declare function updatePreferences(preferences: any): Promise<{
success: boolean;
preferences: any;
}>;
export { checkPortInUse, config, getServerStatus, isServerRunning, startServer, stopServer, togglePresence, updatePreferences };