use of fun.rubicon.sql.MemberSQL 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.MemberSQL in project Rubicon by Rubicon-Bot.
the class CommandProfile method generateProfile.
private void generateProfile(Member member, TextChannel textChannel) {
User user = member.getUser();
MemberSQL memberSQL = new MemberSQL(member);
UserSQL userSQL = new UserSQL(user);
EmbedBuilder embedBuilder = new EmbedBuilder();
embedBuilder.setColor(Colors.COLOR_PRIMARY);
embedBuilder.setAuthor(member.getEffectiveName() + "'s profile", null, member.getUser().getAvatarUrl());
if (Arrays.asList(Info.BOT_AUTHOR_IDS).contains(member.getUser().getIdLong())) {
embedBuilder.addField("VIP", "Official RubiconBot Developer", false);
} else {
Role staffRole = member.getGuild().getRoleById(Info.COMMUNITY_STAFF_ROLE);
if (member.getRoles().contains(staffRole))
embedBuilder.addField("VIP", "RubiconBot Community Staff", false);
}
embedBuilder.setDescription(userSQL.get("bio"));
embedBuilder.addField("Money", "Balance: " + userSQL.get("money") + " Rubys", true);
embedBuilder.addField("Premium", (userSQL.isPremium()) ? "Until " + userSQL.formatExpiryDate() : "No premium", true);
embedBuilder.addField("Level", buildProgressBar(memberSQL), false);
textChannel.sendMessage(EmbedUtil.message(embedBuilder)).queue(message -> message.delete().queueAfter(5, TimeUnit.MINUTES));
}
Aggregations