簡體   English   中英

(Discord.JS)我如何聽取作者選擇的特定用戶的用戶提及

[英](Discord.JS) How do I listen for a user mention for a specific user chosen by the author

所以我正在制作一個 Discord.Js 機器人,其中包含一個命令,可以讓我提供某些用戶的信息。 例如:我想添加一個命令,該命令將提供提到的用戶的 PlayStation 玩家標簽(假設特定的用戶 ID 是 <@123>)。 輸入消息看起來像這樣:

".psn @mention" 然后機器人將 output 他的玩家標簽,我將手動記錄為 --> message.channel;send('Here is <@1235467890>'s @psnname');

我想在我的服務器中包含每個成員的玩家標簽,這樣任何人都可以在使用命令“psn”提及它時請求它,我已經用不同的代碼經歷了大量的試驗和錯誤,但我不知道如何指定消息。提及.members.first(); 通過特定的用戶 ID。 請幫忙

module.exports = {

name: 'codtag',
execute(message, args){

    let member = message.mentions.members.first();

    if(!args.length){
        return message.channel.send({embed: {
            
            color: '#da1801',
            title: 'Activision Gamertag: Error',
            description: 'You need to tag a user dummy.'
    }})
}  
   
   if (member !== '<@772597378142306354>')return;
       else if (member === `772597378142306354`)return 
       {
    (args[0] === member)
        return message.channel.send({embed: {
            
            color: '#1243c6',
            title: 'Activision Gamertag',
            description: 'Here is <@772597378142306354> Activision: \n\n **WalterWhite#2396124**'
     
        }});

    }}

}

對於發現此帖子有相同問題的任何人,我想通了。 以下代碼完美運行

我補充說: let guild = message.mentions.members.first();

我還將 args[0] 的條件包括為: if (message.mentions.members.had('put users id here without the <@>')

module.exports = {

    name: 'cod',
     execute(message, args){


      let guild =  message.mentions.members.first();

        if(!args.length){
            return message.channel.send({embed: {
                
                color: '#da1801',
                title: 'Activision Gamertag: Error',
                description: 'You need to tag a valid user dummy.'
        }})
    }  
       
     if(message.mentions.members.has('772597378142306354')){
     
     (args[0] == guild)
             message.channel.send({embed: {
                
                color: '#1243c6',
                title: 'Activision Gamertag',
                description: 'Here is <@772597378142306354> Activision: \n\n **WalterWhite#2396124**',
                footer: {

                    text: 'Message @issmayo if your gamertag is not included.'
                }
         
            }});
   
        }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM