gpt4 book ai didi

discord.js - 如果有使用 discordjs 的用户,请了解我

转载 作者:行者123 更新时间:2023-12-04 14:03:11 25 4
gpt4 key购买 nike

因此,我试图在用户个人资料上获取关于我的部分,然后将其放在节点 Canvas 上,但在 discordjs 上找不到文档,因此只需检查它是否可能
我的个人资料 Canvas 代码:

        const Discord = require('discord.js')
const Canvas = require('canvas');
const client = new Discord.Client({
intents: ['DIRECT_MESSAGES', 'GUILD_MESSAGES', 'GUILDS', 'GUILD_MEMBERS', 'GUILD_MESSAGE_REACTIONS', 'GUILD_VOICE_STATES', 'GUILD_PRESENCES']
});

const applyText = (canvas, text) => {
const context = canvas.getContext('2d');
let fontSize = 70;

do {
context.font = `${fontSize -= 10}px sans-serif`;
} while (context.measureText(text).width > canvas.width - 300);
return context.font;
};

client.on('messageCreate', async message => {
if (message.author.bot) return;
if (message.channel.type === 'dm') return;
if (!prefix[message.guild.id]) return;
if (!langs[message.author.id]) return;
if (message.content.toLowerCase().startsWith(prefix[message.guild.id].custprefix + 'profile')) {
const canvas = Canvas.createCanvas(700, 250);
const context = canvas.getContext('2d');
const background = await Canvas.loadImage('./profiles/backround.jpg');
context.drawImage(background, 0, 0, canvas.width, canvas.height);
context.strokeStyle = '#34eb6e';
context.strokeRect(0, 0, canvas.width, canvas.height);

context.font = applyText(canvas, message.author.username);
context.fillStyle = '#ffffff';

context.fillText(message.author.username, canvas.width / 2.5, canvas.height / 3.8);
context.beginPath();
context.arc(125, 125, 100, 0, Math.PI * 2, true);
context.closePath();
context.clip();
const avatar = await Canvas.loadImage(message.author.displayAvatarURL({ dynamic: true, format: jpg }));
context.drawImage(avatar, 25, 25, 200, 200);
const attachment = new Discord.MessageAttachment(canvas.toBuffer(), 'profile-image.png');
message.channel.send({ files: [attachment] })
}
})

最佳答案

机器人目前无法获取用户的个人简介。
An Issue/Feature Request在 discord-api-docs 存储库上打开
说明:

Currently, user bio and banner fields are only returned on the profile endpoint, so they cannot be accessed via bots or OAuth2. It would be useful if they were returned in endpoints that can be accessed.


您可以点击链接了解更多信息

关于discord.js - 如果有使用 discordjs 的用户,请了解我,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69339283/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com