displayAvatarURL() returns .webp 图像而不是 .gif
displayAvatarURL() returns an .webp image instead of a .gif
我的代码:
const { SlashCommandBuilder } = require('@discordjs/builders');
const Discord = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('avatar')
.setDescription('Get the avatar URL of the selected user.')
.addUserOption(option => option.setName('user').setDescription('The user\'s avatar to show')),
async execute(interaction) {
const user = interaction.options.getUser('user');
const embed = new Discord.MessageEmbed();
embed.setTitle(`${user.username}'s avatar`);
embed.setURL(user.avatarURL);
embed.setColor('RANDOM');
embed.setImage(user.displayAvatarURL() + "?size=1024");
interaction.reply({ embeds: [embed] });
}
};
基本上我希望它显示原始 image/gif 而不是 .webp 文件,因为出于某种原因它显示 .webp 文件
.displayAvatarURL()
采用 https://discord.js.org/#/docs/main/stable/typedef/ImageURLOptions,其中包含 dynamic
选项:
"If true, the format will dynamically change to gif
for animated avatars."
user.displayAvatarURL({
dynamic: true
});
我的代码:
const { SlashCommandBuilder } = require('@discordjs/builders');
const Discord = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('avatar')
.setDescription('Get the avatar URL of the selected user.')
.addUserOption(option => option.setName('user').setDescription('The user\'s avatar to show')),
async execute(interaction) {
const user = interaction.options.getUser('user');
const embed = new Discord.MessageEmbed();
embed.setTitle(`${user.username}'s avatar`);
embed.setURL(user.avatarURL);
embed.setColor('RANDOM');
embed.setImage(user.displayAvatarURL() + "?size=1024");
interaction.reply({ embeds: [embed] });
}
};
基本上我希望它显示原始 image/gif 而不是 .webp 文件,因为出于某种原因它显示 .webp 文件
.displayAvatarURL()
采用 https://discord.js.org/#/docs/main/stable/typedef/ImageURLOptions,其中包含 dynamic
选项:
"If true, the format will dynamically change to
gif
for animated avatars."
user.displayAvatarURL({
dynamic: true
});