Now for the fun part! Scripts are what makes Canal unique. They are hot swappable pieces of code that define how your bot functions.

TRIGGER = 'i\\'m ';
client.on('message', async (m) => {
  if(!m.content.toLowerCase().startsWith(TRIGGER)) return;
  let text = 'Hi, ' + m.content.substr(TRIGGER.length) + ', I\\'m dad';
  text = text.replace(/@[a-zA-Z]+/g, m.author);
  m.channel.send(text);
})

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/9cef9d02-c98f-430e-9619-a4437655c176/Untitled.png

Testing the new script out

Now, you've got the bot, but no way to chat to it! This section will show you how to add it to an existing discord server.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/d4dfdc46-dae0-41e4-b3cf-3b711036d97e/Untitled.png