简体   繁体   English

Discord Java bot通过名称验证用户

[英]Discord java bot verify user by name

in my current Discord (java) bot im trying to apply a command to a user name. 在我当前的Discord(java)机器人中,我试图将命令应用于用户名。 how can i make sure this is an actual existing user ? 我怎样才能确定这是一个实际的现有用户?

in psuedo code: 在伪代码中:

if User "A" exists {
User "A" types something at all
send message "hello"+ user "A"
}
else 
{
this is no valid user;
}

i can't figure out how to write the 'check if exist code'. 我不知道如何编写“检查是否存在代码”。

This is from JDA-Utilities which is a really useful tool when building discord bots. 这是来自JDA-Utilities的,它在构建不一致的bot时是一个非常有用的工具。

import com.jagrosh.jdautilities.command.Command;
import com.jagrosh.jdautilities.command.CommandEvent;

public class Example extends Command {
    public Example() {
        this.name = "'isBot";
        this.help = "Tells you if the user is a bot!";
    }
    @Override
    protected void execute(CommandEvent e) {
        if (e.getAuthor().isBot()) {
            e.reply("Hey you're not a person!!");
        } else {
            e.reply("Hey " + e.getAuthor().getName() + ", you're not a bot!");
        }
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM