Discord java bot按名称验证用户

Discord java bot按名称验证用户,java,discord,Java,Discord,在我当前的Discord(java)bot中,我试图对用户名应用命令。如何确保这是一个实际的现有用户 在psuedo代码中: if User "A" exists { User "A" types something at all send message "hello"+ user "A" } else { this is no valid user; } 我不知道如何编写“检查是否存在代码”。这是来自JDA实用程序,它是构建discord Bot时非常有用的工具 import com.j

在我当前的Discord(java)bot中,我试图对用户名应用命令。如何确保这是一个实际的现有用户

在psuedo代码中:

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

我不知道如何编写“检查是否存在代码”。

这是来自JDA实用程序,它是构建discord 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!");
        }
    }
}

告诉我们你有什么样的数据,是字符串还是类?请提供更多信息,我想我可以用字符串检查用户名。大致如下:String Checkuser=“john”。然后验证john是否是discord Channel中的真实用户,然后您已经拥有该用户名,只需将其与现有用户名进行比较即可。既然您说它是字符串,就不要使用
=
而是使用
equals()