java—有没有一种方法可以通过不一致的名称获得成员?

41zrol4v  于 2021-07-11  发布在  Java
关注(0)|答案(1)|浏览(206)

我正在使用java的jda包编写一个discord bot,并正在寻找一种通过discord名称获取成员的方法。名称应如下所示: IPSDSILVA#1849 .
我已经查过了,但我看到的唯一结果是服务器中包含成员id的结果,如下所示: 1234567890L .
我的代码如下所示。我已经评论了我需要帮助的地方:

import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;

public class Commands {
    public void onMessage(GuildMessageReceivedEvent event) {
        String[] args = event.getMessage().getContentRaw().split(" ");

        if (args[0].equalsIgnoreCase(Main.prefix + "info")) {
            EmbedBuilder embed = new EmbedBuilder();

            embed.setTitle("Information");
            embed.setDescription("This is a moderation bot. " +
                    "This bot moderates servers that it is in. " +
                    "Enter `?help` for information about the available commands. " +
                    "For help with the bot, suggestions, or more, please contact the creator: IPSDSILVA#1849.");
            embed.setColor(0xff9d00);
            embed.addField("Creator", /* Here, I need to get my profile picture, as the creator. In other words, I need to get my own profile picture, and put it here */, false);
        }
    }
}

谢谢你的帮助。

svujldwt

svujldwt1#

尝试使用guild#getmemberastag()方法。https://ci.dv8tion.net/job/jda/javadoc/net/dv8tion/jda/api/entities/guild.html#getmemberbytag(java.lang.string)

相关问题