Update Biscuit to work on multiple guilds simultaneously
This commit is contained in:
@@ -2,13 +2,10 @@ package com.fpghoti.biscuit.commands;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.logging.BiscuitLog;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
|
||||
import net.dv8tion.jda.api.JDA;
|
||||
import net.dv8tion.jda.api.entities.ChannelType;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
@@ -16,23 +13,29 @@ import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||
|
||||
public class CommandListener extends ListenerAdapter implements Runnable {
|
||||
|
||||
public Scanner sc;
|
||||
public JDA jda;
|
||||
Logger log = Main.log;
|
||||
private Scanner sc;
|
||||
private BiscuitLog log;
|
||||
|
||||
public CommandListener(Scanner sc, BiscuitLog log) {
|
||||
this.sc = sc;
|
||||
this.log = log;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessageReceived(MessageReceivedEvent event){
|
||||
if (event.isFromType(ChannelType.TEXT)) {
|
||||
if(PermUtil.isAdmin(event.getMember()) || !PropertiesRetrieval.restrictCmdChannels() || (PropertiesRetrieval.restrictCmdChannels() && isBotChannel(event.getTextChannel()))) {
|
||||
if(!event.getAuthor().isBot() && event.getMessage().getContentDisplay().startsWith(PropertiesRetrieval.getCommandSignifier()) && event.getMessage().getAuthor().getId() != event.getJDA().getSelfUser().getId()){
|
||||
Main.getBiscuit().getCommandManager().parse(event.getMessage().getContentRaw().toLowerCase(), event);
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
if(PermUtil.isAdmin(event.getMember()) || !b.getProperties().restrictCmdChannels() || (b.getProperties().restrictCmdChannels() && isBotChannel(event.getTextChannel()))) {
|
||||
if(!event.getAuthor().isBot() && event.getMessage().getContentDisplay().startsWith(b.getProperties().getCommandSignifier()) && event.getMessage().getAuthor().getId() != event.getJDA().getSelfUser().getId()){
|
||||
CommandManager.parse(event.getMessage().getContentRaw().toLowerCase(), event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isBotChannel(TextChannel c) {
|
||||
for(String s : PropertiesRetrieval.getCmdChannels()) {
|
||||
Biscuit b = Biscuit.getBiscuit(c.getGuild());
|
||||
for(String s : b.getProperties().getCmdChannels()) {
|
||||
if(s.equals(c.getName())) {
|
||||
return true;
|
||||
}
|
||||
@@ -55,7 +58,7 @@ public class CommandListener extends ListenerAdapter implements Runnable {
|
||||
|
||||
private void runCommand(String label, String[] args) {
|
||||
log.info(label);
|
||||
Main.getBiscuit().getCommandManager().dispatch(label, args);
|
||||
CommandManager.dispatch(label, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,9 +3,8 @@ package com.fpghoti.biscuit.commands;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.fpghoti.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
import com.fpghoti.biscuit.util.Util;
|
||||
|
||||
@@ -13,11 +12,12 @@ import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
public class CommandManager {
|
||||
|
||||
private List<BaseCommand> commands = new ArrayList<BaseCommand>();
|
||||
private static List<BaseCommand> commands = new ArrayList<BaseCommand>();
|
||||
|
||||
public void parse(String message, MessageReceivedEvent e){
|
||||
public static void parse(String message, MessageReceivedEvent e){
|
||||
Biscuit b = Biscuit.getBiscuit(e.getGuild());
|
||||
ArrayList<String> split = new ArrayList<String>();
|
||||
String fixed = message.replaceFirst(PropertiesRetrieval.getCommandSignifier(), "");
|
||||
String fixed = message.replaceFirst(b.getProperties().getCommandSignifier(), "");
|
||||
String[] splitMsg = fixed.split(" ");
|
||||
for(String s: splitMsg){
|
||||
split.add(s);
|
||||
@@ -30,18 +30,20 @@ public class CommandManager {
|
||||
}
|
||||
|
||||
|
||||
public boolean dispatch(String label, String[] args) {
|
||||
public static boolean dispatch(String label, String[] args) {
|
||||
return dispatch(null,label,args);
|
||||
}
|
||||
|
||||
public boolean dispatch(MessageReceivedEvent e, String label, String[] args) {
|
||||
|
||||
public static boolean dispatch(MessageReceivedEvent e, String label, String[] args) {
|
||||
Biscuit b = Main.getMainBiscuit();
|
||||
boolean isMain = true;
|
||||
if(e != null) {
|
||||
|
||||
if(Util.contains(PropertiesRetrieval.disabledCommands(), label)) {
|
||||
b = Biscuit.getBiscuit(e.getGuild());
|
||||
isMain = false;
|
||||
if(Util.contains(b.getProperties().disabledCommands(), label)) {
|
||||
return false;
|
||||
}
|
||||
if(!PermUtil.isAdmin(e.getMember()) && Util.contains(PropertiesRetrieval.disabledUserCommands(), label)) {
|
||||
if(!PermUtil.isAdmin(e.getMember()) && Util.contains(b.getProperties().disabledUserCommands(), label)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -83,8 +85,17 @@ public class CommandManager {
|
||||
}
|
||||
}
|
||||
}else {
|
||||
if(Util.contains(PropertiesRetrieval.getCustomCmds(), label)) {
|
||||
CustomCommand cc = new CustomCommand(label);
|
||||
if(Util.contains(Main.getMainBiscuit().getProperties().getCustomCmds(), label)) {
|
||||
CustomCommand cc = new CustomCommand(label, Main.getMainBiscuit());
|
||||
if(args.length >= 1) {
|
||||
commandReply(e, "``Command:" + " " + cc.getName() + "``");
|
||||
commandReply(e, "``Description:" + " " + cc.getDescription() + "``");
|
||||
commandReply(e, "``Usage:" + " " + cc.getUsage() + "``");
|
||||
}else {
|
||||
commandReply(e, CustomCommand.fixPlaceholders(e, cc.getMessage()));
|
||||
}
|
||||
}else if(!isMain && Util.contains(b.getProperties().getCustomCmds(), label)) {
|
||||
CustomCommand cc = new CustomCommand(label, b);
|
||||
if(args.length >= 1) {
|
||||
commandReply(e, "``Command:" + " " + cc.getName() + "``");
|
||||
commandReply(e, "``Description:" + " " + cc.getDescription() + "``");
|
||||
@@ -97,25 +108,24 @@ public class CommandManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void commandReply(MessageReceivedEvent e, String msg) {
|
||||
Biscuit b = Main.getBiscuit();
|
||||
public static void commandReply(MessageReceivedEvent e, String msg) {
|
||||
if(e != null) {
|
||||
b.say(e.getTextChannel(), msg);
|
||||
e.getTextChannel().sendMessage(msg).queue();
|
||||
}else {
|
||||
b.log(msg);
|
||||
Main.getLogger().info(msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void addCommand(BaseCommand command) {
|
||||
public static void addCommand(BaseCommand command) {
|
||||
commands.add(command);
|
||||
}
|
||||
|
||||
public void removeCommand(BaseCommand command) {
|
||||
public static void removeCommand(BaseCommand command) {
|
||||
commands.remove(command);
|
||||
}
|
||||
|
||||
public List<BaseCommand> getCommands() {
|
||||
public static List<BaseCommand> getCommands() {
|
||||
return commands;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.fpghoti.biscuit.commands;
|
||||
|
||||
import com.fpghoti.biscuit.config.ConfigRetrieval;
|
||||
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
@@ -13,9 +12,11 @@ public class CustomCommand extends BaseCommand {
|
||||
}
|
||||
|
||||
private String name;
|
||||
private Biscuit biscuit;
|
||||
|
||||
public CustomCommand(String name) {
|
||||
public CustomCommand(String name, Biscuit biscuit) {
|
||||
this.name = name;
|
||||
this.biscuit = biscuit;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -25,12 +26,12 @@ public class CustomCommand extends BaseCommand {
|
||||
|
||||
@Override
|
||||
public String getUsage() {
|
||||
return PropertiesRetrieval.getCommandSignifier() + name;
|
||||
return biscuit.getProperties().getCommandSignifier() + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
String desc = ConfigRetrieval.getFromConfig("cc-" + name + "-description");
|
||||
String desc = biscuit.getConfig().getFromConfig("cc-" + name + "-description", biscuit);
|
||||
if(desc == null) {
|
||||
return "null";
|
||||
}
|
||||
@@ -43,7 +44,7 @@ public class CustomCommand extends BaseCommand {
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
String msg = ConfigRetrieval.getFromConfig("cc-" + name + "-message");
|
||||
String msg = biscuit.getConfig().getFromConfig("cc-" + name + "-message", biscuit);
|
||||
if(msg == null) {
|
||||
return "null";
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package com.fpghoti.biscuit.commands.client;
|
||||
|
||||
import com.fpghoti.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||
import com.fpghoti.biscuit.util.Util;
|
||||
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
@@ -13,7 +12,7 @@ public class AddCommand extends ClientCommand{
|
||||
public AddCommand() {
|
||||
name = "Add";
|
||||
description = "Finds sum of two numbers.";
|
||||
usage = PropertiesRetrieval.getCommandSignifier() + "add <Num1> <Num2>";
|
||||
usage = Main.getMainBiscuit().getProperties().getCommandSignifier() + "add <Num1> <Num2>";
|
||||
minArgs = 2;
|
||||
maxArgs = 2;
|
||||
identifiers.add("add");
|
||||
@@ -21,7 +20,7 @@ public class AddCommand extends ClientCommand{
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Main.getBiscuit();
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -add");
|
||||
if(args[0] != null && Util.isDeciDigit(args[0]) && args[1] != null && Util.isDeciDigit(args[1])) {
|
||||
double num = Double.parseDouble(args[0]);
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package com.fpghoti.biscuit.commands.client;
|
||||
|
||||
import com.fpghoti.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
@@ -12,7 +11,7 @@ public class ChanIDCommand extends ClientCommand{
|
||||
public ChanIDCommand() {
|
||||
name = "Channel ID";
|
||||
description = "Retrieves the channel ID.";
|
||||
usage = PropertiesRetrieval.getCommandSignifier() + "chanid";
|
||||
usage = Main.getMainBiscuit().getProperties().getCommandSignifier() + "chanid";
|
||||
minArgs = 0;
|
||||
maxArgs = 0;
|
||||
identifiers.add("chanid");
|
||||
@@ -20,7 +19,7 @@ public class ChanIDCommand extends ClientCommand{
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Main.getBiscuit();
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -chanid");
|
||||
String id = event.getTextChannel().getId();
|
||||
event.getTextChannel().sendMessage(id).queue();
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package com.fpghoti.biscuit.commands.client;
|
||||
|
||||
import com.fpghoti.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||
import com.fpghoti.biscuit.util.Util;
|
||||
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
@@ -13,7 +12,7 @@ public class DivideCommand extends ClientCommand{
|
||||
public DivideCommand() {
|
||||
name = "Divide";
|
||||
description = "Divides two numbers.";
|
||||
usage = PropertiesRetrieval.getCommandSignifier() + "divide <Num 1> <Num 2>";
|
||||
usage = Main.getMainBiscuit().getProperties().getCommandSignifier() + "divide <Num 1> <Num 2>";
|
||||
minArgs = 2;
|
||||
maxArgs = 2;
|
||||
identifiers.add("divide");
|
||||
@@ -22,7 +21,7 @@ public class DivideCommand extends ClientCommand{
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Main.getBiscuit();
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -divide");
|
||||
if(args[0] != null && Util.isDeciDigit(args[0]) && args[1] != null && Util.isDeciDigit(args[1])) {
|
||||
double num = Double.parseDouble(args[0]);
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.fpghoti.biscuit.commands.client;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||
import com.fpghoti.biscuit.logging.BColor;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
public class GetConfigCommand extends ClientCommand{
|
||||
|
||||
public GetConfigCommand() {
|
||||
name = "Get Config";
|
||||
description = "Gets the config of the current guild.";
|
||||
usage = Main.getMainBiscuit().getProperties().getCommandSignifier() + "getconfig";
|
||||
minArgs = 0;
|
||||
maxArgs = 0;
|
||||
identifiers.add("getconfig");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -getconfig");
|
||||
if(PermUtil.isAdmin(event.getMember())) {
|
||||
event.getTextChannel().sendFile(b.getConfig().getFile(), "config-" + b.getProperties().getGuildCode() + ".properties").queue();
|
||||
}else {
|
||||
b.log(BColor.MAGENTA_BOLD + event.getAuthor().getName() + " lacks permission to view the config!");
|
||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + " You do not have "
|
||||
+ "permission to view the config.").queue(new Consumer<Message>()
|
||||
{
|
||||
@Override
|
||||
public void accept(Message msg){
|
||||
msg.delete().submitAfter(5, TimeUnit.SECONDS);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.fpghoti.biscuit.commands.client;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
public class GuildIDCommand extends ClientCommand{
|
||||
|
||||
public GuildIDCommand() {
|
||||
name = "Guild ID";
|
||||
description = "Retrieves a guild's ID.";
|
||||
usage = Main.getMainBiscuit().getProperties().getCommandSignifier() + "guildid";
|
||||
minArgs = 0;
|
||||
maxArgs = 0;
|
||||
identifiers.add("guildid");
|
||||
identifiers.add("gid");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -guildid");
|
||||
if(PermUtil.isMod(event.getMember())) {
|
||||
event.getTextChannel().sendMessage(event.getGuild().getId()).queue();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,12 +3,12 @@ package com.fpghoti.biscuit.commands.client;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.fpghoti.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.BaseCommand;
|
||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||
import com.fpghoti.biscuit.commands.CommandManager;
|
||||
import com.fpghoti.biscuit.commands.CustomCommand;
|
||||
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||
import com.fpghoti.biscuit.util.Util;
|
||||
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
@@ -18,7 +18,7 @@ public class HelpCommand extends ClientCommand {
|
||||
public HelpCommand() {
|
||||
name = "Help";
|
||||
description = "Pulls up help menu";
|
||||
usage = PropertiesRetrieval.getCommandSignifier() + "help [Page #]";
|
||||
usage = Main.getMainBiscuit().getProperties().getCommandSignifier() + "help [Page #]";
|
||||
minArgs = 0;
|
||||
maxArgs = 1;
|
||||
identifiers.add("help");
|
||||
@@ -27,7 +27,7 @@ public class HelpCommand extends ClientCommand {
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
|
||||
Biscuit biscuit = Main.getBiscuit();
|
||||
Biscuit biscuit = Biscuit.getBiscuit(event.getGuild());
|
||||
|
||||
int pg = 1;
|
||||
if (args.length > 0) {
|
||||
@@ -37,28 +37,35 @@ public class HelpCommand extends ClientCommand {
|
||||
event.getTextChannel().sendMessage("Usage: ``" + usage + "``").queue();
|
||||
}
|
||||
}
|
||||
|
||||
List<BaseCommand> commands = new ArrayList<BaseCommand>();
|
||||
String[] ccs = PropertiesRetrieval.getCustomCmds();
|
||||
|
||||
String[] ccs = biscuit.getProperties().getCustomCmds();
|
||||
for(String s : ccs) {
|
||||
if(!Util.contains(PropertiesRetrieval.disabledCommands(), s)) {
|
||||
CustomCommand cc = new CustomCommand(s);
|
||||
if(!Util.contains(biscuit.getProperties().disabledCommands(), s)) {
|
||||
CustomCommand cc = new CustomCommand(s, biscuit);
|
||||
commands.add(cc);
|
||||
}
|
||||
}
|
||||
for(BaseCommand bc : biscuit.getCommandManager().getCommands()) {
|
||||
ccs = Main.getMainBiscuit().getProperties().getCustomCmds();
|
||||
for(String s : ccs) {
|
||||
if(!Util.contains(biscuit.getProperties().disabledCommands(), s)) {
|
||||
CustomCommand cc = new CustomCommand(s, Main.getMainBiscuit());
|
||||
commands.add(cc);
|
||||
}
|
||||
}
|
||||
|
||||
for(BaseCommand bc : CommandManager.getCommands()) {
|
||||
String bclabel = bc.getUsage().split(" ")[0];
|
||||
if(!Util.contains(PropertiesRetrieval.disabledCommands(), bclabel.replace(PropertiesRetrieval.getCommandSignifier(), ""))) {
|
||||
if(!Util.contains(biscuit.getProperties().disabledCommands(), bclabel.replace(Main.getMainBiscuit().getProperties().getCommandSignifier(), ""))) {
|
||||
commands.add(bc);
|
||||
}
|
||||
}
|
||||
|
||||
int pageCount = (int) Math.ceil((double) commands.size() / 8);
|
||||
if (pg > pageCount) {
|
||||
pg = pageCount;
|
||||
}
|
||||
|
||||
event.getTextChannel().sendMessage("**Use " + PropertiesRetrieval.getCommandSignifier() + "help [Page #] to navigate the different pages.**").queue();
|
||||
event.getTextChannel().sendMessage("**Use " + Main.getMainBiscuit().getProperties().getCommandSignifier() + "help [Page #] to navigate the different pages.**").queue();
|
||||
event.getTextChannel().sendMessage("[" + Integer.toString(pg) + "/" + Integer.toString(pageCount) + "] **Bot Commands:**").queue();
|
||||
String msg = "";
|
||||
for (int i = 0; i < 8; i++) {
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package com.fpghoti.biscuit.commands.client;
|
||||
|
||||
import com.fpghoti.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
import com.fpghoti.biscuit.util.Util;
|
||||
|
||||
@@ -16,7 +15,7 @@ public class MakeInviteCommand extends ClientCommand{
|
||||
public MakeInviteCommand() {
|
||||
name = "Make Invite";
|
||||
description = "Creates an invite in the specified channel";
|
||||
usage = PropertiesRetrieval.getCommandSignifier() + "makeinvite <channel-name> [max-age-hours]";
|
||||
usage = Main.getMainBiscuit().getProperties().getCommandSignifier() + "makeinvite <channel-name> [max-age-hours]";
|
||||
minArgs = 1;
|
||||
maxArgs = 2;
|
||||
identifiers.add("makeinvite");
|
||||
@@ -29,30 +28,29 @@ public class MakeInviteCommand extends ClientCommand{
|
||||
doubAge = Double.parseDouble(args[1]) * 3600;
|
||||
}
|
||||
int maxAge = (int)Math.round(doubAge);
|
||||
Biscuit b = Main.getBiscuit();
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -makeinvite " + args[0]);
|
||||
if((PermUtil.isAdmin(event.getMember()))) {
|
||||
for(Guild g : b.getJDA().getGuilds()) {
|
||||
TextChannel c = null;
|
||||
for(TextChannel t : g.getTextChannels()) {
|
||||
if(t.getName().equalsIgnoreCase(args[0])) {
|
||||
c = t;
|
||||
Guild g = event.getGuild();
|
||||
TextChannel c = null;
|
||||
for(TextChannel t : g.getTextChannels()) {
|
||||
if(t.getName().equalsIgnoreCase(args[0])) {
|
||||
c = t;
|
||||
}
|
||||
}
|
||||
if(doubAge > 86400) {
|
||||
event.getChannel().sendMessage("That length is longer than what Discord allows. Please try again. (Max 24 hours)").queue();
|
||||
return;
|
||||
}
|
||||
final double db = doubAge;
|
||||
if(c != null) {
|
||||
c.createInvite().setMaxAge(maxAge).queue((i) -> {
|
||||
String exp = "Never";
|
||||
if(db > 0) {
|
||||
exp = args[1] + " hour(s)";
|
||||
}
|
||||
}
|
||||
if(doubAge > 86400) {
|
||||
event.getChannel().sendMessage("That length is longer than what Discord allows. Please try again. (Max 24 hours)").queue();
|
||||
return;
|
||||
}
|
||||
final double db = doubAge;
|
||||
if(c != null) {
|
||||
c.createInvite().setMaxAge(maxAge).queue((i) -> {
|
||||
String exp = "Never";
|
||||
if(db > 0) {
|
||||
exp = args[1] + " hour(s)";
|
||||
}
|
||||
event.getChannel().sendMessage("Created invite **" + i.getCode() + "** Expiration: **" + exp + "**.").queue();
|
||||
});
|
||||
}
|
||||
event.getChannel().sendMessage("Created invite **" + i.getCode() + "** Expiration: **" + exp + "**.").queue();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package com.fpghoti.biscuit.commands.client;
|
||||
|
||||
import com.fpghoti.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||
import com.fpghoti.biscuit.util.Util;
|
||||
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
@@ -13,7 +12,7 @@ public class MultiplyCommand extends ClientCommand{
|
||||
public MultiplyCommand() {
|
||||
name = "Multiply";
|
||||
description = "Multiplies two numbers.";
|
||||
usage = PropertiesRetrieval.getCommandSignifier() + "multiply <Num1> <Num2>";
|
||||
usage = Main.getMainBiscuit().getProperties().getCommandSignifier() + "multiply <Num1> <Num2>";
|
||||
minArgs = 2;
|
||||
maxArgs = 2;
|
||||
identifiers.add("multiply");
|
||||
@@ -22,7 +21,7 @@ public class MultiplyCommand extends ClientCommand{
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Main.getBiscuit();
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -multiply");
|
||||
if(args[0] != null && Util.isDeciDigit(args[0]) && args[1] != null && Util.isDeciDigit(args[1])) {
|
||||
double num = Double.parseDouble(args[0]);
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
package com.fpghoti.biscuit.commands.client;
|
||||
|
||||
import com.fpghoti.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||
import com.fpghoti.biscuit.global.SpamRecords;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
@@ -16,7 +14,7 @@ public class NotSpammerCommand extends ClientCommand{
|
||||
public NotSpammerCommand() {
|
||||
name = "Not Spammer";
|
||||
description = "Delists user as spammer.";
|
||||
usage = PropertiesRetrieval.getCommandSignifier() + "notspammer @<mention-user>";
|
||||
usage = Main.getMainBiscuit().getProperties().getCommandSignifier() + "notspammer @<mention-user>";
|
||||
minArgs = 1;
|
||||
maxArgs = 1;
|
||||
identifiers.add("notspammer");
|
||||
@@ -24,13 +22,13 @@ public class NotSpammerCommand extends ClientCommand{
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Main.getBiscuit();
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -notspammer " + args[0]);
|
||||
for(Member m : event.getMessage().getMentionedMembers()){
|
||||
User u = m.getUser();
|
||||
String s = u.getAsMention();
|
||||
if(event.getChannel().getName().equals("public-spam-test") || (PermUtil.isMod(event.getMember()))) {
|
||||
SpamRecords.spammers.remove(u);
|
||||
b.getMessageStore().removeSpammer(u);
|
||||
event.getTextChannel().sendMessage(s+ " is no longer flagged as spam.").queue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package com.fpghoti.biscuit.commands.client;
|
||||
|
||||
import com.fpghoti.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
@@ -12,7 +11,7 @@ public class PingCommand extends ClientCommand{
|
||||
public PingCommand() {
|
||||
name = "Ping";
|
||||
description = "Pings the bot.";
|
||||
usage = PropertiesRetrieval.getCommandSignifier() + "ping";
|
||||
usage = Main.getMainBiscuit().getProperties().getCommandSignifier() + "ping";
|
||||
minArgs = 0;
|
||||
maxArgs = 0;
|
||||
identifiers.add("ping");
|
||||
@@ -20,7 +19,7 @@ public class PingCommand extends ClientCommand{
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Main.getBiscuit();
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -ping");
|
||||
event.getTextChannel().sendMessage("Pong!").queue();
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package com.fpghoti.biscuit.commands.client;
|
||||
|
||||
import com.fpghoti.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||
import com.fpghoti.biscuit.util.Util;
|
||||
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
@@ -13,7 +12,7 @@ public class PowerCommand extends ClientCommand{
|
||||
public PowerCommand() {
|
||||
name = "Power";
|
||||
description = "Finds Num1 ^ Num2";
|
||||
usage = PropertiesRetrieval.getCommandSignifier() + "power <Num1> <Num2>";
|
||||
usage = Main.getMainBiscuit().getProperties().getCommandSignifier() + "power <Num1> <Num2>";
|
||||
minArgs = 2;
|
||||
maxArgs = 2;
|
||||
identifiers.add("power");
|
||||
@@ -22,7 +21,7 @@ public class PowerCommand extends ClientCommand{
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Main.getBiscuit();
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -power");
|
||||
if(args[0] != null && Util.isDeciDigit(args[0]) && args[1] != null && Util.isDeciDigit(args[1])) {
|
||||
double num = Double.parseDouble(args[0]);
|
||||
|
||||
@@ -1,35 +1,29 @@
|
||||
package com.fpghoti.biscuit.commands.client;
|
||||
|
||||
import com.fpghoti.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||
import com.fpghoti.biscuit.global.SpamRecords;
|
||||
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
public class RecentSpammersCommand extends ClientCommand{
|
||||
|
||||
public RecentSpammersCommand() {
|
||||
name = "Recent Spammers";
|
||||
description = "Retrieves a list of recent spammers.";
|
||||
usage = PropertiesRetrieval.getCommandSignifier() + "recentspammers";
|
||||
minArgs = 0;
|
||||
maxArgs = 0;
|
||||
identifiers.add("recentspammers");
|
||||
}
|
||||
|
||||
public RecentSpammersCommand() {
|
||||
name = "Recent Spammers";
|
||||
description = "Retrieves a list of recent spammers.";
|
||||
usage = Main.getMainBiscuit().getProperties().getCommandSignifier() + "recentspammers";
|
||||
minArgs = 0;
|
||||
maxArgs = 0;
|
||||
identifiers.add("recentspammers");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Main.getBiscuit();
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -recentspammers");
|
||||
String msg = "Recent spammers:";
|
||||
for( User u: SpamRecords.spammers){
|
||||
msg = msg + " " + u.getAsMention();
|
||||
}
|
||||
String msg = b.getMessageStore().getSpammerList();
|
||||
event.getTextChannel().sendMessage(msg).queue();
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.fpghoti.biscuit.commands.client;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||
import com.fpghoti.biscuit.logging.BColor;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.Message.Attachment;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
public class SaveConfigCommand extends ClientCommand{
|
||||
|
||||
public SaveConfigCommand() {
|
||||
name = "Save Config";
|
||||
description = "Saves the config of the current guild.";
|
||||
usage = Main.getMainBiscuit().getProperties().getCommandSignifier() + "getconfig (with file upload)";
|
||||
minArgs = 0;
|
||||
maxArgs = 0;
|
||||
identifiers.add("saveconfig");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -saveconfig");
|
||||
List<Attachment> attch = event.getMessage().getAttachments();
|
||||
if(PermUtil.isAdmin(event.getMember())) {
|
||||
if(!attch.isEmpty()) {
|
||||
if(attch.size() == 1) {
|
||||
for(Attachment a : attch) {
|
||||
b.getConfig().replaceConfig(a, event.getTextChannel());
|
||||
b.remove();
|
||||
b = Biscuit.loadGuild(event.getGuild());
|
||||
}
|
||||
}else {
|
||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + " Too many attachments added! "
|
||||
+ "Please only include the config file you want to save.").queue(new Consumer<Message>()
|
||||
{
|
||||
@Override
|
||||
public void accept(Message msg){
|
||||
msg.delete().submitAfter(5, TimeUnit.SECONDS);
|
||||
}
|
||||
});
|
||||
}
|
||||
}else {
|
||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + " You need to send "
|
||||
+ "a file in order to save the config.").queue(new Consumer<Message>()
|
||||
{
|
||||
@Override
|
||||
public void accept(Message msg){
|
||||
msg.delete().submitAfter(5, TimeUnit.SECONDS);
|
||||
}
|
||||
});
|
||||
}
|
||||
}else {
|
||||
b.log(BColor.MAGENTA_BOLD + event.getAuthor().getName() + " lacks permission to save the config!");
|
||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + " You do not have "
|
||||
+ "permission to save the config.").queue(new Consumer<Message>()
|
||||
{
|
||||
@Override
|
||||
public void accept(Message msg){
|
||||
msg.delete().submitAfter(5, TimeUnit.SECONDS);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,13 +1,15 @@
|
||||
package com.fpghoti.biscuit.commands.client;
|
||||
|
||||
import com.fpghoti.biscuit.Biscuit;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||
import com.fpghoti.biscuit.global.SpamRecords;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
@@ -16,7 +18,7 @@ public class SoftMuteCommand extends ClientCommand{
|
||||
public SoftMuteCommand() {
|
||||
name = "Soft Mute";
|
||||
description = "Soft mutes a user. In this state, they will only be able to send a message every two minutes.";
|
||||
usage = PropertiesRetrieval.getCommandSignifier() + "softmute @<mention-user>";
|
||||
usage = Main.getMainBiscuit().getProperties().getCommandSignifier() + "softmute @<mention-user>";
|
||||
minArgs = 1;
|
||||
maxArgs = 1;
|
||||
identifiers.add("softmute");
|
||||
@@ -24,13 +26,23 @@ public class SoftMuteCommand extends ClientCommand{
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Main.getBiscuit();
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -softmute " + args[0]);
|
||||
for(Member m : event.getMessage().getMentionedMembers()){
|
||||
User u = m.getUser();
|
||||
String s = u.getAsMention();
|
||||
if(b.getMessageStore().isSoftmuted(u)) {
|
||||
event.getTextChannel().sendMessage(s+ " is already softmuted.").queue(new Consumer<Message>()
|
||||
{
|
||||
@Override
|
||||
public void accept(Message msg){
|
||||
msg.delete().reason("Automatic bot message removal").submitAfter(3, TimeUnit.SECONDS);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
if(event.getChannel().getName().equals("public-softmute-test") || (PermUtil.isMod(event.getMember()))) {
|
||||
SpamRecords.softmute.add(u);
|
||||
b.getMessageStore().addSoftmuted(u);
|
||||
u.openPrivateChannel().queue();
|
||||
event.getTextChannel().sendMessage(s+ " is now soft-muted. They will now be only able to send one message every two minutes.").queue();
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package com.fpghoti.biscuit.commands.client;
|
||||
|
||||
import com.fpghoti.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||
import com.fpghoti.biscuit.util.Util;
|
||||
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
@@ -13,7 +12,7 @@ public class SquareRootCommand extends ClientCommand{
|
||||
public SquareRootCommand() {
|
||||
name = "Square Root";
|
||||
description = "Finds square root.";
|
||||
usage = PropertiesRetrieval.getCommandSignifier() + "squareroot <Num>";
|
||||
usage = Main.getMainBiscuit().getProperties().getCommandSignifier() + "squareroot <Num>";
|
||||
minArgs = 1;
|
||||
maxArgs = 1;
|
||||
identifiers.add("squareroot");
|
||||
@@ -22,7 +21,7 @@ public class SquareRootCommand extends ClientCommand{
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Main.getBiscuit();
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -squareroot");
|
||||
if(args[0] != null && Util.isDeciDigit(args[0])) {
|
||||
double num = Double.parseDouble(args[0]);
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package com.fpghoti.biscuit.commands.client;
|
||||
|
||||
import com.fpghoti.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||
import com.fpghoti.biscuit.util.Util;
|
||||
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
@@ -13,7 +12,7 @@ public class SubtractCommand extends ClientCommand{
|
||||
public SubtractCommand() {
|
||||
name = "Subtract";
|
||||
description = "Subtracts two numbers.";
|
||||
usage = PropertiesRetrieval.getCommandSignifier() + "subtract <Num1> <Num2>";
|
||||
usage = Main.getMainBiscuit().getProperties().getCommandSignifier() + "subtract <Num1> <Num2>";
|
||||
minArgs = 2;
|
||||
maxArgs = 2;
|
||||
identifiers.add("subtract");
|
||||
@@ -22,7 +21,7 @@ public class SubtractCommand extends ClientCommand{
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Main.getBiscuit();
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -subtract");
|
||||
if(args[0] != null && Util.isDeciDigit(args[0]) && args[1] != null && Util.isDeciDigit(args[1])) {
|
||||
double num = Double.parseDouble(args[0]);
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package com.fpghoti.biscuit.commands.client;
|
||||
|
||||
import com.fpghoti.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
|
||||
import net.dv8tion.jda.api.entities.Emote;
|
||||
@@ -15,7 +14,7 @@ public class ToggleRoleCommand extends ClientCommand{
|
||||
public ToggleRoleCommand() {
|
||||
name = "ToggleRole";
|
||||
description = "Toggles specified role on/off";
|
||||
usage = PropertiesRetrieval.getCommandSignifier() + "togglerole <role>";
|
||||
usage = Main.getMainBiscuit().getProperties().getCommandSignifier() + "togglerole <role>";
|
||||
minArgs = 1;
|
||||
maxArgs = 1;
|
||||
identifiers.add("togglerole");
|
||||
@@ -24,13 +23,14 @@ public class ToggleRoleCommand extends ClientCommand{
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Main.getBiscuit();
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
if(!event.getAuthor().isBot()) {
|
||||
b.log(event.getAuthor().getName() + " issued a command: -togglerole " + args[0]);
|
||||
boolean foundEmote = false;
|
||||
|
||||
String rolename = "";
|
||||
|
||||
for(String s : PropertiesRetrieval.getToggleRoles()) {
|
||||
for(String s : b.getProperties().getToggleRoles()) {
|
||||
if(s.equalsIgnoreCase(args[0])) {
|
||||
rolename = s;
|
||||
}
|
||||
@@ -54,13 +54,14 @@ public class ToggleRoleCommand extends ClientCommand{
|
||||
|
||||
Emote done = null;
|
||||
for(Emote e : event.getGuild().getEmotes()) {
|
||||
if(e.getName().contains(PropertiesRetrieval.getDoneEmote())) {
|
||||
if(e.getName().contains(b.getProperties().getDoneEmote())) {
|
||||
done = e;
|
||||
}
|
||||
}
|
||||
if(done == null) {
|
||||
if(done != null) {
|
||||
foundEmote = true;
|
||||
}else {
|
||||
b.error("Cannot find emote!");
|
||||
return;
|
||||
}
|
||||
if(PermUtil.hasRole(event.getMember(), role)){
|
||||
event.getGuild().removeRoleFromMember(event.getMember(),role).queue();
|
||||
@@ -75,9 +76,13 @@ public class ToggleRoleCommand extends ClientCommand{
|
||||
}
|
||||
if(canAdd) {
|
||||
event.getGuild().addRoleToMember(event.getMember(), role).queue();
|
||||
if(foundEmote) {
|
||||
event.getMessage().addReaction(done).queue();
|
||||
}else {
|
||||
event.getMessage().addReaction("✔").queue();
|
||||
}
|
||||
}
|
||||
}
|
||||
event.getMessage().addReaction(done).queue();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package com.fpghoti.biscuit.commands.client;
|
||||
|
||||
import com.fpghoti.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
@@ -15,7 +14,7 @@ public class UIDCommand extends ClientCommand{
|
||||
public UIDCommand() {
|
||||
name = "User ID";
|
||||
description = "Retrieves a user's ID.";
|
||||
usage = PropertiesRetrieval.getCommandSignifier() + "uid @<mention-user>";
|
||||
usage = Main.getMainBiscuit().getProperties().getCommandSignifier() + "uid @<mention-user>";
|
||||
minArgs = 1;
|
||||
maxArgs = 1;
|
||||
identifiers.add("uid");
|
||||
@@ -23,7 +22,7 @@ public class UIDCommand extends ClientCommand{
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Main.getBiscuit();
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -uid " + args[0]);
|
||||
for(Member m : event.getMessage().getMentionedMembers()){
|
||||
User u = m.getUser();
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
package com.fpghoti.biscuit.commands.client;
|
||||
|
||||
import com.fpghoti.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||
import com.fpghoti.biscuit.global.SpamRecords;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
@@ -16,7 +14,7 @@ public class UnSoftMuteCommand extends ClientCommand{
|
||||
public UnSoftMuteCommand() {
|
||||
name = "Un Soft Mute";
|
||||
description = "Removes a soft mute from a user.";
|
||||
usage = PropertiesRetrieval.getCommandSignifier() + "unsoftmute @<mention-user>";
|
||||
usage = Main.getMainBiscuit().getProperties().getCommandSignifier() + "unsoftmute @<mention-user>";
|
||||
minArgs = 1;
|
||||
maxArgs = 1;
|
||||
identifiers.add("unsoftmute");
|
||||
@@ -24,13 +22,13 @@ public class UnSoftMuteCommand extends ClientCommand{
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Main.getBiscuit();
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -unsoftmute " + args[0]);
|
||||
for(Member m : event.getMessage().getMentionedMembers()){
|
||||
User u = m.getUser();
|
||||
String s = u.getAsMention();
|
||||
if(event.getChannel().getName().equals("public-softmute-test") || (PermUtil.isMod(event.getMember()))) {
|
||||
SpamRecords.softmute.remove(u);
|
||||
b.getMessageStore().removeSoftmuted(u);
|
||||
event.getTextChannel().sendMessage(s+ " is no longer soft-muted.").queue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.fpghoti.biscuit.commands.client;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
public class WikiCommand extends ClientCommand{
|
||||
|
||||
public WikiCommand() {
|
||||
name = "Wiki";
|
||||
description = "Sends a link to the Biscuit wiki. Look there for config help.";
|
||||
usage = Main.getMainBiscuit().getProperties().getCommandSignifier() + "wiki";
|
||||
minArgs = 0;
|
||||
maxArgs = 0;
|
||||
identifiers.add("wiki");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -wiki");
|
||||
if(PermUtil.isMod(event.getMember())) {
|
||||
event.getTextChannel().sendMessage("https://git.fpghoti.com/thmsdy/Biscuit/wiki").queue();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.fpghoti.biscuit.commands.console;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.ConsoleCommand;
|
||||
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
|
||||
public class GuildSayCommand extends ConsoleCommand{
|
||||
|
||||
public GuildSayCommand() {
|
||||
name = "Guild Say (Console)";
|
||||
description = "Makes bot send message to a channel in the specified guild.";
|
||||
usage = "[CONSOLE] guildsay <guild-code> <channel-name> <message>";
|
||||
minArgs = 3;
|
||||
maxArgs = 2000;
|
||||
identifiers.add("guildsay");
|
||||
identifiers.add("gsay");
|
||||
}
|
||||
|
||||
public void execute(String[] args) {
|
||||
if(args.length > 0) {
|
||||
String guildcode = args[0];
|
||||
Biscuit b = Biscuit.getBiscuit(guildcode);
|
||||
if(b == null) {
|
||||
Main.getMainBiscuit().log("INVALID GUILD! TRY: guildsay <guild-code> <channel-name> <message>");
|
||||
return;
|
||||
}
|
||||
Guild guild = b.getGuild();
|
||||
if(args.length > 1) {
|
||||
String channel = args[1];
|
||||
String message = "";
|
||||
if(args.length > 2) {
|
||||
message = args[2];
|
||||
if(args.length > 3) {
|
||||
for(int i = 3; i < args.length; i++) {
|
||||
message = message + " " + args[i];
|
||||
}
|
||||
}
|
||||
|
||||
for(TextChannel c : guild.getTextChannels()) {
|
||||
if(c.getName().equalsIgnoreCase(channel) || c.getName().equalsIgnoreCase("#" + channel)) {
|
||||
c.sendMessage(message).queue();
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
b.log("INCORRECT USAGE! TRY: guildsay " + guildcode + " " + channel + " <message>");
|
||||
}
|
||||
|
||||
}else{
|
||||
b.log("INCORRECT USAGE! TRY: guildsay " + guildcode + " <channel-name> <message>");
|
||||
}
|
||||
}else{
|
||||
Main.getMainBiscuit().log("INCORRECT USAGE! TRY: guildsay <guild-code> <channel-name> <message>");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.fpghoti.biscuit.commands.console;
|
||||
|
||||
import com.fpghoti.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.ConsoleCommand;
|
||||
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
@@ -11,7 +11,7 @@ public class SayCommand extends ConsoleCommand{
|
||||
|
||||
public SayCommand() {
|
||||
name = "Say (Console)";
|
||||
description = "Makes bot send message on specified channel.";
|
||||
description = "Makes bot send message to a channel in all guilds.";
|
||||
usage = "[CONSOLE] say <channel-name> <message>";
|
||||
minArgs = 2;
|
||||
maxArgs = 2000;
|
||||
@@ -22,7 +22,7 @@ public class SayCommand extends ConsoleCommand{
|
||||
}
|
||||
|
||||
public void execute(String[] args) {
|
||||
Biscuit b = Main.getBiscuit();
|
||||
Biscuit b = Main.getMainBiscuit();
|
||||
if(args.length > 0) {
|
||||
String target = args[0];
|
||||
String message = "";
|
||||
@@ -33,7 +33,7 @@ public class SayCommand extends ConsoleCommand{
|
||||
message = message + " " + args[i];
|
||||
}
|
||||
}
|
||||
for(Guild guild : b.getJDA().getGuilds()) {
|
||||
for(Guild guild : Main.getJDA().getGuilds()) {
|
||||
|
||||
for(TextChannel c : guild.getTextChannels()) {
|
||||
if(c.getName().equalsIgnoreCase(target) || c.getName().equalsIgnoreCase("#" + target)) {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.fpghoti.biscuit.commands.console;
|
||||
|
||||
import com.fpghoti.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.commands.ConsoleCommand;
|
||||
|
||||
@@ -16,11 +15,10 @@ public class ShutdownConsoleCommand extends ConsoleCommand{
|
||||
}
|
||||
|
||||
public void execute(String[] args) {
|
||||
Biscuit b = Main.getBiscuit();
|
||||
if(args.length == 0) {
|
||||
Main.shutdown();
|
||||
}else{
|
||||
b.log("INCORRECT USAGE! TRY: say <channel-name> <message>");
|
||||
Main.getLogger().info("INCORRECT USAGE! TRY: say <channel-name> <message>");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user