本文整理汇总了Java中net.dv8tion.jda.core.entities.Guild.getMember方法的典型用法代码示例。如果您正苦于以下问题:Java Guild.getMember方法的具体用法?Java Guild.getMember怎么用?Java Guild.getMember使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.dv8tion.jda.core.entities.Guild
的用法示例。
在下文中一共展示了Guild.getMember方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkMutedMembers
import net.dv8tion.jda.core.entities.Guild; //导入方法依赖的package包/类
/**
* Check through muted members and unmute any which have passed their unmute time
*/
private static void checkMutedMembers()
{
long currentTime = System.currentTimeMillis();
for(Map.Entry<User, Long> timeEntry : unmuteTimes.entrySet())
{
if(timeEntry.getValue() <= currentTime)
{
User user = timeEntry.getKey();
for(Guild guild : user.getMutualGuilds())
{
Member member = guild.getMember(user);
if(member != null)
{
unmuteMember(member);
Util.logChannel(LogLevel.INFO, "%s has been auto-unmuted", member.getEffectiveName());
Util.info(MuteHandler.class, "%s has been auto-unmuted", member.getEffectiveName());
}
}
}
}
}
示例2: assignRole
import net.dv8tion.jda.core.entities.Guild; //导入方法依赖的package包/类
public static void assignRole(UserData data) {
User user = ZLevels.jda.getUserById(data.getUserId());
Guild guild = ZLevels.jda.getGuildById(Config.SERVER);
int level = data.getLevel();
for (int requiredLevel : roles.keySet()) {
if (level < requiredLevel) return;
Member member = guild.getMember(user);
Role role = guild.getRolesByName(roles.get(requiredLevel).getString("name"), false).get(0);
if (member == null || role == null) return;
if (member.getRoles().contains(role)) return;
try {
guild.getController().addRolesToMember(member, role).queue();
} catch (Exception e) {
ZLogger.warn("Could not assign role to " + user.getName() + "!");
}
}
}
示例3: ofGuildAndUser
import net.dv8tion.jda.core.entities.Guild; //导入方法依赖的package包/类
public static final AdvancedMember ofGuildAndUser(Guild guild, User user) {
if (guild == null) {
return null;
}
final AdvancedMember temp = getObjects(AdvancedMember.class).stream().filter((advancedMember) -> {
if (advancedMember.getMember() == null) {
return false;
}
return (advancedMember.getMember().getGuild() == guild) && (advancedMember.user == user);
}).findFirst().orElse(null);
if (temp != null) {
return temp;
}
return new AdvancedMember(guild.getMember(user));
}
示例4: doCommand
import net.dv8tion.jda.core.entities.Guild; //导入方法依赖的package包/类
@Override
protected void doCommand(CommandEvent event)
{
if(event.getChannelType() != ChannelType.PRIVATE)
return;
User user = event.getAuthor();
List<Guild> mutualGuilds = user.getMutualGuilds();
for(Guild guild : mutualGuilds)
{
Member member = guild.getMember(user);
if(member != null && member.getRoles().isEmpty())
{
GuildController gc = guild.getController();
gc.addSingleRoleToMember(member, MDCBot.newMemberRole).queue();
Util.info(getClass(), "New member %s given the role %s in guild %s", member.getEffectiveName(), MDCBot.newMemberRole.getName(), guild.getName());
}
}
}
示例5: isUserBotCommander
import net.dv8tion.jda.core.entities.Guild; //导入方法依赖的package包/类
public static boolean isUserBotCommander(Guild guild, User user) {
Member member = guild.getMember(user);
if (member == null) return false;
List<Role> roles = member.getRoles();
for (Role r : roles) {
if (r.getName().equals("Bot Commander")) {
return true;
}
}
return false;
}
示例6: giveTeamRoleToUser
import net.dv8tion.jda.core.entities.Guild; //导入方法依赖的package包/类
public static void giveTeamRoleToUser(BTBRole role, User user) {
if (null != user) {
Guild guild = getJDA().getGuildById(Long.toString(role.getGuildID()));
Member member = guild.getMember(user);
if (null != member) {
guild.getController().addRolesToMember(member, guild.getRoleById(role.getRoleID())).queue();
}
}
}
示例7: removeTeamRoleFromUser
import net.dv8tion.jda.core.entities.Guild; //导入方法依赖的package包/类
public static void removeTeamRoleFromUser(BTBRole role, User user) {
Guild guild = getJDA().getGuildById(Long.toString(role.getGuildID()));
Member member = guild.getMember(user);
if (null != member) {
guild.getController().removeRolesFromMember(member, guild.getRoleById(role.getRoleID())).queue();
}
}
示例8: action
import net.dv8tion.jda.core.entities.Guild; //导入方法依赖的package包/类
@Override
public void action(String[] args, GuildMessageReceivedEvent event) throws ParseException, IOException {
//CODE BY SCHLAUBI
User author = event.getAuthor();
Message message = event.getMessage();
MessageChannel channel = event.getChannel();
Guild guild =event.getGuild();
channel.sendTyping().queue();
message.delete().queue();
Member member;
if (args.length > 0){
//DANke SCHLAUBI
member = guild.getMember(event.getMessage().getMentionedUsers().get(0));
}else
member = guild.getMember(event.getAuthor());
String NAME = member.getEffectiveName();
String TAG = member.getUser().getName() + "#" + member.getUser().getDiscriminator();
String ID = member.getUser().getId();
String STATUS = member.getOnlineStatus().getKey();
String ROLES = "";
String GAME;
String AVATAR = member.getUser().getAvatarUrl();
String GUILDDATE = member.getJoinDate().format(DateTimeFormatter.RFC_1123_DATE_TIME);
String JOINDATE = member.getUser().getCreationTime().format(DateTimeFormatter.RFC_1123_DATE_TIME);
try {
GAME = member.getGame().getName();
} catch (Exception e){
GAME = "~";
}
if(AVATAR == null){
AVATAR = "No avatar";
}
for(Role role : member.getRoles()){
ROLES += role.getName() + ", ";
}
if(ROLES.length() > 0){
ROLES = ROLES.substring(0, ROLES.length()-2);
} else {
ROLES = "NO ROLES";
}
EmbedBuilder embed = new EmbedBuilder()
.setColor(Color.cyan)
.setDescription(":spy: UserInfo for " + NAME + " (" + TAG + ")")
.addField("Name/Nick", NAME, false)
.addField("User tag", TAG, false)
.addField("User id", ID , false)
.addField("Current status", STATUS, false)
.addField("Current game", GAME, false)
.addField("Guild joined", GUILDDATE, false)
.addField("Roles", ROLES, false)
.addField("Dicord joined", JOINDATE, false)
.addField("Avatar url", AVATAR, false);
if(AVATAR != "No avatar"){
embed.setThumbnail(AVATAR);
}
channel.sendMessage(embed.build()).queue();
}
示例9: isMainBotPresent
import net.dv8tion.jda.core.entities.Guild; //导入方法依赖的package包/类
public static boolean isMainBotPresent(Guild guild) {
JDA jda = guild.getJDA();
User other = jda.getUserById(BotConstants.MAIN_BOT_ID);
return other != null && guild.getMember(other) != null;
}
示例10: isMusicBotPresent
import net.dv8tion.jda.core.entities.Guild; //导入方法依赖的package包/类
public static boolean isMusicBotPresent(Guild guild) {
JDA jda = guild.getJDA();
User other = jda.getUserById(BotConstants.MUSIC_BOT_ID);
return other != null && guild.getMember(other) != null;
}
示例11: isPatronBotPresentAndOnline
import net.dv8tion.jda.core.entities.Guild; //导入方法依赖的package包/类
public static boolean isPatronBotPresentAndOnline(Guild guild) {
JDA jda = guild.getJDA();
User other = jda.getUserById(BotConstants.PATRON_BOT_ID);
return other != null && guild.getMember(other) != null && guild.getMember(other).getOnlineStatus() == OnlineStatus.ONLINE;
}