久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Discord.js 錯誤提供的角色不是角色、雪花或數組或

Discord.js Error Supplied roles is not a Role, Snowflake or Array or Collection of Roles or Snowflakes(Discord.js 錯誤提供的角色不是角色、雪花或數組或角色或雪花的集合)
本文介紹了Discord.js 錯誤提供的角色不是角色、雪花或數組或角色或雪花的集合的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在為我的機器人創建一個靜音命令,如果還沒有一個靜音角色,它會創建一個靜音角色并將其提供給命令中提到的用戶,目前我得到的錯誤是;

I'm making a mute command for my bot where it creates a muted role if there isn't one already and gives it to the user that is mentioned in the command, currently the error im getting is;

[INVALID_TYPE]:提供的角色不是角色、雪花或數組或角色或雪花的集合.

我最好的猜測是,這個錯誤的發生是因為它沒有創建它應該創建的角色,它不能把它給提到的成員,不過我可能完全錯了.

My best guess is that this error occurs because it doesn't create the role that it is supposed to create therefor it cannot give it to the mentioned member, i may be completely wrong though.

const BaseCommand = require('../../utils/structures/BaseCommand');
const Discord = require('discord.js');

module.exports = class MuteCommand extends BaseCommand {
  constructor() {
    super('mute', 'moderation', []);
  }

  async run(client, message, args) {
    if(!message.member.hasPermission("MUTE_MEMBERS")) return message.channel.send("You do not have Permission to use this command.");
    if(!message.guild.me.hasPermission("MUTE_MEMBERS")) return message.channel.send("I do not have Permissions to mute members.");
    const Embedhelp = new Discord.MessageEmbed()
    .setTitle('Mute Command')
    .setColor('#6DCE75')
    .setDescription('Use this command to Mute a member so that they cannot chat in text channels nor speak in voice channels')
    .addFields(
      { name: '**Usage:**', value: '=mute (user) (time) (reason)'},
      { name: '**Example:**', value: '=mute @Michael stfu'},
      { name: '**Info**', value: 'You cannot mute yourself.
You cannot mute me.
You cannot mute members with a role higher than yours
You cannot mute members that have already been muted'}
   )
    .setFooter(client.user.tag, client.user.displayAvatarURL());

    let role = 'muted' || 'Muted';
    let newrole = message.guild.roles.cache.find(x => x.name === role);
    if (typeof newrole === undefined) {
      message.guild.roles.create({
        data: {
          name: 'Muted',
          color: '#ff0000',
          permissions: {
              SEND_MESSAGES: false,
              ADD_REACTIONS: false,
              SPEAK: false
          }
        },
        reason: 'to mute people',
      })
      .catch(console.log(err)); {
        message.channel.send('Could not create muted role');
      };
    };
    let muterole = message.guild.roles.cache.find(x => x.name === role);

    const mentionedMember = message.mentions.members.first() || await message.guild.members.fetch(args[0]);
    let reason = args.slice(1).join(" ");
    const banEmbed = new Discord.MessageEmbed()
     .setTitle('You have been Muted in '+message.guild.name)
     .setDescription('Reason for Mute: '+reason)
     .setColor('#6DCE75')
     .setTimestamp()
     .setFooter(client.user.tag, client.user.displayAvatarURL());

   if (!reason) reason = 'No reason provided';
   if (!args[0]) return message.channel.send(Embedhelp);
   if (!mentionedMember) return message.channel.send(Embedhelp);
   if (!mentionedMember.bannable) return message.channel.send(Embedhelp);
   if (mentionedMember.user.id == message.author.id) return message.channel.send(Embedhelp);
   if (mentionedMember.user.id == client.user.id) return message.channel.send(Embedhelp);
   if (mentionedMember.roles.cache.has(muterole)) return message.channel.send(Embedhelp);
   if (message.member.roles.highest.position <= mentionedMember.roles.highest.position) return message.channel.send(Embedhelp);

   await mentionedMember.send(banEmbed).catch(err => console.log(err));
   await mentionedMember.roles
  .add(muterole)
  .then(() => message.channel.send("There was an error while muting the member"))
  .catch((err) => console.log(err));

  } 
}

創建角色的代碼行是:

message.guild.roles.create({
        data: {
          name: 'Muted',
          color: '#ff0000',
          permissions: {
              SEND_MESSAGES: false,
              ADD_REACTIONS: false,
              SPEAK: false
          }
        },
        reason: 'to mute people',
      })

推薦答案

您可以使用 async/await 或 .then,但我建議使用 async/await.例如:

You can use either async/await or .then, but i recommend using async/await. For example:


const mentionedMember = message.mentions.members.first() || await 
message.guild.members.fetch(args[0]);

const newMutedRole = await message.guild.roles.create({
        data: {
          name: 'Muted',
          color: '#ff0000',
          permissions: {
              SEND_MESSAGES: false,
              ADD_REACTIONS: false,
              SPEAK: false
          }
        },
        reason: 'to mute people',
      })


mendtionedMember.roles.add(newMutedRole)

這篇關于Discord.js 錯誤提供的角色不是角色、雪花或數組或角色或雪花的集合的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

discord.js v12: How do I await for messages in a DM channel?(discord.js v12:我如何等待 DM 頻道中的消息?)
how to make my bot mention the person who gave that bot command(如何讓我的機器人提及發出該機器人命令的人)
How to fix Must use import to load ES Module discord.js(如何修復必須使用導入來加載 ES 模塊 discord.js)
How to list all members from a specific server?(如何列出來自特定服務器的所有成員?)
Discord bot: Fix ‘FFMPEG not found’(Discord bot:修復“找不到 FFMPEG)
Welcome message when joining discord Server using discord.js(使用 discord.js 加入 discord 服務器時的歡迎消息)
主站蜘蛛池模板: 国产精品久久久久久久午夜片 | 国内成人免费视频 | 久久久成人动漫 | 久久精品日产第一区二区三区 | 91爱爱·com | 午夜精品一区二区三区免费视频 | 中文字幕视频在线看 | 福利网址 | 成人黄色网址大全 | 综合久久色 | 成人高清在线 | 午夜视频在线免费观看 | 成人片免费看 | 91欧美| 91性高湖久久久久久久久_久久99 | 国产高清免费视频 | 中文字幕视频在线观看 | 国产成人精品久久二区二区91 | a在线观看| 黑人精品 | 一区二区在线免费观看 | 国产一区二区三区四区在线观看 | 精品在线免费观看视频 | 成人免费在线视频 | 乱一性一乱一交一视频a∨ 色爱av | 不卡的av在线 | 午夜视频网 | 99久久久国产精品 | 欧美色偷拍 | 99re热这里只有精品视频 | 91久久综合| 亚洲成人播放器 | 日韩国产在线 | 做a网站 | 欧美视频三区 | 亚洲三区视频 | 成人免费小视频 | 亚洲欧美激情精品一区二区 | 亚洲欧美中文日韩在线v日本 | 国产电影一区二区 | 国产一级一级毛片 |