【问题标题】:How to make discord bot reply messages to user such that no one else can see the messages in channel?如何让不和谐的机器人回复用户消息,以使其他人无法看到频道中的消息?
【发布时间】:2021-02-04 16:52:26
【问题描述】:

我是不和谐的新手,并试图制作一个机器人,当用户收到命令时,它会回复用户,其中用户和机器人之间的消息将只对使用该命令的用户可见。我不知道该怎么做。这是我的以下代码源:

        if (message.author.bot) return;
        const filter = m => m.author.id === message.author.id;
    message.reply("Enter your email Id please? you have some time of 100 seconds")
        .then(msg => msg.delete(10000)) // so the message will delete after the time is up (10 seconds)
            .catch(err => {}) // if the bot hasnt got perms to delete the message, it will ignore the error 
    message.channel.awaitMessages(filter, {
        max: 1, // do NOT change this 
        time: 10000, // this is the time in MS you want it to last. (There are 1000 MS in 1 second)
        errors: ['time'] // this ensures the only error is "time"
    }).then(async(collected) => { // collected is a collection so we use collected.first().content
        if (collected.first().content.toLowerCase() == 'cancel') { // .toLowerCase() converts the user input to lower case, so if they type "CaNcEl" it will still be read as "cancel" and the if statement will run
            message.reply(":sob: The command has been cancelled.") // what to do if the user repleis "cancel"
        } 
       email = collected.first().content; // finally send the collected message content to the message channel
       if(email == emailregistered){
        console.log(email);
        message.reply("Check your DM please!");
        }else{
        message.reply("Sorry You are not authorized! Please contact  team to get access to the channel!");
        }
    }).catch(() => {
        message.reply("You took too long!")
    })
       
    }else{
        message.reply("Channel Name does not exist, Try contacting  Dev");
    }

   
}

【问题讨论】:

    标签: javascript node.js discord discord.js bots


    【解决方案1】:

    通常你会使用以下输出消息:

    await message.channel.send("TEST")
    

    要向用户发送直接消息,请使用以下命令:

    await message.author.send("TEST")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-12-06
      • 2021-03-05
      • 1970-01-01
      • 2021-08-14
      • 1970-01-01
      • 2021-11-19
      • 2018-11-19
      相关资源
      最近更新 更多