This snippet will set a default nickname to newly joined users with inappropriate username
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
const user = context.params.event.user;
const HITLIST = ["bad", "unacceptable", "inappropriate", "words"]; // List all the words that you want to filter out from user's username
let nickName = `Omitted#${user.discriminator}`; //this will be the default nickname
for(let i = 0; i < HITLIST.length; i++){
let regex = new RegExp(HITLIST[i], 'gi' );
if(user.username.match(regex)){
return lib.discord.guilds['@0.2.4'].members.update({
user_id: `${user.id}`,
guild_id: `${context.params.event.guild_id}`,
nick: nickName
});
}
}