Fixed outstanding buds, added 3 additional commands, added ConversationModule and Discord Utils for Role / Member search
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package io.rixa.bot.commands;
|
||||
|
||||
import io.rixa.bot.commands.perms.RixaPermission;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
|
||||
@@ -31,5 +32,5 @@ public abstract class Command {
|
||||
setAliases(aliases);
|
||||
}
|
||||
|
||||
public abstract boolean execute(GuildMessageReceivedEvent event);
|
||||
public abstract void execute(GuildMessageReceivedEvent event);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
package io.rixa.bot.commands.cmds;
|
||||
|
||||
import io.rixa.bot.commands.Command;
|
||||
import io.rixa.bot.commands.RixaPermission;
|
||||
import io.rixa.bot.commands.perms.RixaPermission;
|
||||
import io.rixa.bot.utils.MessageFactory;
|
||||
import net.dv8tion.jda.core.EmbedBuilder;
|
||||
import net.dv8tion.jda.core.entities.Message;
|
||||
import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
|
||||
import net.dv8tion.jda.core.exceptions.ErrorResponseException;
|
||||
import net.dv8tion.jda.core.exceptions.PermissionException;
|
||||
|
||||
public class HelpCommand extends Command {
|
||||
|
||||
@@ -11,7 +16,29 @@ public class HelpCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(GuildMessageReceivedEvent event) {
|
||||
return false;
|
||||
public void execute(GuildMessageReceivedEvent event) {
|
||||
try {
|
||||
event.getMessage().delete().complete();
|
||||
} catch (PermissionException ignored) {}
|
||||
EmbedBuilder embedBuilder = new EmbedBuilder();
|
||||
String stringBuilder = "\u2753" +
|
||||
" **Help**" +
|
||||
"\n" +
|
||||
"Click the corresponding number for more information about the command menu.";
|
||||
embedBuilder.setTitle(String.format("Help: %s", event.getGuild().getId()))
|
||||
.setDescription(stringBuilder)
|
||||
.addField("1 - General Commands", "Reveals usable commands intended for `everyone`", false)
|
||||
.addField("2 - Staff Commands", "Reveals usable commands intended for `staff` use only", false)
|
||||
.addField("3 - Music Commands", "Reveals usable commands to configure Rixa for your discord!", false)
|
||||
.setColor(event.getMember().getColor());
|
||||
Message message = event.getAuthor().openPrivateChannel().complete().sendMessage(embedBuilder.build()).complete();
|
||||
MessageFactory.create(event.getMember().getAsMention()
|
||||
+ ", the help menu has been private messaged to you!").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
try {
|
||||
message.addReaction("\u0031\u20E3").queue();
|
||||
message.addReaction("\u0032\u20E3").queue();
|
||||
message.addReaction("\u0033\u20E3").queue();
|
||||
message.addReaction("\uD83D\uDDD1").queue();
|
||||
} catch (ErrorResponseException ignored) {}
|
||||
}
|
||||
}
|
||||
|
||||
83
src/main/java/io/rixa/bot/commands/cmds/InfoCommand.java
Normal file
83
src/main/java/io/rixa/bot/commands/cmds/InfoCommand.java
Normal file
@@ -0,0 +1,83 @@
|
||||
package io.rixa.bot.commands.cmds;
|
||||
|
||||
import io.rixa.bot.Rixa;
|
||||
import io.rixa.bot.commands.Command;
|
||||
import io.rixa.bot.commands.perms.RixaPermission;
|
||||
import io.rixa.bot.utils.DiscordUtils;
|
||||
import io.rixa.bot.utils.MessageFactory;
|
||||
import net.dv8tion.jda.core.EmbedBuilder;
|
||||
import net.dv8tion.jda.core.JDA;
|
||||
import net.dv8tion.jda.core.JDAInfo;
|
||||
import net.dv8tion.jda.core.entities.Member;
|
||||
import net.dv8tion.jda.core.entities.Message;
|
||||
import net.dv8tion.jda.core.entities.MessageEmbed;
|
||||
import net.dv8tion.jda.core.entities.User;
|
||||
import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class InfoCommand extends Command {
|
||||
|
||||
public InfoCommand(String command, RixaPermission rixaPermission, String description) {
|
||||
super(command, rixaPermission, description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(GuildMessageReceivedEvent event) {
|
||||
System.out.println("INFO COMMAND TRIGGERED");
|
||||
String[] messages = event.getMessage().getContent().split(" ");
|
||||
System.out.println(messages.length);
|
||||
if(messages.length >= 2) {
|
||||
Member member = DiscordUtils.memberSearch(event.getGuild(), event.getMessage().getContent(), false).get(0);
|
||||
User user = member.getUser();
|
||||
OffsetDateTime time = user.getCreationTime();
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MMM/dd/yyyy HH:mm:ss");
|
||||
MessageFactory.create("Playing **" + (member.getGame() == null ? "Unknown" : member.getGame().getName()) + "**")
|
||||
.setColor(member.getColor())
|
||||
.setThumbnail(user.getAvatarUrl())
|
||||
.setAuthor("User Information: " + user.getName(), null, user.getAvatarUrl())
|
||||
.addField("User", user.getAsMention(), true)
|
||||
.addField("ID", user.getId(), true)
|
||||
.addField("Roles", String.valueOf(member.getRoles().size()), true)
|
||||
.addField("Status", member.getOnlineStatus().name(), true)
|
||||
.addField("Mutual Guilds", String.valueOf(user.getMutualGuilds().size()), true)
|
||||
.addField("Nickname", member.getNickname() == null ? "None" : member.getNickname(), true)
|
||||
.addField("Created", time.format(formatter), true)
|
||||
.addField("Joined", member.getJoinDate().format(formatter), true)
|
||||
.queue(event.getChannel());
|
||||
return;
|
||||
}
|
||||
User botOwner = event.getJDA().getUserById("202944101333729280");
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy HH:mm:ss");
|
||||
Date date1 = new Date(Rixa.getTimeUp());
|
||||
long difference = new Date().getTime() - date1.getTime();
|
||||
long seconds = difference / 1000;
|
||||
int day = (int) TimeUnit.SECONDS.toDays(seconds);
|
||||
long hours = TimeUnit.SECONDS.toHours(seconds) - (day * 24);
|
||||
long minute = TimeUnit.SECONDS.toMinutes(seconds) - (TimeUnit.SECONDS.toHours(seconds) * 60);
|
||||
long second = TimeUnit.SECONDS.toSeconds(seconds) - (TimeUnit.SECONDS.toMinutes(seconds) * 60);
|
||||
int guildCount = 0;
|
||||
int userCount = 0;
|
||||
for (JDA jda : Rixa.getInstance().getShardList()) {
|
||||
guildCount += jda.getGuilds().size();
|
||||
userCount += jda.getUsers().size();
|
||||
}
|
||||
String uptime = String.format("Uptime: %d days %d hours %d minutes %d seconds", day, hours, minute, second);
|
||||
MessageFactory.create("Rixa is a user-friendly, multi-purpose bot currently in development which is capable of being customized to your Discord server needs. " +
|
||||
"Rixa is complete with a dashboard, user profile, server statistics system, and many more features such as assigning roles on user join, music module, " +
|
||||
"levels, and more. Rixa was created to bring ease and simplicity to managing Discord servers, and has since grown into much more than just a bot used for " +
|
||||
"moderation.")
|
||||
.setTitle("Rixa Discord Bot", "http://rixa.io/")
|
||||
.addField("Created", event.getJDA().getSelfUser().getCreationTime().format(formatter), true)
|
||||
.addField("Bot Uptime ", uptime, true)
|
||||
.addField("Total Guilds", String.valueOf(guildCount), true)
|
||||
.addField("Total Users", String.valueOf(userCount), true)
|
||||
.addField("JDA Version", JDAInfo.VERSION, true)
|
||||
.addField("Rixa Developer", botOwner.getName() + "#" + botOwner.getDiscriminator(), true)
|
||||
.footer("Requested by " + event.getAuthor().getName() + "#" + event.getAuthor().getDiscriminator(), event.getAuthor().getAvatarUrl())
|
||||
.queue(event.getChannel());
|
||||
}
|
||||
}
|
||||
18
src/main/java/io/rixa/bot/commands/cmds/PingCommand.java
Normal file
18
src/main/java/io/rixa/bot/commands/cmds/PingCommand.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package io.rixa.bot.commands.cmds;
|
||||
|
||||
import io.rixa.bot.commands.Command;
|
||||
import io.rixa.bot.commands.perms.RixaPermission;
|
||||
import io.rixa.bot.utils.MessageFactory;
|
||||
import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
|
||||
|
||||
public class PingCommand extends Command {
|
||||
|
||||
public PingCommand(String command, RixaPermission rixaPermission, String description) {
|
||||
super(command, rixaPermission, description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(GuildMessageReceivedEvent event) {
|
||||
MessageFactory.create("Pong! [" + event.getJDA().getPing() + "ms]").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package io.rixa.bot.commands.cmds;
|
||||
|
||||
import io.rixa.bot.commands.Command;
|
||||
import io.rixa.bot.commands.perms.RixaPermission;
|
||||
import io.rixa.bot.guild.RixaGuild;
|
||||
import io.rixa.bot.guild.manager.GuildManager;
|
||||
import io.rixa.bot.utils.MessageFactory;
|
||||
import net.dv8tion.jda.core.entities.User;
|
||||
import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
|
||||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
public class ServerInfoCommand extends Command {
|
||||
|
||||
public ServerInfoCommand(String command, RixaPermission rixaPermission, String description) {
|
||||
super(command, rixaPermission, description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(GuildMessageReceivedEvent event) {
|
||||
RixaGuild rixaGuild = GuildManager.getInstance().getGuild(event.getGuild());
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy HH:mm:ss");
|
||||
User owner = event.getGuild().getOwner().getUser();
|
||||
MessageFactory
|
||||
.create(rixaGuild.getDescription())
|
||||
.setTitle(event.getGuild().getName(), String.format("http://rixa.io/servers/%s", event.getGuild().getId()))
|
||||
.addField("Created", event.getGuild().getCreationTime().format(formatter), true)
|
||||
.addField("Region", event.getGuild().getRegion().toString(), true)
|
||||
.addField("Users", String.valueOf(event.getGuild().getMembers().size()), true)
|
||||
.addField("Channel Categories", String.valueOf(event.getGuild().getCategories().size()), true)
|
||||
.addField("Text Channels", String.valueOf(event.getGuild().getTextChannels().size()), true)
|
||||
.addField("Voice Channels", String.valueOf(event.getGuild().getVoiceChannels().size()), true)
|
||||
.addField("Verification Level", event.getGuild().getVerificationLevel().toString(), true)
|
||||
.addField("Roles", String.valueOf(event.getGuild().getRoles().size()), true)
|
||||
.addField("Owner", owner.getName() + "#" + owner.getDiscriminator(), true)
|
||||
.addField("Enlisted", String.valueOf(true), true)
|
||||
.setThumbnail(event.getGuild().getIconUrl())
|
||||
.footer("Server Id: " + event.getGuild().getId(), event.getGuild().getIconUrl())
|
||||
.queue(event.getChannel());
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.rixa.bot.commands;
|
||||
package io.rixa.bot.commands.handler;
|
||||
|
||||
import io.rixa.bot.commands.Command;
|
||||
import io.rixa.bot.commands.exceptions.CommandNotFoundException;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -14,7 +15,14 @@ public class CommandHandler {
|
||||
commandMap.put(command.getCommand(), command);
|
||||
}
|
||||
|
||||
public void registerCommands(Command...commands) {
|
||||
for (Command command : commands) {
|
||||
registerCommand(command);
|
||||
}
|
||||
}
|
||||
|
||||
public Command getCommand(String commandName) throws CommandNotFoundException {
|
||||
if (commandMap.containsKey(commandName)) return commandMap.get(commandName);
|
||||
for(Command command: commandMap.values()) {
|
||||
if (command.getAliases().contains(commandName)) {
|
||||
return command;
|
||||
@@ -1,7 +1,18 @@
|
||||
package io.rixa.bot.commands;
|
||||
package io.rixa.bot.commands.perms;
|
||||
|
||||
public enum RixaPermission {
|
||||
NONE;
|
||||
NONE,
|
||||
MUTE,
|
||||
ADD_ROLE,
|
||||
REMOVE_ROLE,
|
||||
CLEAR_CHAT,
|
||||
ACCESS_CONFIG,
|
||||
PM_MESSAGE,
|
||||
KICK_MEMBER,
|
||||
BAN_MEMBER,
|
||||
BATCH_MOVE,
|
||||
UNMUTE,
|
||||
TOGGLE_RAIDMODE;
|
||||
|
||||
public static RixaPermission fromString(String string) {
|
||||
for (RixaPermission value : values()) {
|
||||
Reference in New Issue
Block a user