javascript - 获取用户头像时出错 (discord.js)
问题描述
代码
module.exports.run = async (bot, message, args) =>{
// at the top of your file
const discord = require('discord.js');
const config = require("../config");
// inside a command, event listener, etc.
const embed = new discord.MessageEmbed()
.setColor('RANDOM')
.setTitle('Créditos do Os Profissionais')
.setURL('https://discord.gg/')
.setAuthor('Effy', 'https://i.imgur.com/wSTFkRM.png', 'https://stackoverflow.com/users/15303029/meredithgrey')
.setDescription('Criador do grupo e desenvolvedor do BOT')
.setThumbnail('https://i.imgur.com/1oHJJZQ.png')
.addFields(
{ name: 'Créditos de equipe', value: 'Equipe gestora' },
{ name: '\u200B', value: '\u200B' },
{ name: 'Snoot', value: 'Owner', inline: true },
{ name: 'Texugo', value: 'Owner', inline: true },
)
.addField('Leo', 'Owner', true)
.setImage('https://i.imgur.com/1oHJJZQ.png')
.setTimestamp()
.setFooter(message.author.username, message.author.avatar);
message.channel.send(embed);
}
module.exports.config = {
name: "credits",
aliases: ["creditos"]
}
错误:
(node:5676) UnhandledPromiseRejectionWarning: DiscordAPIError: Invalid Form Body
embed.footer.icon_url: Scheme "fbea7946b1cf05e3bfbff344733ba775" is not supported. Scheme must be one of ('http', 'https').
at RequestHandler.execute (C:\Users\Pc\Desktop\RemakeTO\node_modules\discord.js\src\rest\RequestHandler.js:154:13)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async RequestHandler.push (C:\Users\Pc\Desktop\RemakeTO\node_modules\discord.js\src\rest\RequestHandler.js:39:14)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:5676) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:5676) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
自从我开始使用 discord.js V12 时,我就带着很多疑问,其中之一是,如何捕捉用户的头像?有人能帮我吗?我知道这是一个愚蠢的怀疑,但我真的不知道
解决方案
message.author.avatar
不是一种方法。你需要message.author.avatarURL
//author's avatar:
.setThumbnail(message.author.avatarURL);
如上所述,尝试使用文档
推荐阅读
- r - 在 R 中读取一个非常小的 p 值
- java - 打印 100 到 1000 之间的素数,其数字总和等于 19
- python - Python - 如何从第 0 个元素而不是第 x 个元素循环数组?
- google-sheets - Google Sheet - 一个接一个地放置 3 个动态列(原始更改的数量)以创建一个列表
- google-apps-script - 替换特定文件夹的多个 Google 文档中的文本
- angular - 处理程序 Ionic PWA ionBackButton
- postgresql - postgresql:使用序列键创建表作为联合选择
- java - 问题:参考变量和while循环问题
- python - 在 Python MySQL 连接器的数据框中显示列名
- azure - 定期将 azure cosmos db 复制到 dev cosmos db 的最佳方法?