diff --git a/src/classes/Commands/Commands.ts b/src/classes/Commands/Commands.ts index 2c5463911..854b242c0 100644 --- a/src/classes/Commands/Commands.ts +++ b/src/classes/Commands/Commands.ts @@ -123,6 +123,7 @@ export default class Commands { 'You', '/quote', '/pre', + '/pre2', '/me', '/code', 'Oh', diff --git a/src/classes/Commands/sub-classes/Manager.ts b/src/classes/Commands/sub-classes/Manager.ts index 5119b8b10..2ab489f53 100644 --- a/src/classes/Commands/sub-classes/Manager.ts +++ b/src/classes/Commands/sub-classes/Manager.ts @@ -8,6 +8,7 @@ import * as timersPromises from 'timers/promises'; import path from 'path'; import child from 'child_process'; import dayjs from 'dayjs'; +import { Message as DiscordMessage } from 'discord.js'; import { EPersonaState } from 'steam-user'; import { EFriendRelationship } from 'steam-user'; import { removeLinkProtocol } from '../functions/utils'; @@ -528,7 +529,11 @@ export default class ManagerCommands { } } - this.bot.sendMessage(steamID, '/pre ' + ManagerCommands.generateAutokeysReply(steamID, this.bot)); + this.bot.sendMessage( + steamID, + (steamID.redirectAnswerTo instanceof DiscordMessage ? '/pre2' : '/pre ') + + ManagerCommands.generateAutokeysReply(steamID, this.bot) + ); } refreshAutokeysCommand(steamID: SteamID): void { diff --git a/src/classes/Commands/sub-classes/Misc.ts b/src/classes/Commands/sub-classes/Misc.ts index 762fe7190..8f97f8a34 100644 --- a/src/classes/Commands/sub-classes/Misc.ts +++ b/src/classes/Commands/sub-classes/Misc.ts @@ -2,6 +2,7 @@ import SteamID from 'steamid'; import SKU from '@tf2autobot/tf2-sku'; import pluralize from 'pluralize'; import * as timersPromises from 'timers/promises'; +import { Message as DiscordMessage } from 'discord.js'; import { removeLinkProtocol } from '../functions/utils'; import CommandParser from '../../CommandParser'; import Bot from '../../Bot'; @@ -195,7 +196,7 @@ export default class MiscCommands { reply += custom ? custom.replace(/%stocklist%/g, stock.join(', \n')) : `${ - isWithSomething ? '\n\n' : '/pre ' + isWithSomething ? '\n\n' : steamID.redirectAnswerTo instanceof DiscordMessage ? '/pre2' : '/pre ' }📜 Here's a list of all the items that I have in my inventory:\n${stock.join(', \n')}`; if (left > 0) { diff --git a/src/classes/DiscordBot.ts b/src/classes/DiscordBot.ts index 235062138..d5a2d104e 100644 --- a/src/classes/DiscordBot.ts +++ b/src/classes/DiscordBot.ts @@ -54,6 +54,10 @@ export default class DiscordBot { return; // don't talk to myself } + if (message.webhookId) { + return; // Ignore webhook messages + } + log.info( `Got new message ${String(message.content)} from ${message.author.tag} (${String(message.author.id)})` ); @@ -81,6 +85,8 @@ export default class DiscordBot { private static reformat(message: string): string { if (message.startsWith('/code')) { return '```json\n' + message.slice(6) + '\n```'; + } else if (message.startsWith('/pre2')) { + return '```\n' + message.slice(5) + '\n```'; } else if (message.startsWith('/pre')) { return '>>> ' + message.slice(5); } else {