Now for the fun part! Scripts are what makes Canal unique. They are hot swappable pieces of code that define how your bot functions.
- Head to the Scripts tab in the dashboard
- Click the plus in the bottom right
- Give your script a name, we're going to be using
dadbot
as an example
- Paste in the following code
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);
})
- Click the deploy icon in the top right, then choose the bot you created earlier
- Your script will now be running on your bot! Congrats!
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.
- In the Canal dashboard, select the Bots tab, then click on the bot that you created.
- Under overview, select Copy Invite Link
- Paste this URL into a browser, and choose a Discord server
- Your bot's in a server! Go you! Now, try saying I'm Bored in the server you just added it to