From c282448d5be36e98dfe01e469fb8dbb7983b3f88 Mon Sep 17 00:00:00 2001 From: Ryan Cao <70191398+ryanccn@users.noreply.github.com> Date: Wed, 8 Jun 2022 14:25:24 +0800 Subject: [PATCH] nitpicks --- src/commands/help.ts | 5 ++++- src/commands/members.ts | 2 +- src/commands/ping.ts | 2 +- src/commands/stars.ts | 2 +- src/commands/tags.ts | 6 +++--- src/filters.ts | 1 - src/index.ts | 4 ++-- src/logproviders/0x0.ts | 2 +- src/logproviders/haste.ts | 2 +- src/logproviders/mclogs.ts | 2 +- src/logproviders/pastegg.ts | 2 +- src/logs.ts | 9 ++++----- 12 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/commands/help.ts b/src/commands/help.ts index 1675ad5..580e21c 100644 --- a/src/commands/help.ts +++ b/src/commands/help.ts @@ -9,10 +9,12 @@ export const cmd: Command = { const embed = new MessageEmbed() .setTitle('Help Menu') .setColor('DARK_GREEN'); - let comman = commands; + + const comman = commands; comman.sort((x, y) => { return x.name == 'help' ? -1 : y.name == 'help' ? 1 : 0; }); + for (const i in comman) { const cmd = comman[i]; const resp = []; @@ -27,6 +29,7 @@ export const cmd: Command = { } embed.addField('!' + cmd.name, resp.join('\n')); } + return e.reply({ embeds: [embed] }); }, }; diff --git a/src/commands/members.ts b/src/commands/members.ts index 11a36d7..24c9f7a 100644 --- a/src/commands/members.ts +++ b/src/commands/members.ts @@ -1,4 +1,4 @@ -import { Command } from '../index'; +import type { Command } from '../index'; export const cmd: Command = { name: 'members', diff --git a/src/commands/ping.ts b/src/commands/ping.ts index abf46e4..689861a 100644 --- a/src/commands/ping.ts +++ b/src/commands/ping.ts @@ -1,4 +1,4 @@ -import { Command } from '../index'; +import type { Command } from '../index'; export const cmd: Command = { name: 'ping', diff --git a/src/commands/stars.ts b/src/commands/stars.ts index 8ee5aed..97b3406 100644 --- a/src/commands/stars.ts +++ b/src/commands/stars.ts @@ -1,4 +1,4 @@ -import { Command } from '../index'; +import type { Command } from '../index'; export const cmd: Command = { name: 'stars', diff --git a/src/commands/tags.ts b/src/commands/tags.ts index 464cd39..2570b85 100644 --- a/src/commands/tags.ts +++ b/src/commands/tags.ts @@ -1,5 +1,5 @@ import { MessageEmbed } from 'discord.js'; -import { Command } from '../index'; +import type { Command } from '../index'; import { tags } from '../index'; export const cmd: Command = { @@ -8,11 +8,11 @@ export const cmd: Command = { exec: async (e) => { const em = new MessageEmbed().setTitle('tags').setColor('DARK_GREEN'); - for (let i in tags) { + for (const i in tags) { const tag = tags[i]; let text = ''; if (tag.aliases && tag.aliases[0]) { - text += '**Aliases**: ' + tag.aliases.join(', ') + "\n"; + text += '**Aliases**: ' + tag.aliases.join(', ') + '\n'; } if (tag.text) { diff --git a/src/filters.ts b/src/filters.ts index fb873c0..71d1119 100644 --- a/src/filters.ts +++ b/src/filters.ts @@ -1,4 +1,3 @@ -import * as BuildConfig from './constants'; import { Message } from 'discord.js'; import { isBad } from './badLinks'; import urlRegex from 'url-regex'; diff --git a/src/index.ts b/src/index.ts index 5f3a8ae..98858fd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -12,7 +12,7 @@ import { green, bold, blue, underline, yellow } from 'kleur/colors'; import * as parser from 'discord-command-parser'; import * as fs from 'fs'; import * as path from 'path'; -import { SuccessfulParsedMessage } from 'discord-command-parser'; +import type { SuccessfulParsedMessage } from 'discord-command-parser'; import * as dotenv from 'dotenv'; import { parseLog } from './logs'; dotenv.config(); @@ -29,7 +29,7 @@ export interface Command { } type Commands = Array; -export let commands: Commands = []; +export const commands: Commands = []; interface Tag { name: string; diff --git a/src/logproviders/0x0.ts b/src/logproviders/0x0.ts index 6bc436a..86ced5c 100644 --- a/src/logproviders/0x0.ts +++ b/src/logproviders/0x0.ts @@ -1,4 +1,4 @@ -const reg = /https\:\/\/0x0.st\/[^ ]*/; +const reg = /https:\/\/0x0.st\/[^ ]*/; export async function read0x0(s: string): Promise { const r = s.match(reg); diff --git a/src/logproviders/haste.ts b/src/logproviders/haste.ts index 331fa43..c295f41 100644 --- a/src/logproviders/haste.ts +++ b/src/logproviders/haste.ts @@ -1,4 +1,4 @@ -const reg = /https\:\/\/hst.sh\/[\w]*/; +const reg = /https:\/\/hst.sh\/[\w]*/; export async function readHastebin(s: string): Promise { const r = s.match(reg); diff --git a/src/logproviders/mclogs.ts b/src/logproviders/mclogs.ts index 8972614..0464150 100644 --- a/src/logproviders/mclogs.ts +++ b/src/logproviders/mclogs.ts @@ -1,4 +1,4 @@ -const reg = /https\:\/\/mclo.gs\/[^ ]*/; +const reg = /https:\/\/mclo.gs\/[^ ]*/; export async function readMcLogs(s: string): Promise { const r = s.match(reg); diff --git a/src/logproviders/pastegg.ts b/src/logproviders/pastegg.ts index f721532..ffb2fe3 100644 --- a/src/logproviders/pastegg.ts +++ b/src/logproviders/pastegg.ts @@ -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 { const r = s.match(reg); diff --git a/src/logs.ts b/src/logs.ts index 0956f86..588a98b 100644 --- a/src/logs.ts +++ b/src/logs.ts @@ -6,8 +6,6 @@ import { read0x0 } from './logproviders/0x0'; import { readPasteGG } from './logproviders/pastegg'; import { readHastebin } from './logproviders/haste'; -const reg = /https\:\/\/mclo.gs\/[^ ]*/g; - type analyzer = (text: string) => Promise | null>; type logProvider = (text: string) => Promise; @@ -167,8 +165,9 @@ export async function parseLog(s: string): Promise { .setColor('DARK_RED'); return embed; } - let log: string = ''; - for (let i in providers) { + + let log = ''; + for (const i in providers) { const provider = providers[i]; const res = await provider(s); if (res) { @@ -183,7 +182,7 @@ export async function parseLog(s: string): Promise { const embed = new MessageEmbed() .setTitle('Log analysis') .setColor('DARK_GREEN'); - for (let i in analyzers) { + for (const i in analyzers) { const analyzer = analyzers[i]; const out = await analyzer(log); if (out) embed.addField(out[0], out[1]);