本文介绍了JDA-转换“用户"成为“会员"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为了从不同用户中删除角色,我使用以下代码行:
In order to remove roles from different users I use the following lines of code:
Member member = e.getMember();
Guild guild = member.getGuild();
for (Role role : guild.getRoles()) {
System.out.println("getting em!");
System.out.println(role.getId());
if (role.getId().equals("496415978603675658")) {
System.out.println("he has it, boss");
guild.getController().removeSingleRoleFromMember(member, role)
.complete();
guild.getController().addSingleRoleToMember(member, jda.getRoleById("496415995569766410"))
.complete();
}
}
它可以正常工作,但是问题在于它仅适用于Member对象( e.getMember
),而我不知道如何以其他方式检索Member对象.我将另一个用户存储为用户对象,但是我不知道如何将其转换为成员.
It works just fine, but the issue is that it only works with a Member object (e.getMember
), and I can't figure out how do I retrieve the Member object otherwise. I have the other User stored as a User Object but I don't know how to convert him into a Member.
推荐答案
Member member = guild.getMember(user);
这篇关于JDA-转换“用户"成为“会员"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!