mirror of
https://github.com/toast-ts/Daggerbot-TS.git
synced 2024-12-27 04:15:38 -05:00
why is this here?
This commit is contained in:
parent
21f3e3f7c6
commit
15747d1bed
@ -2,7 +2,7 @@ import Discord, { Client, GatewayIntentBits, Partials } from 'discord.js';
|
||||
import fs from 'node:fs';
|
||||
import { Database } from './database';
|
||||
import timeNames from './timeNames';
|
||||
import { Punishment, formatTimeOpt, createTableOpt, punOpt, Tokens, Config } from './typings/interfaces';
|
||||
import { Punishment, formatTimeOpt, punOpt, Tokens, Config } from './typings/interfaces';
|
||||
import MPDB from './models/MPServer';
|
||||
import axios from 'axios';
|
||||
import moment from 'moment';
|
||||
@ -140,39 +140,6 @@ export class TClient extends Client {
|
||||
text = text + emptyChar.repeat(length - text.length);
|
||||
} return text;
|
||||
}
|
||||
createTable(columnTitles = [], rowsData = [], options: createTableOpt, client: TClient){
|
||||
const rows: any = [];
|
||||
let { columnAlign = [], columnSeparator = [], columnEmptyChar = [] } = options;
|
||||
if (columnSeparator.length < 1) columnSeparator.push('|');
|
||||
columnSeparator = columnSeparator.map((x: string)=>`${x}`);
|
||||
// col widths
|
||||
const columnWidths = columnTitles.map((title: any, i)=>Math.max(title.length, ...rowsData.map((x: any)=>x[i].length)));
|
||||
// first row
|
||||
rows.push(columnTitles.map((title, i)=>{
|
||||
let text = client.alignText(title, columnWidths[i], columnAlign[i], columnEmptyChar[i]);
|
||||
if (columnSeparator[i]){
|
||||
text += ' '.repeat(columnSeparator[i].length);
|
||||
}
|
||||
return text;
|
||||
}).join(''))
|
||||
// big line
|
||||
rows.push('━'.repeat(rows[0].length));
|
||||
//data
|
||||
// remove unicode
|
||||
rowsData.map((row: any)=>{
|
||||
return row.map((element: string)=>{
|
||||
return element.split('').map((char: string)=>{
|
||||
if (char.charCodeAt(0)>128) return '□';
|
||||
}).join('')
|
||||
})
|
||||
})
|
||||
rows.push(rowsData.map((row: any)=>row.map((element: string, i: number)=>{
|
||||
return client.alignText(element, columnWidths[i], columnEmptyChar[i])+(i === columnTitles.length - 1 ? '' : columnSeparator[i]);
|
||||
}).join('')
|
||||
).join('\n'))
|
||||
|
||||
return rows.join('\n');
|
||||
}
|
||||
async punish(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>, type: string){
|
||||
if (!client.isStaff(interaction.member as Discord.GuildMember)) return client.youNeedRole(interaction, "dcmod");
|
||||
|
||||
|
5
src/typings/interfaces.d.ts
vendored
5
src/typings/interfaces.d.ts
vendored
@ -8,11 +8,6 @@ export interface formatTimeOpt {
|
||||
longNames: boolean,
|
||||
commas: boolean
|
||||
}
|
||||
export interface createTableOpt {
|
||||
columnAlign: any,
|
||||
columnSeparator: any,
|
||||
columnEmptyChar: any
|
||||
}
|
||||
export interface punOpt {
|
||||
time?: string,
|
||||
reason?: string,
|
||||
|
Loading…
Reference in New Issue
Block a user