小编It'*_*o20的帖子

如果有使用discordjs 的用户,请了解我

所以我试图获取用户个人资料上的“关于我”部分,然后将其放在节点画布上,但在不和谐的js上找不到文档,所以只是检查它是否可能

我的个人资料画布代码:

        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')) …
Run Code Online (Sandbox Code Playgroud)

node-canvas discord.js

5
推荐指数
1
解决办法
3838
查看次数

标签 统计

discord.js ×1

node-canvas ×1