utility.presence: fix timestamps
This commit is contained in:
		
							parent
							
								
									c87d1e1422
								
							
						
					
					
						commit
						147e1d5028
					
				
					 1 changed files with 25 additions and 23 deletions
				
			
		| 
						 | 
				
			
			@ -754,33 +754,35 @@ presence.callback = async function (msg, line) {
 | 
			
		|||
          if (activity.state) descLines.push(activity.state);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (activity.timestamps.start && !activity.timestamps.end) {
 | 
			
		||||
          descLines.push(
 | 
			
		||||
            formatTime(Date.now() - activity.timestamps.start) + " elapsed"
 | 
			
		||||
          );
 | 
			
		||||
        } else if (!activity.timestamps.start && activity.timestamps.end) {
 | 
			
		||||
          descLines.push(
 | 
			
		||||
            formatTime(activity.timestamps.end - Date.now()) + " remaining"
 | 
			
		||||
          );
 | 
			
		||||
        } else {
 | 
			
		||||
          const position = Date.now() - activity.timestamps.start;
 | 
			
		||||
          const length = activity.timestamps.end - activity.timestamps.start;
 | 
			
		||||
        if (activity.timestamps) {
 | 
			
		||||
          if (activity.timestamps.start && !activity.timestamps.end) {
 | 
			
		||||
            descLines.push(
 | 
			
		||||
              formatTime(Date.now() - activity.timestamps.start) + " elapsed"
 | 
			
		||||
            );
 | 
			
		||||
          } else if (!activity.timestamps.start && activity.timestamps.end) {
 | 
			
		||||
            descLines.push(
 | 
			
		||||
              formatTime(activity.timestamps.end - Date.now()) + " remaining"
 | 
			
		||||
            );
 | 
			
		||||
          } else {
 | 
			
		||||
            const position = Date.now() - activity.timestamps.start;
 | 
			
		||||
            const length = activity.timestamps.end - activity.timestamps.start;
 | 
			
		||||
 | 
			
		||||
          const timeEnd = formatTime(length);
 | 
			
		||||
          const timePos = formatTime(position);
 | 
			
		||||
            const timeEnd = formatTime(length);
 | 
			
		||||
            const timePos = formatTime(position);
 | 
			
		||||
 | 
			
		||||
          const progress = position / length;
 | 
			
		||||
          const barLength = Math.round(progress * NOWPLAYING_BAR_LENGTH);
 | 
			
		||||
            const progress = position / length;
 | 
			
		||||
            const barLength = Math.round(progress * NOWPLAYING_BAR_LENGTH);
 | 
			
		||||
 | 
			
		||||
          const bar = `\`[${"=".repeat(barLength)}${" ".repeat(
 | 
			
		||||
            NOWPLAYING_BAR_LENGTH - barLength
 | 
			
		||||
          )}]\``;
 | 
			
		||||
          const time = `\`${timePos}${" ".repeat(
 | 
			
		||||
            NOWPLAYING_BAR_LENGTH + 2 - timePos.length - timeEnd.length
 | 
			
		||||
          )}${timeEnd}\``;
 | 
			
		||||
            const bar = `\`[${"=".repeat(barLength)}${" ".repeat(
 | 
			
		||||
              NOWPLAYING_BAR_LENGTH - barLength
 | 
			
		||||
            )}]\``;
 | 
			
		||||
            const time = `\`${timePos}${" ".repeat(
 | 
			
		||||
              NOWPLAYING_BAR_LENGTH + 2 - timePos.length - timeEnd.length
 | 
			
		||||
            )}${timeEnd}\``;
 | 
			
		||||
 | 
			
		||||
          descLines.push(bar);
 | 
			
		||||
          descLines.push(time);
 | 
			
		||||
            descLines.push(bar);
 | 
			
		||||
            descLines.push(time);
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        embed.description = descLines.join("\n");
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue