1
0
mirror of https://github.com/toast-ts/Daggerbot-TS.git synced 2024-09-29 16:30:59 -04:00

why is this here?

This commit is contained in:
toast-ts 2023-01-28 08:59:37 +11:00
parent 21f3e3f7c6
commit 15747d1bed
2 changed files with 1 additions and 39 deletions

View File

@ -2,7 +2,7 @@ import Discord, { Client, GatewayIntentBits, Partials } from 'discord.js';
import fs from 'node:fs'; import fs from 'node:fs';
import { Database } from './database'; import { Database } from './database';
import timeNames from './timeNames'; 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 MPDB from './models/MPServer';
import axios from 'axios'; import axios from 'axios';
import moment from 'moment'; import moment from 'moment';
@ -140,39 +140,6 @@ export class TClient extends Client {
text = text + emptyChar.repeat(length - text.length); text = text + emptyChar.repeat(length - text.length);
} return text; } 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){ async punish(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>, type: string){
if (!client.isStaff(interaction.member as Discord.GuildMember)) return client.youNeedRole(interaction, "dcmod"); if (!client.isStaff(interaction.member as Discord.GuildMember)) return client.youNeedRole(interaction, "dcmod");

View File

@ -8,11 +8,6 @@ export interface formatTimeOpt {
longNames: boolean, longNames: boolean,
commas: boolean commas: boolean
} }
export interface createTableOpt {
columnAlign: any,
columnSeparator: any,
columnEmptyChar: any
}
export interface punOpt { export interface punOpt {
time?: string, time?: string,
reason?: string, reason?: string,