diff --git a/README.md b/README.md index ab35b1a..a991d14 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# The Artificer - A Dice Rolling Discord Bot | V2.1.0 - 2022/07/10 +# The Artificer - A Dice Rolling Discord Bot | V2.1.1 - 2022/07/10 [![SonarCloud](https://sonarcloud.io/images/project_badges/sonarcloud-orange.svg)](https://sonarcloud.io/summary/new_code?id=TheArtificer) [![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=TheArtificer&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=TheArtificer) [![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=TheArtificer&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=TheArtificer) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=TheArtificer&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=TheArtificer) [![Bugs](https://sonarcloud.io/api/project_badges/measure?project=TheArtificer&metric=bugs)](https://sonarcloud.io/summary/new_code?id=TheArtificer) [![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=TheArtificer&metric=duplicated_lines_density)](https://sonarcloud.io/summary/new_code?id=TheArtificer) [![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=TheArtificer&metric=ncloc)](https://sonarcloud.io/summary/new_code?id=TheArtificer) @@ -61,7 +61,7 @@ The Artificer comes with a few supplemental commands to the main rolling command * `[[report [[2+2]] returned 5 when I expected it to return 4` will send the entire message after `[[report` to the devs via Discord. * `[[opt-out` or `[[ignore-me` * Adds you to an ignore list so the bot will never respond to you -* `[[opt-in` +* `[[opt-in` **Available only via DM** * Removes you from the ignore list * `[[xdydzracsq!]]` * This is the command the bot was built specifically for. diff --git a/config.example.ts b/config.example.ts index ee0f2be..bb9aa91 100644 --- a/config.example.ts +++ b/config.example.ts @@ -1,6 +1,6 @@ export const config = { 'name': 'The Artificer', // Name of the bot - 'version': '2.1.0', // Version of the bot + 'version': '2.1.1', // Version of the bot 'token': 'the_bot_token', // Discord API Token for this bot 'localtoken': 'local_testing_token', // Discord API Token for a secondary OPTIONAL testing bot, THIS MUST BE DIFFERENT FROM "token" 'prefix': '[[', // Prefix for all commands diff --git a/mod.ts b/mod.ts index 4126a75..2d3def6 100644 --- a/mod.ts +++ b/mod.ts @@ -174,7 +174,7 @@ startBot({ if (message.isBot) return; // Ignore users who requested to be ignored - if (ignoreList.includes(message.authorId) && !message.content.startsWith(`${config.prefix}opt-in`)) return; + if (ignoreList.includes(message.authorId) && (!message.content.startsWith(`${config.prefix}opt-in`) || message.guildId !== 0n)) return; // Ignore all messages that are not commands if (message.content.indexOf(config.prefix) !== 0) { diff --git a/src/commands/optIn.ts b/src/commands/optIn.ts index 7df5037..cf9429c 100644 --- a/src/commands/optIn.ts +++ b/src/commands/optIn.ts @@ -11,29 +11,29 @@ export const optIn = async (message: DiscordenoMessage) => { // Light telemetry to see how many times a command is being run dbClient.execute(queries.callIncCnt('opt-out')).catch((e) => utils.commonLoggers.dbError('optIn.ts:11', 'call sproc INC_CNT on', e)); - try { - const idIdx = ignoreList.indexOf(message.authorId); - if (idIdx !== -1) { + const idIdx = ignoreList.indexOf(message.authorId); + if (idIdx !== -1) { + try { ignoreList.splice(idIdx, 1); await dbClient.execute('DELETE FROM ignore_list WHERE userid = ?', [message.authorId]); + + message.reply({ + embeds: [{ + color: successColor, + title: `${config.name} will now respond to you again.`, + description: `If you want ${config.name} to ignore to you again, please run the following command: + + \`${config.prefix}opt-out\``, + }], + }).catch((e: Error) => utils.commonLoggers.messageSendError('optIn.ts:27', message, e)); + } catch (err) { + message.reply({ + embeds: [{ + color: failColor, + title: 'Opt-In failed', + description: 'Please try the command again. If the issue persists, please join the support server, linked in my About Me section.', + }], + }).catch((e: Error) => utils.commonLoggers.messageSendError('optIn.ts:27', message, e)); } - - message.reply({ - embeds: [{ - color: successColor, - title: `${config.name} will now respond to you again.`, - description: `If you want ${config.name} to ignore to you again, please run the following command: - -\`${config.prefix}opt-out\``, - }], - }).catch((e: Error) => utils.commonLoggers.messageSendError('optIn.ts:27', message, e)); - } catch (err) { - message.reply({ - embeds: [{ - color: failColor, - title: 'Opt-In failed', - description: 'Please try the command again. If the issue persists, please join the support server, linked in my About Me section.', - }], - }).catch((e: Error) => utils.commonLoggers.messageSendError('optIn.ts:27', message, e)); } }; diff --git a/src/commands/optOut.ts b/src/commands/optOut.ts index 2ec3b10..0d3164f 100644 --- a/src/commands/optOut.ts +++ b/src/commands/optOut.ts @@ -19,7 +19,7 @@ export const optOut = async (message: DiscordenoMessage) => { embeds: [{ color: successColor, title: `${config.name} will no longer respond to you.`, - description: `If you want ${config.name} to respond to you again, please run the following command: + description: `If you want ${config.name} to respond to you again, please DM ${config.name} the following command: \`${config.prefix}opt-in\``, }],