Search in sources :

Example 1 with UserSQL

use of fun.rubicon.sql.UserSQL in project Rubicon by Rubicon-Bot.

the class CommandBio method execute.

@Override
protected Message execute(CommandManager.ParsedCommandInvocation invocation, UserPermissions userPermissions) {
    if (invocation.getArgs().length == 0) {
        return createHelpMessage();
    }
    if (invocation.getArgs()[0].equalsIgnoreCase("set")) {
        UserSQL sql = new UserSQL(invocation.getAuthor());
        String bioText = invocation.getMessage().getContentDisplay().replace(invocation.getPrefix() + invocation.getCommandInvocation() + " set", "");
        if (bioText.toCharArray().length > 280) {
            return EmbedUtil.message(EmbedUtil.error("Error!", "Maximum char length is 280."));
        }
        bioText = filterWords(bioText);
        sql.set("bio", bioText);
        return EmbedUtil.message(EmbedUtil.success("Updated Bio!", "Successfully updated your bio."));
    }
    return createHelpMessage();
}
Also used : UserSQL(fun.rubicon.sql.UserSQL)

Example 2 with UserSQL

use of fun.rubicon.sql.UserSQL in project Rubicon by Rubicon-Bot.

the class CommandVolume method execute.

@Override
protected Message execute(CommandManager.ParsedCommandInvocation parsedCommandInvocation, UserPermissions userPermissions) {
    UserSQL userSQL = UserSQL.fromUser(parsedCommandInvocation.getAuthor());
    if (!userSQL.isPremium()) {
        return EmbedUtil.message(EmbedUtil.noPremium());
    }
    MusicManager manager = new MusicManager(parsedCommandInvocation);
    Message msg = manager.executeVolume();
    if (msg == null)
        return createHelpMessage();
    else
        return msg;
}
Also used : UserSQL(fun.rubicon.sql.UserSQL) MusicManager(fun.rubicon.core.music.MusicManager) Message(net.dv8tion.jda.core.entities.Message)

Example 3 with UserSQL

use of fun.rubicon.sql.UserSQL in project Rubicon by Rubicon-Bot.

the class CommandForceplay method execute.

@Override
protected Message execute(CommandManager.ParsedCommandInvocation parsedCommandInvocation, UserPermissions userPermissions) {
    UserSQL userSQL = new UserSQL(parsedCommandInvocation.getAuthor());
    if (!userSQL.isPremium()) {
        return EmbedUtil.message(EmbedUtil.noPremium());
    }
    MusicManager manager = new MusicManager(parsedCommandInvocation);
    return manager.playMusic(true);
}
Also used : UserSQL(fun.rubicon.sql.UserSQL) MusicManager(fun.rubicon.core.music.MusicManager)

Example 4 with UserSQL

use of fun.rubicon.sql.UserSQL in project Rubicon by Rubicon-Bot.

the class MemberLevelListener method onGuildMessageReceived.

public void onGuildMessageReceived(GuildMessageReceivedEvent event) {
    if (event.getAuthor().isBot()) {
        return;
    }
    if (Cooldown.has(event.getAuthor().getId())) {
        return;
    }
    MemberSQL memberSQL = new MemberSQL(event.getMember());
    // Point System
    int currentPoints = Integer.parseInt(memberSQL.get("points"));
    int pRandom = (int) ((Math.random() * 12 + 3));
    int nowPoints = currentPoints + pRandom;
    String sPoints = String.valueOf(nowPoints);
    memberSQL.set("points", sPoints);
    // Cooldown
    Cooldown.add(event.getAuthor().getId());
    new Timer().schedule(new TimerTask() {

        @Override
        public void run() {
            Cooldown.remove(event.getAuthor().getId());
        }
    }, 20000);
    int currentLevel = Integer.parseInt(memberSQL.get("level"));
    int requiredPoints = getRequiredPointsByLevel(currentLevel);
    if (nowPoints > requiredPoints) {
        currentLevel++;
        String fina = String.valueOf(currentLevel);
        memberSQL.set("level", fina);
        memberSQL.set("points", "0");
        UserSQL userSQL = new UserSQL(event.getAuthor());
        int oldMoney = Integer.parseInt(userSQL.get("money"));
        userSQL.set("money", (oldMoney + (currentLevel * 100)) + "");
    // Level Up
    /*if (event.getMessage().getGuild().getSelfMember().hasPermission(event.getChannel(), Permission.MESSAGE_READ) && event.getMessage().getGuild().getSelfMember().hasPermission(event.getChannel(), Permission.MESSAGE_WRITE)) {
                event.getChannel().sendMessage(new EmbedBuilder()
                        .setAuthor(event.getAuthor().getName() + " leveled up!", null, event.getAuthor().getAvatarUrl())
                        .setDescription("You are now level **" + fina + "**")
                        .setFooter("rc!profile to see money, level, points and more", null)
                        .setColor(Colors.COLOR_SECONDARY)
                        .build()
                ).queue(message -> message.delete().queueAfter(10, TimeUnit.SECONDS));
            }*/
    }
}
Also used : UserSQL(fun.rubicon.sql.UserSQL) Timer(java.util.Timer) TimerTask(java.util.TimerTask) MemberSQL(fun.rubicon.sql.MemberSQL)

Example 5 with UserSQL

use of fun.rubicon.sql.UserSQL in project Rubicon by Rubicon-Bot.

the class UserJoinListener method onGuildMemberJoin.

public void onGuildMemberJoin(GuildMemberJoinEvent e) {
    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
    }
    UserSQL userSQL = new UserSQL(e.getUser());
    CommandPremium.assignPremiumRole(userSQL);
}
Also used : UserSQL(fun.rubicon.sql.UserSQL) TextChannel(net.dv8tion.jda.core.entities.TextChannel)

Aggregations

UserSQL (fun.rubicon.sql.UserSQL)11 EmbedBuilder (net.dv8tion.jda.core.EmbedBuilder)4 MusicManager (fun.rubicon.core.music.MusicManager)2 MemberSQL (fun.rubicon.sql.MemberSQL)2 PriceList (fun.rubicon.core.PriceList)1 CoinhiveUser (fun.rubicon.core.coinhive.CoinhiveUser)1 PermissionRequirements (fun.rubicon.permission.PermissionRequirements)1 List (java.util.List)1 Timer (java.util.Timer)1 TimerTask (java.util.TimerTask)1 MessageBuilder (net.dv8tion.jda.core.MessageBuilder)1 Message (net.dv8tion.jda.core.entities.Message)1 TextChannel (net.dv8tion.jda.core.entities.TextChannel)1 User (net.dv8tion.jda.core.entities.User)1