/[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 51 by rakin, Mon Jul 29 17:28:23 2024 UTC revision 153 by rakin, Mon Jul 29 17:28:48 2024 UTC
# Line 1  Line 1 
1  import fs from 'fs';  import fs from 'fs';
2    import DiscordClient from '../client/Client';
3    import { GuildMember } from 'discord.js';
4  import Axios, { AxiosRequestHeaders, HeadersDefaults } from 'axios';  import Axios, { AxiosRequestHeaders, HeadersDefaults } from 'axios';
5    
6    export function shouldNotModerate(client: DiscordClient, member: GuildMember) {
7        if (!client.config.props[member.guild.id].admin) {
8            return false;
9        }
10    
11        const role = client.config.props[member.guild.id].admin;
12    
13        return member.roles.cache.has(role);
14    }
15    
16  export function timeProcess(seconds: number) {        export function timeProcess(seconds: number) {      
17      let interval = seconds / (60 * 60 * 24 * 30 * 365);      let interval = seconds / (60 * 60 * 24 * 30 * 365);
18    
# Line 79  export async function deleteFile(path: s Line 91  export async function deleteFile(path: s
91  export function random(arr: Array <any>) {  export function random(arr: Array <any>) {
92      let index = Math.floor(Math.random() * arr.length);      let index = Math.floor(Math.random() * arr.length);
93      return arr[index];      return arr[index];
 }  
94    }
95    
96    export function fill(length: number, string: string, token: string = ' ') {
97        let safe = 0;
98    
99        if (length < string.length)
100            return string;
101    
102        const diff = length - string.length;
103    
104        for (let i = 1; i <= diff; i++, safe++) {
105            if (safe >= 500)
106                break;        
107    
108            string += ' ';
109        }  
110    
111        return string;
112    }
113    
114    export function green(string: string) {
115        return '\u001b[1;32m' + string + '\u001b[0m';
116    }
117    
118    export function yellow(string: string) {
119        return '\u001b[1;33m' + string + '\u001b[0m';
120    }
121    
122    export function red(string: string) {
123        return '\u001b[1;31m' + string + '\u001b[0m';
124    }

Legend:
Removed from v.51  
changed lines
  Added in v.153

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26