use of net.dv8tion.jda.api.EmbedBuilder in project c0debaseBot by Biospheere.
the class Tempchannel method onTempchannelLeave.
@Override
public void onTempchannelLeave(final VoiceChannel voiceChannel, final Member member) {
if (voiceChannel.equals(voiceChannel.getGuild().getAfkChannel())) {
return;
}
if (voiceChannel.getMembers().isEmpty()) {
textChannel.delete().queue();
textChannel = null;
} else if (textChannel.getPermissionOverride(member) != null) {
textChannel.getPermissionOverride(member).delete().queue();
if (member.getUser().isBot()) {
return;
}
final EmbedBuilder embedBuilder = new EmbedBuilder();
embedBuilder.setColor(member.getColor());
embedBuilder.setDescription(":arrow_left: " + member.getAsMention() + " hat uns verlassen");
textChannel.sendMessage(embedBuilder.build()).queue();
}
}
use of net.dv8tion.jda.api.EmbedBuilder in project c0debaseBot by Biospheere.
the class Tempchannel method onTempchannelJoin.
@Override
public void onTempchannelJoin(final VoiceChannel voiceChannel, final Member member) {
if (voiceChannel.equals(voiceChannel.getGuild().getAfkChannel())) {
return;
}
if (textChannel == null) {
final Guild guild = voiceChannel.getGuild();
voiceChannel.getParent().createTextChannel("temp-" + voiceChannel.getName().toLowerCase()).addPermissionOverride(guild.getSelfMember(), MEMBER_PERMISSIONS, null).addPermissionOverride(member, MEMBER_PERMISSIONS, null).addPermissionOverride(guild.getPublicRole(), null, MEMBER_PERMISSIONS).queue(channel -> setTextChannel((TextChannel) channel));
} else {
if (textChannel.getPermissionOverride(member) != null) {
textChannel.getPermissionOverride(member).getManager().grant(MEMBER_PERMISSIONS).queue();
} else {
textChannel.createPermissionOverride(member).setAllow(MEMBER_PERMISSIONS).queue();
}
if (member.getUser().isBot()) {
return;
}
final EmbedBuilder embedBuilder = new EmbedBuilder();
embedBuilder.setColor(member.getColor());
embedBuilder.setDescription(":arrow_right: " + member.getAsMention() + " ist beigetreten");
textChannel.sendMessage(embedBuilder.build()).queue();
}
}
use of net.dv8tion.jda.api.EmbedBuilder in project c0debaseBot by Biospheere.
the class InviteTracker method start.
/**
* See which invite has been used by a new member of a guild
*/
public void start() {
Executors.newScheduledThreadPool(1).scheduleAtFixedRate(() -> bot.getJDA().getGuilds().get(0).retrieveInvites().queue(inviteList -> inviteList.forEach(invite -> {
if (inviteHashMap.containsKey(invite.getCode()) && invite.getUses() > inviteHashMap.get(invite.getCode()).getUses()) {
final User user = bot.getDatabase().getUserDao().getOrCreateUser(invite.getGuild().getId(), invite.getInviter().getId());
EmbedBuilder embedBuilder = new EmbedBuilder();
embedBuilder.setDescription(invite.getInviter().getAsMention() + " vielen Dank das du jemand neues auf c0debase gebracht hast [" + invite.getCode() + "]");
bot.getJDA().getTextChannelById(System.getenv("BOTCHANNEL")).sendMessage(embedBuilder.build()).queue();
if (user.addXP(100)) {
EmbedBuilder levelUpEmbed = new EmbedBuilder();
levelUpEmbed.setDescription(invite.getInviter().getAsMention() + " ist nun Level " + user.getLevel());
bot.getJDA().getTextChannelById(System.getenv("BOTCHANNEL")).sendMessage(levelUpEmbed.build()).queue();
}
bot.getDatabase().getUserDao().updateUser(user);
}
inviteHashMap.put(invite.getCode(), invite);
})), 5, 5, TimeUnit.SECONDS);
}
use of net.dv8tion.jda.api.EmbedBuilder in project c0debaseBot by Biospheere.
the class SinceCommand method execute.
@Override
public void execute(final String[] args, final Message message) {
final Member member = message.getMentionedMembers().size() == 0 ? message.getMember() : message.getMentionedMembers().get(0);
final EmbedBuilder embedBuilder = getEmbed(message.getGuild(), message.getAuthor());
if (args.length > 0 && message.getMentionedMembers().isEmpty() && StringUtils.isInteger(args[0]) && message.getGuild().isLoaded()) {
final Integer since = Integer.valueOf(args[0]);
if (since < 0) {
final Member oldestMember = DiscordUtils.getOldestMember(message.getGuild());
embedBuilder.setDescription("!since [0-" + ((oldestMember == null) ? "?]" : ChronoUnit.DAYS.between(oldestMember.getTimeJoined(), LocalDateTime.now().atOffset(ZoneOffset.UTC)) + "]"));
} else {
final Integer memberCount = getMemberCoundByDays(since, message.getGuild());
final float percentage = ((float) memberCount / (float) message.getGuild().getMemberCount()) * 100;
embedBuilder.setDescription("Es gibt " + memberCount + " Mitglieder welche seit mehr als " + since + " Tagen auf diesem Server sind.\n Das sind " + DECIMAL_FORMAT.format(percentage) + "%");
}
} else {
embedBuilder.setDescription(member.getAsMention() + " ist seit " + ChronoUnit.DAYS.between(member.getTimeJoined(), LocalDateTime.now().atOffset(ZoneOffset.UTC)) + " Tagen auf " + message.getGuild().getName());
}
message.getTextChannel().sendMessage(embedBuilder.build()).queue();
}
use of net.dv8tion.jda.api.EmbedBuilder in project c0debaseBot by Biospheere.
the class CoinCommand method execute.
@Override
public void execute(final String[] args, final Message message) {
final Member member = DiscordUtils.getAddressedMember(message);
final EmbedBuilder embedBuilder = getEmbed(message.getGuild(), member.getUser());
embedBuilder.setDescription(member.getAsMention() + " hat " + String.format("%.2f", bot.getDatabase().getUserDao().getOrCreateUser(member.getGuild().getId(), member.getUser().getId()).getCoins()) + " Coins");
message.getTextChannel().sendMessage(embedBuilder.build()).queue();
}
Aggregations