/[sudobot]/trunk/src/utils/util.ts
ViewVC logotype

Diff of /trunk/src/utils/util.ts

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 236 by rakin, Mon Jul 29 17:29:09 2024 UTC revision 239 by rakin, Mon Jul 29 17:29:09 2024 UTC
# Line 2  import fs from 'fs'; Line 2  import fs from 'fs';
2  import DiscordClient from '../client/Client';  import DiscordClient from '../client/Client';
3  import { GuildMember, Message, CommandInteraction, MessageEmbed, ContextMenuInteraction, Interaction } from 'discord.js';  import { GuildMember, Message, CommandInteraction, MessageEmbed, ContextMenuInteraction, Interaction } from 'discord.js';
4  import Axios, { AxiosRequestHeaders, HeadersDefaults } from 'axios';  import Axios, { AxiosRequestHeaders, HeadersDefaults } from 'axios';
5    import { formatDistance } from 'date-fns';
6    
7  export function splitMessage(message: string, limit: number = 1000, maxIterationCount: number = 100) {  export function splitMessage(message: string, limit: number = 1000, maxIterationCount: number = 100) {
8      const splitted: string[] = [];      const splitted: string[] = [];
# Line 78  export async function hasPermission(clie Line 79  export async function hasPermission(clie
79      return true;      return true;
80  }  }
81    
82  export function timeProcess(seconds: number) {        export function timeProcess(seconds: number) {
83        return formatDistance(new Date(), new Date(seconds));
84    }
85    
86    
87    /**
88     * @deprecated
89     */
90    export function timeProcessOld(seconds: number) {      
91      let interval = seconds / (60 * 60 * 24 * 30 * 365);      let interval = seconds / (60 * 60 * 24 * 30 * 365);
92    
93      if (interval >= 1) {      if (interval >= 1) {
# Line 119  export function escapeRegex(string: stri Line 128  export function escapeRegex(string: stri
128  }  }
129    
130  export function timeSince(date: number) {  export function timeSince(date: number) {
131      const seconds = Math.floor((Date.now() - date) / 1000);      // const seconds = Math.floor((Date.now() - date) / 1000);
132      return timeProcess(seconds) + ' ago';      // return timeProcess(seconds) + ' ago';
133        return formatDistance(new Date(), new Date(date), { addSuffix: true });
134  }  }
135    
136  export async function download(url: string, path: string, headers?: AxiosRequestHeaders) {    export async function download(url: string, path: string, headers?: AxiosRequestHeaders) {  

Legend:
Removed from v.236  
changed lines
  Added in v.239

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26