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();
}
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;
}
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);
}
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));
}*/
}
}
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);
}
Aggregations