Get autocode info like about me, autocode username, autocode displayname and autocode user icon in discord. Example: !profile nintendobot2 will send back this https://cdn.discordapp.com/attachments/937274428067295272/949685379450150952/developer-testing_-_Google_Chrome_05-03-2022_20_40_10.png
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
const args = context.params.event.content.split(' ').slice(1);
if (!args.length) {
await lib.discord.channels['@0.1.2'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: `No username provided. It should be used as !autocode-profile [username]`,
});
} else {
let info = await lib.http.request['@1.1.6'].get({
url: `https://autocode.com/${args}/?prefetch`,
});
if (info.data.data === null) {
await lib.discord.channels['@0.1.2'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: `No username found.`,
});
}else {
if (!info.data.data.user.display_name) {
display_name = info.data.data.user.username;
} else {
display_name = info.data.data.user.display_name;
}
await lib.discord.channels['@0.3.0'].messages.create({
"channel_id": `${context.params.event.channel_id}`,
"content": " ",
"tts": false,
"components": [
{
"type": 1,
"components": [
{
"style": 5,
"label": `View Profile`,
"url": `https://autocode.com/${args}/`,
"disabled": false,
"type": 2
}
]
}
],
"embeds": [
{
"type": "rich",
"title": "",
"description": `π¨ **Username:** ${info.data.data.user.username}
π **Display name:** ${display_name}
π
**Created at:**
π§βπ **About me:** ${info.data.data.user.about_me}`,
"color": 0x00FFFF,
"image": {
"url": `https://cdn.discordapp.com/attachments/911294620439293993/942672443821137940/banner.png`,
"height": 0,
"width": 0
},
"thumbnail": {
"url": `${info.data.data.user.full_image_url}`,
"height": 0,
"width": 0
},
"author": {
"name": `${display_name}`,
"icon_url": `${info.data.data.user.full_image_url}`
}
}
]
});
}
}