Discord.js & Canvacord:错误:libuuid.so.1:无法打开共享对象文件:没有这样的文件或目录

Posted

技术标签:

【中文标题】Discord.js & Canvacord:错误:libuuid.so.1:无法打开共享对象文件:没有这样的文件或目录【英文标题】:Discord.js & Canvacord: Error: libuuid.so.1: cannot open shared object file: No such file or directory 【发布时间】:2022-01-06 11:53:39 【问题描述】:

在我的命令文件夹中添加 level.js 文件并运行机器人后,它显示了错误:

node:internal/modules/cjs/loader:1183
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: libuuid.so.1: cannot open shared object file: No such file or directory
    at Object.Module._extensions..node (node:internal/modules/cjs/loader:1183:18)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:94:18)
    at Object.<anonymous> (/home/runner/UnfortunateDistortedEngine/node_modules/canvas/lib/bindings.js:3:18)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:94:18)
    at Object.<anonymous> (/home/runner/UnfortunateDistortedEngine/node_modules/canvas/lib/canvas.js:9:18)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) 
  code: 'ERR_DLOPEN_FAILED'

level.js文件代码:

const  client, CommandInteraction, MessageEmbed  = require("discord.js");
const db = require('quick.db')
const canvacord = require("canvacord");
const Levels = require('discord-xp')

module.exports = 
  name: "level",
  description: "Displays the user's level and XP.",
  type: 'CHAT_INPUT',
  options: [
    
      name: "member",
      type: "USER",
      description: "Specify a user.",
      required: false
    
  ],
  run: async (client, interaction, args) => 
    let user1 = message.author;
    const Blacklisted = db.fetch(`blacklistedUsers_$user1.id`)
    if (Blacklisted === true) return;
    let target = await interaction.options.getUser('member')
    let mentionedMember = target || interaction.user;
    const user = await Levels.fetch(mentionedMember.id, interaction.guild.id, true)

    const rank = new canvacord.Rank()
      .setAvatar(mentionedMember.displayAvatarURL( format: 'png', size: 512 ))
      .setCurrentXP(mentionedMember.xp || 0)
      .setRequiredXP(Levels.xpFor(user.level + 1) || Levels.xpFor(1))
      .setRank(user.position)
      .setLevel(user.level)
      .setStatus(mentionedMember.presence.status)
      .setBackground("IMAGE", "https://i.pinimg.com/originals/22/90/0f/22900f16a05211e2562828b6b3fe86b7.jpg")
      .setProgressBar("#FFFFFF")
      .setUsername(mentionedMember.username)
      .setDiscriminator(mentionedMember.discriminator);

    rank.build()
      .then(data => 
        const attachment = new MessageAttachment(data, "RankCard.png");
        interaction.followUp(
      files: [attachment]
    )
      );
    
  

在 GitHub 上已经打开了一个issue,但是打开者没有说明任何解决方案,只是说“已解决”。这与使用画布的 Canvacord 包有关。

【问题讨论】:

【参考方案1】:

您需要libuuid,它是node-canvas 的依赖项,而canvacord 的开发依赖项又是canvacord 的依赖项,它通常预装在许多Linux 系统中,尽管您可以使用

apt-get install libuuid1

要安装它,这应该可以解决问题,请注意,如果您使用的主机(例如 repl.it)您没有 root 访问权限,则可能必须使用 Nix。

【讨论】:

安装后还是一样的错误。

以上是关于Discord.js & Canvacord:错误:libuuid.so.1:无法打开共享对象文件:没有这样的文件或目录的主要内容,如果未能解决你的问题,请参考以下文章

Discord.JS 嵌入:页脚中的用户头像

无法使用 Discord.js 在数据库中写入和读取值

Discord.js & Canvacord:错误:libuuid.so.1:无法打开共享对象文件:没有这样的文件或目录

Discord.js 无法检查“lastMessage.content”

Discord.js - 通过 ID 或提及获取用户

打印用户在 discord.js 中显示用户 ID