This commit is contained in:
Ryan Cao 2022-06-08 14:25:24 +08:00
parent ea11dbba01
commit c282448d5b
No known key found for this signature in database
GPG key ID: 528A2C1B6656B97F
12 changed files with 20 additions and 19 deletions

View file

@ -9,10 +9,12 @@ export const cmd: Command = {
const embed = new MessageEmbed() const embed = new MessageEmbed()
.setTitle('Help Menu') .setTitle('Help Menu')
.setColor('DARK_GREEN'); .setColor('DARK_GREEN');
let comman = commands;
const comman = commands;
comman.sort((x, y) => { comman.sort((x, y) => {
return x.name == 'help' ? -1 : y.name == 'help' ? 1 : 0; return x.name == 'help' ? -1 : y.name == 'help' ? 1 : 0;
}); });
for (const i in comman) { for (const i in comman) {
const cmd = comman[i]; const cmd = comman[i];
const resp = []; const resp = [];
@ -27,6 +29,7 @@ export const cmd: Command = {
} }
embed.addField('!' + cmd.name, resp.join('\n')); embed.addField('!' + cmd.name, resp.join('\n'));
} }
return e.reply({ embeds: [embed] }); return e.reply({ embeds: [embed] });
}, },
}; };

View file

@ -1,4 +1,4 @@
import { Command } from '../index'; import type { Command } from '../index';
export const cmd: Command = { export const cmd: Command = {
name: 'members', name: 'members',

View file

@ -1,4 +1,4 @@
import { Command } from '../index'; import type { Command } from '../index';
export const cmd: Command = { export const cmd: Command = {
name: 'ping', name: 'ping',

View file

@ -1,4 +1,4 @@
import { Command } from '../index'; import type { Command } from '../index';
export const cmd: Command = { export const cmd: Command = {
name: 'stars', name: 'stars',

View file

@ -1,5 +1,5 @@
import { MessageEmbed } from 'discord.js'; import { MessageEmbed } from 'discord.js';
import { Command } from '../index'; import type { Command } from '../index';
import { tags } from '../index'; import { tags } from '../index';
export const cmd: Command = { export const cmd: Command = {
@ -8,11 +8,11 @@ export const cmd: Command = {
exec: async (e) => { exec: async (e) => {
const em = new MessageEmbed().setTitle('tags').setColor('DARK_GREEN'); const em = new MessageEmbed().setTitle('tags').setColor('DARK_GREEN');
for (let i in tags) { for (const i in tags) {
const tag = tags[i]; const tag = tags[i];
let text = ''; let text = '';
if (tag.aliases && tag.aliases[0]) { if (tag.aliases && tag.aliases[0]) {
text += '**Aliases**: ' + tag.aliases.join(', ') + "\n"; text += '**Aliases**: ' + tag.aliases.join(', ') + '\n';
} }
if (tag.text) { if (tag.text) {

View file

@ -1,4 +1,3 @@
import * as BuildConfig from './constants';
import { Message } from 'discord.js'; import { Message } from 'discord.js';
import { isBad } from './badLinks'; import { isBad } from './badLinks';
import urlRegex from 'url-regex'; import urlRegex from 'url-regex';

View file

@ -12,7 +12,7 @@ import { green, bold, blue, underline, yellow } from 'kleur/colors';
import * as parser from 'discord-command-parser'; import * as parser from 'discord-command-parser';
import * as fs from 'fs'; import * as fs from 'fs';
import * as path from 'path'; import * as path from 'path';
import { SuccessfulParsedMessage } from 'discord-command-parser'; import type { SuccessfulParsedMessage } from 'discord-command-parser';
import * as dotenv from 'dotenv'; import * as dotenv from 'dotenv';
import { parseLog } from './logs'; import { parseLog } from './logs';
dotenv.config(); dotenv.config();
@ -29,7 +29,7 @@ export interface Command {
} }
type Commands = Array<Command>; type Commands = Array<Command>;
export let commands: Commands = []; export const commands: Commands = [];
interface Tag { interface Tag {
name: string; name: string;

View file

@ -1,4 +1,4 @@
const reg = /https\:\/\/0x0.st\/[^ ]*/; const reg = /https:\/\/0x0.st\/[^ ]*/;
export async function read0x0(s: string): Promise<null | string> { export async function read0x0(s: string): Promise<null | string> {
const r = s.match(reg); const r = s.match(reg);

View file

@ -1,4 +1,4 @@
const reg = /https\:\/\/hst.sh\/[\w]*/; const reg = /https:\/\/hst.sh\/[\w]*/;
export async function readHastebin(s: string): Promise<string | null> { export async function readHastebin(s: string): Promise<string | null> {
const r = s.match(reg); const r = s.match(reg);

View file

@ -1,4 +1,4 @@
const reg = /https\:\/\/mclo.gs\/[^ ]*/; const reg = /https:\/\/mclo.gs\/[^ ]*/;
export async function readMcLogs(s: string): Promise<null | string> { export async function readMcLogs(s: string): Promise<null | string> {
const r = s.match(reg); const r = s.match(reg);

View file

@ -1,4 +1,4 @@
const reg = /https\:\/\/paste.gg\/p\/[\w]*\/[\w]*/; const reg = /https:\/\/paste.gg\/p\/[\w]*\/[\w]*/;
export async function readPasteGG(s: string): Promise<null | string> { export async function readPasteGG(s: string): Promise<null | string> {
const r = s.match(reg); const r = s.match(reg);

View file

@ -6,8 +6,6 @@ import { read0x0 } from './logproviders/0x0';
import { readPasteGG } from './logproviders/pastegg'; import { readPasteGG } from './logproviders/pastegg';
import { readHastebin } from './logproviders/haste'; import { readHastebin } from './logproviders/haste';
const reg = /https\:\/\/mclo.gs\/[^ ]*/g;
type analyzer = (text: string) => Promise<Array<string> | null>; type analyzer = (text: string) => Promise<Array<string> | null>;
type logProvider = (text: string) => Promise<null | string>; type logProvider = (text: string) => Promise<null | string>;
@ -167,8 +165,9 @@ export async function parseLog(s: string): Promise<MessageEmbed | null> {
.setColor('DARK_RED'); .setColor('DARK_RED');
return embed; return embed;
} }
let log: string = '';
for (let i in providers) { let log = '';
for (const i in providers) {
const provider = providers[i]; const provider = providers[i];
const res = await provider(s); const res = await provider(s);
if (res) { if (res) {
@ -183,7 +182,7 @@ export async function parseLog(s: string): Promise<MessageEmbed | null> {
const embed = new MessageEmbed() const embed = new MessageEmbed()
.setTitle('Log analysis') .setTitle('Log analysis')
.setColor('DARK_GREEN'); .setColor('DARK_GREEN');
for (let i in analyzers) { for (const i in analyzers) {
const analyzer = analyzers[i]; const analyzer = analyzers[i];
const out = await analyzer(log); const out = await analyzer(log);
if (out) embed.addField(out[0], out[1]); if (out) embed.addField(out[0], out[1]);