本文整理汇总了Java中net.dv8tion.jda.core.events.guild.member.GuildMemberJoinEvent类的典型用法代码示例。如果您正苦于以下问题:Java GuildMemberJoinEvent类的具体用法?Java GuildMemberJoinEvent怎么用?Java GuildMemberJoinEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GuildMemberJoinEvent类属于net.dv8tion.jda.core.events.guild.member包,在下文中一共展示了GuildMemberJoinEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onGuildMemberJoin
import net.dv8tion.jda.core.events.guild.member.GuildMemberJoinEvent; //导入依赖的package包/类
@Override
public void onGuildMemberJoin(GuildMemberJoinEvent event) {
Member member = event.getMember();
Guild guild = event.getGuild();
Long guildID = guild.getIdLong();
String name = dbMan.getLoggingChannel(guildID);
if (dbMan.isLoggingOn(guildID) || name != null) {
List<TextChannel> ltc = guild.getTextChannelsByName(name, true);
if (ltc.isEmpty()) {
System.out.printf("Found no text channels with event-log");
return;
}
for (TextChannel tc : ltc) {
tc.sendMessage(i18n.localize(dbMan, tc, "member_joined_guild", member.getEffectiveName(), guild.getName())).queue();
}
}
}
示例2: onGuildMemberJoin
import net.dv8tion.jda.core.events.guild.member.GuildMemberJoinEvent; //导入依赖的package包/类
public void onGuildMemberJoin(GuildMemberJoinEvent event) {
Guild guild = event.getGuild();
if(!SQL.ifGuildExists(guild))
SQL.createServer(guild);
if (event.getMember().getUser().isBot()) return;
if (event.getGuild().getId().equals("307084334198816769")) return;
PrivateChannel pc = event.getMember().getUser().openPrivateChannel().complete();
if(SQL.getValue(event.getGuild(), "autorole").equals("0")) {
pc.sendMessage(
"**Hey,** " + event.getMember().getAsMention() + " and welcome on " + event.getGuild().getName() + " :wave:\n\n" +
"Now, have a nice day and a lot of fun on the server! ;)"
).queue();
}else {
try {
event.getGuild().getController().addRolesToMember(event.getMember(), event.getGuild().getRolesByName(SQL.getValue(event.getGuild(), "autorole"), true)).queue();
pc.sendMessage(
"**Hey,** " + event.getMember().getAsMention() + " and welcome on " + event.getGuild().getName() + " :wave:\n\n" +
"You automatically got the Role `" + SQL.getValue(event.getGuild(), "autorole") + "` \n" +
"Now, have a nice day and a lot of fun on the server! ;)"
).queue();
} catch (Exception e) {
e.printStackTrace();
PrivateChannel ow = event.getGuild().getOwner().getUser().openPrivateChannel().complete();
ow.sendMessage("Please enter a valid Autorole Role!").queue();
ow.sendMessage(Main.commands.get("settings").help() + "\n Only in Guild do not send commands at PM!");
}
String enabled = SQL.getValue(guild, "joinchannel");
String channelid = SQL.getValue(guild, "joinchannel");
String joinmessage = SQL.getValue(guild, "joinmessage").replace("%user%", event.getUser().getAsMention()).replace("%guild%", guild.getName());
if (!enabled.equals("0")) {
TextChannel channel = guild.getTextChannelById(channelid);
channel.sendTyping().queue();
channel.sendMessage(joinmessage).queue();
}
}
}
示例3: onGuildMemberJoin
import net.dv8tion.jda.core.events.guild.member.GuildMemberJoinEvent; //导入依赖的package包/类
public void onGuildMemberJoin(GuildMemberJoinEvent e) {
if (!RubiconBot.getMySQL().ifUserExist(e.getUser())) {
RubiconBot.getMySQL().createUser(e.getUser());
}
try {
String joinMessage = RubiconBot.getMySQL().getGuildValue(e.getGuild(), "joinmsg");
if (joinMessage.equals("0")) {
return;
} else {
TextChannel messageChannel = e.getJDA().getTextChannelById(RubiconBot.getMySQL().getGuildValue(e.getGuild(), "channel"));
if (messageChannel == null)
return;
joinMessage = joinMessage.replace("%user%", e.getMember().getAsMention());
joinMessage = joinMessage.replace("%guild%", e.getGuild().getName());
messageChannel.sendMessage(joinMessage).queue();
}
} catch (NullPointerException ex) {
//Channel does not exits
}
}
示例4: onGuildMemberJoin
import net.dv8tion.jda.core.events.guild.member.GuildMemberJoinEvent; //导入依赖的package包/类
@Override
public void onGuildMemberJoin(GuildMemberJoinEvent event)
{
// Add roles to new member
short rating = database.getUserRating(event.getUser());
if(rating == -1)
return;
Role role = database.getRatingRole(event.getGuild(), rating);
// Role is not null
// Can interact with role
// Can interact with member
if(role != null && event.getGuild().getSelfMember().canInteract(role)
&& event.getGuild().getSelfMember().canInteract(event.getMember()))
{
event.getGuild().getController().addRolesToMember(event.getMember(), role).queue(v -> {}, v -> {});
}
}
示例5: onGuildMemberJoin
import net.dv8tion.jda.core.events.guild.member.GuildMemberJoinEvent; //导入依赖的package包/类
@Override
public void onGuildMemberJoin(GuildMemberJoinEvent event) {
Member member = event.getMember();
Guild guild = member.getGuild();
try {
for (DefaultRole dr : Bot.defaultRoles) {
if (dr.getGuildID().equals(guild.getId())) {
for (Role role : guild.getRoles()) {
if (role.getId().equals(dr.getRoleID())) {
guild.getController().addRolesToMember(member, role).complete();
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例6: onGuildMemberJoin
import net.dv8tion.jda.core.events.guild.member.GuildMemberJoinEvent; //导入依赖的package包/类
@Override
public void onGuildMemberJoin(GuildMemberJoinEvent event) {
WelcomeMessage message = welcomeMessageRepository.findByGuild(event.getGuild());
if (message == null || !message.isJoinEnabled() || (!message.isJoinToDM() && message.getJoinChannelId() == null)) {
return;
}
MessageChannel channel = null;
if (message.isJoinToDM() && !event.getJDA().getSelfUser().equals(event.getUser())) {
User user = event.getUser();
try {
channel = user.openPrivateChannel().complete();
} catch (Exception e) {
LOGGER.error("Could not open private channel for user {}", user, e);
}
}
if (channel == null) {
channel = event.getGuild().getTextChannelById(message.getJoinChannelId());
}
send(event, channel, message.getJoinMessage(), message.isJoinRichEnabled());
}
示例7: onGuildMemberJoin
import net.dv8tion.jda.core.events.guild.member.GuildMemberJoinEvent; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void onGuildMemberJoin(final GuildMemberJoinEvent event) {
if (event.getGuild().getIdLong() != this.guildId) {
return;
}
final Member joined = event.getMember();
//kick the joined user if they aren't on the allowed list
if (!this.allowedUsers.contains(joined.getUser().getIdLong())) {
final Consumer whenDone = aVoid -> event.getGuild().getController().kick(joined).queue(null, RestActions.defaultOnFail());
final String message = String.format("You are not allowed to join private guild #%s currently.", this.privateGuildNumber);
RestActions.sendPrivateMessage(joined.getUser(), message, whenDone, whenDone);
return;
}
final Role wolf = RoleAndPermissionUtils.getOrCreateRole(event.getGuild(), WOLF_ROLE_NAME).complete();
event.getGuild().getController().addRolesToMember(event.getMember(), wolf).queue(
aVoid -> RestActions.sendMessage(Wolfia.fetchTextChannel(this.currentChannelId),
event.getMember().getAsMention() + ", welcome to wolf chat!")
);
}
示例8: onGuildMemberJoin
import net.dv8tion.jda.core.events.guild.member.GuildMemberJoinEvent; //导入依赖的package包/类
@Override
public void onGuildMemberJoin(final GuildMemberJoinEvent event) {
if (event.getGuild().getIdLong() != App.WOLFIA_LOUNGE_ID
|| Config.C.isDebug) {
return;
}
//send greetings to spam channel
final TextChannel spam = event.getGuild().getTextChannelById(SPAM_CHANNEL_ID);
if (spam != null) {
RestActions.sendMessage(spam, String.format(welcomePattern, event.getMember().getAsMention()));
} else {
log.warn("Did the spam channel disappear in the Wolfia Lounge?");
}
//add role announcements
final Role announcements = event.getGuild().getRoleById(ANNOUNCEMENTS_ROLE_ID);
if (announcements != null) {
event.getGuild().getController().addSingleRoleToMember(event.getMember(), announcements).queue();
} else {
log.warn("Did the Announcements role disappear in the Wolfia Lounge?");
}
}
示例9: handleInternally
import net.dv8tion.jda.core.events.guild.member.GuildMemberJoinEvent; //导入依赖的package包/类
@Override
protected Long handleInternally(JSONObject content)
{
final long id = content.getLong("guild_id");
if (api.getGuildLock().isLocked(id))
return id;
GuildImpl guild = (GuildImpl) api.getGuildMap().get(id);
if (guild == null)
{
api.getEventCache().cache(EventCache.Type.GUILD, id, () ->
{
handle(responseNumber, allContent);
});
return null;
}
Member member = api.getEntityBuilder().createMember(guild, content);
api.getEventManager().handle(
new GuildMemberJoinEvent(
api, responseNumber,
guild, member));
api.getEventCache().playbackCache(EventCache.Type.USER, member.getUser().getIdLong());
return null;
}
示例10: onGuildMemberJoin
import net.dv8tion.jda.core.events.guild.member.GuildMemberJoinEvent; //导入依赖的package包/类
@Override
public final void onGuildMemberJoin(GuildMemberJoinEvent event) {
final Instant timestamp = Instant.now();
if (!TempBan.isAllowedToJoin(event.getMember())) {
event.getGuild().getController().kick(event.getMember(), TempBan.getReason(event.getMember())).queue();
onGuildMemberJoinKicked(timestamp, event);
return;
}
Standard.log(timestamp, event.getGuild(), LOG_NAME, LOG_CHANNEL_ID_MEMBER, LOG_TEXT_MEMBER_JOIN, "[%1$s] [%2$s] %3$s joined this Guild", LOG_DATE_TIME_FORMAT, Config.CONFIG.getUserNameForUser(event.getUser(), event.getGuild(), true));
}
示例11: onGuildMemberJoin
import net.dv8tion.jda.core.events.guild.member.GuildMemberJoinEvent; //导入依赖的package包/类
@Override
public void onGuildMemberJoin(GuildMemberJoinEvent event)
{
Guild guild = event.getGuild();
TextChannel serverlog = db.getServerlogChannel(guild);
TextChannel welcome = db.getWelcomeChannel(guild);
TextChannel channel = FinderUtil.getDefaultChannel(event.getGuild());
User newmember = event.getMember().getUser();
Calendar calendar = GregorianCalendar.getInstance();
calendar.setTime(new Date());
String hour = String.format("%02d",calendar.get(Calendar.HOUR_OF_DAY));
String min = String.format("%02d", calendar.get(Calendar.MINUTE));
String sec = String.format("%02d", calendar.get(Calendar.SECOND));
String msg = db.getWelcomeMessage(guild);
parser.clear().put("user", newmember).put("guild", guild).put("channel", welcome);
if(!(serverlog==null))
{
if(!(serverlog.getGuild().getSelfMember().hasPermission(serverlog, Permission.MESSAGE_READ, Permission.MESSAGE_WRITE, Permission.MESSAGE_EMBED_LINKS, Permission.MESSAGE_HISTORY)))
guild.getOwner().getUser().openPrivateChannel().queue(s -> s.sendMessage(Messages.SRVLOG_NOPERMISSIONS).queue(
null, (e) -> channel.sendMessage(Messages.SRVLOG_NOPERMISSIONS).queue()));
else
serverlog.sendMessage("`["+hour+":"+min+":"+sec+"] [Member Join]:` :inbox_tray: :bust_in_silhouette: **"+newmember.getName()+"**#**"+newmember.getDiscriminator()+"** ("+newmember.getId()+") joined the guild! User count: **"+guild.getMembers().size()+"** members").queue();
}
if(!(welcome==null) && !(msg==null))
{
if(!(welcome.getGuild().getSelfMember().hasPermission(welcome, Permission.MESSAGE_READ, Permission.MESSAGE_WRITE, Permission.MESSAGE_HISTORY)))
guild.getOwner().getUser().openPrivateChannel().queue(s -> s.sendMessage(Messages.WELCOME_NOPERMISSIONS).queue(
null, (e) -> channel.sendMessage(Messages.WELCOME_NOPERMISSIONS).queue()));
else
welcome.sendMessage(parser.parse(msg).trim()).queueAfter(2, TimeUnit.SECONDS);
}
}
示例12: onGuildMemberJoin
import net.dv8tion.jda.core.events.guild.member.GuildMemberJoinEvent; //导入依赖的package包/类
@Override
public void onGuildMemberJoin(GuildMemberJoinEvent event) {
if (!RubiconBot.getMySQL().verificationEnabled(event.getGuild())) return;
TextChannel channel = event.getGuild().getTextChannelById(RubiconBot.getMySQL().getVerificationValue(event.getGuild(), "channelid"));
Message message = channel.sendMessage(new EmbedBuilder().setDescription(RubiconBot.getMySQL().getVerificationValue(event.getGuild(), "text").replace("%user%", event.getUser().getAsMention())).build()).complete();
CommandVerification.users.put(message, event.getUser());
String emoteRaw = RubiconBot.getMySQL().getVerificationValue(event.getGuild(), "emote");
if (!isNumeric(emoteRaw))
message.addReaction(emoteRaw).queue();
else
message.addReaction(event.getJDA().getEmoteById(emoteRaw)).queue();
Role verified = event.getGuild().getRoleById(RubiconBot.getMySQL().getVerificationValue(event.getGuild(), "roleid"));
int delay = Integer.parseInt(RubiconBot.getMySQL().getVerificationValue(event.getGuild(), "kicktime"));
if (delay == 0) return;
new Timer().schedule(new TimerTask() {
@Override
public void run() {
if (!event.getMember().getRoles().contains(verified)) {
event.getUser().openPrivateChannel().complete().sendMessage(RubiconBot.getMySQL().getVerificationValue(event.getGuild(), "kicktext").replace("%user%", event.getUser().getAsMention())).queue();
event.getGuild().getController().kick(event.getMember()).queue();
}
}
}, delay * 1000 * 60);
}
示例13: onGuildMemberJoin
import net.dv8tion.jda.core.events.guild.member.GuildMemberJoinEvent; //导入依赖的package包/类
@Override
public void onGuildMemberJoin(GuildMemberJoinEvent event) {
if (!isEventEnabled(event.getGuild(), LogEventKeys.JOIN))
return;
TextChannel textChannel = getLogChannel(event.getGuild());
if (textChannel == null)
return;
EmbedBuilder embedBuilder = new EmbedBuilder();
embedBuilder.setAuthor("New member joined the server", null, event.getMember().getUser().getAvatarUrl());
embedBuilder.setDescription("**" + event.getMember().getEffectiveName() + " (" + event.getMember().getUser().getId() + ")** joined the server");
embedBuilder.setColor(evJoinColor);
sendLog(textChannel, embedBuilder);
}
示例14: onGuildMemberJoin
import net.dv8tion.jda.core.events.guild.member.GuildMemberJoinEvent; //导入依赖的package包/类
@Override
public void onGuildMemberJoin(GuildMemberJoinEvent event) {
for (WebpanelRequest request : requestList.stream().filter(request -> request instanceof MemberJoinRequest).collect(Collectors.toList())) {
((MemberJoinRequest) request).setGuild(event.getGuild());
sendRequest(request.build());
}
}
示例15: onGuildMemberJoin
import net.dv8tion.jda.core.events.guild.member.GuildMemberJoinEvent; //导入依赖的package包/类
@Override
public void onGuildMemberJoin(GuildMemberJoinEvent event) {
users = event.getJDA().getUsers();
for(User user : users){
if(!PlayerKt.checkForPlayer(user)){
Player player = new Player(user, 0);
}
}
}