本文整理汇总了Java中net.dv8tion.jda.core.events.guild.GuildJoinEvent类的典型用法代码示例。如果您正苦于以下问题:Java GuildJoinEvent类的具体用法?Java GuildJoinEvent怎么用?Java GuildJoinEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GuildJoinEvent类属于net.dv8tion.jda.core.events.guild包,在下文中一共展示了GuildJoinEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
}
}
});
}
示例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));
}
}
示例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);
}
}
}
示例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);
}
}
示例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()
);
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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);
}
示例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());
}
示例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();
}
示例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());
}
示例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();
}
}*/
}
示例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());
}
示例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();
}
}