Use the command `!my-avatar` to change your bots icon to the attached image. The env variable OWNER_ID is your ID (or the ID of the user you want to have access to this command)
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
if (context.params.event.author.id == process.env.OWNER_ID) {
if (!context.params.event.attachments?.length)
return lib.discord.channels['@0.3.1'].messages.create({
channel_id: context.params.event.channel_id,
content: `You must attach a file`,
});
if (!context.params.event.attachments[0].content_type.includes('image'))
return lib.discord.channels['@0.3.1'].messages.create({
channel_id: context.params.event.channel_id,
content: `You must attach a valid image`,
});
let req = await lib.http.request['@1.1.7']({
method: 'GET',
url: context.params.event.attachments[0].url,
});
await lib.discord.users['@0.2.1'].me.update({
avatar: req.body,
});
await lib.discord.channels['@0.3.1'].messages.create({
channel_id: context.params.event.channel_id,
content: `Updated my avatar to:`,
attachments: [
{
file: req.body,
filename: context.params.event.attachments[0].filename,
description: ``,
},
],
});
}