A prefix command that sends a user's discord profile picture
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN}); //This line of code is required for this snippet to work
const events = context.params.event; //this line of code makes a variable that can be used as context.params.event
const message = events.content; //this line of code is creating a variable and its value is the command , this code only works with prefix commands and not slash commands
const user_id = message.split(' ')[2]; //this line of code get the id of the user in the prefix commands and to be specific it gets the third word/number/mention in the message , to edit it replace [2] with [Num] and Num starts from 0 and not 1
let user = await lib.discord.users['@0.2.1'].retrieve({
user_id: `${user_id}`,
}); // these lines of codes made an object that has the pfp of the user and some other things like the id of the user
const imageUrl = user.avatar_url; //this line of code makes a variable and its value is the profile picture of the user we want , when the profile picture of the user is the default discord profile picture the value change automatically to undefined
if (imageUrl === undefined) {
//this line of code checks if the profile picture is the default discord profile picture
await lib.discord.channels['@0.3.2'].messages.create({
// this line of code checks of the profile picture is the default discord profile picture
channel_id: `${context.params.event.channel_id}`,
content: `Sorry , this bot doesn't support the default discord profile picture`,
tts: false,
}); //these lines send a message that you can change by edit the tect inside `` that is after content:
} else {
//this line of code does the commands below when the profile picture is not the default discord profile picture
await lib.discord.channels['@0.3.2'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: `${imageUrl}`,
tts: false,
}); //these lines of codes send the profile picture of the user that is mentioned in the prefix command to the user who sent the message that has the command
}