cmd.user.avatar
Returns the avatar URL of a user. If no ID is provided, returns the avatar of the message author.
JavaScript
const { cmd } = require("syntx.js");
await cmd.user.avatar(id, message, options);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | No | The user ID to fetch the avatar for. Defaults to the message author. |
message | discord.js Message | Interaction | Yes | The message or interaction context. |
options | object | No | Image options. See options below. |
Options
| Field | Type | Default | Description |
|---|---|---|---|
format | string | "png" | Image format: "png", "jpg", "webp", or "gif" for animated avatars. |
size | number | 128 | Image size in pixels. Must be a power of 2 between 16 and 4096. |
Returns
string : The URL of the user's avatar.
Examples
Get the message author's avatar
JavaScript
client.command({
name: "avatar",
content: async (message) => {
const url = await cmd.user.avatar(null, message, { size: 512 });
message.reply(url);
},
});Get another user's avatar
JavaScript
client.command({
name: "avatar",
content: async (message) => {
const id = cmd.message.mentioned(message, 1);
if (!id) return message.reply("Please mention a user.");
const url = await cmd.user.avatar(id, message, { size: 1024, format: "webp" });
message.reply(url);
},
});