Implemented user blacklist functionality
This commit is contained in:
parent
a570400b66
commit
d8ca10c2c1
@ -11,10 +11,13 @@ import dev.salmonllama.fsbot.commands.osrssearch.*;
|
|||||||
import dev.salmonllama.fsbot.commands.rs3search.*;
|
import dev.salmonllama.fsbot.commands.rs3search.*;
|
||||||
import dev.salmonllama.fsbot.commands.staff.OutfitInfoCommand;
|
import dev.salmonllama.fsbot.commands.staff.OutfitInfoCommand;
|
||||||
import dev.salmonllama.fsbot.commands.staff.*;
|
import dev.salmonllama.fsbot.commands.staff.*;
|
||||||
|
import dev.salmonllama.fsbot.database.controllers.UserBlacklistController;
|
||||||
import org.javacord.api.DiscordApi;
|
import org.javacord.api.DiscordApi;
|
||||||
import org.javacord.api.entity.message.MessageAuthor;
|
import org.javacord.api.entity.message.MessageAuthor;
|
||||||
import org.javacord.api.event.message.MessageCreateEvent;
|
import org.javacord.api.event.message.MessageCreateEvent;
|
||||||
import org.javacord.api.listener.message.MessageCreateListener;
|
import org.javacord.api.listener.message.MessageCreateListener;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -23,6 +26,8 @@ import java.util.HashMap;
|
|||||||
* Guthix is Fashionscape Bot's command repository and dispatcher
|
* Guthix is Fashionscape Bot's command repository and dispatcher
|
||||||
*/
|
*/
|
||||||
public class Guthix implements MessageCreateListener {
|
public class Guthix implements MessageCreateListener {
|
||||||
|
private final static Logger logger = LoggerFactory.getLogger(Guthix.class);
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private final DiscordApi api;
|
private final DiscordApi api;
|
||||||
|
|
||||||
@ -58,6 +63,7 @@ public class Guthix implements MessageCreateListener {
|
|||||||
addCommand(new WelcomeMessageCommand());
|
addCommand(new WelcomeMessageCommand());
|
||||||
addCommand(new ShowGalleriesCommand());
|
addCommand(new ShowGalleriesCommand());
|
||||||
addCommand(new EditMetaCommand());
|
addCommand(new EditMetaCommand());
|
||||||
|
addCommand(new BlacklistUserCommand());
|
||||||
|
|
||||||
// General Commands
|
// General Commands
|
||||||
addCommand(new PingCommand());
|
addCommand(new PingCommand());
|
||||||
@ -96,7 +102,6 @@ public class Guthix implements MessageCreateListener {
|
|||||||
|
|
||||||
public void addCommand(Command cmd) {
|
public void addCommand(Command cmd) {
|
||||||
registry.addCommand(cmd);
|
registry.addCommand(cmd);
|
||||||
// return cmd;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<Command> listCommands() {
|
public Collection<Command> listCommands() {
|
||||||
@ -126,18 +131,19 @@ public class Guthix implements MessageCreateListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check for blacklisted user
|
||||||
|
if (!UserBlacklistController.exists(author.getIdAsString()).join()) {
|
||||||
|
// User is not blacklisted, continue as normal
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
RegistryCommand rComm = registry.getCommandInfo(content);
|
RegistryCommand rComm = registry.getCommandInfo(content);
|
||||||
String cmdString = rComm.getCommand().toLowerCase();
|
String cmdString = rComm.getCommand().toLowerCase();
|
||||||
|
|
||||||
// if (registry.isCommandAlias(cmdString)) {
|
|
||||||
//
|
|
||||||
// } else {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
String[] cmdArgs = rComm.getArgs();
|
String[] cmdArgs = rComm.getArgs();
|
||||||
|
|
||||||
Command cmd = registry.findCommand(cmdString).orElse(new DefaultCommand()); // TODO: default command here
|
Command cmd = registry.findCommand(cmdString).orElse(new DefaultCommand());
|
||||||
|
|
||||||
CommandContext ctx = new CommandContext.CommandContextBuilder(
|
CommandContext ctx = new CommandContext.CommandContextBuilder(
|
||||||
event,
|
event,
|
||||||
|
@ -9,6 +9,7 @@ import com.vdurmont.emoji.EmojiParser;
|
|||||||
import dev.salmonllama.fsbot.config.BotConfig;
|
import dev.salmonllama.fsbot.config.BotConfig;
|
||||||
import dev.salmonllama.fsbot.database.controllers.GalleryController;
|
import dev.salmonllama.fsbot.database.controllers.GalleryController;
|
||||||
import dev.salmonllama.fsbot.database.controllers.OutfitController;
|
import dev.salmonllama.fsbot.database.controllers.OutfitController;
|
||||||
|
import dev.salmonllama.fsbot.database.controllers.UserBlacklistController;
|
||||||
import dev.salmonllama.fsbot.database.models.Outfit;
|
import dev.salmonllama.fsbot.database.models.Outfit;
|
||||||
import dev.salmonllama.fsbot.endpoints.imgur.ImgurAPIConnection;
|
import dev.salmonllama.fsbot.endpoints.imgur.ImgurAPIConnection;
|
||||||
import org.javacord.api.entity.channel.ServerTextChannel;
|
import org.javacord.api.entity.channel.ServerTextChannel;
|
||||||
@ -17,11 +18,15 @@ import org.javacord.api.entity.message.embed.EmbedBuilder;
|
|||||||
import org.javacord.api.event.message.MessageCreateEvent;
|
import org.javacord.api.event.message.MessageCreateEvent;
|
||||||
import org.javacord.api.listener.message.MessageCreateListener;
|
import org.javacord.api.listener.message.MessageCreateListener;
|
||||||
import org.javacord.api.util.logging.ExceptionLogger;
|
import org.javacord.api.util.logging.ExceptionLogger;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class ImageListener implements MessageCreateListener {
|
public class ImageListener implements MessageCreateListener {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(ImageListener.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMessageCreate(MessageCreateEvent event) {
|
public void onMessageCreate(MessageCreateEvent event) {
|
||||||
@ -38,6 +43,10 @@ public class ImageListener implements MessageCreateListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (UserBlacklistController.exists(event.getMessageAuthor().getIdAsString()).join()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Only works in Server Text Channels
|
// Only works in Server Text Channels
|
||||||
event.getChannel().asServerTextChannel().ifPresent(channel -> {
|
event.getChannel().asServerTextChannel().ifPresent(channel -> {
|
||||||
// Only works in registered Gallery Channels
|
// Only works in registered Gallery Channels
|
||||||
|
Loading…
Reference in New Issue
Block a user