• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java GuildJoinEvent类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中net.dv8tion.jda.core.events.guild.GuildJoinEvent的典型用法代码示例。如果您正苦于以下问题:Java GuildJoinEvent类的具体用法?Java GuildJoinEvent怎么用?Java GuildJoinEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



GuildJoinEvent类属于net.dv8tion.jda.core.events.guild包,在下文中一共展示了GuildJoinEvent类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: onGuildJoin

import net.dv8tion.jda.core.events.guild.GuildJoinEvent; //导入依赖的package包/类
@Override
public void onGuildJoin(GuildJoinEvent event) {
    Guild guild = event.getGuild();
    MessageEmbed embed = createWelcomeMessage(guild);
    guild.getOwner().getUser().openPrivateChannel().submit().whenComplete((e, t) -> {
        if (e != null) {
            e.sendMessage(embed).submit();
            return;
        }
        TextChannel channel = guild.getDefaultChannel();
        if (channel != null && PermissionUtil.checkPermission(channel, guild.getSelfMember(), Permission.MESSAGE_WRITE)) {
            channel.sendMessage(embed).submit();
        } else {
            for (TextChannel textChannel : guild.getTextChannels()) {
                if (PermissionUtil.checkPermission(textChannel, guild.getSelfMember(), Permission.MESSAGE_WRITE)) {
                    textChannel.sendMessage(embed).submit();
                    break;
                }
            }
        }
    });
}
 
开发者ID:GoldRenard,项目名称:JuniperBotJ,代码行数:23,代码来源:WelcomeGuildListener.java


示例2: onEvent

import net.dv8tion.jda.core.events.guild.GuildJoinEvent; //导入依赖的package包/类
@Listener
@Override
public void onEvent(Event event) {
	if (event instanceof ShardMonitorEvent) {
		((ShardMonitorEvent) event).alive(shardId, ShardMonitorEvent.MANTARO_LISTENER);
		return;
	}

	if (event instanceof GuildJoinEvent) {
		Async.thread("LogThread", () -> onJoin((GuildJoinEvent) event));
		return;
	}

	if (event instanceof GuildLeaveEvent) {
		Async.thread("LogThread", () -> onLeave((GuildLeaveEvent) event));
	}

	if (event instanceof StatusChangeEvent) {
		ThreadPoolHelper.defaultPool().startThread("LogThread", () -> logStatusChange((StatusChangeEvent) event));
	}
}
 
开发者ID:Mantaro,项目名称:MantaroRPG,代码行数:22,代码来源:MantaroListener.java


示例3: onJoin

import net.dv8tion.jda.core.events.guild.GuildJoinEvent; //导入依赖的package包/类
private void onJoin(GuildJoinEvent event) {
		try {
			TextChannel tc = getLogChannel();
			String hour = df.format(new Date(System.currentTimeMillis()));

//			if (MantaroData.db().getMantaroData().getBlackListedGuilds().contains(event.getGuild().getId())
//				|| MantaroData.db().getMantaroData().getBlackListedUsers().contains(event.getGuild().getOwner().getUser().getId())) {
//				event.getGuild().leave().queue();
//				tc.sendMessage(String.format(EmoteReference.MEGA + "`[%s]` I left a guild with name: ``%s`` (%s members) since it was blacklisted.", hour, event.getGuild().getName(), event.getGuild().getMembers().size())).queue();
//				return;
//			}
			//TODO

			tc.sendMessage(String.format(EmoteReference.MEGA + "`[%s]` I joined a new guild with name: ``%s`` (%s members)", hour, event.getGuild().getName(), event.getGuild().getMembers().size())).queue();
			logTotal++;

			GuildStatsManager.log(LoggedEvent.JOIN);
		} catch (Exception e) {
			if (!(e instanceof NullPointerException) && !(e instanceof IllegalArgumentException)) {
				log.warn("Unexpected error while logging a edit.", e);
			}
		}
	}
 
开发者ID:Mantaro,项目名称:MantaroRPG,代码行数:24,代码来源:MantaroListener.java


示例4: onGuildJoin

import net.dv8tion.jda.core.events.guild.GuildJoinEvent; //导入依赖的package包/类
/**
 * Creates the new guild in the database
 * @param event
 */
@Override
public void onGuildJoin(GuildJoinEvent event) {
    //post statistics to discordbots.org
    DBLUtil.postStats(event.getJDA());
    try {
        Guild g = event.getGuild();
        if (!RubiconBot.getMySQL().ifGuildExits(event.getGuild())) {
            RubiconBot.getMySQL().createGuildServer(g);
            RubiconBot.getMySQL().createMember(event.getGuild().getOwner());
            new ServerLogSQL(event.getGuild()).createDefaultEntryIfNotExist();
        }
    } catch (Exception ex) {
        Logger.error(ex);
    }
}
 
开发者ID:Rubicon-Bot,项目名称:Rubicon,代码行数:20,代码来源:BotJoinListener.java


示例5: logGuildJoin

import net.dv8tion.jda.core.events.guild.GuildJoinEvent; //导入依赖的package包/类
public static void logGuildJoin(AvaIre avaire, GuildJoinEvent event) {
    if (!isWebhookEnabled(avaire)) {
        return;
    }

    User owner = event.getGuild().getOwner().getUser();

    GUILD_MESSAGES.add(new EmbedBuilder()
        .setColor(Color.decode("#66BB6A"))
        .setTimestamp(Instant.now())
        .addField("Added", String.format("%s (ID: %s)",
            event.getGuild().getName(), event.getGuild().getId()
        ), false)
        .addField("Owner", String.format("%s#%s (ID: %s)",
            owner.getName(), owner.getDiscriminator(), owner.getId()
        ), false)
        .build()
    );
}
 
开发者ID:avaire,项目名称:avaire,代码行数:20,代码来源:EventLogger.java


示例6: onGuildJoin

import net.dv8tion.jda.core.events.guild.GuildJoinEvent; //导入依赖的package包/类
@Override
public void onGuildJoin(GuildJoinEvent event) {

    Long guildID = event.getGuild().getIdLong();
    try {
        dbMan.setNewPermissionNames(guildID);
    } catch (SQLException e) {
        e.printStackTrace();
    }
}
 
开发者ID:IANetworks,项目名称:Ducky-Mc-Duckerson,代码行数:11,代码来源:EventListener.java


示例7: onGuildJoin

import net.dv8tion.jda.core.events.guild.GuildJoinEvent; //导入依赖的package包/类
@Override
public void onGuildJoin(GuildJoinEvent event) {
    final Instant timestamp = Instant.now();
    if (Standard.getConsoleTextChannel() != null) {
        Standard.getConsoleTextChannel().sendMessage(String.format("[%s] Joined guild %s", LocalDateTime.ofInstant(timestamp, getZoneId()).format(DateTimeFormatter.ofPattern(Standard.STANDARD_DATE_TIME_FORMAT)), Standard.getCompleteName(event.getGuild()))).queue();
    }
}
 
开发者ID:Panzer1119,项目名称:Supreme-Bot,代码行数:8,代码来源:GuildLogger.java


示例8: onGuildJoin

import net.dv8tion.jda.core.events.guild.GuildJoinEvent; //导入依赖的package包/类
@Override
public void onGuildJoin(GuildJoinEvent event)
{
    Guild guild = event.getGuild();
    User owner = guild.getOwner().getUser();
    LoggerFactory.getLogger("Logging").info("[GUILD JOIN]: "+guild.getName()+" (ID: "+guild.getId()+")\n");
    long botCount = guild.getMembers().stream().map(m -> m.getUser()).filter(u -> u.isBot()).count();
    long userCount = guild.getMembers().stream().map(m -> m.getUser()).filter(u -> !(u.isBot())).count();
    long totalCount = guild.getMembers().size();
    GuildUtils.checkBadGuild(guild);
    TextChannel tc = event.getJDA().getTextChannelById(config.getBotlogChannelId());
    TextChannel defaultTc = FinderUtil.getDefaultChannel(guild);

    if(!(GuildUtils.isBadGuild(guild)) && config.isBotlogEnabled() && !(tc==null) && tc.canTalk())
    {
        tc.sendMessage(":inbox_tray: `[New Guild]:` "+guild.getName()+" (ID: "+guild.getId()+")\n" +
                "`[Owner]:` **"+owner.getName()+"**#**"+owner.getDiscriminator()+"** (ID: "+owner.getId()+"\n" +
                "`[Members]:` Humans: **"+userCount+"** Bots: **"+botCount+"** Total Count: **"+totalCount+"**\n").queue();

        if(!(defaultTc==null) && defaultTc.canTalk())
            defaultTc.sendMessage("Hey! Thanks for adding Endless to your guild! First of all, you need to know if you activate the ModLogging/ServerLogging " +
                    "you allow me to log all your messages, users, ids, avatars, channels, roles and other guild settings.\n" +
                    "If you don't agree to this you **must** remove Endless from your guild.\n" +
                    "\n" +
                    "To know what Endless can do check out `"+config.getPrefix()+"help` which shows all of my available commands.\n" +
                    "\n" +
                    "If you want to recieve a notification when a new update is released, report a bug or ask for an improvement please join my server: " +
                    "**<"+Const.INVITE+">** and post it on the correspondient channel.").queue();
    }
}
 
开发者ID:EndlessBot,项目名称:Endless,代码行数:31,代码来源:GuildEvents.java


示例9: onGuildJoin

import net.dv8tion.jda.core.events.guild.GuildJoinEvent; //导入依赖的package包/类
public void onGuildJoin(GuildJoinEvent event) {
    Guild g = event.getGuild();
        SQL.createServer(g);
        System.out.println("[Amme]System started on: " + g.getName());
    Guild guild = event.getGuild();
    GuildController controller = guild.getController();

    new Timer().schedule(new TimerTask() {
        @Override
        public void run() {

            controller.createCategory("Amme").queue(cat -> {

                controller.modifyCategoryPositions()
                        .selectPosition(cat.getPosition())
                        .moveTo(0).queue();

                String[] list = {"music", "commands", "log", "randomstuff"};

                Arrays.stream(list).forEach(s ->
                        controller.createTextChannel(s).queue(chan -> chan.getManager().setParent((Category) cat).queue())
                );
            });
            SQL.updateValue(guild, "music", event.getGuild().getTextChannelsByName("music", true).get(0).getName());
            SQL.updateValue(guild, "logchannel", event.getGuild().getTextChannelsByName("log", true).get(0).getId());
            SQL.updateValue(guild, "joinchannel", event.getGuild().getTextChannelsByName("randomstuff", true).get(0).getId());
        }
    }, 5000);


}
 
开发者ID:LeeDJD,项目名称:Amme,代码行数:32,代码来源:overflowListener.java


示例10: onGuildJoin

import net.dv8tion.jda.core.events.guild.GuildJoinEvent; //导入依赖的package包/类
@Override
public void onGuildJoin( GuildJoinEvent event )
{
    // leave guild if guild is blacklisted
    if(Main.getBotSettingsManager().getBlackList().contains(event.getGuild().getId()))
    {
        event.getGuild().leave().queue();
        return;
    }

    // identify which shard is responsible for the guild
    String guildId = event.getGuild().getId();
    JDA jda = Main.getShardManager().isSharding() ? Main.getShardManager().getShard(guildId) : Main.getShardManager().getJDA();

    // send welcome message to the server owner
    String welcomeMessage = "```diff\n- Joined```\n" +
            "**" + jda.getSelfUser().getName() + "**, a calendar bot, has been added to the guild you own, '"
            + event.getGuild().getName() + "'." +
            "\n\n" +
            "If this is your first time using the bot, you will need to create a new channel in your guild named" +
            " **" + Main.getBotSettingsManager().getControlChan() + "** to control the bot.\n" +
            "The bot will not listen to commands in any other channel!" +
            "\n\n" +
            "If you have not yet reviewed the **Quickstart** guide (as seen on the bots.discord.pw listing), " +
            "it may be found here: https://bots.discord.pw/bots/250801603630596100";
    MessageUtilities.sendPrivateMsg(
            welcomeMessage,
            event.getGuild().getOwner().getUser(),
            null
    );

    // update web stats
    JDA.ShardInfo info = event.getJDA().getShardInfo();
    HttpUtilities.updateStats(info==null ? null : info.getShardId());
}
 
开发者ID:notem,项目名称:Saber-Bot,代码行数:36,代码来源:EventListener.java


示例11: onGuildJoin

import net.dv8tion.jda.core.events.guild.GuildJoinEvent; //导入依赖的package包/类
@Override
public void onGuildJoin(GuildJoinEvent event) {
    if (DiscordUtils.isBotFarm(event.getGuild())) {
        event.getGuild().leave().queue();
        return;
    }

    Guild guild = event.getGuild();
    DSLContext database = bot.getDatabase();
    String message = String.format("Hello! I am Safety Jim, `%s` is my default prefix!", bot.getConfig().jim.default_prefix);
    DiscordUtils.sendMessage(DiscordUtils.getDefaultChannel(guild), message);
    DatabaseUtils.createGuildSettings(bot, database, guild);
    bot.updateBotLists();
}
 
开发者ID:Samoxive,项目名称:SafetyJim,代码行数:15,代码来源:DiscordShard.java


示例12: onGuildJoin

import net.dv8tion.jda.core.events.guild.GuildJoinEvent; //导入依赖的package包/类
@Override
public void onGuildJoin(GuildJoinEvent event) {
    if (!avaire.areWeReadyYet()) {
        return;
    }

    Metrics.guilds.inc();
    Metrics.geoTracker.labels(event.getGuild().getRegion().getName()).inc();
    EventLogger.logGuildJoin(avaire, event);

    AvaIre.getLogger().info("Joined guild with an ID of " + event.getGuild().getId() + " called: " + event.getGuild().getName());
}
 
开发者ID:avaire,项目名称:avaire,代码行数:13,代码来源:GuildJoinLeave.java


示例13: onGuildJoin

import net.dv8tion.jda.core.events.guild.GuildJoinEvent; //导入依赖的package包/类
@Override 
public void onGuildJoin(GuildJoinEvent e) {
	if (!e.getGuild().getSelfMember().hasPermission(net.dv8tion.jda.core.Permission.MESSAGE_WRITE)) {
		e.getGuild().leave().queue();
		return;
	}
	checkFiles(e.getGuild());
	GuildObject g = new GuildObject(e.getGuild());
	GuildObject.guildMap.put(e.getGuild().getId(), g);
	g.getConfig().setFirstTime(false);
	/*
	 * If you want a welcome message, set it here!
	 */
	/*if (g.getConfig().isFirstTime()) {
		AtomicInteger guildCount = new AtomicInteger();
		Bot.getInstance().getBots().stream()
		.forEach(j -> guildCount.addAndGet(j.getGuilds().size()));
		e.getGuild().getPublicChannel().sendMessage("Hi, I'm Momo! You are my "
				+ Util.ordinal(guildCount.get()) + " server.\n"
				+ "If you want a list of commands, use `$help`. If you want some tutorials on my features, "
				+ "do `$howto` - I suggest doing `$howto setup` immediately.\n"
				+ "I also feature a web dashboard for my configuration! "
				+ "Access it here: <https://momobot.io/dash>").queue(success -> {
					g.getConfig().setFirstTime(false);
				}, failure -> {
					g.getConfig().setFirstTime(false);
				});
		if (!e.getGuild().getSelfMember().hasPermission(net.dv8tion.jda.core.Permission.MESSAGE_EMBED_LINKS)) {
			e.getGuild().getPublicChannel().sendMessage("I require permissions to Embed Links for the"
					+ " vast majority of my functionality. Please enable it!").queue();
		}
	}*/
}
 
开发者ID:paul-io,项目名称:momo-2,代码行数:34,代码来源:Listeners.java


示例14: onGuildJoin

import net.dv8tion.jda.core.events.guild.GuildJoinEvent; //导入依赖的package包/类
@Override
public void onGuildJoin(GuildJoinEvent e) {
	Guild g = e.getGuild();
	
	// Check if bot is already in the guild.
	// If there is a discord outage, onGuildJoin may be fired incorrectly.
	if (SettingsManager.getInstance(g.getId()).getSettings().isJoined()) {
		return;
	}
	
	String message = "JOINED GUILD " + JDAUtil.guildToString(g);
	
	MessageLogger.guildEvent(g, message);
	SendMessage.sendDeveloper(message);
	
	String botName = ConfigManager.getInstance().getConfig().getBotName();
	StringBuilder sb = new StringBuilder()
			.append("Hello! Thank you for adding ").append(botName).append(" to ").append(g.getName()).append(".\n");
	
	SettingsManager manager = SettingsManager.getInstance(g.getId());
	
	if (!manager.getSettings().getModerators().isEmpty()) {
		sb.append("Since this is not the first time ").append(botName).append(" has been joined ").append(g.getName()).append(", please note that your settings have been reset.\n");
		manager.resetSettings();
	}
	
	List<User> us = JDAUtil.addDefaultModerators(g);
	
	sb.append("Added ").append(StringUtils.join(JDAUtil.userListToString(us), ", ")).append(" as moderators.\n")
	.append("The guild owner (currently " + g.getOwner().getEffectiveName() + ") may add or remove moderators at any time.\n")
	.append("The default command prefix is \"" + manager.getSettings().getPrefix() + "\". You can also mention instead of using a prefix.\n")
	.append("Use the help and about commands for more information.");
	
	SendMessage.sendMessage(JDAUtil.findTopWriteChannel(g), sb.toString());
}
 
开发者ID:Tazzie02,项目名称:Tazbot,代码行数:36,代码来源:Listeners.java


示例15: onGuildJoin

import net.dv8tion.jda.core.events.guild.GuildJoinEvent; //导入依赖的package包/类
@Override
public void onGuildJoin(GuildJoinEvent event) {
    if(event.getGuild().getSelfMember().getJoinDate().plusMinutes(10).isBefore(OffsetDateTime.now()))
        return;

    if (!GSONUtils.getConfig().getBlockedUsers().contains(event.getGuild().getOwner().getUser().getId())) {
        for (JDA jda : KekBot.jdas) {
            try {
                jda.getUserById(GSONUtils.getConfig().getBotOwner()).openPrivateChannel().queue(ch -> ch.sendMessage("Joined server: \"" + event.getGuild().getName() + "\" (ID: " + event.getGuild().getId() + ")").queue());
                break;
            } catch (NullPointerException | IllegalStateException e) {
                //do nothing.
            }
        }
        Settings settings = new Settings().setName(event.getGuild().getName());
        settings.save(event.getGuild());
        String joinSpeech = "Hi! I'm KekBot! Thanks for inviting me!" + "\n" +
                "Use $help to see a list of commands, and use $prefix to change my prefix!" + "\n" +
                "If you ever need help, join my discord server: " + "https://discord.gg/3nbqavE";
        for (TextChannel channel : event.getGuild().getTextChannels()) {
            try {
                channel.sendMessage(joinSpeech).queue();
                break;
            } catch (PermissionException er) {
                //¯\_(ツ)_/¯
            }
        }
        Utils.sendStats(event.getJDA());
    } else {
        event.getGuild().leave().queue();
    }
}
 
开发者ID:Godson777,项目名称:KekBot,代码行数:33,代码来源:Listener.java


示例16: onGuildJoin

import net.dv8tion.jda.core.events.guild.GuildJoinEvent; //导入依赖的package包/类
@Override
public void onGuildJoin(GuildJoinEvent event) {
    Main.leaveServerIfUnauthorized(event.getGuild());
}
 
开发者ID:michidk,项目名称:GGD-Discord-Bot,代码行数:5,代码来源:AuthorizedServerCheckFeature.java


示例17: onGuildJoin

import net.dv8tion.jda.core.events.guild.GuildJoinEvent; //导入依赖的package包/类
@Override
public void onGuildJoin(GuildJoinEvent event) {
    send(
            "[:white_check_mark:] Joined guild `" + event.getGuild() + "`. Users: `" + event.getGuild().getMembers().size() + "`."
    );
}
 
开发者ID:Frederikam,项目名称:GensokyoBot,代码行数:7,代码来源:EventLogger.java


示例18: onGenericGuild

import net.dv8tion.jda.core.events.guild.GuildJoinEvent; //导入依赖的package包/类
@Override
public void onGenericGuild(GenericGuildEvent e) {
	//Update guild, channel, and user count
	Config.update();
	
	//Get guild info
	EmbedBuilder eb = new EmbedBuilder();
	Guild guild = e.getGuild();
	Member owner = guild.getOwner();
	
	//Create embed
	if (e instanceof GuildJoinEvent) {
		
		eb.setAuthor("Joined guild!", null, owner.getUser().getAvatarUrl());
		eb.addField("Name", guild.getName(), true);
		eb.addField("Guild ID", guild.getId(), true);
		eb.addField("Owner", owner.getEffectiveName(), true);
		eb.addField("Owner ID", owner.getUser().getId(), true);
		eb.addField("Users", guild.getMembers().size() + "", true);
		ArrayList<Member> users = new ArrayList<Member>(guild.getMembers());
		for (Member u : new ArrayList<Member>(users)) {
			if (u.getUser().isBot() || u.getUser().isFake()) {
				users.remove(u);
			}
		}
		eb.addField("Humans", users.size() + "", true);
		eb.addField("Bots", guild.getMembers().size() - users.size() + "", true);
		eb.addField("Channels", guild.getTextChannels().size() + "", true);
		
	} else if (e instanceof GuildLeaveEvent) {
		eb.setAuthor(owner.getEffectiveName() + " (" + owner.getUser().getId() + ")",
			null, owner.getUser().getAvatarUrl());
		eb.setDescription("Left guild `" + guild.getName() + "` (" + guild.getId() + ")");
	} else {
		return;
	}
	
	eb.setThumbnail(guild.getIconUrl());
	MessageUtils.log(eb.build());
	RequestUtils.sendGuilds();
}
 
开发者ID:Tisawesomeness,项目名称:Minecord,代码行数:42,代码来源:Listener.java


示例19: onGuildJoin

import net.dv8tion.jda.core.events.guild.GuildJoinEvent; //导入依赖的package包/类
@Override
public void onGuildJoin(GuildJoinEvent event) {
    plugin.joinGuildEvent(event.getGuild());
}
 
开发者ID:greatman,项目名称:legendarybot,代码行数:5,代码来源:GuildJoinListener.java


示例20: onGuildJoin

import net.dv8tion.jda.core.events.guild.GuildJoinEvent; //导入依赖的package包/类
@Override
public void onGuildJoin(GuildJoinEvent event) {
    bot.addGuild(event.getGuild());
}
 
开发者ID:greatman,项目名称:legendarybot,代码行数:5,代码来源:MessageListener.java



注:本文中的net.dv8tion.jda.core.events.guild.GuildJoinEvent类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PolicyConstraintsExtension类代码示例发布时间:2022-05-21
下一篇:
Java ValidatorAction类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap