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

查明某人是否有角色

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

問題描述

我為服務(wù)器制作了一個簡單的報價機(jī)器人,但管理員只希望 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 角色,它會起作用,但大多數(shù)時候它不會.如果我這樣做了

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,但會起作用嗎?老實(shí)說,我現(xiàn)在不知道.

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() 好,因?yàn)?.find() 返回角色對象(或未定義),然后將其轉(zhuǎn)換為布爾值..some() 方法默認(rèn)返回一個布爾值.

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.

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

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

相關(guān)文檔推薦

Using discord.js to detect image and respond(使用 discord.js 檢測圖像并響應(yīng))
Check if user ID exists in Discord server(檢查 Discord 服務(wù)器中是否存在用戶 ID)
Guild Member Add does not work (discordjs)(公會成員添加不起作用(discordjs))
Creating my first bot using REPLIT but always error Discord.JS(使用 REPLIT 創(chuàng)建我的第一個機(jī)器人,但總是錯誤 Discord.JS)
How do I code event/command handlers for my Discord.js bot?(如何為我的 Discord.js 機(jī)器人編寫事件/命令處理程序?)
How to find a User ID from a Username in Discord.js?(如何從 Discord.js 中的用戶名中查找用戶 ID?)
主站蜘蛛池模板: 日韩中文一区 | 成人午夜视频在线观看 | 亚洲一区免费在线 | 日韩欧美视频网站 | 日韩a v在线免费观看 | 欧美日韩最新 | www.狠狠干 | 日本涩涩视频 | 黄色精品 | 在线视频日韩 | 久久国产传媒 | 久久久久亚洲精品国产 | 久久久久99| 久久精品亚洲 | 亚洲va国产日韩欧美精品色婷婷 | 一级欧美一级日韩片免费观看 | 日韩电影一区二区三区 | 国产做爰 | 亚洲视频在线播放 | а_天堂中文最新版地址 | 欧美亚洲视频 | 嫩草影院黄 | 成人免费福利视频 | 日p视频免费看 | 精品国产一区二区在线 | www.日韩系列 | 本地毛片 | 亚洲网视频| 欧美国产精品一区二区三区 | 国产成人免费网站 | 五月激情综合网 | 国产成人福利在线观看 | 久久精品中文字幕 | 国产精品性做久久久久久 | 亚洲第一天堂无码专区 | 国产伦一区二区三区视频 | 国产一区二区视频在线观看 | 欧美日韩福利 | 久久久国产一区二区三区 | 国产精品久久久久永久免费观看 | 一区二区三区国产在线观看 |