Skip to content

Commit

Permalink
🐛 chore(index.ts): update colors and reformatted
Browse files Browse the repository at this point in the history
  • Loading branch information
RagnarLothbrok-Odin committed Dec 24, 2023
1 parent 123c2a4 commit 1f72f95
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,8 @@ function generateBarProgress(options: Options, params: Params): string {
const incomplete = (options.barIncompleteString || '').slice(0, Math.round((1 - params.progress) * (options.barsize ?? 0)));

// Combine complete and incomplete parts to form the progress bar string.
// @ts-expect-error [issue with the package not defining 'bright' colors']
return `${complete.brightRed}${incomplete.green}`;
// @ts-expect-error [issue with the package not defining 'bright' colors within its type definitions]
return `${complete.red}${incomplete.brightBlue}`;
}

/**
Expand All @@ -380,6 +380,11 @@ async function generateProgressBar() {
// Define a custom format function for the progress bar
const formatFunction: GenericFormatter = (options, params, payload) => {
switch (instanceState) {
case ConnectionState.Connecting:
return '🔒 Connecting to Discord...'.magenta.bold.toString();

case ConnectionState.Connected:
return '🎉 Connected to Discord!'.green.bold.toString();
case ConnectionState.Playing: {
// Extract relevant information from the payload
const {
Expand All @@ -401,21 +406,16 @@ async function generateProgressBar() {
const barProgress = generateBarProgress(options, params);

// Construct the progress bar line with formatted information
return `🎭 ${`[${type}]`.italic} ${content.yellow} ${barProgress} | Finishes At: ${localEndDate.blue} ⏳ Remaining: ${prettyRemainingTime.blue}`.bold.toString();
// @ts-expect-error [issue with the package not defining 'bright' colors within its type definitions]
return `🎭 ${`[${type}]`.italic} ${content.yellow} ${barProgress} Finishes At: ${localEndDate.brightBlue} ⏳ Remaining: ${prettyRemainingTime.brightBlue}`.bold.toString();
}

case ConnectionState.NotPlaying:
return `📅 ${formatDate().green.italic} ${'|'.magenta} ${'Trakt:'.red} ${'Not playing.'}`.bold.toString();

case ConnectionState.Connected:
return '🎉 Connected to Discord!'.green.bold.toString();

case ConnectionState.Disconnected:
// @ts-expect-error [issue with the package not defining 'bright' colors']
return `⚠️ ${'Discord connection lost. Retrying in'.red} ${countdownTimer.toString().brightBlue} ${'seconds... '.red}`.bold.toString();

case ConnectionState.Connecting:
return '🔒 Connecting to Discord...'.magenta.bold.toString();
// @ts-expect-error [issue with the package not defining 'bright' colors within its type definitions]
return `⚠️ ${'Discord connection lost. Retrying in'.brightRed} ${countdownTimer.toString().brightBlue} ${'seconds... '.red}`.bold.toString();

default:
return `📅 ${formatDate().green.italic} ${'|'.magenta} ${'Trakt:'.red} ${'Not playing.'}`.bold.toString();
Expand All @@ -425,8 +425,8 @@ async function generateProgressBar() {
// Create a new SingleBar instance with specified options
return new SingleBar({
format: formatFunction,
barCompleteChar: '\u2588',
barIncompleteChar: '\u2591',
barCompleteChar: '',
barIncompleteChar: '',
hideCursor: true,
clearOnComplete: true,
linewrap: true,
Expand Down

0 comments on commit 1f72f95

Please sign in to comment.