Search in sources :

Example 41 with TextChannel

use of net.dv8tion.jda.core.entities.TextChannel in project Rubicon by Rubicon-Bot.

the class CommandWhitelist method execute.

@Override
protected Message execute(CommandManager.ParsedCommandInvocation parsedCommandInvocation, UserPermissions userPermissions) {
    String[] args = parsedCommandInvocation.getArgs();
    Member member = parsedCommandInvocation.getMember();
    Guild guild = parsedCommandInvocation.getGuild();
    TextChannel channel = parsedCommandInvocation.getTextChannel();
    Message message = parsedCommandInvocation.getMessage();
    if (args.length == 0)
        return createHelpMessage();
    GuildSQL guildSQL = GuildSQL.fromGuild(guild);
    if (guildSQL.enabledBlacklist()) {
        return new MessageBuilder().setEmbed(EmbedUtil.error("Already using blacklist", "You can't use black- and whitelist on the same server").build()).build();
    }
    switch(args[0]) {
        case "list":
            executeList(args, member, guild, channel);
            break;
        case "add":
        case "whitelist":
            executeAdd(args, member, guild, channel, message);
            break;
        case "remove":
        case "blacklist":
            executeRemove(args, member, guild, channel, message);
            break;
        default:
            SafeMessage.sendMessage(channel, createHelpMessage(), 5);
            break;
    }
    return null;
}
Also used : GuildSQL(fun.rubicon.sql.GuildSQL) TextChannel(net.dv8tion.jda.core.entities.TextChannel) SafeMessage(fun.rubicon.util.SafeMessage) Message(net.dv8tion.jda.core.entities.Message) MessageBuilder(net.dv8tion.jda.core.MessageBuilder) Guild(net.dv8tion.jda.core.entities.Guild) Member(net.dv8tion.jda.core.entities.Member)

Example 42 with TextChannel

use of net.dv8tion.jda.core.entities.TextChannel in project Rubicon by Rubicon-Bot.

the class ChannelDeleteListener method onTextChannelDelete.

@Override
public void onTextChannelDelete(TextChannelDeleteEvent e) {
    String portalStatus = RubiconBot.getMySQL().getGuildValue(e.getGuild(), "portal");
    if (portalStatus.equalsIgnoreCase("closed") || portalStatus.equalsIgnoreCase("waiting"))
        return;
    if (portalStatus.equalsIgnoreCase("open")) {
        TextChannel channel = e.getJDA().getTextChannelById(RubiconBot.getMySQL().getPortalValue(e.getGuild(), "channelid"));
        if (e.getChannel().getId() != channel.getId())
            return;
        Guild partnerGuild = e.getJDA().getGuildById(RubiconBot.getMySQL().getPortalValue(e.getGuild(), "partnerid"));
        RubiconBot.getMySQL().deletePortal(e.getGuild());
        RubiconBot.getMySQL().deletePortal(partnerGuild);
        RubiconBot.getMySQL().updateGuildValue(e.getGuild(), "portal", "closed");
        RubiconBot.getMySQL().updateGuildValue(partnerGuild, "portal", "closed");
        sendPortalNotification(e.getGuild(), "Portal was closed.");
        sendPortalNotification(partnerGuild, "Portal was closed on the other side.");
    }
}
Also used : TextChannel(net.dv8tion.jda.core.entities.TextChannel) Guild(net.dv8tion.jda.core.entities.Guild)

Example 43 with TextChannel

use of net.dv8tion.jda.core.entities.TextChannel in project Rubicon by Rubicon-Bot.

the class VerificationListener method onGuildMemberJoin.

@Override
public void onGuildMemberJoin(GuildMemberJoinEvent event) {
    if (event.getUser().isBot())
        return;
    if (!RubiconBot.getMySQL().verificationEnabled(event.getGuild()))
        return;
    if (event.getUser().isBot())
        return;
    TextChannel channel = event.getGuild().getTextChannelById(RubiconBot.getMySQL().getVerificationValue(event.getGuild(), "channelid"));
    Message message = SafeMessage.sendMessageBlocking(channel, RubiconBot.getMySQL().getVerificationValue(event.getGuild(), "text").replace("%user%", event.getUser().getAsMention()).replace("%guild%", event.getGuild().getName()));
    CommandVerification.users.put(message, event.getUser());
    String emoteRaw = RubiconBot.getMySQL().getVerificationValue(event.getGuild(), "emote");
    if (!StringUtil.isNumeric(emoteRaw))
        message.addReaction(emoteRaw).queue();
    else
        message.addReaction(event.getJDA().getEmoteById(emoteRaw)).queue();
    int delay = Integer.parseInt(RubiconBot.getMySQL().getVerificationValue(event.getGuild(), "kicktime"));
    if (delay == 0)
        return;
    new VerificationUserHandler.VerifyUser(event.getMember(), message);
    new VerificationKickHandler.VerifyKick(event.getGuild(), event.getMember(), getKickTime(delay), RubiconBot.getMySQL().getVerificationValue(event.getGuild(), "kicktext").replace("%guild%", event.getGuild().getName()), message.getIdLong(), false, true);
}
Also used : TextChannel(net.dv8tion.jda.core.entities.TextChannel) SafeMessage(fun.rubicon.util.SafeMessage) Message(net.dv8tion.jda.core.entities.Message)

Example 44 with TextChannel

use of net.dv8tion.jda.core.entities.TextChannel in project Rubicon by Rubicon-Bot.

the class MemberLeaveListener method onGuildMemberLeave.

@Override
public void onGuildMemberLeave(GuildMemberLeaveEvent event) {
    /* Leave message */
    String message = RubiconBot.getMySQL().getGuildValue(event.getGuild(), "leavemsg").replace("%user%", event.getMember().getAsMention()).replace("%guild%", event.getGuild().getName());
    if (message == null)
        return;
    if (message.equalsIgnoreCase("0") || message.equalsIgnoreCase(" 0"))
        return;
    TextChannel channel = event.getGuild().getTextChannelById(RubiconBot.getMySQL().getGuildValue(event.getGuild(), "channel"));
    if (channel == null)
        return;
    SafeMessage.sendMessage(channel, message);
}
Also used : TextChannel(net.dv8tion.jda.core.entities.TextChannel)

Example 45 with TextChannel

use of net.dv8tion.jda.core.entities.TextChannel in project Rubicon by Rubicon-Bot.

the class ServerLogHandler method onGuildMemberJoin.

@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);
}
Also used : TextChannel(net.dv8tion.jda.core.entities.TextChannel) EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder)

Aggregations

TextChannel (net.dv8tion.jda.core.entities.TextChannel)91 EmbedBuilder (net.dv8tion.jda.core.EmbedBuilder)27 Guild (net.dv8tion.jda.core.entities.Guild)22 User (net.dv8tion.jda.core.entities.User)20 Member (net.dv8tion.jda.core.entities.Member)18 List (java.util.List)17 Message (net.dv8tion.jda.core.entities.Message)17 ArrayList (java.util.ArrayList)14 VoiceChannel (net.dv8tion.jda.core.entities.VoiceChannel)13 GuildWrapper (stream.flarebot.flarebot.objects.GuildWrapper)13 MessageUtils (stream.flarebot.flarebot.util.MessageUtils)13 Collectors (java.util.stream.Collectors)11 CommandType (stream.flarebot.flarebot.commands.CommandType)8 Role (net.dv8tion.jda.core.entities.Role)7 FlareBot (stream.flarebot.flarebot.FlareBot)7 Track (com.arsenarsen.lavaplayerbridge.player.Track)6 MessageEmbed (net.dv8tion.jda.core.entities.MessageEmbed)6 MantaroData (net.kodehawa.mantarobot.data.MantaroData)6 DBGuild (net.kodehawa.mantarobot.db.entities.DBGuild)6 EmoteReference (net.kodehawa.mantarobot.utils.commands.EmoteReference)6