TypeError:client.users.get 不是函数 discord.js V12 [重复]

Posted

技术标签:

【中文标题】TypeError:client.users.get 不是函数 discord.js V12 [重复]【英文标题】:TypeError: client.users.get is not a function discord.js V12 [duplicate] 【发布时间】:2020-09-02 17:56:55 【问题描述】:

再次,当我将我的机器人更新到 discord.js V12 时,我收到了一个错误

TypeError:client.users.get 不是函数

我不知道 clent.users.get 是否还在 discord.js V12 中

这里是代码

const  MessageEmbed  = require("discord.js");
const  stripIndents  = require("common-tags");
const  prefix  = require("../../botconfig.json");
const db = require('quick.db')
let balance = require("../../database/balance.json");
let bank = require("../../database/bank.json");
module.exports = 
  config:
    name: "balance",
    aliases: ["bal"],
    category: "economy",
    description: "Gives you your balance",
    usage: "[command | alias]",
  ,
    run: async (client, message, args) => 
if (message.channel.type == "dm") return;  

  let member = message.mentions.users.first() || client.users.get(args[0]);
  if (!member) member = message.author;
  if (member.bot) return message.channel.send(`**$message.author.username**, Bot don't have a balance!`);
  //!coins
  //WAJIB biar ga undefined
    if(!balance[member.id])
      balance[member.id] = 
      balance: 0

      ;
    
    //wajib biar ga undefined
    if(!bank[member.id])
    bank[member.id] = 
      bank: 0
    ;
    
  //buat read json  
  let uBalance = balance[member.id].balance;
  let uBank = bank[member.id].bank
  if (uBalance == 0) 
    let bEmbed = new MessageEmbed()
    .setColor("RANDOM")
    .setTitle(`$member.username's Balance`)
    .addField(`Balance:`, `0`, true)
    .addField(`Bank:`, `0`, true)
    message.channel.send(bEmbed);
   else 
    let baEmbed = new MessageEmbed()
    .setColor("RANDOM")
    .setTitle(`$member.username's Balance`)
    .addField(`Wallet:`, `$uBalance`, true)
    .addField(`Bank:`, `$uBank`, true)
    message.channel.send(baEmbed);

  

    

我不知道我是否需要改变任何东西,但这就是我所拥有的。

【问题讨论】:

这能回答你的问题吗? How can I migrate my code to Discord.js v12 from v11? 【参考方案1】:

好的,我发现了错误...我忘了在client.users 之后添加cache

【讨论】:

以上是关于TypeError:client.users.get 不是函数 discord.js V12 [重复]的主要内容,如果未能解决你的问题,请参考以下文章

反应本机获取多标记[未处理的承诺拒绝:TypeError:TypeError:未定义不是对象(评估'this.state.markers.map

Django TypeError - TypeError: issubclass() arg 1 必须是一个类

pyspark:TypeError:'float'对象不可迭代

Python 3.8 TypeError: can't concat str to bytes - TypeError: a bytes-like object is required, not 's

TypeError: key 必须是一个字符串,一个缓冲区或一个对象在 typeError 与 GCP 文件存在

TypeError: jQueryxxxxxx 不是函数