From cbfea20517f6832778affe882218c758c1dcec16 Mon Sep 17 00:00:00 2001 From: liushuyu Date: Sat, 5 Nov 2022 16:14:10 -0600 Subject: [PATCH] tree-wide: code clean-up ... * remove commented-out code blocks * remove usages of deprecated JS functions --- src/commands/game.ts | 2 +- src/commands/quote.ts | 2 +- src/commands/status.ts | 2 +- src/server.ts | 4 +--- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/commands/game.ts b/src/commands/game.ts index 0ad1daa..3ca0d1d 100644 --- a/src/commands/game.ts +++ b/src/commands/game.ts @@ -70,7 +70,7 @@ export async function command(message: discord.Message) { } } - const game = message.content.substr(message.content.indexOf(' ') + 1); + const game = message.content.substring(message.content.indexOf(' ') + 1); // Search all games. This is only linear time, so /shrug? let bestGame: IGameDBEntry | null = null; diff --git a/src/commands/quote.ts b/src/commands/quote.ts index 04b3267..ed94f7e 100644 --- a/src/commands/quote.ts +++ b/src/commands/quote.ts @@ -4,7 +4,7 @@ export const roles = ['Admins', 'Moderators']; export async function command (message: discord.Message, reply: string | undefined) { let replyMessage; if (reply == null) { - replyMessage = message.content.substr(message.content.indexOf(' ') + 1); + replyMessage = message.content.substring(message.content.indexOf(' ') + 1); } else { replyMessage = `${message.mentions.users.map(user => `${user.toString()}`).join(' ')} ${reply}`; } diff --git a/src/commands/status.ts b/src/commands/status.ts index 4c9cf30..82c83d6 100644 --- a/src/commands/status.ts +++ b/src/commands/status.ts @@ -8,7 +8,7 @@ const repo = process.env.GITHUB_REPOSITORY || 'citra-emu/citra'; export const roles = ['Admins', 'Moderators', 'Developer']; export async function command(message: discord.Message) { - const prNumber = message.content.substr(message.content.indexOf(' ') + 1).replace(/\n/g, ''); + const prNumber = message.content.substring(message.content.indexOf(' ') + 1).replace(/\n/g, ''); const url = `https://api.github.com/repos/${repo}/pulls/${prNumber}`; return fetch(url, fetchOptions).then(response => response.json()).then((pr: any) => { if (!pr || pr.documentation_url || !pr.head) throw new Error('PR not found'); diff --git a/src/server.ts b/src/server.ts index 7f2ea9e..799dea6 100644 --- a/src/server.ts +++ b/src/server.ts @@ -140,9 +140,7 @@ client.on('messageCreate', async (message) => { if (message.author.bot && message.content.startsWith('.ban') === false) { return; } if (message.guild == null && state.responses.pmReply) { - // We want to log PM attempts. - // logger.info(`${message.author.username} ${message.author} [PM]: ${message.content}`); - // state.logChannel.send(`${message.author.toString()} [PM]: ${message.content}`); + // We want to reply to PM attempts. await message.reply(state.responses.pmReply); return; }