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

查明某人是否有角色

Find out if someone has a role(查明某人是否有角色)
本文介紹了查明某人是否有角色的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我為服務器制作了一個簡單的報價機器人,但管理員只希望 mod+ 的人能夠添加報價以避免垃圾郵件.我去了文檔并做了所有事情,但我無法讓它工作.這是我所擁有的:

I made a simple quote bot for a server, but the admin only wants mod+ people to be able to add quotes to avoid spam. I went to the documentation and did everything, but I can't get this to work. Here's what I have:

//other code
else if (command === "addquote" && arg) {
    let adminRole = message.guild.roles.find("name", "Admin");
    let modRole = message.guild.roles.find("name", "Mod");

    if(message.member.roles.has(adminRole) || message.member.roles.has(modRole)){
        const hasArr = arr.some((el) => {
            return el.toLowerCase().replace(/s/g, '') === arg.toLowerCase().replace(/s/g, '');
        });

        if(hasArr){
            message.channel.send(arg.replace(/s+/g,' ').trim() + " is already a Quote");
        } else {
            fs.appendFileSync('./Quotes.txt', '
' + arg);
            message.channel.send("Quote added: " + arg);
            arr.push(arg);            
        }   
    }
}

非常挑剔.有時,如果用戶具有 mod 角色,它會起作用,但大多數時候它不會.如果我這樣做了

It's very finicky. Sometimes it will work if the user has the mod role, most of the times it wont. If I do

console.log(message.memeber.roles.has(adminRole));
console.log(message.memeber.roles.has(modRole));

兩者都將輸出為 false,但會起作用嗎?老實說,我現在不知道.

both will output to false, but will work? Honestly, I have no idea at this point.

推薦答案

discord.js api 已更新,由于 .exists() 已被棄用,因此有更好的方法.

The discord.js api has been updated and there is a better way since .exists() has been deprecated.

if (message.member.roles.cache.some(role => role.name === 'Whatever')) {}

這比 .find() 好,因為 .find() 返回角色對象(或未定義),然后將其轉換為布爾值..some() 方法默認返回一個布爾值.

This is better than .find() because .find() returns the role object (or undefined) which is then converted into a boolean. The .some() method returns a boolean by default.

這篇關于查明某人是否有角色的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

Using discord.js to detect image and respond(使用 discord.js 檢測圖像并響應)
Check if user ID exists in Discord server(檢查 Discord 服務器中是否存在用戶 ID)
Guild Member Add does not work (discordjs)(公會成員添加不起作用(discordjs))
Creating my first bot using REPLIT but always error Discord.JS(使用 REPLIT 創建我的第一個機器人,但總是錯誤 Discord.JS)
How do I code event/command handlers for my Discord.js bot?(如何為我的 Discord.js 機器人編寫事件/命令處理程序?)
How to find a User ID from a Username in Discord.js?(如何從 Discord.js 中的用戶名中查找用戶 ID?)
主站蜘蛛池模板: 国产成人综合网 | 黄色激情毛片 | 人人做人人澡人人爽欧美 | 99只有精品| 成人在线免费观看视频 | 欧美久久一级特黄毛片 | 免费看国产片在线观看 | 久草免费在线 | 久久久无码精品亚洲日韩按摩 | 亚洲精品4| 日韩免费在线 | 午夜在线视频一区二区三区 | 9191av| 国产亚洲一区二区精品 | 天天操天天摸天天爽 | 免费观看的av | 一区二区在线不卡 | www.4567| 国产色婷婷精品综合在线播放 | 国产精品99久久久久久久久久久久 | 狠狠色综合久久丁香婷婷 | 欧美精品91 | 久久久夜色精品亚洲 | 99久久精品免费看国产四区 | 久久久久久久国产精品影院 | 欧美日韩国产高清 | 99精品久久久国产一区二区三 | 国产成人精品一区二区三区在线 | 亚洲伊人精品酒店 | 成人精品视频在线 | 国产欧美一区二区三区久久 | 亚洲欧美在线观看 | 国产精品久久久久久久久久久久久久 | 99免费精品视频 | 久久激情五月丁香伊人 | 四色成人av永久网址 | 欧美日韩不卡 | 日韩精品免费一区 | 日本精品久久久久 | 国产一区二区在线播放 | 99久久久99久久国产片鸭王 |