This snippet will check if a message contains a rickroll link and respond to it if it does. Uses an up-to-date list from Github to make sure you will never be rickrolled again! You can add more links in the github repo: https://github.com/larssieboy18/rickroll-list
// authenticates you with the API standard library
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
/* if you want to add more rickroll links and/or responses, feel free to contribute to the github repo:
https://github.com/larssieboy18/rickroll-list
This snippet will automatically pull the newest data so you are protected against all rickrolls!
*/
// set variables
let {id, guild_id, channel_id, content, author} = context.params.event;
let {username} = author;
// get the latest data (rickroll links and responses) from github
let rickroll = (
await lib.http.request['@1.1.6'].get({
url: `https://raw.githubusercontent.com/larssieboy18/rickroll-list/main/rickrolls.json`,
})
).data.rickrolls;
let response = (
await lib.http.request['@1.1.6'].get({
url: `https://raw.githubusercontent.com/larssieboy18/rickroll-list/main/responses.json`,
})
).data.discord;
// run the following code for every url that is listed
for (let i = 0; i < rickroll.length; i++) {
let rickrollLink = rickroll[i];
// because URL's contain special characters, we need to filter those
let specialCharacters = rickroll[i].match(/\W/gi);
for (let z = 0; z < specialCharacters.length; z++) {
rickrollLink = rickrollLink.replace(/(?