【问题标题】:if (fn(val, key, this)) error (Discord.js)if (fn(val, key, this)) 错误 (Discord.js)
【发布时间】:2020-12-24 16:29:05
【问题描述】:

此程序应将角色添加到服务器成员 这是一个错误:

Users\Администратор.ADMIN-5IU14HIGH\Desktop\DSBot\node_modules@discordjs\collection\dist\index.js:235 if (fn(val, key, this)) ^ TypeError: fn 不是函数

const Discord = require('discord.js');
const client = new Discord.Client();
const guild = new Discord.Guild();
module.exports = {
    name: 'role',
    description: 'role',
    execute(message, args) {
        const member = message.mentions.members.first();
        let myRole = message.guild.roles.cache.some(791413811529515008);
        member.roles.add(role);
        
    },
};

【问题讨论】:

    标签: discord.js


    【解决方案1】:

    .some 接收一个函数,如果集合中的某个值与该函数匹配,则返回 true。你传入一个值,所以你得到错误。您想实际获取键的值,因此使用get 函数:

    let myRole = message.guild.roles.cache.get(791413811529515008);
    

    【讨论】:

      猜你喜欢
      • 2021-01-26
      • 2015-11-09
      • 2014-02-13
      • 2020-08-23
      • 2020-09-23
      • 2018-04-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多