Skip to content

Instantly share code, notes, and snippets.

@apos37
Created August 12, 2022 21:43
Show Gist options
  • Save apos37/1d90f212b51548bf4844940f425af70d to your computer and use it in GitHub Desktop.
Save apos37/1d90f212b51548bf4844940f425af70d to your computer and use it in GitHub Desktop.
Pylon Bot Avatar Command
/**
* Display any user's avatar
*/
commands.raw('avatar', async (message) => {
// Get the user id
const _mentions = message.mentions;
const _msg = message.content.replace('!avatar', '').replaceAll(' ', '');
var _userID = '';
if (_mentions[0]) {
_userID = _mentions[0].id;
} else if (_msg != '') {
_userID = _msg;
} else {
_userID = message.author.id;
}
// Get the user
const user = await discord.getUser(_userID);
// console.log(user);
// Get avatar
const avatar = user?.getAvatarUrl();
message.reply(
new discord.Embed({
title: `${user?.getTag()}'s Avatar`,
color: (Math.random() * 0xffffff) | 0,
footer: {
text: '!avatar',
},
})
.setTimestamp(new Date().toISOString())
.setImage({ url: avatar })
);
// console.log(_profileName);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment