如果有人使用 discordjs,让用户了解我

Getting a users about me if has one using discordjs

所以我试图在用户个人资料上获取关于我的部分,然后将其放在节点上 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.

您可以关注link获取更多信息