Initial Commit
This commit is contained in:
86
src/main/java/com/fpghoti/biscuit/commands/BaseCommand.java
Normal file
86
src/main/java/com/fpghoti/biscuit/commands/BaseCommand.java
Normal file
@@ -0,0 +1,86 @@
|
||||
package com.fpghoti.biscuit.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class BaseCommand{
|
||||
|
||||
protected String name;
|
||||
protected String description;
|
||||
protected String usage;
|
||||
protected int minArgs;
|
||||
protected int maxArgs;
|
||||
protected List<String> identifiers;
|
||||
protected List<String> notes;
|
||||
|
||||
public BaseCommand() {
|
||||
this.identifiers = new ArrayList<String>();
|
||||
this.notes = new ArrayList<String>();
|
||||
}
|
||||
|
||||
public abstract CommandType getType();
|
||||
|
||||
public String[] validate(String input, StringBuilder identifier) {
|
||||
String match = matchIdentifier(input);
|
||||
|
||||
if (match != null) {
|
||||
identifier = identifier.append(match);
|
||||
int i = identifier.length();
|
||||
String[] args = input.substring(i).trim().split(" ");
|
||||
if (args[0].isEmpty()) {
|
||||
args = new String[0];
|
||||
}
|
||||
int l = args.length;
|
||||
if (l >= minArgs && l <= maxArgs) {
|
||||
return args;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String matchIdentifier(String input) {
|
||||
String lower = input.toLowerCase();
|
||||
|
||||
int index = -1;
|
||||
int n = identifiers.size();
|
||||
for (int i = 0; i < n; i++) {
|
||||
String identifier = identifiers.get(i).toLowerCase();
|
||||
if (lower.matches(identifier + "(\\s+.*|\\s*)")) {
|
||||
if (index == -1 || identifier.length() > identifiers.get(index).length()) {
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (index != -1) {
|
||||
return identifiers.get(index);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getIdentifiers() {
|
||||
return identifiers;
|
||||
}
|
||||
|
||||
public void setIdentifiers(List<String> identifiers) {
|
||||
this.identifiers = identifiers;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public String getUsage() {
|
||||
return usage;
|
||||
}
|
||||
|
||||
public List<String> getNotes() {
|
||||
return notes;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.fpghoti.biscuit.commands;
|
||||
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
public abstract class ClientCommand extends BaseCommand{
|
||||
|
||||
public boolean called(String[] args, MessageReceivedEvent event) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public abstract void execute(String[] args, MessageReceivedEvent event);
|
||||
|
||||
public CommandType getType() {
|
||||
return CommandType.CLIENT;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.fpghoti.biscuit.commands;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.api.API;
|
||||
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||
|
||||
import net.dv8tion.jda.api.JDA;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||
|
||||
public class CommandListener extends ListenerAdapter implements Runnable {
|
||||
|
||||
public Scanner sc;
|
||||
public JDA jda;
|
||||
Logger log = Main.log;
|
||||
|
||||
@Override
|
||||
public void onMessageReceived(MessageReceivedEvent event){
|
||||
if(!event.getAuthor().isBot() && event.getMessage().getContentDisplay().startsWith(PropertiesRetrieval.getCommandSignifier()) && event.getMessage().getAuthor().getId() != event.getJDA().getSelfUser().getId()){
|
||||
log.info("True");
|
||||
API.getBiscuit().getCommandManager().parse(event.getMessage().getContentRaw().toLowerCase(), event);
|
||||
}
|
||||
}
|
||||
|
||||
public void run() {
|
||||
|
||||
while(sc.hasNextLine()) {
|
||||
String command = sc.nextLine();
|
||||
String label = command.split(" ")[0];
|
||||
String[] args = new String[command.split(" ").length - 1];
|
||||
for(int i = 1; i < command.split(" ").length; i++) {
|
||||
args[i - 1] = command.split(" ")[i];
|
||||
}
|
||||
runCommand(label, args);
|
||||
}
|
||||
}
|
||||
|
||||
private void runCommand(String label, String[] args) {
|
||||
log.info(label);
|
||||
API.getBiscuit().getCommandManager().dispatch(label, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.fpghoti.biscuit.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.fpghoti.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.api.API;
|
||||
import com.fpghoti.biscuit.config.PropertiesRetrieval;
|
||||
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
public class CommandManager {
|
||||
|
||||
private List<BaseCommand> commands = new ArrayList<BaseCommand>();
|
||||
|
||||
public void parse(String message, MessageReceivedEvent e){
|
||||
ArrayList<String> split = new ArrayList<String>();
|
||||
String fixed = message.replaceFirst(PropertiesRetrieval.getCommandSignifier(), "");
|
||||
String[] splitMsg = fixed.split(" ");
|
||||
for(String s: splitMsg){
|
||||
split.add(s);
|
||||
}
|
||||
String label = split.get(0);
|
||||
String[] args = new String[split.size() - 1];
|
||||
split.subList(1, split.size()).toArray(args);
|
||||
|
||||
dispatch(e, label, args);
|
||||
}
|
||||
|
||||
|
||||
public boolean dispatch(String label, String[] args) {
|
||||
return dispatch(null,label,args);
|
||||
}
|
||||
|
||||
public boolean dispatch(MessageReceivedEvent e, String label, String[] args) {
|
||||
String input = label + " ";
|
||||
for (String s : args) {
|
||||
input += s + " ";
|
||||
}
|
||||
|
||||
BaseCommand match = null;
|
||||
String[] trimmedArgs = null;
|
||||
StringBuilder identifier = new StringBuilder();
|
||||
|
||||
for(BaseCommand cmd : commands) {
|
||||
StringBuilder tmpIdentifier = new StringBuilder();
|
||||
String[] tmpArgs = cmd.validate(input, tmpIdentifier);
|
||||
if (tmpIdentifier.length() > identifier.length()) {
|
||||
identifier = tmpIdentifier;
|
||||
match = cmd;
|
||||
trimmedArgs = tmpArgs;
|
||||
}
|
||||
}
|
||||
|
||||
if(match != null) {
|
||||
if (trimmedArgs == null || (trimmedArgs.length > 0 && trimmedArgs[0].equals("?"))) {
|
||||
commandReply(e, "``Command:" + " " + match.getName() + "``");
|
||||
commandReply(e, "``Description:" + " " + match.getDescription() + "``");
|
||||
commandReply(e, "``Usage:" + " " + match.getUsage() + "``");
|
||||
List<String> notes = match.getNotes();
|
||||
for (String note : notes) {
|
||||
commandReply(e, note);
|
||||
}
|
||||
} else {
|
||||
if(match instanceof ClientCommand && e != null) {
|
||||
((ClientCommand)match).execute(trimmedArgs, e);
|
||||
}else if(match instanceof ConsoleCommand && e == null) {
|
||||
((ConsoleCommand)match).execute(trimmedArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void commandReply(MessageReceivedEvent e, String msg) {
|
||||
Biscuit b = API.getBiscuit();
|
||||
if(e != null) {
|
||||
b.say(e.getTextChannel(), msg);
|
||||
}else {
|
||||
b.log(msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void addCommand(BaseCommand command) {
|
||||
commands.add(command);
|
||||
}
|
||||
|
||||
public void removeCommand(BaseCommand command) {
|
||||
commands.remove(command);
|
||||
}
|
||||
|
||||
public List<BaseCommand> getCommands() {
|
||||
return commands;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.fpghoti.biscuit.commands;
|
||||
|
||||
public enum CommandType {
|
||||
CLIENT,
|
||||
CONSOLE
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.fpghoti.biscuit.commands;
|
||||
|
||||
public abstract class ConsoleCommand extends BaseCommand{
|
||||
|
||||
public abstract void execute(String[] args);
|
||||
|
||||
public CommandType getType() {
|
||||
return CommandType.CONSOLE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.fpghoti.biscuit.commands.client;
|
||||
|
||||
import com.fpghoti.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.api.API;
|
||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
public class ChanIDCommand extends ClientCommand{
|
||||
|
||||
public ChanIDCommand() {
|
||||
name = "Channel ID";
|
||||
description = "Retrieves the channel ID.";
|
||||
usage = "-chanid";
|
||||
minArgs = 0;
|
||||
maxArgs = 0;
|
||||
identifiers.add("chanid");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = API.getBiscuit();
|
||||
b.log(event.getAuthor().getName() + " issued a command: -chanid");
|
||||
String id = event.getTextChannel().getId();
|
||||
event.getTextChannel().sendMessage(id).queue();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.fpghoti.biscuit.commands.client;
|
||||
|
||||
import com.fpghoti.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.api.API;
|
||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
public class ChnameCommand extends ClientCommand{
|
||||
|
||||
public ChnameCommand() {
|
||||
name = "Channel Name";
|
||||
description = "Retrieves the channel name.";
|
||||
usage = "-chname";
|
||||
minArgs = 0;
|
||||
maxArgs = 0;
|
||||
identifiers.add("chname");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = API.getBiscuit();
|
||||
b.log(event.getAuthor().getName() + " issued a command: -chname");
|
||||
if(PermUtil.isMod(event.getMember()) || PermUtil.canMute(event.getMember())) {
|
||||
event.getTextChannel().sendMessage("DEBUG: " + event.getTextChannel().getName()).queue();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.fpghoti.biscuit.commands.client;
|
||||
|
||||
import com.fpghoti.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.api.API;
|
||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||
|
||||
import net.dv8tion.jda.api.entities.Emote;
|
||||
import net.dv8tion.jda.api.entities.Role;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
public class DontNotifyCommand extends ClientCommand{
|
||||
|
||||
public DontNotifyCommand() {
|
||||
name = "Don't Notify";
|
||||
description = "Puts user in Don't Notify status.";
|
||||
usage = "-dontnotify";
|
||||
minArgs = 0;
|
||||
maxArgs = 0;
|
||||
identifiers.add("dontnotify");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = API.getBiscuit();
|
||||
if(!event.getAuthor().isBot()) {
|
||||
b.log(event.getAuthor().getName() + " issued a command: -dontnotify");
|
||||
Role role = null;
|
||||
for(Role r : event.getGuild().getRoles()) {
|
||||
if(r.getName().toLowerCase().contains("don't notify")) {
|
||||
role = r;
|
||||
}
|
||||
}
|
||||
if(role == null) {
|
||||
b.error("Cannot find role!");
|
||||
return;
|
||||
}
|
||||
|
||||
Emote done = null;
|
||||
for(Emote e : event.getGuild().getEmotes()) {
|
||||
if(e.getName().contains("ActionComplete")) {
|
||||
done = e;
|
||||
}
|
||||
}
|
||||
if(done == null) {
|
||||
b.error("Cannot find emote!");
|
||||
return;
|
||||
}
|
||||
|
||||
event.getGuild().addRoleToMember(event.getMember(), role).queue();
|
||||
event.getMessage().addReaction(done).queue();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.fpghoti.biscuit.commands.client;
|
||||
|
||||
import com.fpghoti.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.api.API;
|
||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||
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.User;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
public class NotSpammerCommand extends ClientCommand{
|
||||
|
||||
public NotSpammerCommand() {
|
||||
name = "Not Spammer";
|
||||
description = "Delists user as spammer.";
|
||||
usage = "-notspammer @<mention-user>";
|
||||
minArgs = 1;
|
||||
maxArgs = 1;
|
||||
identifiers.add("notspammer");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = API.getBiscuit();
|
||||
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()) || PermUtil.canMute(event.getMember()))) {
|
||||
SpamRecords.spammers.remove(u);
|
||||
event.getTextChannel().sendMessage(s+ " is no longer flagged as spam.").queue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.fpghoti.biscuit.commands.client;
|
||||
|
||||
import com.fpghoti.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.api.API;
|
||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||
|
||||
import net.dv8tion.jda.api.entities.Emote;
|
||||
import net.dv8tion.jda.api.entities.Role;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
public class NotifyCommand extends ClientCommand{
|
||||
|
||||
public NotifyCommand() {
|
||||
name = "Notify";
|
||||
description = "Puts user in Notify status.";
|
||||
usage = "-notify";
|
||||
minArgs = 0;
|
||||
maxArgs = 0;
|
||||
identifiers.add("notify");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = API.getBiscuit();
|
||||
if(!event.getAuthor().isBot()) {
|
||||
b.log(event.getAuthor().getName() + " issued a command: -notify");
|
||||
Role role = null;
|
||||
for(Role r : event.getGuild().getRoles()) {
|
||||
if(r.getName().toLowerCase().contains("don't notify")) {
|
||||
role = r;
|
||||
}
|
||||
}
|
||||
if(role == null) {
|
||||
b.error("Cannot find role!");
|
||||
return;
|
||||
}
|
||||
|
||||
Emote done = null;
|
||||
for(Emote e : event.getGuild().getEmotes()) {
|
||||
if(e.getName().contains("ActionComplete")) {
|
||||
done = e;
|
||||
}
|
||||
}
|
||||
if(done == null) {
|
||||
b.error("Cannot find emote!");
|
||||
return;
|
||||
}
|
||||
|
||||
event.getGuild().removeRoleFromMember(event.getMember(),role).queue();
|
||||
event.getMessage().addReaction(done).queue();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.fpghoti.biscuit.commands.client;
|
||||
|
||||
import com.fpghoti.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.api.API;
|
||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
public class PingCommand extends ClientCommand{
|
||||
|
||||
public PingCommand() {
|
||||
name = "Ping";
|
||||
description = "Pings the bot.";
|
||||
usage = "-ping";
|
||||
minArgs = 0;
|
||||
maxArgs = 0;
|
||||
identifiers.add("ping");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = API.getBiscuit();
|
||||
b.log(event.getAuthor().getName() + " issued a command: -ping");
|
||||
event.getTextChannel().sendMessage("Pong!").queue();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.fpghoti.biscuit.commands.client;
|
||||
|
||||
import com.fpghoti.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.api.API;
|
||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||
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 = "-recentspammers";
|
||||
minArgs = 0;
|
||||
maxArgs = 0;
|
||||
identifiers.add("recentspammers");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = API.getBiscuit();
|
||||
b.log(event.getAuthor().getName() + " issued a command: -recentspammers");
|
||||
String msg = "Recent spammers:";
|
||||
for( User u: SpamRecords.spammers){
|
||||
msg = msg + " " + u.getAsMention();
|
||||
}
|
||||
event.getTextChannel().sendMessage(msg).queue();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.fpghoti.biscuit.commands.client;
|
||||
|
||||
import com.fpghoti.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.api.API;
|
||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
public class ShutDownCommand extends ClientCommand{
|
||||
|
||||
public ShutDownCommand() {
|
||||
name = "Shut Down";
|
||||
description = "Shuts down the bot.";
|
||||
usage = "-shutdown";
|
||||
minArgs = 0;
|
||||
maxArgs = 0;
|
||||
identifiers.add("shutdown");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = API.getBiscuit();
|
||||
b.log(event.getAuthor().getName() + " issued a command: -shutdown");
|
||||
if(PermUtil.isAdmin(event.getMember())) {
|
||||
|
||||
event.getTextChannel().sendMessage("Shutting down Mr. Bouncer...").queue();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.fpghoti.biscuit.commands.client;
|
||||
|
||||
import com.fpghoti.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.api.API;
|
||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||
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.User;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
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 = "-softmute @<mention-user>";
|
||||
minArgs = 1;
|
||||
maxArgs = 1;
|
||||
identifiers.add("softmute");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = API.getBiscuit();
|
||||
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(event.getChannel().getName().equals("public-softmute-test") || (PermUtil.isMod(event.getMember()) || PermUtil.canMute(event.getMember()))) {
|
||||
SpamRecords.softmute.add(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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.fpghoti.biscuit.commands.client;
|
||||
|
||||
import com.fpghoti.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.api.API;
|
||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
public class UIDCommand extends ClientCommand{
|
||||
|
||||
public UIDCommand() {
|
||||
name = "User ID";
|
||||
description = "Retrieves a user's ID.";
|
||||
usage = "-uid @<mention-user>";
|
||||
minArgs = 1;
|
||||
maxArgs = 1;
|
||||
identifiers.add("uid");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = API.getBiscuit();
|
||||
b.log(event.getAuthor().getName() + " issued a command: -uid " + args[0]);
|
||||
for(Member m : event.getMessage().getMentionedMembers()){
|
||||
User u = m.getUser();
|
||||
String s = u.getAsMention();
|
||||
if(PermUtil.isMod(event.getMember()) || PermUtil.canMute(event.getMember()))
|
||||
event.getTextChannel().sendMessage("DEBUG: " + s+ " retrieved.").queue();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.fpghoti.biscuit.commands.client;
|
||||
|
||||
import com.fpghoti.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.api.API;
|
||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
||||
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.User;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
public class UnSoftMuteCommand extends ClientCommand{
|
||||
|
||||
public UnSoftMuteCommand() {
|
||||
name = "Un Soft Mute";
|
||||
description = "Removes a soft mute from a user.";
|
||||
usage = "-unsoftmute @<mention-user>";
|
||||
minArgs = 1;
|
||||
maxArgs = 1;
|
||||
identifiers.add("unsoftmute");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = API.getBiscuit();
|
||||
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()) || PermUtil.canMute(event.getMember()))) {
|
||||
SpamRecords.softmute.remove(u);
|
||||
event.getTextChannel().sendMessage(s+ " is no longer soft-muted.").queue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.fpghoti.biscuit.commands.console;
|
||||
|
||||
import com.fpghoti.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.api.API;
|
||||
import com.fpghoti.biscuit.commands.ConsoleCommand;
|
||||
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
|
||||
public class SayCommand extends ConsoleCommand{
|
||||
|
||||
public SayCommand() {
|
||||
name = "Say";
|
||||
description = "Makes bot send message on specified channel.";
|
||||
usage = "say <channel-name> <message>";
|
||||
minArgs = 2;
|
||||
maxArgs = 2000;
|
||||
identifiers.add("say");
|
||||
}
|
||||
|
||||
public void execute(String[] args) {
|
||||
Biscuit b = API.getBiscuit();
|
||||
if(args.length > 0) {
|
||||
String target = args[0];
|
||||
String message = "";
|
||||
if(args.length > 1) {
|
||||
message = args[1];
|
||||
if(args.length > 2) {
|
||||
for(int i = 2; i < args.length; i++) {
|
||||
message = message + " " + args[i];
|
||||
}
|
||||
}
|
||||
for(Guild guild : b.getJDA().getGuilds()) {
|
||||
|
||||
for(TextChannel c : guild.getTextChannels()) {
|
||||
if(c.getName().equalsIgnoreCase(target) || c.getName().equalsIgnoreCase("#" + target)) {
|
||||
c.sendMessage(message).queue();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}else{
|
||||
b.log("INCORRECT USAGE! TRY: say " + target + " <message>");
|
||||
}
|
||||
}else{
|
||||
b.log("INCORRECT USAGE! TRY: say <channel-name> <message>");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user