use of com.greatmancode.legendarybot.plugin.customcommands.commands.RemoveCommand in project legendarybot by greatman.
the class CustomCommandsPlugin method start.
@Override
public void start() {
log.info("Loading custom commands");
getBot().getJDA().forEach(jda -> jda.getGuilds().forEach(g -> {
MongoCollection<Document> collection = getBot().getMongoDatabase().getCollection(MONGO_COLLECTION_NAME);
Map<String, String> result = new HashMap<>();
collection.find(eq("guild_id", g.getId())).forEach((Block<Document>) document -> {
if (document.containsKey(MONGO_DOCUMENT_NAME)) {
((Document) document.get(MONGO_DOCUMENT_NAME)).forEach((k, v) -> {
System.out.println("GUILD:" + g.getId() + " key: " + k + " value: " + v);
result.put(k, (String) v);
});
}
});
guildCustomCommands.put(g.getId(), result);
}));
getBot().getJDA().forEach(jda -> jda.addEventListener(listener));
log.info("Custom commands loaded");
getBot().getCommandHandler().setUnknownCommandHandler(new IUnknownCommandHandler(this));
getBot().getCommandHandler().addCommand("createcmd", new CreateCommand(this), "Custom Commands Admin Commands");
getBot().getCommandHandler().addCommand("removecmd", new RemoveCommand(this), "Custom Commands Admin Commands");
getBot().getCommandHandler().addCommand("listcommands", new ListCommand(this), "General Commands");
log.info("Plugin Custom Commands loaded!");
log.info("Command !createcmd loaded!");
}
Aggregations