Repository: TheOdinProject/odin-bot-v2
Pull request #99 (2021-01-26 01:41:37)

Fix commands that do not pass the specified tests.
### Updated
#88 Updated `callbacks` command to be its own group
<img width="1109" alt="callbacks" src="https://user-images.githubusercontent.com/35420073/105787932-cb0f3e00-5fc2-11eb-9a37-e1dd99f346d0.png">

#89 Updated `cqg` command to be its own group
<img width="1156" alt="cqg" src="https://user-images.githubusercontent.com/35420073/105787958-d6626980-5fc2-11eb-8321-f8521b326921.png">

#90 Updated `help`, `code` commands to be its own group
<img width="1073" alt="help" src="https://user-images.githubusercontent.com/35420073/105787966-dc584a80-5fc2-11eb-9110-c5cdf3456ad6.png">

#94 Updated all commands to pass the tests
<img width="729" alt="simpleCommands" src="https://user-images.githubusercontent.com/35420073/105787980-e37f5880-5fc2-11eb-95ff-dc43b290151b.png">

#95 Updated `time` command to be its own group
<img width="1018" alt="time" src="https://user-images.githubusercontent.com/35420073/105787990-eaa66680-5fc2-11eb-96ef-402a08665e80.png">




Patch:
diff --git a/botCommands/callbacks.js b/botCommands/callbacks.js
index daba6c2..1b1bde9 100644
--- a/botCommands/callbacks.js
+++ b/botCommands/callbacks.js
@@ -1,7 +1,7 @@
 const {registerBotCommand} = require('../botEngine.js');
 
 const command = {
-    regex: /\B\/callbacks/,
+    regex: /(?<!\S)\/callbacks(?!\S)/,
     cb: () => `**DID SOMEONE SAY CALLBACKS?: https://briggs.dev/blog/understanding-callbacks**`
   }
 
diff --git a/botCommands/carlosQuote.js b/botCommands/carlosQuote.js
index 906f7e8..c5bba7f 100644
--- a/botCommands/carlosQuote.js
+++ b/botCommands/carlosQuote.js
@@ -1,7 +1,7 @@
 const {registerBotCommand} = require("../botEngine.js");
 
 const command = {
-    regex: /\B\/cqg/,
+    regex: /(?<!\S)\/cqg(?!\S)/,
     cb: () => `**Here is a great quote about "Asking Questions in the TOP Discord"**
     "Here's my take on asking questions here:
     Naturally, we welcome them. But we will hold you accountable when you ask a question that is easily researched. Not because we think you're a jerk. But because independent research is so critical to your continued learning.
diff --git a/botCommands/help.js b/botCommands/help.js
index a2a00cf..ed294f8 100644
--- a/botCommands/help.js
+++ b/botCommands/help.js
@@ -1,7 +1,7 @@
 const { registerBotCommand } = require('../botEngine.js');
 
 const help = {
-  regex: /\B\/help(\s+)?$/,
+  regex: /(?<!\S)\/help(?!\S)/,
   cb : ({ room }) => {
     return `
     **By posting in this chatroom you agree to our code of conduct:** <https://github.com/TheOdinProject/theodinproject/blob/master/doc/code_of_conduct.md>
@@ -20,7 +20,7 @@ const help = {
 }
 
 const code = {
-  regex: /\B\/code\b/,
+  regex: /(?<!\S)\/code(?!\S)/,
   cb: ({ room, mentions }) => {
     let users = '';
     if (mentions.users) {
diff --git a/botCommands/shrug.js b/botCommands/shrug.js
index afe6ca0..bb4695b 100644
--- a/botCommands/shrug.js
+++ b/botCommands/shrug.js
@@ -1,7 +1,7 @@
 const { registerBotCommand } = require("../botEngine.js");
 
 const command = {
-  regex: /\/[shurg]{5}/,
+  regex: /(?<!\S)\/[shurg]{5}(?!\S)/,
   cb: ({ content }) => {
     function onlyUnique(value, index, self) {
       return self.indexOf(value) === index;
diff --git a/botCommands/simpleCommands.js b/botCommands/simpleCommands.js
index f1ef8ba..468ce91 100644
--- a/botCommands/simpleCommands.js
+++ b/botCommands/simpleCommands.js
@@ -1,25 +1,25 @@
 const { registerBotCommand } = require('../botEngine.js');
 
 const hug = {
-  regex: /\B\/hug/,
+  regex: /(?<!\S)\/hug(?!\S)/,
   cb: () => `⊂(´・ω・｀⊂)`
 }
 registerBotCommand(hug.regex, hug.cb);
 
 const smart = {
-  regex: /\B\/smart/,
+  regex: /(?<!\S)\/smart(?!\S)/,
   cb: () => String.raw`f(ಠ‿↼)z`
 }
 registerBotCommand(smart.regex, smart.cb);
 
 const lenny = {
-  regex: /\B\/lenny/,
+  regex: /(?<!\S)\/lenny(?!\S)/,
   cb: () => String.raw`( ͡° ͜ʖ ͡°)`
 }
 registerBotCommand(lenny.regex, lenny.cb);
 
 const fu = {
-  regex: /:fu:/,
+  regex: /(?<!\S)\/fu(?!\S)/,
   cb: async (message) => {
     await message.reply('http://media.riffsy.com/images/636a97aa416ad674eb2b72d4a6e9ad6c/tenor.gif')
     return null;
@@ -28,13 +28,13 @@ const fu = {
 registerBotCommand(fu.regex, fu.cb);
 
 const question = {
-  regex: /\B\/question/,
+  regex: /(?<!\S)\/question(?!\S)/,
   cb: () => `**It looks like you're trying to ask a question! Please give this page a read: https://medium.com/@gordon_zhu/how-to-be-great-at-asking-questions-e37be04d0603**`
 }
 registerBotCommand(question.regex, question.cb);
 
 const data = {
-  regex: /\B\/data/,
+  regex: /(?<!\S)\/data(?!\S)/,
   cb: () => `**Please state your question in the form of a question! https://www.dontasktoask.com/**`
 }
 registerBotCommand(data.regex, data.cb);
@@ -42,13 +42,13 @@ registerBotCommand(data.regex, data.cb);
 // registerBotCommand(/\/sexpresso/, () => `https://i.gifer.com/8EC5.gif`);
 
 const sexpresso = {
-  regex: /\/sexpresso/,
+  regex: /(?<!\S)\/sexpresso(?!\S)/,
   cb: () => `https://tenor.com/view/mac-spilling-coffee-starbucks-gif-6241590`
 }
 registerBotCommand(sexpresso.regex, sexpresso.cb);
 
 const peen = {
-  regex: /\peen/,
+  regex: /(?<!\S)\/peen(?!\S)/,
   cb: ({ author }) => {
     if (author.id == 418918922507780096) {
       return `https://media.giphy.com/media/K5IEMtDZHxQZy/giphy.gif`;
@@ -86,19 +86,19 @@ const fg = {
 registerBotCommand(fg.regex, fg.cb);
 
 const dab = {
-  regex: /\/dab/,
+  regex: /(?<!\S)\/dab(?!\S)/,
   cb: () => `https://tenor.com/view/bettywhite-dab-gif-5044603`
 }
 registerBotCommand(dab.regex, dab.cb);
 
 const gandalf = {
-  regex: /\/gandalf/,
+  regex: /(?<!\S)\/gandalf(?!\S)/,
   cb: () => `http://emojis.slackmojis.com/emojis/images/1450458362/181/gandalf.gif`
 }
 registerBotCommand(gandalf.regex, gandalf.cb);
 
 const motivate = {
-  regex: /\/motivate/,
+  regex: /(?<!\S)\/motivate(?!\S)/,
   cb: () => {
     return `Don't give up! https://www.youtube.com/watch?v=KxGRhd_iWuE`;
   }
@@ -107,7 +107,7 @@ registerBotCommand(motivate.regex, motivate.cb);
 
 
 const justDoIt = {
-  regex: /\/justdoit/,
+  regex: /(?<!\S)\/justdoit(?!\S)/,
   cb: () => {
     return `What are you waiting for?! https://www.youtube.com/watch?v=ZXsQAXx_ao0`;
   }
diff --git a/botCommands/time.js b/botCommands/time.js
index 6da8f57..387b1c9 100644
--- a/botCommands/time.js
+++ b/botCommands/time.js
@@ -1,7 +1,7 @@
 const { registerBotCommand } = require("../botEngine.js");
 
 const command = {
-    regex: /\B\/time\b/,
+    regex: /(?<!\S)\/time(?!\S)/,
     cb: async ({ mentions }) => {
         let users = '';
         const mentionedUsers = mentions.users.array()


Test patch:
diff --git a/botCommands/help.test.js b/botCommands/help.test.js
index 81da697..f911130 100644
--- a/botCommands/help.test.js
+++ b/botCommands/help.test.js
@@ -1,5 +1,5 @@
 const commands = require("./help");
-const generateMentions = require("./mockData");
+const { generateMentions } = require('./mockData');
 
 describe("/help", () => {
   it.each([
diff --git a/botCommands/shrug.test.js b/botCommands/shrug.test.js
index a736101..3742f96 100644
--- a/botCommands/shrug.test.js
+++ b/botCommands/shrug.test.js
@@ -17,7 +17,7 @@ describe('/shrug', () => {
       ['/shurgs'],
       ['/shrg'],
       ['```function("/shrug", () => {}```'],
-      ['/shurg'],
+      ['/shurga'],
       [''],
       [' '],
       [' /'],
diff --git a/botCommands/simpleCommands.test.js b/botCommands/simpleCommands.test.js
index 1411c5a..a89f070 100644
--- a/botCommands/simpleCommands.test.js
+++ b/botCommands/simpleCommands.test.js
@@ -76,7 +76,7 @@ describe('/smart', () => {
       ['/smrt'],
       ['/smarts'],
       ['```function("/smart", () => {}```'],
-      ['/smart'],
+      ['/smarta'],
       [''],
       [' '],
       [' /'],
@@ -135,7 +135,7 @@ describe('/lenny', () => {
       ['/hu'],
       ['/lennys'],
       ['```function("/lenny", () => {}```'],
-      ['/lenny'],
+      ['/lennya'],
       [''],
       [' '],
       [' /'],
@@ -194,7 +194,7 @@ describe('/fu', () => {
       ['/fuu'],
       ['/fus'],
       ['```function("/fu", () => {}```'],
-      ['/fu'],
+      ['/fua'],
       [''],
       [' '],
       [' /'],
@@ -254,7 +254,7 @@ describe('/question', () => {
       ['/questio'],
       ['/questions'],
       ['```function("/question", () => {}```'],
-      ['/question'],
+      ['/questiona'],
       [''],
       [' '],
       [' /'],
@@ -313,7 +313,7 @@ describe('/data', () => {
       ['/daa'],
       ['/datas'],
       ['```function("/data", () => {}```'],
-      ['/data'],
+      ['/dataa'],
       [''],
       [' '],
       [' /'],
@@ -431,7 +431,7 @@ describe('/peen', () => {
       ['/pee'],
       ['/peens'],
       ['```function("/peen", () => {}```'],
-      ['/peen'],
+      ['/peena'],
       [''],
       [' '],
       [' /'],
diff --git a/botCommands/time.test.js b/botCommands/time.test.js
index 6ae5b56..462d203 100644
--- a/botCommands/time.test.js
+++ b/botCommands/time.test.js
@@ -1,5 +1,5 @@
 const command = require('./time')
-const generateMentions = require('./mockData')
+const { generateMentions } = require('./mockData')
 
 describe('/time', () => {
   describe('regex', () => {
@@ -18,7 +18,7 @@ describe('/time', () => {
       ['/ti'],
       ['/times'],
       ['```function("/time", () => {}```'],
-      ['/time'],
+      ['/timea'],
       [''],
       [' '],
       [' /'],