commit
68b436ee96
@ -1,15 +1,16 @@
|
||||
FROM gradle:6.6.1-jdk11 AS build
|
||||
|
||||
ENV ENVIRONMENT=PROD
|
||||
|
||||
COPY --chown=gradle:gradle . /home/gradle/src
|
||||
WORKDIR /home/gradle/src
|
||||
RUN gradle clean --no-daemon
|
||||
RUN gradle build --no-daemon
|
||||
|
||||
FROM openjdk:11-jre-slim
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
ENV ENVIRONMENT=PROD
|
||||
|
||||
RUN mkdir /app
|
||||
|
||||
COPY --from=build /home/gradle/src/build/libs/*.jar /app/fashionscape-bot.jar
|
||||
|
7
Makefile
7
Makefile
@ -1,7 +1,12 @@
|
||||
USERNAME=salmonllama
|
||||
IMAGE=fsbot
|
||||
TAG := $(shell git describe --tags)
|
||||
BUILD=${USERNAME}/${IMAGE}:${TAG}
|
||||
LATEST=${USERNAME}/${IMAGE}:latest
|
||||
|
||||
docker:
|
||||
echo ${TAG}
|
||||
docker build -t ${USERNAME}/${IMAGE}:${TAG} .
|
||||
docker build -t ${BUILD} .
|
||||
docker tag ${BUILD} ${LATEST}
|
||||
docker push ${BUILD}
|
||||
docker push ${LATEST}
|
@ -1,3 +1,5 @@
|
||||
#Fashionscape Bot | [](https://discord.gg/Tfvxe22)
|
||||
#Fashionscape Bot |
|
||||
[](https://discord.gg/Tfvxe22)
|
||||

|
||||
|
||||
--> More info coming soon!
|
||||
--> More info coming soon!
|
||||
|
@ -12,7 +12,7 @@ plugins {
|
||||
apply plugin: 'io.spring.dependency-management'
|
||||
|
||||
group 'dev.salmonllama'
|
||||
version '2.0.1'
|
||||
version '2.0.3'
|
||||
|
||||
sourceCompatibility = 11
|
||||
|
||||
@ -26,9 +26,11 @@ repositories {
|
||||
dependencies {
|
||||
implementation 'org.xerial:sqlite-jdbc:3.30.1'
|
||||
implementation 'com.github.Kaaz:ConfigurationBuilder:0.4'
|
||||
implementation 'org.javacord:javacord:3.0.6'
|
||||
implementation 'org.javacord:javacord:3.1.1'
|
||||
implementation 'com.vdurmont:emoji-java:4.0.0'
|
||||
implementation 'com.squareup.okhttp3:okhttp:4.4.0'
|
||||
implementation 'ch.qos.logback:logback-classic:1.2.3'
|
||||
implementation 'com.google.code.gson:gson:2.8.6'
|
||||
|
||||
implementation 'org.springframework.boot:spring-boot-starter-actuator'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||
|
95
privacy.md
95
privacy.md
@ -1,47 +1,72 @@
|
||||
# Privacy Policy
|
||||
**Last updated and effective: July 29, 2020**
|
||||
|
||||
To comply with Discord's new Terms of Service, this document exists
|
||||
to provide an overview of Fashionscape Bot and the information it
|
||||
collects, and why.
|
||||
In compliance with Discord’s new Terms of Service regarding Bot/API usage, the FashionScape Bot has created a privacy policy to provide transparency to users regarding the information our bot collects, why it collects this information, and how data is used. A link to this privacy policy can be found by running the `~privacy` command in any Discord server that uses our bot.
|
||||
|
||||
This document is also accessible to users within Discord through the
|
||||
`~privacy` command.
|
||||
# Stored Data
|
||||
## Server Data
|
||||
The FashionScape Bot tracks the “Guild Snowflakes” (also known as “Server ID”) of Discord Servers.
|
||||
|
||||
## The data we store
|
||||
### Guild Data:
|
||||
Guild Snowflakes (IDs) - Generated by Discord
|
||||
## User Data
|
||||
The FashionScape Bot tracks the “User Snowflakes” (also known as “User ID”) of Discord accounts.
|
||||
|
||||
### User Data:
|
||||
User Snowflakes (IDs) - Generated by Discord
|
||||
## User Content
|
||||
The FashionScape Bot stores permanent links of user-provided images that have been posted to its designated gallery channels.
|
||||
|
||||
### User Content:
|
||||
Permanent links to user-provided images supplied in gallery channels.
|
||||
|
||||
## Why we store it and how we use it
|
||||
### Guild Data:
|
||||
Guild IDs are stored so that the bot may use custom prefixes and settings
|
||||
as a guild's administrators see fit. It is also used to prevent the bot
|
||||
from joining a guild, should the guild prove to be abusing or misusing
|
||||
either the bot, or Discord/Jagex Terms of Service.
|
||||
# Why data is stored, and how we use your data
|
||||
Data and information are not collected beyond the base information necessary for the FashionScape Bot to perform its necessary functions for users. Such information is outlined below as follows:
|
||||
|
||||
### User Data:
|
||||
User IDs are stored mainly for image attribution, to give proper credit
|
||||
to users who submit their screenshots to the gallery.
|
||||
## Guild Data:
|
||||
- Guild IDs are stored so that the bot may use custom prefixes and settings as a guild's administrators see fit. It is also used to prevent the bot from joining a guild, should the guild prove to be abusing or misusing either the bot, or Discord/Jagex Terms of Service.
|
||||
|
||||
User IDs may also be used to prevent a user from utilizing some or all
|
||||
features of the bot, if the user is proven to be abusing or misusing it.
|
||||
## User Data:
|
||||
- User IDs are stored so we can track and give attribution to users who submit screenshots to the FashionScape Bot’s gallery.
|
||||
- User IDs may also be stored to deny a user from utilizing some or all features of the bot, if we suspect the user to be abusing or misusing our services.
|
||||
|
||||
User Content:
|
||||
Images posted to gallery channels are not stored directly. The bot
|
||||
first uploads them to a private imgur gallery, and retrieves the link.
|
||||
This link is then stored in the bot's database as part of the gallery.
|
||||
## User Content:
|
||||
- Images posted to gallery channels are not stored directly by the FashionScape Bot. Rather, the bot first uploads them to a private imgur gallery, and retrieves the link. This link is then stored in the bot's database as part of the gallery.
|
||||
- Text-based content that is sent in the same message as the image being posted. In Discord, this will be the message posted in the “Add A Comment” box in an image upload. [Here](https://media.discordapp.net/attachments/458346171681996815/737738392929829007/meta-describe.png?width=400&height=293) is an example.
|
||||
- This meta information is only collected so users may add clarifying information to their outfit submissions, such as components used in its creation. In addition, it can be used to credit someone if the outfit was not self-made.
|
||||
|
||||
## Accessing and deleting your data
|
||||
You may request deletion of your submitted content through myself
|
||||
or another administrator. To do this, either join our discord and
|
||||
ping one of us, or create an issue on GitHub.
|
||||
# Accessing and deleting your data
|
||||
You may request deletion of your data by contacting Salmonllama#5727 or another FashionScapers Administrator. To do this, either join our discord and ping one of us, or create an issue on GitHub. A link to both are provided at the bottom of this privacy policy.
|
||||
|
||||
## Questions, Comments, Concerns
|
||||
Any further questions or concerns may be submitted through the
|
||||
[Fashionscape Server](https://discord.com/invite/Tfvxe22)'s #report-issues-here channel, or directed to
|
||||
Salmonllama#5727 or LisaaRS#2604.
|
||||
# Our Disclosure of Your Information.
|
||||
We are not in the business of selling your information. We consider this information to be a vital part of our relationship with you. There are, however, certain circumstances in which we may share your information with certain third parties, as set forth below:
|
||||
- Consent: We may transfer your information with your consent.
|
||||
- Related Companies: We may also share your information with our Related Companies for purposes consistent with this Privacy Policy. For example, because the FashionScape Bot stores submissions on a private Imgur gallery, that information is sent to Imgur, who are considered to be a “related company.”
|
||||
- Legal Requirements: We may disclose your information if required to do so by law or in the good faith belief that such action is necessary to (i) comply with a legal obligation, (ii) protect and defend the rights or property of the Company or Related Companies, (iii) protect the personal safety of users of the Services or the public, or (iv) protect against legal liability.
|
||||
|
||||
# Unsolicited Suggestions
|
||||
You may provide us with ideas for new FashionScape Bot functions, or modifications to existing features, and other unsolicited submissions (collectively, “Unsolicited Suggestions”). All Unsolicited Suggestions shall be deemed to be non-confidential and we shall be free to reproduce, use, disclose, and distribute such unsolicited Information to others without limitation or attribution.
|
||||
|
||||
# Children
|
||||
Our Services are for users age 13 and over and we do not knowingly collect personal information from children under the age of 13. If you are a parent or guardian of a child under the age of 13 and believe he or she has disclosed personal information to us please contact us through one of our listed contact outlets at the end of this privacy policy. Note: In some countries, the age of digital consent is older than 13. If you are in those countries, you must be at least that age to use the Services. For example, for residents of the EEA, where processing of personal information is based on consent, FashionScape Bot will not knowingly engage in that processing for users under the age of consent established by applicable data protection law. If we learn that we are engaged in that processing with such users, we will halt such processing and will take reasonable measures to promptly remove applicable information from our records.
|
||||
|
||||
# Security
|
||||
We take reasonable steps to protect the information provided via the Services from loss, misuse, and unauthorized access, disclosure, alteration, or destruction. However, no Internet or email transmission is ever fully secure or error free. In particular, email sent to or from the Services may not be secure. Therefore, you should take special care in deciding what information you send to us via email. Please keep this in mind when disclosing any information via the Internet.
|
||||
|
||||
# Your Data Rights & Choices
|
||||
- **How can I access the personal data you have about me?**
|
||||
|
||||
If you would like to submit a data access request, please contact us through one of our listed contact outlets at the end of this privacy policy. We will then start the process and provide you a link to access the personal data that FashionScape Bot has on you within 30 days.
|
||||
|
||||
- **How do I correct, update, amend, or delete the personal data you have about me?**
|
||||
|
||||
Please contact us with an explanation of what data subject right you are seeking to exercise. For your protection, we may take steps to verify identity before responding to your request.
|
||||
|
||||
- **How do I object or restrict the manner in which Discord processes my personal data?**
|
||||
You have a right to ask us to stop using or limit our use of your personal data in certain circumstances—for example, if we have no lawful basis to keep using your data, or if you think your personal data is inaccurate.
|
||||
|
||||
# Changes to this Privacy Policy
|
||||
We reserve the right to update or modify this Privacy Policy at any time and from time to time without prior notice. Please review this policy periodically, and especially before you provide any information. This Privacy Policy was last updated on the date indicated above. Your continued use of the Services after any changes or revisions to this Privacy Policy shall indicate your agreement with the terms of such revised Privacy Policy.
|
||||
|
||||
# Contact
|
||||
If you need to contact us for assistance regarding information outlined in this policy, you may contact us through the following methods:
|
||||
|
||||
Salmonllama’s Discord Tag: Salmonllama#5727.
|
||||
LisaaRS’s Discord Tag: LisaaRS#2604.
|
||||
FashionScapers Discord Server: [https://discord.com/invite/Tfvxe22](https://discord.com/invite/Tfvxe22). Please use the “#report-issues-here” channel.
|
||||
Github: [https://github.com/Salmonllama/Fashionscape-Bot/issues/new](https://github.com/Salmonllama/Fashionscape-Bot/issues/new)
|
||||
Email: salmonllama999@gmail.com
|
||||
|
@ -12,6 +12,8 @@ import dev.salmonllama.fsbot.listeners.*;
|
||||
import org.javacord.api.DiscordApiBuilder;
|
||||
|
||||
import dev.salmonllama.fsbot.utilities.Constants;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@ -20,6 +22,9 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class Main {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(Main.class);
|
||||
|
||||
public static void main(String[] args) {
|
||||
String configLocation = Constants.BOT_FOLDER.concat(Constants.CONFIG_NAME);
|
||||
BotConfig.initConfig(configLocation, false);
|
||||
@ -29,7 +34,6 @@ public class Main {
|
||||
|
||||
new DiscordApiBuilder().setToken(BotConfig.TOKEN).login().thenAccept(api -> {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
Guthix guthix = new Guthix(api);
|
||||
|
||||
// Register listeners
|
||||
@ -40,8 +44,7 @@ public class Main {
|
||||
api.addMessageCreateListener(new AchievementListener());
|
||||
api.addMessageCreateListener(new ReportListener());
|
||||
|
||||
System.out.printf("Bot invite: %s%n", api.createBotInvite());
|
||||
System.out.printf("Logged in as %s%n", api.getYourself().getDiscriminatedName());
|
||||
logger.info("{} reporting for duty", api.getYourself().getDiscriminatedName());
|
||||
});
|
||||
|
||||
SpringApplication.run(Main.class, args);
|
||||
|
@ -2,22 +2,19 @@ package dev.salmonllama.fsbot.commands.developer;
|
||||
|
||||
import dev.salmonllama.fsbot.database.controllers.UserBlacklistController;
|
||||
import dev.salmonllama.fsbot.database.models.UserBlacklist;
|
||||
import dev.salmonllama.fsbot.guthix.Command;
|
||||
import dev.salmonllama.fsbot.guthix.CommandContext;
|
||||
import dev.salmonllama.fsbot.guthix.CommandPermission;
|
||||
import dev.salmonllama.fsbot.guthix.PermissionType;
|
||||
import dev.salmonllama.fsbot.guthix.*;
|
||||
import org.javacord.api.entity.message.embed.EmbedBuilder;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class BlacklistUserCommand extends Command {
|
||||
@Override public String name() { return "Blacklist User"; }
|
||||
@Override public String description() { return "Adds the user to the bot's blacklist, preventing them from using any commands or features"; }
|
||||
@Override public String usage() { return "blacklistuser <userId> <reason>"; }
|
||||
@Override public String category() { return "Developer"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.DEVELOPER; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.STATIC, "owner"); }
|
||||
@Override public Collection<String> aliases() { return Arrays.asList("blacklistuser", "bluser", "sabusr"); }
|
||||
@Override public List<String> aliases() { return Arrays.asList("blacklistuser", "bluser", "sabusr"); }
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandContext ctx) {
|
||||
|
@ -5,30 +5,24 @@
|
||||
|
||||
package dev.salmonllama.fsbot.commands.developer;
|
||||
|
||||
import com.vdurmont.emoji.EmojiManager;
|
||||
import com.vdurmont.emoji.EmojiParser;
|
||||
import dev.salmonllama.fsbot.config.BotConfig;
|
||||
import dev.salmonllama.fsbot.database.controllers.GalleryController;
|
||||
import dev.salmonllama.fsbot.database.models.GalleryChannel;
|
||||
import dev.salmonllama.fsbot.guthix.Command;
|
||||
import dev.salmonllama.fsbot.guthix.CommandContext;
|
||||
import dev.salmonllama.fsbot.guthix.CommandPermission;
|
||||
import dev.salmonllama.fsbot.guthix.PermissionType;
|
||||
import dev.salmonllama.fsbot.guthix.*;
|
||||
import org.javacord.api.entity.message.embed.EmbedBuilder;
|
||||
import org.javacord.api.util.logging.ExceptionLogger;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class CreateGalleryCommand extends Command { // TODO: This command needs help.
|
||||
@Override public String name() { return "Create Gallery"; }
|
||||
@Override public String description() { return "Creates a channel gallery, tracking any posted images"; }
|
||||
@Override public String usage() { return "creategallery <String tag>"; }
|
||||
@Override public String category() { return "Developer"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.DEVELOPER; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.STATIC, "owner"); }
|
||||
@Override public Collection<String> aliases() { return new ArrayList<>(Arrays.asList("creategallery", "addgallery", "newgallery")); }
|
||||
@Override public List<String> aliases() { return Arrays.asList("creategallery", "addgallery", "newgallery"); }
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandContext ctx) {
|
||||
|
@ -1,21 +1,18 @@
|
||||
package dev.salmonllama.fsbot.commands.developer;
|
||||
|
||||
import dev.salmonllama.fsbot.guthix.Command;
|
||||
import dev.salmonllama.fsbot.guthix.CommandContext;
|
||||
import dev.salmonllama.fsbot.guthix.CommandPermission;
|
||||
import dev.salmonllama.fsbot.guthix.PermissionType;
|
||||
import dev.salmonllama.fsbot.guthix.*;
|
||||
import org.javacord.api.entity.message.embed.EmbedBuilder;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class DefaultCommand extends Command {
|
||||
@Override public String name() { return "Default"; }
|
||||
@Override public String description() { return "The command that gets invoked when the prefix is used, but the command is not recognized"; }
|
||||
@Override public String usage() { return "you don't use this command"; }
|
||||
@Override public String category() { return "Invisible"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.DEVELOPER; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.OWNER); }
|
||||
@Override public Collection<String> aliases() { return Collections.singletonList("default"); }
|
||||
@Override public List<String> aliases() { return Collections.singletonList("default"); }
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandContext ctx) {
|
||||
|
@ -5,24 +5,22 @@
|
||||
|
||||
package dev.salmonllama.fsbot.commands.developer;
|
||||
|
||||
import dev.salmonllama.fsbot.guthix.Command;
|
||||
import dev.salmonllama.fsbot.guthix.CommandContext;
|
||||
import dev.salmonllama.fsbot.guthix.CommandPermission;
|
||||
import dev.salmonllama.fsbot.guthix.PermissionType;
|
||||
import dev.salmonllama.fsbot.guthix.*;
|
||||
import org.javacord.api.DiscordApi;
|
||||
import org.javacord.api.entity.channel.TextChannel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class InviteCommand extends Command {
|
||||
@Override public String name() { return "Invite"; }
|
||||
@Override public String description() { return "Spits out a bot invite"; }
|
||||
@Override public String usage() { return "invite"; }
|
||||
@Override public String category() { return "Developer"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.DEVELOPER; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.STATIC, "owner"); }
|
||||
@Override public Collection<String> aliases() { return new ArrayList<>(Arrays.asList("invite", "inv")); }
|
||||
@Override public List<String> aliases() { return Arrays.asList("invite", "inv"); }
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandContext ctx) {
|
||||
|
@ -7,26 +7,22 @@ package dev.salmonllama.fsbot.commands.developer;
|
||||
|
||||
import dev.salmonllama.fsbot.database.controllers.StaticPermissionController;
|
||||
import dev.salmonllama.fsbot.database.models.StaticPermission;
|
||||
import dev.salmonllama.fsbot.guthix.Command;
|
||||
import dev.salmonllama.fsbot.guthix.CommandContext;
|
||||
import dev.salmonllama.fsbot.guthix.CommandPermission;
|
||||
import dev.salmonllama.fsbot.guthix.PermissionType;
|
||||
import dev.salmonllama.fsbot.guthix.*;
|
||||
import org.javacord.api.entity.message.embed.EmbedBuilder;
|
||||
import org.javacord.api.entity.user.User;
|
||||
import org.javacord.api.util.logging.ExceptionLogger;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class PermissionCommand extends Command {
|
||||
@Override public String name() { return "Permission"; }
|
||||
@Override public String description() { return "Manages a user's static permissions"; }
|
||||
@Override public String usage() { return "permission <list|add|remove> <keyword>"; }
|
||||
@Override public String category() { return "Staff"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.DEVELOPER; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.OWNER); }
|
||||
@Override public Collection<String> aliases() { return new ArrayList<>(Arrays.asList("permission", "permissions", "perm", "perms")); }
|
||||
@Override public List<String> aliases() { return Arrays.asList("permission", "permissions", "perm", "perms"); }
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandContext ctx) {
|
||||
|
@ -5,39 +5,29 @@
|
||||
|
||||
package dev.salmonllama.fsbot.commands.developer;
|
||||
|
||||
import dev.salmonllama.fsbot.Main;
|
||||
import dev.salmonllama.fsbot.database.controllers.OutfitController;
|
||||
import dev.salmonllama.fsbot.guthix.Command;
|
||||
import dev.salmonllama.fsbot.guthix.CommandContext;
|
||||
import dev.salmonllama.fsbot.guthix.CommandPermission;
|
||||
import dev.salmonllama.fsbot.guthix.PermissionType;
|
||||
import org.javacord.api.entity.message.Message;
|
||||
import org.javacord.api.entity.permission.Role;
|
||||
import dev.salmonllama.fsbot.endpoints.scapefashion.ScapeFashionConnection;
|
||||
import dev.salmonllama.fsbot.guthix.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.List;
|
||||
|
||||
public class TestCommand extends Command {
|
||||
@Override public String name() { return "Test"; }
|
||||
@Override public String description() { return "A test command"; }
|
||||
@Override public String usage() { return "test"; }
|
||||
@Override public String category() { return "Developer"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.DEVELOPER; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.OWNER); }
|
||||
@Override public Collection<String> aliases() { return new ArrayList<>(Arrays.asList("test", "t")); }
|
||||
@Override public List<String> aliases() { return Arrays.asList("test", "t"); }
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandContext ctx) {
|
||||
Message msg = ctx.getMessage();
|
||||
ScapeFashionConnection conn = new ScapeFashionConnection();
|
||||
|
||||
Collection<Role> roles = msg.getMentionedRoles();
|
||||
|
||||
roles.stream().map(Role::getIdAsString).collect(Collectors.toList()).forEach(id -> {
|
||||
ctx.getServer().ifPresent(server -> {
|
||||
Role r = server.getRoleById(id).orElse(null);
|
||||
ctx.reply(r.getMentionTag());
|
||||
});
|
||||
});
|
||||
try {
|
||||
var result = conn.osrsColor("#00ff00");
|
||||
ctx.reply(String.format("Best match: %s", result.getItems().get(0).toString()));
|
||||
} catch (Exception e) {
|
||||
ctx.reply(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,25 +7,21 @@ package dev.salmonllama.fsbot.commands.general;
|
||||
|
||||
import dev.salmonllama.fsbot.config.BotConfig;
|
||||
import dev.salmonllama.fsbot.database.controllers.ColorRoleController;
|
||||
import dev.salmonllama.fsbot.guthix.Command;
|
||||
import dev.salmonllama.fsbot.guthix.CommandContext;
|
||||
import dev.salmonllama.fsbot.guthix.CommandPermission;
|
||||
import dev.salmonllama.fsbot.guthix.PermissionType;
|
||||
import dev.salmonllama.fsbot.guthix.*;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.javacord.api.entity.server.Server;
|
||||
import org.javacord.api.entity.user.User;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class ColorCommand extends Command {
|
||||
@Override public String name() { return "Color"; }
|
||||
@Override public String description() { return "Assigns the provided cosmetic role"; }
|
||||
@Override public String usage() { return "color <colorName>"; }
|
||||
@Override public String category() { return "General"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.GENERAL; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.NONE); }
|
||||
@Override public Collection<String> aliases() { return new ArrayList<>(Arrays.asList("color", "colour")); }
|
||||
@Override public List<String> aliases() { return Arrays.asList("color", "colour"); }
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandContext ctx) {
|
||||
|
@ -7,23 +7,19 @@ package dev.salmonllama.fsbot.commands.general;
|
||||
|
||||
import dev.salmonllama.fsbot.config.BotConfig;
|
||||
import dev.salmonllama.fsbot.database.controllers.ColorRoleController;
|
||||
import dev.salmonllama.fsbot.guthix.Command;
|
||||
import dev.salmonllama.fsbot.guthix.CommandContext;
|
||||
import dev.salmonllama.fsbot.guthix.CommandPermission;
|
||||
import dev.salmonllama.fsbot.guthix.PermissionType;
|
||||
import dev.salmonllama.fsbot.guthix.*;
|
||||
import org.javacord.api.entity.message.embed.EmbedBuilder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class ColorsCommand extends Command {
|
||||
@Override public String name() { return "Colors"; }
|
||||
@Override public String description() { return "Lists available cosmetic roles"; }
|
||||
@Override public String usage() { return "colors"; }
|
||||
@Override public String category() { return "General"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.GENERAL; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.NONE); }
|
||||
@Override public Collection<String> aliases() { return new ArrayList<>(Arrays.asList("colors", "colours")); }
|
||||
@Override public List<String> aliases() { return Arrays.asList("colors", "colours"); }
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandContext ctx) {
|
||||
|
@ -21,9 +21,9 @@ public class HelpCommand extends Command {
|
||||
@Override public String name() { return "Help"; }
|
||||
@Override public String description() { return "Shows all commands, or a specific command's information"; }
|
||||
@Override public String usage() { return "help [String command]"; }
|
||||
@Override public String category() { return "General"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.GENERAL; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.NONE); }
|
||||
@Override public Collection<String> aliases() { return new ArrayList<>(Arrays.asList("help", "h")); }
|
||||
@Override public List<String> aliases() { return Arrays.asList("help", "h"); }
|
||||
|
||||
private final Guthix guthix;
|
||||
|
||||
@ -60,7 +60,7 @@ public class HelpCommand extends Command {
|
||||
List<String> categories = new ArrayList<>();
|
||||
|
||||
for (Command cmd : guthix.listCommands()) {
|
||||
String category = cmd.category();
|
||||
String category = cmd.category().getCategory();
|
||||
if (!categories.contains(category)) {
|
||||
categories.add(category);
|
||||
|
||||
@ -82,9 +82,9 @@ public class HelpCommand extends Command {
|
||||
StringBuilder builder = new StringBuilder().append("```yml");
|
||||
|
||||
for (Command cmd : guthix.listCommands()) {
|
||||
String cat = cmd.category().toLowerCase();
|
||||
String cat = cmd.category().getCategory().toLowerCase();
|
||||
if (cat.equals(category.toLowerCase())) {
|
||||
builder.append("\n- ").append(cmd.name());
|
||||
builder.append("\n- ").append(cmd.aliases().get(0));
|
||||
}
|
||||
}
|
||||
|
||||
@ -161,7 +161,7 @@ public class HelpCommand extends Command {
|
||||
|
||||
public boolean isCategory(String input) {
|
||||
for (Command cmd : guthix.listCommands()) {
|
||||
String category = cmd.category();
|
||||
String category = cmd.category().getCategory().toLowerCase();
|
||||
if (category.toLowerCase().equals(input.toLowerCase())) {
|
||||
return true;
|
||||
}
|
||||
|
@ -7,10 +7,7 @@ package dev.salmonllama.fsbot.commands.general;
|
||||
|
||||
import dev.salmonllama.fsbot.database.controllers.OutfitController;
|
||||
import dev.salmonllama.fsbot.database.models.Outfit;
|
||||
import dev.salmonllama.fsbot.guthix.Command;
|
||||
import dev.salmonllama.fsbot.guthix.CommandContext;
|
||||
import dev.salmonllama.fsbot.guthix.CommandPermission;
|
||||
import dev.salmonllama.fsbot.guthix.PermissionType;
|
||||
import dev.salmonllama.fsbot.guthix.*;
|
||||
import org.javacord.api.entity.message.Message;
|
||||
import org.javacord.api.entity.message.embed.EmbedBuilder;
|
||||
import org.javacord.api.util.logging.ExceptionLogger;
|
||||
@ -18,6 +15,7 @@ import org.javacord.api.util.logging.ExceptionLogger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class OutfitCommand extends Command {
|
||||
@ -27,9 +25,9 @@ public class OutfitCommand extends Command {
|
||||
@Override public String name() { return "Outfit"; }
|
||||
@Override public String description() { return "Generates a random image with the given tag. Use ~tags to see valid tags."; }
|
||||
@Override public String usage() { return "outfit <String tag>"; }
|
||||
@Override public String category() { return "General"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.GENERAL; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.NONE); }
|
||||
@Override public Collection<String> aliases() { return initAliases(); }
|
||||
@Override public List<String> aliases() { return initAliases(); }
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandContext ctx) {
|
||||
@ -195,8 +193,8 @@ public class OutfitCommand extends Command {
|
||||
}
|
||||
}
|
||||
|
||||
private Collection<String> initAliases() {
|
||||
Collection<String> aliases = OutfitController.getDistinctTags().join();
|
||||
private List<String> initAliases() {
|
||||
List<String> aliases = OutfitController.getDistinctTags().join();
|
||||
aliases.addAll(NON_TAG_ALIASES);
|
||||
return aliases;
|
||||
}
|
||||
|
@ -5,10 +5,7 @@
|
||||
|
||||
package dev.salmonllama.fsbot.commands.general;
|
||||
|
||||
import dev.salmonllama.fsbot.guthix.Command;
|
||||
import dev.salmonllama.fsbot.guthix.CommandContext;
|
||||
import dev.salmonllama.fsbot.guthix.CommandPermission;
|
||||
import dev.salmonllama.fsbot.guthix.PermissionType;
|
||||
import dev.salmonllama.fsbot.guthix.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@ -16,9 +13,9 @@ public class PingCommand extends Command {
|
||||
@Override public String name() { return "Ping"; }
|
||||
@Override public String description() { return "Pings the bot, checks for a heartbeat"; }
|
||||
@Override public String usage() { return "ping"; }
|
||||
@Override public String category() { return "General"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.GENERAL; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.NONE); }
|
||||
@Override public Collection<String> aliases() { return new ArrayList<>(Collections.singletonList("ping")); }
|
||||
@Override public List<String> aliases() { return Collections.singletonList("ping"); }
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandContext ctx) {
|
||||
|
@ -1,26 +1,23 @@
|
||||
package dev.salmonllama.fsbot.commands.general;
|
||||
|
||||
import dev.salmonllama.fsbot.guthix.Command;
|
||||
import dev.salmonllama.fsbot.guthix.CommandContext;
|
||||
import dev.salmonllama.fsbot.guthix.CommandPermission;
|
||||
import dev.salmonllama.fsbot.guthix.PermissionType;
|
||||
import dev.salmonllama.fsbot.guthix.*;
|
||||
import org.javacord.api.entity.message.embed.EmbedBuilder;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class PrivacyCommand extends Command {
|
||||
@Override public String name() { return "Privacy"; }
|
||||
@Override public String description() { return "Directs users to the bot's privacy policy"; }
|
||||
@Override public String usage() { return "privacy"; }
|
||||
@Override public String category() { return "General"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.GENERAL; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.NONE); }
|
||||
@Override public Collection<String> aliases() { return Collections.singletonList("privacy"); }
|
||||
@Override public List<String> aliases() { return Collections.singletonList("privacy"); }
|
||||
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandContext ctx) {
|
||||
String privacyUrl = "https://github.com/Salmonllama/Fashionscape-Bot/blob/database-rewrite/privacy.md"; // TODO: Change this to master
|
||||
String privacyUrl = "https://github.com/Salmonllama/Fashionscape-Bot/blob/master/privacy.md";
|
||||
|
||||
EmbedBuilder response = new EmbedBuilder()
|
||||
.setTitle("Click Here to open")
|
||||
|
@ -5,34 +5,31 @@
|
||||
|
||||
package dev.salmonllama.fsbot.commands.general;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import dev.salmonllama.fsbot.guthix.*;
|
||||
import org.javacord.api.entity.channel.ServerTextChannel;
|
||||
import org.javacord.api.entity.message.embed.EmbedBuilder;
|
||||
import org.javacord.api.entity.server.Server;
|
||||
|
||||
import dev.salmonllama.fsbot.database.controllers.GalleryController;
|
||||
import dev.salmonllama.fsbot.database.models.GalleryChannel;
|
||||
import dev.salmonllama.fsbot.guthix.Command;
|
||||
import dev.salmonllama.fsbot.guthix.CommandContext;
|
||||
import dev.salmonllama.fsbot.guthix.CommandPermission;
|
||||
import dev.salmonllama.fsbot.guthix.PermissionType;
|
||||
import org.javacord.api.util.logging.ExceptionLogger;
|
||||
|
||||
public class ShowGalleriesCommand extends Command {
|
||||
@Override public String name() { return "Show Galleries"; }
|
||||
@Override public String description() { return "Shows registered gallery channels in the current server"; }
|
||||
@Override public String usage() { return "showgalleries"; }
|
||||
@Override public String category() { return "General"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.GENERAL; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.NONE); }
|
||||
@Override public Collection<String> aliases() { return new ArrayList<>(Arrays.asList("showgalleries", "listgalleries")); }
|
||||
@Override public List<String> aliases() { return Arrays.asList("showgalleries", "listgalleries"); }
|
||||
|
||||
@Override public void onCommand(CommandContext ctx) {
|
||||
if (ctx.isPrivateMessage()) {
|
||||
ctx.reply("This command can only be used within a server"); // TODO: Preset embeds again, yeah
|
||||
ctx.reply("This command can only be used within a server");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -45,7 +42,7 @@ public class ShowGalleriesCommand extends Command {
|
||||
});
|
||||
}
|
||||
|
||||
EmbedBuilder galleryEmbed(Collection<GalleryChannel> galleries, Server server) { // TODO: Base FSBot embed.
|
||||
EmbedBuilder galleryEmbed(Collection<GalleryChannel> galleries, Server server) {
|
||||
EmbedBuilder embed = new EmbedBuilder()
|
||||
.setTitle("Server Gallery Channels");
|
||||
|
||||
|
@ -1,24 +1,19 @@
|
||||
package dev.salmonllama.fsbot.commands.general;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.*;
|
||||
|
||||
import dev.salmonllama.fsbot.guthix.*;
|
||||
import org.javacord.api.entity.message.embed.EmbedBuilder;
|
||||
|
||||
import dev.salmonllama.fsbot.database.controllers.OutfitController;
|
||||
import dev.salmonllama.fsbot.guthix.Command;
|
||||
import dev.salmonllama.fsbot.guthix.CommandContext;
|
||||
import dev.salmonllama.fsbot.guthix.CommandPermission;
|
||||
import dev.salmonllama.fsbot.guthix.PermissionType;
|
||||
|
||||
public class StatsCommand extends Command {
|
||||
@Override public String name() { return "Stats"; }
|
||||
@Override public String description() { return "Shows various stats from Fashionscape Bot"; }
|
||||
@Override public String usage() { return "stats"; }
|
||||
@Override public String category() { return "General"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.GENERAL; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.NONE); }
|
||||
@Override public Collection<String> aliases() { return new ArrayList<>(Arrays.asList("stats")); }
|
||||
@Override public List<String> aliases() { return Collections.singletonList("stats"); }
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandContext ctx) {
|
||||
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2020. Aleksei Gryczewski
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
package dev.salmonllama.fsbot.commands.osrssearch;
|
||||
|
||||
import dev.salmonllama.fsbot.endpoints.scapefashion.ScapeFashionConnection;
|
||||
import dev.salmonllama.fsbot.endpoints.scapefashion.ScapeFashionSlotOsrs;
|
||||
import dev.salmonllama.fsbot.guthix.*;
|
||||
import dev.salmonllama.fsbot.utilities.DiscordUtilities;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class OsrsBodyCommand extends Command {
|
||||
@Override public String name() { return "OSRS Body"; }
|
||||
@Override public String description() { return "Searches scape.fashion for body slot items."; }
|
||||
@Override public String usage() { return "osrsbody <#color or item name>"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.OSRS_ITEM_SEARCH; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.NONE); }
|
||||
@Override public List<String> aliases() { return Arrays.asList("07body", "osrsbody"); }
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(OsrsBodyCommand.class);
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandContext ctx) {
|
||||
if (ctx.getArgs().length == 0) {
|
||||
ctx.reply("Specify something");
|
||||
return;
|
||||
}
|
||||
|
||||
var args = ctx.getArgs();
|
||||
ScapeFashionConnection conn = new ScapeFashionConnection();
|
||||
var params = Strings.join(Arrays.asList(args), ' ');
|
||||
|
||||
if (OsrsSearchUtilities.isColor(args[0])) {
|
||||
// Color search
|
||||
try {
|
||||
var bestMatch = conn.osrsColor(params, ScapeFashionSlotOsrs.BODY);
|
||||
OsrsSearchUtilities.sendResult(bestMatch, ctx.getChannel());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DiscordUtilities.handleException(e, ctx);
|
||||
}
|
||||
} else {
|
||||
// Item search
|
||||
try {
|
||||
var bestMatch = conn.osrsItem(params, ScapeFashionSlotOsrs.BODY);
|
||||
OsrsSearchUtilities.sendResult(bestMatch, ctx.getChannel());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DiscordUtilities.handleException(e, ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2020. Aleksei Gryczewski
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
package dev.salmonllama.fsbot.commands.osrssearch;
|
||||
|
||||
import dev.salmonllama.fsbot.endpoints.scapefashion.ScapeFashionConnection;
|
||||
import dev.salmonllama.fsbot.endpoints.scapefashion.ScapeFashionSlotOsrs;
|
||||
import dev.salmonllama.fsbot.guthix.*;
|
||||
import dev.salmonllama.fsbot.utilities.DiscordUtilities;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class OsrsCapeCommand extends Command {
|
||||
@Override public String name() { return "OSRS Cape"; }
|
||||
@Override public String description() { return "Searches scape.fashion for cape slot items."; }
|
||||
@Override public String usage() { return "osrscape <#color or item name>"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.OSRS_ITEM_SEARCH; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.NONE); }
|
||||
@Override public List<String> aliases() { return Arrays.asList("07cape", "osrscape"); }
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(OsrsCapeCommand.class);
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandContext ctx) {
|
||||
if (ctx.getArgs().length == 0) {
|
||||
ctx.reply("Specify something");
|
||||
return;
|
||||
}
|
||||
|
||||
var args = ctx.getArgs();
|
||||
ScapeFashionConnection conn = new ScapeFashionConnection();
|
||||
var params = Strings.join(Arrays.asList(args), ' ');
|
||||
|
||||
if (OsrsSearchUtilities.isColor(args[0])) {
|
||||
// Color search
|
||||
try {
|
||||
var bestMatch = conn.osrsColor(params, ScapeFashionSlotOsrs.CAPE);
|
||||
OsrsSearchUtilities.sendResult(bestMatch, ctx.getChannel());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DiscordUtilities.handleException(e, ctx);
|
||||
}
|
||||
} else {
|
||||
// Item search
|
||||
try {
|
||||
var bestMatch = conn.osrsItem(params, ScapeFashionSlotOsrs.CAPE);
|
||||
OsrsSearchUtilities.sendResult(bestMatch, ctx.getChannel());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DiscordUtilities.handleException(e, ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2020. Aleksei Gryczewski
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
package dev.salmonllama.fsbot.commands.osrssearch;
|
||||
|
||||
import dev.salmonllama.fsbot.endpoints.scapefashion.ScapeFashionConnection;
|
||||
import dev.salmonllama.fsbot.endpoints.scapefashion.ScapeFashionSlotOsrs;
|
||||
import dev.salmonllama.fsbot.guthix.*;
|
||||
import dev.salmonllama.fsbot.utilities.DiscordUtilities;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class OsrsFeetCommand extends Command {
|
||||
@Override public String name() { return "OSRS Feet"; }
|
||||
@Override public String description() { return "Searches scape.fashion for foot slot items."; }
|
||||
@Override public String usage() { return "osrsfeet <#color or item name>"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.OSRS_ITEM_SEARCH; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.NONE); }
|
||||
@Override public List<String> aliases() { return Arrays.asList("07feet", "osrsfeet"); }
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(OsrsFeetCommand.class);
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandContext ctx) {
|
||||
if (ctx.getArgs().length == 0) {
|
||||
ctx.reply("Specify something");
|
||||
return;
|
||||
}
|
||||
|
||||
var args = ctx.getArgs();
|
||||
ScapeFashionConnection conn = new ScapeFashionConnection();
|
||||
var params = Strings.join(Arrays.asList(args), ' ');
|
||||
|
||||
if (OsrsSearchUtilities.isColor(args[0])) {
|
||||
// Color search
|
||||
try {
|
||||
var bestMatch = conn.osrsColor(params, ScapeFashionSlotOsrs.FEET);
|
||||
OsrsSearchUtilities.sendResult(bestMatch, ctx.getChannel());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DiscordUtilities.handleException(e, ctx);
|
||||
}
|
||||
} else {
|
||||
// Item search
|
||||
try {
|
||||
var bestMatch = conn.osrsItem(params, ScapeFashionSlotOsrs.FEET);
|
||||
OsrsSearchUtilities.sendResult(bestMatch, ctx.getChannel());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DiscordUtilities.handleException(e, ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2020. Aleksei Gryczewski
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
package dev.salmonllama.fsbot.commands.osrssearch;
|
||||
|
||||
import dev.salmonllama.fsbot.endpoints.scapefashion.ScapeFashionConnection;
|
||||
import dev.salmonllama.fsbot.endpoints.scapefashion.ScapeFashionSlotOsrs;
|
||||
import dev.salmonllama.fsbot.guthix.*;
|
||||
import dev.salmonllama.fsbot.utilities.DiscordUtilities;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class OsrsHandCommand extends Command {
|
||||
@Override public String name() { return "OSRS Hand"; }
|
||||
@Override public String description() { return "Searches scape.fashion for hand slot items."; }
|
||||
@Override public String usage() { return "osrshand <#color or item name>"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.OSRS_ITEM_SEARCH; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.NONE); }
|
||||
@Override public List<String> aliases() { return Arrays.asList("07hand", "osrshand"); }
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(OsrsHandCommand.class);
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandContext ctx) {
|
||||
if (ctx.getArgs().length == 0) {
|
||||
ctx.reply("Specify something");
|
||||
return;
|
||||
}
|
||||
|
||||
var args = ctx.getArgs();
|
||||
ScapeFashionConnection conn = new ScapeFashionConnection();
|
||||
var params = Strings.join(Arrays.asList(args), ' ');
|
||||
|
||||
if (OsrsSearchUtilities.isColor(args[0])) {
|
||||
// Color search
|
||||
try {
|
||||
var bestMatch = conn.osrsColor(params, ScapeFashionSlotOsrs.HAND);
|
||||
OsrsSearchUtilities.sendResult(bestMatch, ctx.getChannel());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DiscordUtilities.handleException(e, ctx);
|
||||
}
|
||||
} else {
|
||||
// Item search
|
||||
try {
|
||||
var bestMatch = conn.osrsItem(params, ScapeFashionSlotOsrs.HAND);
|
||||
OsrsSearchUtilities.sendResult(bestMatch, ctx.getChannel());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DiscordUtilities.handleException(e, ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2020. Aleksei Gryczewski
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
package dev.salmonllama.fsbot.commands.osrssearch;
|
||||
|
||||
import dev.salmonllama.fsbot.endpoints.scapefashion.ScapeFashionConnection;
|
||||
import dev.salmonllama.fsbot.endpoints.scapefashion.ScapeFashionSlotOsrs;
|
||||
import dev.salmonllama.fsbot.guthix.*;
|
||||
import dev.salmonllama.fsbot.utilities.DiscordUtilities;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class OsrsHeadCommand extends Command {
|
||||
@Override public String name() { return "OSRS Head"; }
|
||||
@Override public String description() { return "Searches scape.fashion for head slot items."; }
|
||||
@Override public String usage() { return "osrshead <#color or item name>"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.OSRS_ITEM_SEARCH; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.NONE); }
|
||||
@Override public List<String> aliases() { return Arrays.asList("07head", "osrshead"); }
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(OsrsHeadCommand.class);
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandContext ctx) {
|
||||
if (ctx.getArgs().length == 0) {
|
||||
ctx.reply("Specify something");
|
||||
return;
|
||||
}
|
||||
|
||||
var args = ctx.getArgs();
|
||||
ScapeFashionConnection conn = new ScapeFashionConnection();
|
||||
var params = Strings.join(Arrays.asList(args), ' ');
|
||||
|
||||
if (OsrsSearchUtilities.isColor(args[0])) {
|
||||
// Color search
|
||||
try {
|
||||
var bestMatch = conn.osrsColor(params, ScapeFashionSlotOsrs.HEAD);
|
||||
OsrsSearchUtilities.sendResult(bestMatch, ctx.getChannel());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DiscordUtilities.handleException(e, ctx);
|
||||
}
|
||||
} else {
|
||||
// Item search
|
||||
try {
|
||||
var bestMatch = conn.osrsItem(params, ScapeFashionSlotOsrs.HEAD);
|
||||
OsrsSearchUtilities.sendResult(bestMatch, ctx.getChannel());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DiscordUtilities.handleException(e, ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2020. Aleksei Gryczewski
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
package dev.salmonllama.fsbot.commands.osrssearch;
|
||||
|
||||
import dev.salmonllama.fsbot.endpoints.scapefashion.ScapeFashionConnection;
|
||||
import dev.salmonllama.fsbot.endpoints.scapefashion.ScapeFashionSlotOsrs;
|
||||
import dev.salmonllama.fsbot.guthix.*;
|
||||
import dev.salmonllama.fsbot.utilities.DiscordUtilities;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class OsrsLegsCommand extends Command {
|
||||
@Override public String name() { return "OSRS Legs"; }
|
||||
@Override public String description() { return "Searches scape.fashion for leg slot items."; }
|
||||
@Override public String usage() { return "osrslegs <#color or item name>"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.OSRS_ITEM_SEARCH; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.NONE); }
|
||||
@Override public List<String> aliases() { return Arrays.asList("07legs", "osrslegs"); }
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(OsrsLegsCommand.class);
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandContext ctx) {
|
||||
if (ctx.getArgs().length == 0) {
|
||||
ctx.reply("Specify something");
|
||||
return;
|
||||
}
|
||||
|
||||
var args = ctx.getArgs();
|
||||
ScapeFashionConnection conn = new ScapeFashionConnection();
|
||||
var params = Strings.join(Arrays.asList(args), ' ');
|
||||
|
||||
if (OsrsSearchUtilities.isColor(args[0])) {
|
||||
// Color search
|
||||
try {
|
||||
var bestMatch = conn.osrsColor(params, ScapeFashionSlotOsrs.LEG);
|
||||
OsrsSearchUtilities.sendResult(bestMatch, ctx.getChannel());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DiscordUtilities.handleException(e, ctx);
|
||||
}
|
||||
} else {
|
||||
// Item search
|
||||
try {
|
||||
var bestMatch = conn.osrsItem(params, ScapeFashionSlotOsrs.LEG);
|
||||
OsrsSearchUtilities.sendResult(bestMatch, ctx.getChannel());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DiscordUtilities.handleException(e, ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2020. Aleksei Gryczewski
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
package dev.salmonllama.fsbot.commands.osrssearch;
|
||||
|
||||
import dev.salmonllama.fsbot.endpoints.scapefashion.ScapeFashionConnection;
|
||||
import dev.salmonllama.fsbot.endpoints.scapefashion.ScapeFashionSlotOsrs;
|
||||
import dev.salmonllama.fsbot.guthix.*;
|
||||
import dev.salmonllama.fsbot.utilities.DiscordUtilities;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class OsrsNeckCommand extends Command {
|
||||
@Override public String name() { return "OSRS Neck"; }
|
||||
@Override public String description() { return "Searches scape.fashion for neck slot items."; }
|
||||
@Override public String usage() { return "osrsneck <#color or item name>"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.OSRS_ITEM_SEARCH; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.NONE); }
|
||||
@Override public List<String> aliases() { return Arrays.asList("07neck", "osrsneck"); }
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(OsrsNeckCommand.class);
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandContext ctx) {
|
||||
if (ctx.getArgs().length == 0) {
|
||||
ctx.reply("Specify something");
|
||||
return;
|
||||
}
|
||||
|
||||
var args = ctx.getArgs();
|
||||
ScapeFashionConnection conn = new ScapeFashionConnection();
|
||||
var params = Strings.join(Arrays.asList(args), ' ');
|
||||
|
||||
if (OsrsSearchUtilities.isColor(args[0])) {
|
||||
// Color search
|
||||
try {
|
||||
var bestMatch = conn.osrsColor(params, ScapeFashionSlotOsrs.NECK);
|
||||
OsrsSearchUtilities.sendResult(bestMatch, ctx.getChannel());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DiscordUtilities.handleException(e, ctx);
|
||||
}
|
||||
} else {
|
||||
// Item search
|
||||
try {
|
||||
var bestMatch = conn.osrsItem(params, ScapeFashionSlotOsrs.NECK);
|
||||
OsrsSearchUtilities.sendResult(bestMatch, ctx.getChannel());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DiscordUtilities.handleException(e, ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 2020. Aleksei Gryczewski
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
package dev.salmonllama.fsbot.commands.osrssearch;
|
||||
|
||||
import dev.salmonllama.fsbot.endpoints.scapefashion.ScapeFashionConnection;
|
||||
import dev.salmonllama.fsbot.guthix.*;
|
||||
import dev.salmonllama.fsbot.utilities.DiscordUtilities;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class OsrsSearchCommand extends Command {
|
||||
@Override public String name() { return "OSRS Search"; }
|
||||
@Override public String description() { return "Searches scape.fashion for any items."; }
|
||||
@Override public String usage() { return "osrssearch <#color or item name>"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.OSRS_ITEM_SEARCH; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.NONE); }
|
||||
@Override public List<String> aliases() { return Arrays.asList("07search", "osrssearch"); }
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(OsrsSearchCommand.class);
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandContext ctx) {
|
||||
if (ctx.getArgs().length == 0) {
|
||||
ctx.reply("Specify something");
|
||||
return;
|
||||
}
|
||||
|
||||
var args = ctx.getArgs();
|
||||
ScapeFashionConnection conn = new ScapeFashionConnection();
|
||||
var params = Strings.join(Arrays.asList(args), ' ');
|
||||
|
||||
if (OsrsSearchUtilities.isColor(args[0])) {
|
||||
// Color search
|
||||
try {
|
||||
var bestMatch = conn.osrsColor(params);
|
||||
OsrsSearchUtilities.sendResult(bestMatch, ctx.getChannel());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DiscordUtilities.handleException(e, ctx);
|
||||
}
|
||||
} else {
|
||||
// Item search
|
||||
try {
|
||||
var bestMatch = conn.osrsItem(params);
|
||||
OsrsSearchUtilities.sendResult(bestMatch, ctx.getChannel());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DiscordUtilities.handleException(e, ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2020. Aleksei Gryczewski
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
package dev.salmonllama.fsbot.commands.osrssearch;
|
||||
|
||||
import dev.salmonllama.fsbot.endpoints.scapefashion.ScapeFashionResult;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.javacord.api.entity.channel.TextChannel;
|
||||
import org.javacord.api.entity.message.embed.EmbedBuilder;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class OsrsSearchUtilities {
|
||||
static boolean isColor(String s) {
|
||||
return s.startsWith("#");
|
||||
}
|
||||
|
||||
static void sendResult(ScapeFashionResult result, TextChannel channel) {
|
||||
var bestMatch = result.getItems().get(0);
|
||||
var colors = Strings.join(Arrays.asList(bestMatch.getColors()), ',');
|
||||
EmbedBuilder embed = new EmbedBuilder()
|
||||
.setTitle(String.format("Best Match - %s", bestMatch.getName()))
|
||||
.setImage(bestMatch.getImages().getDetail())
|
||||
.setAuthor(String.format("Wiki: %s", bestMatch.getName()), bestMatch.getWiki().getLink(), bestMatch.getImages().getDetail())
|
||||
.setUrl(result.getLink())
|
||||
.setColor(Color.decode(bestMatch.getColors()[0]))
|
||||
.addField("Match:", String.valueOf(bestMatch.getMatch()), true)
|
||||
.addField("Colors:", colors, true);
|
||||
|
||||
channel.sendMessage(embed);
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2020. Aleksei Gryczewski
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
package dev.salmonllama.fsbot.commands.osrssearch;
|
||||
|
||||
import dev.salmonllama.fsbot.endpoints.scapefashion.ScapeFashionConnection;
|
||||
import dev.salmonllama.fsbot.endpoints.scapefashion.ScapeFashionSlotOsrs;
|
||||
import dev.salmonllama.fsbot.guthix.*;
|
||||
import dev.salmonllama.fsbot.utilities.DiscordUtilities;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class OsrsShieldCommand extends Command {
|
||||
@Override public String name() { return "OSRS Shield"; }
|
||||
@Override public String description() { return "Searches scape.fashion for shield slot items."; }
|
||||
@Override public String usage() { return "osrsshield <#color or item name>"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.OSRS_ITEM_SEARCH; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.NONE); }
|
||||
@Override public List<String> aliases() { return Arrays.asList("07shield", "osrsshield"); }
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(OsrsShieldCommand.class);
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandContext ctx) {
|
||||
if (ctx.getArgs().length == 0) {
|
||||
ctx.reply("Specify something");
|
||||
return;
|
||||
}
|
||||
|
||||
var args = ctx.getArgs();
|
||||
ScapeFashionConnection conn = new ScapeFashionConnection();
|
||||
var params = Strings.join(Arrays.asList(args), ' ');
|
||||
|
||||
if (OsrsSearchUtilities.isColor(args[0])) {
|
||||
// Color search
|
||||
try {
|
||||
var bestMatch = conn.osrsColor(params, ScapeFashionSlotOsrs.SHIELD);
|
||||
OsrsSearchUtilities.sendResult(bestMatch, ctx.getChannel());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DiscordUtilities.handleException(e, ctx);
|
||||
}
|
||||
} else {
|
||||
// Item search
|
||||
try {
|
||||
var bestMatch = conn.osrsItem(params, ScapeFashionSlotOsrs.SHIELD);
|
||||
OsrsSearchUtilities.sendResult(bestMatch, ctx.getChannel());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DiscordUtilities.handleException(e, ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2020. Aleksei Gryczewski
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
package dev.salmonllama.fsbot.commands.osrssearch;
|
||||
|
||||
import dev.salmonllama.fsbot.endpoints.scapefashion.ScapeFashionConnection;
|
||||
import dev.salmonllama.fsbot.endpoints.scapefashion.ScapeFashionSlotOsrs;
|
||||
import dev.salmonllama.fsbot.guthix.*;
|
||||
import dev.salmonllama.fsbot.utilities.DiscordUtilities;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class OsrsWeaponCommand extends Command {
|
||||
@Override public String name() { return "OSRS Weapon"; }
|
||||
@Override public String description() { return "Searches scape.fashion for weapo slot items."; }
|
||||
@Override public String usage() { return "osrsweapon <#color or item name>"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.OSRS_ITEM_SEARCH; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.NONE); }
|
||||
@Override public List<String> aliases() { return Arrays.asList("07weapon", "osrsweapon"); }
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(OsrsWeaponCommand.class);
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandContext ctx) {
|
||||
if (ctx.getArgs().length == 0) {
|
||||
ctx.reply("Specify something");
|
||||
return;
|
||||
}
|
||||
|
||||
var args = ctx.getArgs();
|
||||
ScapeFashionConnection conn = new ScapeFashionConnection();
|
||||
var params = Strings.join(Arrays.asList(args), ' ');
|
||||
|
||||
if (OsrsSearchUtilities.isColor(args[0])) {
|
||||
// Color search
|
||||
try {
|
||||
var bestMatch = conn.osrsColor(params, ScapeFashionSlotOsrs.WEAPON);
|
||||
OsrsSearchUtilities.sendResult(bestMatch, ctx.getChannel());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DiscordUtilities.handleException(e, ctx);
|
||||
}
|
||||
} else {
|
||||
// Item search
|
||||
try {
|
||||
var bestMatch = conn.osrsItem(params, ScapeFashionSlotOsrs.WEAPON);
|
||||
OsrsSearchUtilities.sendResult(bestMatch, ctx.getChannel());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DiscordUtilities.handleException(e, ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2020. Aleksei Gryczewski
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
package dev.salmonllama.fsbot.commands.rs3search;
|
||||
|
||||
import dev.salmonllama.fsbot.endpoints.scapefashion.ScapeFashionConnection;
|
||||
import dev.salmonllama.fsbot.endpoints.scapefashion.ScapeFashionSlotRs3;
|
||||
import dev.salmonllama.fsbot.guthix.*;
|
||||
import dev.salmonllama.fsbot.utilities.DiscordUtilities;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class Rs3BackCommand extends Command {
|
||||
@Override public String name() { return "RS3 Back"; }
|
||||
@Override public String description() { return "Searches scape.fashion for rs3 back slot items."; }
|
||||
@Override public String usage() { return "rs3back <#color or item name>"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.RS3_ITEM_SEARCH; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.NONE); }
|
||||
@Override public List<String> aliases() { return Collections.singletonList("rs3back"); }
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(Rs3BackCommand.class);
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandContext ctx) {
|
||||
if (ctx.getArgs().length == 0) {
|
||||
ctx.reply("Specify something");
|
||||
return;
|
||||
}
|
||||
|
||||
var args = ctx.getArgs();
|
||||
ScapeFashionConnection conn = new ScapeFashionConnection();
|
||||
var params = Strings.join(Arrays.asList(args), ' ');
|
||||
|
||||
if (Rs3SearchUtilities.isColor(args[0])) {
|
||||
// Color search
|
||||
try {
|
||||
var bestMatch = conn.rs3Color(params, ScapeFashionSlotRs3.BACK);
|
||||
Rs3SearchUtilities.sendResult(bestMatch, ctx.getChannel());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DiscordUtilities.handleException(e, ctx);
|
||||
}
|
||||
} else {
|
||||
// Item search
|
||||
try {
|
||||
var bestMatch = conn.rs3Item(params, ScapeFashionSlotRs3.BACK);
|
||||
Rs3SearchUtilities.sendResult(bestMatch, ctx.getChannel());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DiscordUtilities.handleException(e, ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2020. Aleksei Gryczewski
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
package dev.salmonllama.fsbot.commands.rs3search;
|
||||
|
||||
import dev.salmonllama.fsbot.endpoints.scapefashion.ScapeFashionConnection;
|
||||
import dev.salmonllama.fsbot.endpoints.scapefashion.ScapeFashionSlotRs3;
|
||||
import dev.salmonllama.fsbot.guthix.*;
|
||||
import dev.salmonllama.fsbot.utilities.DiscordUtilities;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class Rs3BodyCommand extends Command {
|
||||
@Override public String name() { return "RS3 Body"; }
|
||||
@Override public String description() { return "Searches scape.fashion for rs3 body slot items."; }
|
||||
@Override public String usage() { return "rs3body <#color or item name>"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.RS3_ITEM_SEARCH; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.NONE); }
|
||||
@Override public List<String> aliases() { return Collections.singletonList("rs3body"); }
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(Rs3BodyCommand.class);
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandContext ctx) {
|
||||
if (ctx.getArgs().length == 0) {
|
||||
ctx.reply("Specify something");
|
||||
return;
|
||||
}
|
||||
|
||||
var args = ctx.getArgs();
|
||||
ScapeFashionConnection conn = new ScapeFashionConnection();
|
||||
var params = Strings.join(Arrays.asList(args), ' ');
|
||||
|
||||
if (Rs3SearchUtilities.isColor(args[0])) {
|
||||
// Color search
|
||||
try {
|
||||
var bestMatch = conn.rs3Color(params, ScapeFashionSlotRs3.TORSO);
|
||||
Rs3SearchUtilities.sendResult(bestMatch, ctx.getChannel());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DiscordUtilities.handleException(e, ctx);
|
||||
}
|
||||
} else {
|
||||
// Item search
|
||||
try {
|
||||
var bestMatch = conn.rs3Item(params, ScapeFashionSlotRs3.TORSO);
|
||||
Rs3SearchUtilities.sendResult(bestMatch, ctx.getChannel());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DiscordUtilities.handleException(e, ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2020. Aleksei Gryczewski
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
package dev.salmonllama.fsbot.commands.rs3search;
|
||||
|
||||
import dev.salmonllama.fsbot.endpoints.scapefashion.ScapeFashionConnection;
|
||||
import dev.salmonllama.fsbot.endpoints.scapefashion.ScapeFashionSlotRs3;
|
||||
import dev.salmonllama.fsbot.guthix.*;
|
||||
import dev.salmonllama.fsbot.utilities.DiscordUtilities;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class Rs3FeetCommand extends Command {
|
||||
@Override public String name() { return "RS3 Feet"; }
|
||||
@Override public String description() { return "Searches scape.fashion for rs3 foot slot items."; }
|
||||
@Override public String usage() { return "rs3feet <#color or item name>"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.RS3_ITEM_SEARCH; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.NONE); }
|
||||
@Override public List<String> aliases() { return Collections.singletonList("rs3feet"); }
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(Rs3FeetCommand.class);
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandContext ctx) {
|
||||
if (ctx.getArgs().length == 0) {
|
||||
ctx.reply("Specify something");
|
||||
return;
|
||||
}
|
||||
|
||||
var args = ctx.getArgs();
|
||||
ScapeFashionConnection conn = new ScapeFashionConnection();
|
||||
var params = Strings.join(Arrays.asList(args), ' ');
|
||||
|
||||
if (Rs3SearchUtilities.isColor(args[0])) {
|
||||
// Color search
|
||||
try {
|
||||
var bestMatch = conn.rs3Color(params, ScapeFashionSlotRs3.FEET);
|
||||
Rs3SearchUtilities.sendResult(bestMatch, ctx.getChannel());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DiscordUtilities.handleException(e, ctx);
|
||||
}
|
||||
} else {
|
||||
// Item search
|
||||
try {
|
||||
var bestMatch = conn.rs3Item(params, ScapeFashionSlotRs3.FEET);
|
||||
Rs3SearchUtilities.sendResult(bestMatch, ctx.getChannel());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DiscordUtilities.handleException(e, ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2020. Aleksei Gryczewski
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
package dev.salmonllama.fsbot.commands.rs3search;
|
||||
|
||||
import dev.salmonllama.fsbot.endpoints.scapefashion.ScapeFashionConnection;
|
||||
import dev.salmonllama.fsbot.endpoints.scapefashion.ScapeFashionSlotRs3;
|
||||
import dev.salmonllama.fsbot.guthix.*;
|
||||
import dev.salmonllama.fsbot.utilities.DiscordUtilities;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class Rs3HandCommand extends Command {
|
||||
@Override public String name() { return "RS3 Hand"; }
|
||||
@Override public String description() { return "Searches scape.fashion for rs3 hand slot items."; }
|
||||
@Override public String usage() { return "rs3hand <#color or item name>"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.RS3_ITEM_SEARCH; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.NONE); }
|
||||
@Override public List<String> aliases() { return Collections.singletonList("rs3hand"); }
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(Rs3HandCommand.class);
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandContext ctx) {
|
||||
if (ctx.getArgs().length == 0) {
|
||||
ctx.reply("Specify something");
|
||||
return;
|
||||
}
|
||||
|
||||
var args = ctx.getArgs();
|
||||
ScapeFashionConnection conn = new ScapeFashionConnection();
|
||||
var params = Strings.join(Arrays.asList(args), ' ');
|
||||
|
||||
if (Rs3SearchUtilities.isColor(args[0])) {
|
||||
// Color search
|
||||
try {
|
||||
var bestMatch = conn.rs3Color(params, ScapeFashionSlotRs3.HAND);
|
||||
Rs3SearchUtilities.sendResult(bestMatch, ctx.getChannel());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DiscordUtilities.handleException(e, ctx);
|
||||
}
|
||||
} else {
|
||||
// Item search
|
||||
try {
|
||||
var bestMatch = conn.rs3Item(params, ScapeFashionSlotRs3.HAND);
|
||||
Rs3SearchUtilities.sendResult(bestMatch, ctx.getChannel());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DiscordUtilities.handleException(e, ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2020. Aleksei Gryczewski
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
package dev.salmonllama.fsbot.commands.rs3search;
|
||||
|
||||
import dev.salmonllama.fsbot.endpoints.scapefashion.ScapeFashionConnection;
|
||||
import dev.salmonllama.fsbot.endpoints.scapefashion.ScapeFashionSlotRs3;
|
||||
import dev.salmonllama.fsbot.guthix.*;
|
||||
import dev.salmonllama.fsbot.utilities.DiscordUtilities;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class Rs3HeadCommand extends Command {
|
||||
@Override public String name() { return "RS3 Head"; }
|
||||
@Override public String description() { return "Searches scape.fashion for rs3 head slot items."; }
|
||||
@Override public String usage() { return "rs3head <#color or item name>"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.RS3_ITEM_SEARCH; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.NONE); }
|
||||
@Override public List<String> aliases() { return Collections.singletonList("rs3head"); }
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(Rs3HeadCommand.class);
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandContext ctx) {
|
||||
if (ctx.getArgs().length == 0) {
|
||||
ctx.reply("Specify something");
|
||||
return;
|
||||
}
|
||||
|
||||
var args = ctx.getArgs();
|
||||
ScapeFashionConnection conn = new ScapeFashionConnection();
|
||||
var params = Strings.join(Arrays.asList(args), ' ');
|
||||
|
||||
if (Rs3SearchUtilities.isColor(args[0])) {
|
||||
// Color search
|
||||
try {
|
||||
var bestMatch = conn.rs3Color(params, ScapeFashionSlotRs3.HEAD);
|
||||
Rs3SearchUtilities.sendResult(bestMatch, ctx.getChannel());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DiscordUtilities.handleException(e, ctx);
|
||||
}
|
||||
} else {
|
||||
// Item search
|
||||
try {
|
||||
var bestMatch = conn.rs3Item(params, ScapeFashionSlotRs3.HEAD);
|
||||
Rs3SearchUtilities.sendResult(bestMatch, ctx.getChannel());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DiscordUtilities.handleException(e, ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2020. Aleksei Gryczewski
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
package dev.salmonllama.fsbot.commands.rs3search;
|
||||
|
||||
import dev.salmonllama.fsbot.endpoints.scapefashion.ScapeFashionConnection;
|
||||
import dev.salmonllama.fsbot.endpoints.scapefashion.ScapeFashionSlotRs3;
|
||||
import dev.salmonllama.fsbot.guthix.*;
|
||||
import dev.salmonllama.fsbot.utilities.DiscordUtilities;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class Rs3LegsCommand extends Command {
|
||||
@Override public String name() { return "RS3 Legs"; }
|
||||
@Override public String description() { return "Searches scape.fashion for rs3 leg slot items."; }
|
||||
@Override public String usage() { return "rs3legs <#color or item name>"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.RS3_ITEM_SEARCH; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.NONE); }
|
||||
@Override public List<String> aliases() { return Collections.singletonList("rs3legs"); }
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(Rs3LegsCommand.class);
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandContext ctx) {
|
||||
if (ctx.getArgs().length == 0) {
|
||||
ctx.reply("Specify something");
|
||||
return;
|
||||
}
|
||||
|
||||
var args = ctx.getArgs();
|
||||
ScapeFashionConnection conn = new ScapeFashionConnection();
|
||||
var params = Strings.join(Arrays.asList(args), ' ');
|
||||
|
||||
if (Rs3SearchUtilities.isColor(args[0])) {
|
||||
// Color search
|
||||
try {
|
||||
var bestMatch = conn.rs3Color(params, ScapeFashionSlotRs3.LEG);
|
||||
Rs3SearchUtilities.sendResult(bestMatch, ctx.getChannel());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DiscordUtilities.handleException(e, ctx);
|
||||
}
|
||||
} else {
|
||||
// Item search
|
||||
try {
|
||||
var bestMatch = conn.rs3Item(params, ScapeFashionSlotRs3.LEG);
|
||||
Rs3SearchUtilities.sendResult(bestMatch, ctx.getChannel());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DiscordUtilities.handleException(e, ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2020. Aleksei Gryczewski
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
package dev.salmonllama.fsbot.commands.rs3search;
|
||||
|
||||
import dev.salmonllama.fsbot.endpoints.scapefashion.ScapeFashionConnection;
|
||||
import dev.salmonllama.fsbot.endpoints.scapefashion.ScapeFashionSlotRs3;
|
||||
import dev.salmonllama.fsbot.guthix.*;
|
||||
import dev.salmonllama.fsbot.utilities.DiscordUtilities;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class Rs3MainhandCommand extends Command {
|
||||
@Override public String name() { return "RS3 Mainhand"; }
|
||||
@Override public String description() { return "Searches scape.fashion for rs3 mainhand slot items."; }
|
||||
@Override public String usage() { return "rs3mainhand <#color or item name>"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.RS3_ITEM_SEARCH; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.NONE); }
|
||||
@Override public List<String> aliases() { return Arrays.asList("rs3mainhand", "rs3mh"); }
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(Rs3MainhandCommand.class);
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandContext ctx) {
|
||||
if (ctx.getArgs().length == 0) {
|
||||
ctx.reply("Specify something");
|
||||
return;
|
||||
}
|
||||
|
||||
var args = ctx.getArgs();
|
||||
ScapeFashionConnection conn = new ScapeFashionConnection();
|
||||
var params = Strings.join(Arrays.asList(args), ' ');
|
||||
|
||||
if (Rs3SearchUtilities.isColor(args[0])) {
|
||||
// Color search
|
||||
try {
|
||||
var bestMatch = conn.rs3Color(params, ScapeFashionSlotRs3.MAIN_HAND);
|
||||
Rs3SearchUtilities.sendResult(bestMatch, ctx.getChannel());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DiscordUtilities.handleException(e, ctx);
|
||||
}
|
||||
} else {
|
||||
// Item search
|
||||
try {
|
||||
var bestMatch = conn.rs3Item(params, ScapeFashionSlotRs3.MAIN_HAND);
|
||||
Rs3SearchUtilities.sendResult(bestMatch, ctx.getChannel());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DiscordUtilities.handleException(e, ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2020. Aleksei Gryczewski
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
package dev.salmonllama.fsbot.commands.rs3search;
|
||||
|
||||
import dev.salmonllama.fsbot.endpoints.scapefashion.ScapeFashionConnection;
|
||||
import dev.salmonllama.fsbot.endpoints.scapefashion.ScapeFashionSlotRs3;
|
||||
import dev.salmonllama.fsbot.guthix.*;
|
||||
import dev.salmonllama.fsbot.utilities.DiscordUtilities;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class Rs3NeckCommand extends Command {
|
||||
@Override public String name() { return "RS3 Neck"; }
|
||||
@Override public String description() { return "Searches scape.fashion for rs3 neck slot items."; }
|
||||
@Override public String usage() { return "rs3neck <#color or item name>"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.RS3_ITEM_SEARCH; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.NONE); }
|
||||
@Override public List<String> aliases() { return Collections.singletonList("rs3neck"); }
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(Rs3NeckCommand.class);
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandContext ctx) {
|
||||
if (ctx.getArgs().length == 0) {
|
||||
ctx.reply("Specify something");
|
||||
return;
|
||||
}
|
||||
|
||||
var args = ctx.getArgs();
|
||||
ScapeFashionConnection conn = new ScapeFashionConnection();
|
||||
var params = Strings.join(Arrays.asList(args), ' ');
|
||||
|
||||
if (Rs3SearchUtilities.isColor(args[0])) {
|
||||
// Color search
|
||||
try {
|
||||
var bestMatch = conn.rs3Color(params, ScapeFashionSlotRs3.NECK);
|
||||
Rs3SearchUtilities.sendResult(bestMatch, ctx.getChannel());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DiscordUtilities.handleException(e, ctx);
|
||||
}
|
||||
} else {
|
||||
// Item search
|
||||
try {
|
||||
var bestMatch = conn.rs3Item(params, ScapeFashionSlotRs3.NECK);
|
||||
Rs3SearchUtilities.sendResult(bestMatch, ctx.getChannel());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DiscordUtilities.handleException(e, ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2020. Aleksei Gryczewski
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
package dev.salmonllama.fsbot.commands.rs3search;
|
||||
|
||||
import dev.salmonllama.fsbot.endpoints.scapefashion.ScapeFashionConnection;
|
||||
import dev.salmonllama.fsbot.endpoints.scapefashion.ScapeFashionSlotRs3;
|
||||
import dev.salmonllama.fsbot.guthix.*;
|
||||
import dev.salmonllama.fsbot.utilities.DiscordUtilities;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class Rs3OffhandCommand extends Command {
|
||||
@Override public String name() { return "RS3 Offhand"; }
|
||||
@Override public String description() { return "Searches scape.fashion for rs3 offhand slot items."; }
|
||||
@Override public String usage() { return "rs3offhand <#color or item name>"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.RS3_ITEM_SEARCH; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.NONE); }
|
||||
@Override public List<String> aliases() { return Arrays.asList("rs3offhand", "rs3oh"); }
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(Rs3OffhandCommand.class);
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandContext ctx) {
|
||||
if (ctx.getArgs().length == 0) {
|
||||
ctx.reply("Specify something");
|
||||
return;
|
||||
}
|
||||
|
||||
var args = ctx.getArgs();
|
||||
ScapeFashionConnection conn = new ScapeFashionConnection();
|
||||
var params = Strings.join(Arrays.asList(args), ' ');
|
||||
|
||||
if (Rs3SearchUtilities.isColor(args[0])) {
|
||||
// Color search
|
||||
try {
|
||||
var bestMatch = conn.rs3Color(params, ScapeFashionSlotRs3.OFF_HAND);
|
||||
Rs3SearchUtilities.sendResult(bestMatch, ctx.getChannel());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DiscordUtilities.handleException(e, ctx);
|
||||
}
|
||||
} else {
|
||||
// Item search
|
||||
try {
|
||||
var bestMatch = conn.rs3Item(params, ScapeFashionSlotRs3.OFF_HAND);
|
||||
Rs3SearchUtilities.sendResult(bestMatch, ctx.getChannel());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DiscordUtilities.handleException(e, ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2020. Aleksei Gryczewski
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
package dev.salmonllama.fsbot.commands.rs3search;
|
||||
|
||||
import dev.salmonllama.fsbot.endpoints.scapefashion.ScapeFashionConnection;
|
||||
import dev.salmonllama.fsbot.guthix.*;
|
||||
import dev.salmonllama.fsbot.utilities.DiscordUtilities;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class Rs3SearchCommand extends Command {
|
||||
@Override public String name() { return "RS3 Search"; }
|
||||
@Override public String description() { return "Searches scape.fashion for rs3 items."; }
|
||||
@Override public String usage() { return "rs3search <#color or item name>"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.RS3_ITEM_SEARCH; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.NONE); }
|
||||
@Override public List<String> aliases() { return Collections.singletonList("rs3search"); }
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(Rs3SearchCommand.class);
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandContext ctx) {
|
||||
if (ctx.getArgs().length == 0) {
|
||||
ctx.reply("Specify something");
|
||||
return;
|
||||
}
|
||||
|
||||
var args = ctx.getArgs();
|
||||
ScapeFashionConnection conn = new ScapeFashionConnection();
|
||||
var params = Strings.join(Arrays.asList(args), ' ');
|
||||
|
||||
if (Rs3SearchUtilities.isColor(args[0])) {
|
||||
// Color search
|
||||
try {
|
||||
var bestMatch = conn.rs3Color(params);
|
||||
Rs3SearchUtilities.sendResult(bestMatch, ctx.getChannel());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DiscordUtilities.handleException(e, ctx);
|
||||
}
|
||||
} else {
|
||||
// Item search
|
||||
try {
|
||||
var bestMatch = conn.rs3Item(params);
|
||||
Rs3SearchUtilities.sendResult(bestMatch, ctx.getChannel());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DiscordUtilities.handleException(e, ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2020. Aleksei Gryczewski
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
package dev.salmonllama.fsbot.commands.rs3search;
|
||||
|
||||
import dev.salmonllama.fsbot.endpoints.scapefashion.ScapeFashionResult;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.javacord.api.entity.channel.TextChannel;
|
||||
import org.javacord.api.entity.message.embed.EmbedBuilder;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Rs3SearchUtilities {
|
||||
static boolean isColor(String s) {
|
||||
return s.startsWith("#");
|
||||
}
|
||||
|
||||
static void sendResult(ScapeFashionResult result, TextChannel channel) {
|
||||
var bestMatch = result.getItems().get(0);
|
||||
var colors = Strings.join(Arrays.asList(bestMatch.getColors()), ',');
|
||||
EmbedBuilder embed = new EmbedBuilder()
|
||||
.setTitle(String.format("Best Match - %s", bestMatch.getName()))
|
||||
.setImage(bestMatch.getImages().getDetail())
|
||||
.setAuthor(String.format("Wiki: %s", bestMatch.getName()), bestMatch.getWiki().getLink(), bestMatch.getImages().getDetail())
|
||||
.setUrl(result.getLink())
|
||||
.setColor(Color.decode(bestMatch.getColors()[0]))
|
||||
.addField("Match:", String.valueOf(bestMatch.getMatch()), true)
|
||||
.addField("Colors:", colors, true);
|
||||
|
||||
channel.sendMessage(embed);
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2020. Aleksei Gryczewski
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
package dev.salmonllama.fsbot.commands.rs3search;
|
||||
|
||||
import dev.salmonllama.fsbot.endpoints.scapefashion.ScapeFashionConnection;
|
||||
import dev.salmonllama.fsbot.endpoints.scapefashion.ScapeFashionSlotRs3;
|
||||
import dev.salmonllama.fsbot.guthix.*;
|
||||
import dev.salmonllama.fsbot.utilities.DiscordUtilities;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class Rs3TwohandedCommand extends Command {
|
||||
@Override public String name() { return "RS3 Twohanded"; }
|
||||
@Override public String description() { return "Searches scape.fashion for rs3 twohanded slot items."; }
|
||||
@Override public String usage() { return "rs3twohanded <#color or item name>"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.RS3_ITEM_SEARCH; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.NONE); }
|
||||
@Override public List<String> aliases() { return Arrays.asList("rs3twohanded", "rs32h"); }
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(Rs3TwohandedCommand.class);
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandContext ctx) {
|
||||
if (ctx.getArgs().length == 0) {
|
||||
ctx.reply("Specify something");
|
||||
return;
|
||||
}
|
||||
|
||||
var args = ctx.getArgs();
|
||||
ScapeFashionConnection conn = new ScapeFashionConnection();
|
||||
var params = Strings.join(Arrays.asList(args), ' ');
|
||||
|
||||
if (Rs3SearchUtilities.isColor(args[0])) {
|
||||
// Color search
|
||||
try {
|
||||
var bestMatch = conn.rs3Color(params, ScapeFashionSlotRs3.TWO_HANDED);
|
||||
Rs3SearchUtilities.sendResult(bestMatch, ctx.getChannel());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DiscordUtilities.handleException(e, ctx);
|
||||
}
|
||||
} else {
|
||||
// Item search
|
||||
try {
|
||||
var bestMatch = conn.rs3Item(params, ScapeFashionSlotRs3.TWO_HANDED);
|
||||
Rs3SearchUtilities.sendResult(bestMatch, ctx.getChannel());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DiscordUtilities.handleException(e, ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -8,24 +8,19 @@ package dev.salmonllama.fsbot.commands.staff;
|
||||
import dev.salmonllama.fsbot.config.BotConfig;
|
||||
import dev.salmonllama.fsbot.database.controllers.ColorRoleController;
|
||||
import dev.salmonllama.fsbot.database.models.ColorRole;
|
||||
import dev.salmonllama.fsbot.guthix.Command;
|
||||
import dev.salmonllama.fsbot.guthix.CommandContext;
|
||||
import dev.salmonllama.fsbot.guthix.CommandPermission;
|
||||
import dev.salmonllama.fsbot.guthix.PermissionType;
|
||||
import dev.salmonllama.fsbot.guthix.*;
|
||||
import org.javacord.api.entity.permission.Role;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class AddColorCommand extends Command {
|
||||
@Override public String name() { return "Add Color"; }
|
||||
@Override public String description() { return "adds the provided role to the toggleable cosmetic roles."; }
|
||||
@Override public String usage() { return "addcolor <colorName> <roleId>"; }
|
||||
@Override public String category() { return "Staff"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.STAFF; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.STATIC, "staff"); }
|
||||
@Override public Collection<String> aliases() { return new ArrayList<>(Arrays.asList("addcolor", "addcolour", "addclr")); }
|
||||
@Override public List<String> aliases() { return Arrays.asList("addcolor", "addcolour", "addclr"); }
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandContext ctx) {
|
||||
|
@ -5,23 +5,18 @@
|
||||
|
||||
package dev.salmonllama.fsbot.commands.staff;
|
||||
|
||||
import dev.salmonllama.fsbot.config.BotConfig;
|
||||
import dev.salmonllama.fsbot.guthix.Command;
|
||||
import dev.salmonllama.fsbot.guthix.CommandContext;
|
||||
import dev.salmonllama.fsbot.guthix.CommandPermission;
|
||||
import dev.salmonllama.fsbot.guthix.PermissionType;
|
||||
import dev.salmonllama.fsbot.guthix.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class EchoCommand extends Command {
|
||||
@Override public String name() { return "Echo"; }
|
||||
@Override public String description() { return "Echos your message. Typical bash"; }
|
||||
@Override public String usage() { return "echo <message>"; }
|
||||
@Override public String category() { return "Staff"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.STAFF; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.STATIC, "staff"); }
|
||||
@Override public Collection<String> aliases() { return new ArrayList<>(Collections.singletonList("echo")); }
|
||||
@Override public List<String> aliases() { return Collections.singletonList("echo"); }
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandContext ctx) {
|
||||
|
@ -0,0 +1,98 @@
|
||||
package dev.salmonllama.fsbot.commands.staff;
|
||||
|
||||
import com.vdurmont.emoji.EmojiParser;
|
||||
import dev.salmonllama.fsbot.config.BotConfig;
|
||||
import dev.salmonllama.fsbot.database.controllers.OutfitController;
|
||||
import dev.salmonllama.fsbot.guthix.*;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.javacord.api.entity.message.embed.EmbedBuilder;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class EditMetaCommand extends Command {
|
||||
@Override public String name() { return "Edit Meta"; }
|
||||
@Override public String description() { return "Edit the meta information on the given outfit"; }
|
||||
@Override public String usage() { return "editmeta <String id> <String newMeta>"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.STAFF; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.STATIC, "staff"); }
|
||||
@Override public List<String> aliases() { return Arrays.asList("editmeta", "emeta"); }
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandContext ctx) {
|
||||
var args = ctx.getArgs();
|
||||
var newMeta = Strings.join(Arrays.asList(Arrays.copyOfRange(args, 1, args.length)), ' ');
|
||||
var channel = ctx.getChannel();
|
||||
var authorId = ctx.getUser().getId();
|
||||
|
||||
if (args.length != 1) {
|
||||
channel.sendMessage("You must supply a valid outfit ID.");
|
||||
return;
|
||||
}
|
||||
|
||||
// get the outfit, confirm meta-edit through confirmation
|
||||
String outfitId = args[0];
|
||||
OutfitController.findById(outfitId).thenAcceptAsync(possibleOutfit -> possibleOutfit.ifPresentOrElse(outfit -> {
|
||||
// Send outfit info, react with selectors, add a listener to the message
|
||||
EmbedBuilder embed = new EmbedBuilder()
|
||||
.setTitle("Confirm Meta Edit")
|
||||
.setThumbnail(outfit.getLink())
|
||||
.setAuthor(ctx.getApi().getUserById(outfit.getSubmitter()).join())
|
||||
.setUrl(outfit.getLink())
|
||||
.setFooter(String.format("Tag: %s", outfit.getTag()))
|
||||
.addField("Submitted by:", ctx.getApi().getUserById(outfit.getSubmitter()).join().getDiscriminatedName())
|
||||
.addField("Current Meta", outfit.getMeta())
|
||||
.addField("Proposed Meta", newMeta);
|
||||
|
||||
ctx.reply(embed).thenAcceptAsync(msg -> {
|
||||
msg.addReaction(EmojiParser.parseToUnicode(":white_check_mark:"));
|
||||
msg.addReaction(EmojiParser.parseToUnicode(":octagonal_sign:"));
|
||||
|
||||
msg.addReactionAddListener(event -> {
|
||||
if (event.getUserId() != authorId) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getEmoji().equalsEmoji(EmojiParser.parseToUnicode(":white_check_mark:"))) {
|
||||
// Edit the outfit's meta
|
||||
|
||||
outfit.setMeta(newMeta);
|
||||
OutfitController.update(outfit);
|
||||
|
||||
EmbedBuilder response = new EmbedBuilder()
|
||||
.setTitle("Meta Modification Successful!")
|
||||
.setDescription(String.format("New Meta: %s", outfit.getMeta()));
|
||||
|
||||
msg.delete();
|
||||
ctx.reply(response);
|
||||
|
||||
EmbedBuilder log = new EmbedBuilder()
|
||||
.setTitle("Outfit Meta Changed")
|
||||
.setThumbnail(outfit.getLink())
|
||||
.setColor(Color.YELLOW)
|
||||
.addField("Edited By:", ctx.getAuthor().getDiscriminatedName());
|
||||
|
||||
ctx.getApi().getServerTextChannelById(BotConfig.OUTFIT_LOG).ifPresent(
|
||||
chnl -> chnl.sendMessage(log)
|
||||
);
|
||||
|
||||
} else if (event.getEmoji().equalsEmoji(EmojiParser.parseToUnicode(":octagonal_sign:"))) {
|
||||
// Do nothing
|
||||
EmbedBuilder response = new EmbedBuilder()
|
||||
.setTitle("Meta Modification Aborted")
|
||||
.setDescription(String.format("No modifications were made to %s", outfit.getId()));
|
||||
|
||||
ctx.reply(response);
|
||||
}
|
||||
});
|
||||
});
|
||||
}, () -> {
|
||||
EmbedBuilder response = new EmbedBuilder()
|
||||
.setTitle("Outfit not Found")
|
||||
.setDescription(String.format("ID %s does not exist", outfitId));
|
||||
|
||||
ctx.reply(response);
|
||||
}));
|
||||
}
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (c) 2020. Aleksei Gryczewski
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
package dev.salmonllama.fsbot.commands.staff;
|
||||
|
||||
import dev.salmonllama.fsbot.database.controllers.OutfitController;
|
||||
import dev.salmonllama.fsbot.guthix.*;
|
||||
import dev.salmonllama.fsbot.listeners.ForceDeleteAttachedListener;
|
||||
import org.javacord.api.entity.message.MessageBuilder;
|
||||
import org.javacord.api.entity.message.embed.EmbedBuilder;
|
||||
import org.javacord.api.event.message.MessageCreateEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class ForceDeleteCommand extends Command {
|
||||
@Override public String name() { return "Force Delete"; }
|
||||
@Override public String description() { return "Forcefully deletes the given outfit from the database. Destructive action"; }
|
||||
@Override public String usage() { return "forcedelete <outfit id>"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.STAFF; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.STATIC, "owner"); }
|
||||
@Override public List<String> aliases() { return Arrays.asList("forcedelete", "sudorm"); }
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandContext ctx) {
|
||||
// Send a confirmation, confirming the outfit to delete.
|
||||
// Confirmation will be done via DM for special confirmation of a destructive action.
|
||||
|
||||
if (ctx.getArgs().length == 0) {
|
||||
ctx.reply("You must supply a valid ID");
|
||||
}
|
||||
|
||||
var outfitId = ctx.getArgs()[0];
|
||||
|
||||
MessageBuilder builder = new MessageBuilder();
|
||||
builder.setContent(
|
||||
":warning: THIS IS A DESTRUCTIVE ACTION :warning:\n\n" +
|
||||
"You are about to destroy an entry from the database.\n\n" +
|
||||
"This is unrecoverable, if the entry in question does not\n" +
|
||||
"break Discord, Fashionscape, or FSBot TOS, please consider using\n" +
|
||||
"`~remove` instead.\n\n" +
|
||||
"Verify the entry's information below and respond with `YES` to proceed\n" +
|
||||
"or `NO` to cancel.\n\n" +
|
||||
"*After 5 minutes, the response window will close and you will have to re-run the command*"
|
||||
);
|
||||
|
||||
OutfitController.findById(outfitId).thenAcceptAsync(possibleOutfit -> possibleOutfit.ifPresentOrElse(outfit -> {
|
||||
// DM the user with confirmation message, disclaimer, and info embed
|
||||
// Attach a 5 minute listener looking for YES or NO
|
||||
EmbedBuilder embed = new EmbedBuilder()
|
||||
.setTitle("Outift Information |" + outfit.getId())
|
||||
.setUrl(outfit.getLink())
|
||||
.addField("Submitter:", outfit.getSubmitter())
|
||||
.addField("Meta:", outfit.getMeta())
|
||||
.addField("Link:", outfit.getLink())
|
||||
.addField("Submitted:", outfit.getCreated().toString())
|
||||
.setThumbnail(outfit.getLink())
|
||||
.setFooter(String.format("%s | %s", outfit.getTag(), outfit.getId()));
|
||||
|
||||
builder.setEmbed(embed);
|
||||
|
||||
builder.send(ctx.getChannel()).thenAcceptAsync(msg -> {
|
||||
// Add the event listeners and check for YES/NO
|
||||
var fdal = new ForceDeleteAttachedListener(ctx);
|
||||
ctx.getChannel().addMessageCreateListener(fdal);
|
||||
|
||||
ctx.getChannel().addMessageCreateListener(event -> {
|
||||
if (event.getMessageAuthor().getIdAsString().equals(ctx.getAuthor().getIdAsString())) {
|
||||
// If it's the same user, do the things
|
||||
if (event.getMessageContent().equals("YES")) {
|
||||
// ForceRemove the outfit
|
||||
} else if (event.getMessageContent().equals("NO")) {
|
||||
// Abort the operation. Delete the message.
|
||||
|
||||
} else {
|
||||
ctx.reply("Response must be YES or NO. In caps. Because shouting increases security.");
|
||||
}
|
||||
}
|
||||
}).removeAfter(5, TimeUnit.MINUTES);
|
||||
});
|
||||
}, () -> ctx.reply("An outfit with that ID was not found.")));
|
||||
}
|
||||
}
|
@ -6,22 +6,18 @@
|
||||
package dev.salmonllama.fsbot.commands.staff;
|
||||
|
||||
import dev.salmonllama.fsbot.database.controllers.OutfitController;
|
||||
import dev.salmonllama.fsbot.guthix.Command;
|
||||
import dev.salmonllama.fsbot.guthix.CommandContext;
|
||||
import dev.salmonllama.fsbot.guthix.CommandPermission;
|
||||
import dev.salmonllama.fsbot.guthix.PermissionType;
|
||||
import dev.salmonllama.fsbot.guthix.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class GetOutfitCommand extends Command { // TODO: This command also needs HELP
|
||||
public class GetOutfitCommand extends Command {
|
||||
@Override public String name() { return "Get Outift"; }
|
||||
@Override public String description() { return "Shows the outfit, given an ID"; }
|
||||
@Override public String usage() { return "getoutfit <String id>"; }
|
||||
@Override public String category() { return "Staff"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.STAFF; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.STATIC, "staff"); }
|
||||
@Override public Collection<String> aliases() { return new ArrayList<>(Arrays.asList("getoutfit", "get")); }
|
||||
@Override public List<String> aliases() { return Arrays.asList("getoutfit", "get"); }
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandContext ctx) {
|
||||
@ -29,11 +25,9 @@ public class GetOutfitCommand extends Command { // TODO: This command also needs
|
||||
String[] args = ctx.getArgs();
|
||||
|
||||
String id = args[0];
|
||||
OutfitController.findById(id).thenAccept(outfitOpt -> {
|
||||
outfitOpt.ifPresentOrElse(
|
||||
outfit -> ctx.reply(outfit.toString()),
|
||||
() -> ctx.reply("Outfit not found, did you get the id right?")
|
||||
);
|
||||
});
|
||||
OutfitController.findById(id).thenAccept(outfitOpt -> outfitOpt.ifPresentOrElse(
|
||||
outfit -> ctx.reply(outfit.toString()),
|
||||
() -> ctx.reply("Outfit not found, did you get the id right?")
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -5,27 +5,22 @@
|
||||
|
||||
package dev.salmonllama.fsbot.commands.staff;
|
||||
|
||||
import dev.salmonllama.fsbot.config.BotConfig;
|
||||
import dev.salmonllama.fsbot.guthix.Command;
|
||||
import dev.salmonllama.fsbot.guthix.CommandContext;
|
||||
import dev.salmonllama.fsbot.guthix.CommandPermission;
|
||||
import dev.salmonllama.fsbot.guthix.PermissionType;
|
||||
import dev.salmonllama.fsbot.guthix.*;
|
||||
import org.javacord.api.DiscordApi;
|
||||
import org.javacord.api.entity.message.embed.EmbedBuilder;
|
||||
import org.javacord.api.entity.server.Server;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class GetServersCommand extends Command {
|
||||
@Override public String name() { return "Get Servers"; }
|
||||
@Override public String description() { return "Lists all the servers the bot is in"; }
|
||||
@Override public String usage() { return "getservers"; }
|
||||
@Override public String category() { return "Staff"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.STAFF; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.STATIC, "staff"); }
|
||||
@Override public Collection<String> aliases() { return new ArrayList<>(Arrays.asList("getservers", "servers")); }
|
||||
@Override public List<String> aliases() { return Arrays.asList("getservers", "servers"); }
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandContext ctx) {
|
||||
|
@ -5,25 +5,20 @@
|
||||
|
||||
package dev.salmonllama.fsbot.commands.staff;
|
||||
|
||||
import dev.salmonllama.fsbot.config.BotConfig;
|
||||
import dev.salmonllama.fsbot.database.controllers.OutfitController;
|
||||
import dev.salmonllama.fsbot.guthix.Command;
|
||||
import dev.salmonllama.fsbot.guthix.CommandContext;
|
||||
import dev.salmonllama.fsbot.guthix.CommandPermission;
|
||||
import dev.salmonllama.fsbot.guthix.PermissionType;
|
||||
import dev.salmonllama.fsbot.guthix.*;
|
||||
import org.javacord.api.entity.message.embed.EmbedBuilder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class OutfitInfoCommand extends Command {
|
||||
@Override public String name() { return "Outfit Info"; }
|
||||
@Override public String description() { return "Shows all related info about the outfit"; }
|
||||
@Override public String usage() { return "outfitinfo <String id>"; }
|
||||
@Override public String category() { return "Staff"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.STAFF; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.STATIC, "staff"); }
|
||||
@Override public Collection<String> aliases() { return new ArrayList<>(Arrays.asList("outfitinfo", "oinfo")); }
|
||||
@Override public List<String> aliases() { return Arrays.asList("outfitinfo", "oinfo"); }
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandContext ctx) {
|
||||
@ -35,23 +30,19 @@ public class OutfitInfoCommand extends Command {
|
||||
}
|
||||
|
||||
String id = args[0];
|
||||
OutfitController.findById(id).thenAcceptAsync(possibleOutfit -> {
|
||||
possibleOutfit.ifPresentOrElse(outfit -> {
|
||||
EmbedBuilder embed = new EmbedBuilder()
|
||||
.setTitle("Outfit Info")
|
||||
.setThumbnail(outfit.getLink())
|
||||
.setAuthor(ctx.getApi().getYourself())
|
||||
.setUrl(outfit.getLink())
|
||||
.setFooter(String.format("Tag: %s", outfit.getTag()))
|
||||
.addField("Added", outfit.getCreated().toString(), true)
|
||||
.addField("Updated", outfit.getUpdated().toString(), true)
|
||||
.addField("Submitted by:", ctx.getApi().getUserById(outfit.getSubmitter()).join().getDiscriminatedName())
|
||||
.addField("Deleted", outfit.isDeleted() ? "True" : "False", true)
|
||||
.addField("Featured", outfit.isFeatured() ? "True" : "False", true);
|
||||
ctx.reply(embed);
|
||||
}, () -> {
|
||||
ctx.reply("Outfit not found");
|
||||
});
|
||||
});
|
||||
OutfitController.findById(id).thenAcceptAsync(possibleOutfit -> possibleOutfit.ifPresentOrElse(outfit -> {
|
||||
EmbedBuilder embed = new EmbedBuilder()
|
||||
.setTitle("Outfit Info")
|
||||
.setThumbnail(outfit.getLink())
|
||||
.setAuthor(ctx.getApi().getYourself())
|
||||
.setUrl(outfit.getLink())
|
||||
.setFooter(String.format("Tag: %s", outfit.getTag()))
|
||||
.addField("Added", outfit.getCreated().toString(), true)
|
||||
.addField("Updated", outfit.getUpdated().toString(), true)
|
||||
.addField("Submitted by:", ctx.getApi().getUserById(outfit.getSubmitter()).join().getDiscriminatedName())
|
||||
.addField("Deleted", outfit.isDeleted() ? "True" : "False", true)
|
||||
.addField("Featured", outfit.isFeatured() ? "True" : "False", true);
|
||||
ctx.reply(embed);
|
||||
}, () -> ctx.reply("Outfit not found")));
|
||||
}
|
||||
}
|
||||
|
@ -8,24 +8,21 @@ package dev.salmonllama.fsbot.commands.staff;
|
||||
import com.vdurmont.emoji.EmojiParser;
|
||||
import dev.salmonllama.fsbot.config.BotConfig;
|
||||
import dev.salmonllama.fsbot.database.controllers.OutfitController;
|
||||
import dev.salmonllama.fsbot.guthix.Command;
|
||||
import dev.salmonllama.fsbot.guthix.CommandContext;
|
||||
import dev.salmonllama.fsbot.guthix.CommandPermission;
|
||||
import dev.salmonllama.fsbot.guthix.PermissionType;
|
||||
import dev.salmonllama.fsbot.guthix.*;
|
||||
import org.javacord.api.entity.channel.TextChannel;
|
||||
import org.javacord.api.entity.message.embed.EmbedBuilder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.awt.Color;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class RemoveOutfitCommand extends Command {
|
||||
@Override public String name() { return "Remove Outfit"; }
|
||||
@Override public String description() { return "Removes an outfit from the database given an id"; }
|
||||
@Override public String usage() { return "remove <String id>"; }
|
||||
@Override public String category() { return "Staff"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.STAFF; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.STATIC, "staff"); }
|
||||
@Override public Collection<String> aliases() { return new ArrayList<>(Arrays.asList("removeoutfit", "remove")); }
|
||||
@Override public List<String> aliases() { return Arrays.asList("removeoutfit", "remove"); }
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandContext ctx) {
|
||||
@ -40,67 +37,66 @@ public class RemoveOutfitCommand extends Command {
|
||||
|
||||
// get the outfit, confirm deletion through reaction.
|
||||
String outfitId = args[0];
|
||||
OutfitController.findById(outfitId).thenAcceptAsync(possibleOutfit -> {
|
||||
possibleOutfit.ifPresentOrElse(outfit -> {
|
||||
// Send outfit info, react with selectors, add a listener to the message
|
||||
EmbedBuilder embed = new EmbedBuilder()
|
||||
.setTitle("Confirm Outfit Deletion")
|
||||
.setThumbnail(outfit.getLink())
|
||||
.setAuthor(ctx.getApi().getUserById(outfit.getSubmitter()).join())
|
||||
.setUrl(outfit.getLink())
|
||||
.setFooter(String.format("Tag: %s", outfit.getTag()))
|
||||
.addField("Added", outfit.getCreated().toString(), true)
|
||||
.addField("Updated", outfit.getUpdated().toString(), true)
|
||||
.addField("Submitted by:", ctx.getApi().getUserById(outfit.getSubmitter()).join().getDiscriminatedName())
|
||||
.addField("Deleted", outfit.isDeleted() ? "True" : "False", true)
|
||||
.addField("Featured", outfit.isFeatured() ? "True" : "False", true);
|
||||
OutfitController.findById(outfitId).thenAcceptAsync(possibleOutfit -> possibleOutfit.ifPresentOrElse(outfit -> {
|
||||
// Send outfit info, react with selectors, add a listener to the message
|
||||
EmbedBuilder embed = new EmbedBuilder()
|
||||
.setTitle("Confirm Outfit Deletion")
|
||||
.setThumbnail(outfit.getLink())
|
||||
.setAuthor(ctx.getApi().getUserById(outfit.getSubmitter()).join())
|
||||
.setUrl(outfit.getLink())
|
||||
.setFooter(String.format("Tag: %s", outfit.getTag()))
|
||||
.addField("Added", outfit.getCreated().toString(), true)
|
||||
.addField("Updated", outfit.getUpdated().toString(), true)
|
||||
.addField("Submitted by:", ctx.getApi().getUserById(outfit.getSubmitter()).join().getDiscriminatedName())
|
||||
.addField("Deleted", outfit.isDeleted() ? "True" : "False", true)
|
||||
.addField("Featured", outfit.isFeatured() ? "True" : "False", true);
|
||||
|
||||
ctx.reply(embed).thenAcceptAsync(msg -> {
|
||||
msg.addReaction(EmojiParser.parseToUnicode(":white_check_mark:"));
|
||||
msg.addReaction(EmojiParser.parseToUnicode(":octagonal_sign:"));
|
||||
ctx.reply(embed).thenAcceptAsync(msg -> {
|
||||
msg.addReaction(EmojiParser.parseToUnicode(":white_check_mark:"));
|
||||
msg.addReaction(EmojiParser.parseToUnicode(":octagonal_sign:"));
|
||||
|
||||
msg.addReactionAddListener(event -> {
|
||||
if (event.getUser().getId() != authorId) {
|
||||
return;
|
||||
}
|
||||
msg.addReactionAddListener(event -> {
|
||||
if (event.getUserId() != authorId) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getEmoji().equalsEmoji(EmojiParser.parseToUnicode(":white_check_mark:"))) {
|
||||
// Delete the outfit
|
||||
OutfitController.delete(outfit.getId());
|
||||
if (event.getEmoji().equalsEmoji(EmojiParser.parseToUnicode(":white_check_mark:"))) {
|
||||
// Delete the outfit
|
||||
OutfitController.delete(outfit.getId());
|
||||
|
||||
EmbedBuilder response = new EmbedBuilder()
|
||||
.setTitle("Deletion Successful!")
|
||||
.setDescription(String.format("Outfit %s marked as deleted", outfit.getId()));
|
||||
EmbedBuilder response = new EmbedBuilder()
|
||||
.setTitle("Deletion Successful!")
|
||||
.setDescription(String.format("Outfit %s marked as deleted", outfit.getId()));
|
||||
|
||||
msg.delete();
|
||||
ctx.reply(response);
|
||||
msg.delete();
|
||||
ctx.reply(response);
|
||||
|
||||
EmbedBuilder log = new EmbedBuilder()
|
||||
.setTitle("Outfit Marked as Deleted")
|
||||
.setThumbnail(outfit.getLink())
|
||||
.addField("Deleted By:", ctx.getAuthor().getDiscriminatedName());
|
||||
EmbedBuilder log = new EmbedBuilder()
|
||||
.setTitle("Outfit Marked as Deleted")
|
||||
.setThumbnail(outfit.getLink())
|
||||
.setColor(Color.RED)
|
||||
.addField("Deleted By:", ctx.getAuthor().getDiscriminatedName());
|
||||
|
||||
ctx.getApi().getServerTextChannelById(BotConfig.OUTFIT_LOG).ifPresent(chnl -> {
|
||||
chnl.sendMessage(log);
|
||||
});
|
||||
ctx.getApi().getServerTextChannelById(BotConfig.OUTFIT_LOG).ifPresent(
|
||||
chnl -> chnl.sendMessage(log)
|
||||
);
|
||||
|
||||
} else if (event.getEmoji().equalsEmoji(EmojiParser.parseToUnicode(":octagonal_sign:"))) {
|
||||
// Do nothing
|
||||
EmbedBuilder response = new EmbedBuilder()
|
||||
.setTitle("Deletion Aborted")
|
||||
.setDescription(String.format("No modifications were made to %s", outfit.getId()));
|
||||
} else if (event.getEmoji().equalsEmoji(EmojiParser.parseToUnicode(":octagonal_sign:"))) {
|
||||
// Do nothing
|
||||
EmbedBuilder response = new EmbedBuilder()
|
||||
.setTitle("Deletion Aborted")
|
||||
.setDescription(String.format("No modifications were made to %s", outfit.getId()));
|
||||
|
||||
ctx.reply(response);
|
||||
}
|
||||
});
|
||||
});
|
||||
}, () -> {
|
||||
EmbedBuilder response = new EmbedBuilder()
|
||||
.setTitle("Outfit not Found")
|
||||
.setDescription(String.format("ID %s does not exist", outfitId));
|
||||
ctx.reply(response);
|
||||
}
|
||||
});
|
||||
});
|
||||
}, () -> {
|
||||
EmbedBuilder response = new EmbedBuilder()
|
||||
.setTitle("Outfit not Found")
|
||||
.setDescription(String.format("ID %s does not exist", outfitId));
|
||||
|
||||
ctx.reply(response);
|
||||
});
|
||||
});
|
||||
ctx.reply(response);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
@ -9,26 +9,22 @@ import com.vdurmont.emoji.EmojiParser;
|
||||
import dev.salmonllama.fsbot.config.BotConfig;
|
||||
import dev.salmonllama.fsbot.database.controllers.OutfitController;
|
||||
import dev.salmonllama.fsbot.database.models.Outfit;
|
||||
import dev.salmonllama.fsbot.guthix.Command;
|
||||
import dev.salmonllama.fsbot.guthix.CommandContext;
|
||||
import dev.salmonllama.fsbot.guthix.CommandPermission;
|
||||
import dev.salmonllama.fsbot.guthix.PermissionType;
|
||||
import dev.salmonllama.fsbot.guthix.*;
|
||||
import org.javacord.api.entity.channel.TextChannel;
|
||||
import org.javacord.api.entity.message.embed.EmbedBuilder;
|
||||
|
||||
import java.awt.*;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class RetagCommand extends Command {
|
||||
@Override public String name() { return "Retag"; }
|
||||
@Override public String description() { return "Changes the tag of the given outfit"; }
|
||||
@Override public String usage() { return "retag <String id> <String newtag>"; }
|
||||
@Override public String category() { return "Staff"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.STAFF; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.STATIC, "staff"); }
|
||||
@Override public Collection<String> aliases() { return new ArrayList<>(Collections.singletonList("retag")); }
|
||||
@Override public List<String> aliases() { return Collections.singletonList("retag"); }
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandContext ctx) {
|
||||
@ -45,71 +41,70 @@ public class RetagCommand extends Command {
|
||||
String outfitId = args[0];
|
||||
String newTag = args[1];
|
||||
|
||||
OutfitController.findById(outfitId).thenAcceptAsync(possibleOutfit -> {
|
||||
possibleOutfit.ifPresentOrElse(outfit -> {
|
||||
// Send info, confirmation, and add reaction listener
|
||||
EmbedBuilder response = new EmbedBuilder()
|
||||
.setTitle("Confirm Tag Edit")
|
||||
.setThumbnail(outfit.getLink())
|
||||
.setAuthor(ctx.getApi().getUserById(outfit.getSubmitter()).join())
|
||||
.setUrl(outfit.getLink())
|
||||
.addField("Current Tag:", outfit.getTag())
|
||||
.addField("New Tag:", newTag);
|
||||
OutfitController.findById(outfitId).thenAcceptAsync(possibleOutfit -> possibleOutfit.ifPresentOrElse(outfit -> {
|
||||
// Send info, confirmation, and add reaction listener
|
||||
EmbedBuilder response = new EmbedBuilder()
|
||||
.setTitle("Confirm Tag Edit")
|
||||
.setThumbnail(outfit.getLink())
|
||||
.setAuthor(ctx.getApi().getUserById(outfit.getSubmitter()).join())
|
||||
.setUrl(outfit.getLink())
|
||||
.addField("Current Tag:", outfit.getTag())
|
||||
.addField("New Tag:", newTag);
|
||||
|
||||
ctx.reply(response).thenAcceptAsync(msg -> {
|
||||
msg.addReaction(EmojiParser.parseToUnicode(":white_check_mark:"));
|
||||
msg.addReaction(EmojiParser.parseToUnicode(":octagonal_sign:"));
|
||||
ctx.reply(response).thenAcceptAsync(msg -> {
|
||||
msg.addReaction(EmojiParser.parseToUnicode(":white_check_mark:"));
|
||||
msg.addReaction(EmojiParser.parseToUnicode(":octagonal_sign:"));
|
||||
|
||||
msg.addReactionAddListener(event -> {
|
||||
if (event.getUser().getId() != authorId) {
|
||||
return;
|
||||
}
|
||||
msg.addReactionAddListener(event -> {
|
||||
if (event.getUserId() != authorId) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getEmoji().equalsEmoji(EmojiParser.parseToUnicode(":white_check_mark:"))) {
|
||||
// Update the outfit
|
||||
Outfit newOutfit = new Outfit.OutfitBuilder(outfit)
|
||||
.setTag(newTag)
|
||||
.setUpdated(new Timestamp(System.currentTimeMillis()))
|
||||
.build();
|
||||
if (event.getEmoji().equalsEmoji(EmojiParser.parseToUnicode(":white_check_mark:"))) {
|
||||
// Update the outfit
|
||||
Outfit newOutfit = new Outfit.OutfitBuilder(outfit)
|
||||
.setTag(newTag)
|
||||
.setUpdated(new Timestamp(System.currentTimeMillis()))
|
||||
.build();
|
||||
|
||||
OutfitController.update(newOutfit).thenAcceptAsync((Void) -> {
|
||||
EmbedBuilder embed = new EmbedBuilder()
|
||||
.setTitle("Outfit retagged successfully!")
|
||||
.setDescription(String.format("Outfit %s will now display as %s", newOutfit.getId(), newOutfit.getTag()));
|
||||
|
||||
msg.delete();
|
||||
ctx.reply(embed);
|
||||
|
||||
EmbedBuilder log = new EmbedBuilder()
|
||||
.setTitle("Outfit Retagged")
|
||||
.setThumbnail(outfit.getLink())
|
||||
.addField("New tag:", newTag);
|
||||
|
||||
ctx.getApi().getServerTextChannelById(BotConfig.OUTFIT_LOG).ifPresent(chnl -> {
|
||||
chnl.sendMessage(log);
|
||||
});
|
||||
});
|
||||
|
||||
} else if (event.getEmoji().equalsEmoji(EmojiParser.parseToUnicode(":octagonal_sign:"))) {
|
||||
// Do nothing
|
||||
msg.delete();
|
||||
OutfitController.update(newOutfit).thenAcceptAsync((Void) -> {
|
||||
EmbedBuilder embed = new EmbedBuilder()
|
||||
.setTitle("Update Cancelled")
|
||||
.setDescription("No modifications were made");
|
||||
.setTitle("Outfit retagged successfully!")
|
||||
.setDescription(String.format("Outfit %s will now display as %s", newOutfit.getId(), newOutfit.getTag()));
|
||||
|
||||
msg.delete();
|
||||
ctx.reply(embed);
|
||||
}
|
||||
});
|
||||
});
|
||||
}, () -> {
|
||||
// Err, outfit not found
|
||||
EmbedBuilder response = new EmbedBuilder()
|
||||
.setTitle("Error occurred")
|
||||
.setDescription("That ID was not found in the database")
|
||||
.setColor(Color.RED);
|
||||
|
||||
ctx.reply(response);
|
||||
EmbedBuilder log = new EmbedBuilder()
|
||||
.setTitle("Outfit Retagged")
|
||||
.setColor(Color.YELLOW)
|
||||
.setThumbnail(outfit.getLink())
|
||||
.addField("New tag:", newTag);
|
||||
|
||||
ctx.getApi().getServerTextChannelById(BotConfig.OUTFIT_LOG).ifPresent(
|
||||
chnl -> chnl.sendMessage(log)
|
||||
);
|
||||
});
|
||||
|
||||
} else if (event.getEmoji().equalsEmoji(EmojiParser.parseToUnicode(":octagonal_sign:"))) {
|
||||
// Do nothing
|
||||
msg.delete();
|
||||
EmbedBuilder embed = new EmbedBuilder()
|
||||
.setTitle("Update Cancelled")
|
||||
.setDescription("No modifications were made");
|
||||
|
||||
ctx.reply(embed);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}, () -> {
|
||||
// Err, outfit not found
|
||||
EmbedBuilder response = new EmbedBuilder()
|
||||
.setTitle("Error occurred")
|
||||
.setDescription("That ID was not found in the database")
|
||||
.setColor(Color.RED);
|
||||
|
||||
ctx.reply(response);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
@ -6,25 +6,22 @@
|
||||
package dev.salmonllama.fsbot.commands.staff;
|
||||
|
||||
import com.vdurmont.emoji.EmojiParser;
|
||||
import dev.salmonllama.fsbot.config.BotConfig;
|
||||
import dev.salmonllama.fsbot.guthix.Command;
|
||||
import dev.salmonllama.fsbot.guthix.CommandContext;
|
||||
import dev.salmonllama.fsbot.guthix.CommandPermission;
|
||||
import dev.salmonllama.fsbot.guthix.PermissionType;
|
||||
import dev.salmonllama.fsbot.guthix.*;
|
||||
import org.javacord.api.entity.message.embed.EmbedBuilder;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class SetStatusCommand extends Command {
|
||||
@Override public String name() { return "Set Status"; }
|
||||
@Override public String description() { return "Updates the bot's current status"; }
|
||||
@Override public String usage() { return "updatestatus <String status>"; }
|
||||
@Override public String category() { return "Staff"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.STAFF; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.STATIC, "staff"); }
|
||||
@Override public Collection<String> aliases() { return new ArrayList<>(Arrays.asList("setstatus", "status")); }
|
||||
@Override public List<String> aliases() { return Arrays.asList("setstatus", "status"); }
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandContext ctx) {
|
||||
|
@ -8,24 +8,20 @@ package dev.salmonllama.fsbot.commands.staff;
|
||||
import dev.salmonllama.fsbot.config.BotConfig;
|
||||
import dev.salmonllama.fsbot.database.controllers.ServerConfigController;
|
||||
import dev.salmonllama.fsbot.database.models.ServerConfig;
|
||||
import dev.salmonllama.fsbot.guthix.Command;
|
||||
import dev.salmonllama.fsbot.guthix.CommandContext;
|
||||
import dev.salmonllama.fsbot.guthix.CommandPermission;
|
||||
import dev.salmonllama.fsbot.guthix.PermissionType;
|
||||
import dev.salmonllama.fsbot.guthix.*;
|
||||
import org.javacord.api.entity.message.embed.EmbedBuilder;
|
||||
import org.javacord.api.util.logging.ExceptionLogger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class WelcomeMessageCommand extends Command {
|
||||
@Override public String name() { return "Welcome Message"; }
|
||||
@Override public String description() { return "View or update the server welcome message. Options: get|set|getchannel|setchannel."; }
|
||||
@Override public String usage() { return "welcomemessage <String opt> [String newMessage]"; }
|
||||
@Override public String category() { return "Staff"; }
|
||||
@Override public CommandCategory category() { return CommandCategory.STAFF; }
|
||||
@Override public CommandPermission permission() { return new CommandPermission(PermissionType.STATIC, "staff"); }
|
||||
@Override public Collection<String> aliases() { return new ArrayList<>(Arrays.asList("welcomemessage", "wmsg")); }
|
||||
@Override public List<String> aliases() { return Arrays.asList("welcomemessage", "wmsg"); }
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandContext ctx) {
|
||||
|
@ -63,6 +63,9 @@ public class BotConfig {
|
||||
@ConfigurationOption
|
||||
public static String HYDRIX_ROLE = "hydrix role id here";
|
||||
|
||||
@ConfigurationOption
|
||||
public static String MEMBER_ROLE = "member role id here";
|
||||
|
||||
@ConfigurationOption
|
||||
public static String IMGUR_ID = "imgur_id_here";
|
||||
|
||||
|
@ -13,6 +13,7 @@ import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CompletionException;
|
||||
@ -159,7 +160,7 @@ public class OutfitController {
|
||||
});
|
||||
}
|
||||
|
||||
public static CompletableFuture<Collection<String>> getDistinctTags() {
|
||||
public static CompletableFuture<List<String>> getDistinctTags() {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
try {
|
||||
return getDistinctTagsExec();
|
||||
@ -199,6 +200,16 @@ public class OutfitController {
|
||||
});
|
||||
}
|
||||
|
||||
public static CompletableFuture<Void> forceRemove(String id) {
|
||||
return CompletableFuture.runAsync(() -> {
|
||||
try {
|
||||
forceRemoveExec(id);
|
||||
} catch (SQLException e) {
|
||||
throw new CompletionException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void insertExec(Outfit outfit) throws SQLException {
|
||||
if (outfit.getCreated() == null) {
|
||||
outfit.setCreated(new Timestamp(System.currentTimeMillis()));
|
||||
@ -332,10 +343,10 @@ public class OutfitController {
|
||||
return extractCount(rs);
|
||||
}
|
||||
|
||||
private static Collection<String> getDistinctTagsExec() throws SQLException {
|
||||
private static List<String> getDistinctTagsExec() throws SQLException {
|
||||
ResultSet rs = FSDB.get().select("SELECT DISTINCT tag FROM outfits");
|
||||
|
||||
Collection<String> tags = new ArrayList<>();
|
||||
List<String> tags = new ArrayList<>();
|
||||
while (rs.next()) {
|
||||
tags.add(rs.getString("tag"));
|
||||
}
|
||||
@ -368,6 +379,10 @@ public class OutfitController {
|
||||
FSDB.get().query("UPDATE outfits SET deleted = true WHERE id = ?", id);
|
||||
}
|
||||
|
||||
private static void forceRemoveExec(String id) throws SQLException {
|
||||
FSDB.get().query("DELETE FROM outfits WHERE id = ?", id);
|
||||
}
|
||||
|
||||
private static Optional<Collection<Outfit>> extractMultiple(ResultSet rs) throws SQLException {
|
||||
Collection<Outfit> outfits = new ArrayList<>();
|
||||
|
||||
|
@ -56,6 +56,10 @@ public class Outfit extends DatabaseModel {
|
||||
return meta;
|
||||
}
|
||||
|
||||
public void setMeta(String meta) {
|
||||
this.meta = meta;
|
||||
}
|
||||
|
||||
public Timestamp getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
@ -0,0 +1,137 @@
|
||||
/*
|
||||
* Copyright (c) 2020. Aleksei Gryczewski
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
package dev.salmonllama.fsbot.endpoints.scapefashion;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URI;
|
||||
import java.net.URLEncoder;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class ScapeFashionConnection {
|
||||
private final String RS3_REQUEST_URL = "https://api.rune.scape.fashion";
|
||||
private final String RS3_LINK_URL = "https://rune.scape.fashion";
|
||||
|
||||
private final String OSRS_REQUEST_URL = "https://api.scape.fashion";
|
||||
private final String OSRS_LINK_URL = "https://scape.fashion";
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ScapeFashionConnection.class);
|
||||
|
||||
public ScapeFashionConnection() {}
|
||||
|
||||
// Uses the color endpoint to search for items
|
||||
// Returns an object with a list of the top results, and a link redirect to see full list
|
||||
public ScapeFashionResult osrsColor(String color) throws Exception {
|
||||
String uri = OSRS_REQUEST_URL + "/colors/" + encode(color);
|
||||
String link = OSRS_LINK_URL + "/colors/" + encode(color);
|
||||
|
||||
var response = makeRequest(uri);
|
||||
response.setLink(link);
|
||||
return response;
|
||||
}
|
||||
|
||||
public ScapeFashionResult osrsColor(String color, ScapeFashionSlotOsrs slot) throws Exception {
|
||||
String uri = OSRS_REQUEST_URL + "/colors/" + encode(color) + "?slot=" + encode(slot.getValue());
|
||||
String link = OSRS_LINK_URL + "/colors/" + encode(color) + "?slot=" + encode(slot.getValue());
|
||||
|
||||
var response = makeRequest(uri);
|
||||
response.setLink(link);
|
||||
return response;
|
||||
}
|
||||
|
||||
public ScapeFashionResult osrsItem(String item) throws Exception {
|
||||
String uri = OSRS_REQUEST_URL + "/items/" + encode(item);
|
||||
String link = OSRS_LINK_URL + "/items/" + encode(item);
|
||||
|
||||
var response = makeRequest(uri);
|
||||
response.setLink(link);
|
||||
if (response.getItems().get(0).getName().toLowerCase().equals(item.toLowerCase())) {
|
||||
response.getItems().remove(0);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
public ScapeFashionResult osrsItem(String item, ScapeFashionSlotOsrs slot) throws Exception {
|
||||
String uri = OSRS_REQUEST_URL + "/items/" + encode(item) + "?slot=" + encode(slot.getValue());
|
||||
String link = OSRS_LINK_URL + "/items/" + encode(item) + "?slot=" + encode(slot.getValue());
|
||||
|
||||
var response = makeRequest(uri);
|
||||
response.setLink(link);
|
||||
if (response.getItems().get(0).getName().toLowerCase().equals(item.toLowerCase())) {
|
||||
response.getItems().remove(0);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
public ScapeFashionResult rs3Color(String color) throws Exception {
|
||||
String uri = RS3_REQUEST_URL + "/colors/" + encode(color);
|
||||
String link = RS3_LINK_URL + "/colors/" + encode(color);
|
||||
|
||||
var response = makeRequest(uri);
|
||||
response.setLink(link);
|
||||
return response;
|
||||
}
|
||||
|
||||
public ScapeFashionResult rs3Color(String color, ScapeFashionSlotRs3 slot) throws Exception {
|
||||
String uri = RS3_REQUEST_URL + "/colors/" + encode(color) + "?slot=" + encode(slot.getValue());
|
||||
String link = RS3_LINK_URL + "/colors/" + encode(color) + "?slot=" + encode(slot.getValue());
|
||||
|
||||
var response = makeRequest(uri);
|
||||
response.setLink(link);
|
||||
return response;
|
||||
}
|
||||
|
||||
public ScapeFashionResult rs3Item(String item) throws Exception {
|
||||
String uri = RS3_REQUEST_URL + "/items/" + encode(item);
|
||||
String link = RS3_LINK_URL + "/items/" + encode(item);
|
||||
|
||||
var response = makeRequest(uri);
|
||||
response.setLink(link);
|
||||
if (response.getItems().get(0).getName().toLowerCase().equals(item.toLowerCase())) {
|
||||
response.getItems().remove(0);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
public ScapeFashionResult rs3Item(String item, ScapeFashionSlotRs3 slot) throws Exception {
|
||||
String uri = RS3_REQUEST_URL + "/items/" + encode(item) + "?slot=" + encode(slot.getValue());
|
||||
String link = RS3_LINK_URL + "/items/" + encode(item) + "?slot=" + encode(slot.getValue());
|
||||
|
||||
var response = makeRequest(uri);
|
||||
response.setLink(link);
|
||||
if (response.getItems().get(0).getName().toLowerCase().equals(item.toLowerCase())) {
|
||||
response.getItems().remove(0);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
private ScapeFashionResult makeRequest(String url) throws Exception {
|
||||
var client = HttpClient.newBuilder().version(HttpClient.Version.HTTP_2).build();
|
||||
|
||||
String USER_AGENT = "Fashionscape-Bot github.com/salmonllama/fashionscape-bot";
|
||||
|
||||
HttpRequest request = HttpRequest.newBuilder(URI.create(url))
|
||||
.header("Content-Type", "application/json")
|
||||
.header("User-Agent", USER_AGENT)
|
||||
.GET()
|
||||
.build();
|
||||
|
||||
Gson gson = new Gson();
|
||||
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
|
||||
var json = response.body();
|
||||
return gson.fromJson(json, ScapeFashionResult.class);
|
||||
}
|
||||
|
||||
private String encode(String value) throws UnsupportedEncodingException {
|
||||
return URLEncoder.encode(value, StandardCharsets.UTF_8.toString()).replace("+", "%20");
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package dev.salmonllama.fsbot.endpoints.scapefashion;
|
||||
|
||||
public class ScapeFashionImages {
|
||||
private String detail;
|
||||
|
||||
public ScapeFashionImages() {
|
||||
|
||||
}
|
||||
|
||||
public String getDetail() {
|
||||
return detail;
|
||||
}
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright (c) 2020. Aleksei Gryczewski
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
package dev.salmonllama.fsbot.endpoints.scapefashion;
|
||||
|
||||
public class ScapeFashionItem {
|
||||
private final ScapeFashionImages images;
|
||||
private final String name;
|
||||
private final String slot;
|
||||
private final ScapeFashionWiki wiki;
|
||||
private final String[] colors;
|
||||
private final float match;
|
||||
|
||||
private ScapeFashionItem(Builder builder) {
|
||||
this.images = builder.images;
|
||||
this.name = builder.name;
|
||||
this.slot = builder.slot;
|
||||
this.wiki = builder.wiki;
|
||||
this.colors = builder.colors;
|
||||
this.match = builder.match;
|
||||
}
|
||||
|
||||
public ScapeFashionImages getImages() {
|
||||
return images;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getSlot() {
|
||||
return slot;
|
||||
}
|
||||
|
||||
public ScapeFashionWiki getWiki() {
|
||||
return wiki;
|
||||
}
|
||||
|
||||
public String[] getColors() {
|
||||
return colors;
|
||||
}
|
||||
|
||||
public float getMatch() {
|
||||
return match;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("Item: [%s]", name);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private ScapeFashionImages images;
|
||||
private String name;
|
||||
private String slot;
|
||||
private ScapeFashionWiki wiki;
|
||||
private String[] colors;
|
||||
private float match;
|
||||
|
||||
public Builder() {
|
||||
|
||||
}
|
||||
|
||||
public Builder setImages(ScapeFashionImages images) {
|
||||
this.images = images;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setSlot(String slot) {
|
||||
this.slot = slot;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setWiki(ScapeFashionWiki wiki) {
|
||||
this.wiki = wiki;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setColors(String[] colors) {
|
||||
this.colors = colors;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setMatch(float match) {
|
||||
this.match = match;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ScapeFashionItem build() {
|
||||
return new ScapeFashionItem(this);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2020. Aleksei Gryczewski
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
package dev.salmonllama.fsbot.endpoints.scapefashion;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ScapeFashionResult {
|
||||
private String link;
|
||||
@SerializedName("items")
|
||||
private final List<ScapeFashionItem> items = new ArrayList<>();
|
||||
|
||||
public ScapeFashionResult() {
|
||||
|
||||
}
|
||||
|
||||
public ScapeFashionResult(String link) {
|
||||
this.link = link;
|
||||
}
|
||||
|
||||
public ScapeFashionResult addItem(ScapeFashionItem item) {
|
||||
this.items.add(item);
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setLink(String link) {
|
||||
this.link = link;
|
||||
}
|
||||
|
||||
public String getLink() {
|
||||
return link;
|
||||
}
|
||||
|
||||
public List<ScapeFashionItem> getItems() {
|
||||
return items;
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2020. Aleksei Gryczewski
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
package dev.salmonllama.fsbot.endpoints.scapefashion;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
// Source: https://github.com/ncpierson/fashionscape/blob/master/api/data/tools/slot.js
|
||||
public enum ScapeFashionSlotOsrs {
|
||||
AMMUNITION("ammunition"),
|
||||
BODY("body"),
|
||||
CAPE("cape"),
|
||||
FEET("feet"),
|
||||
HAND("hand"),
|
||||
HEAD("head"),
|
||||
LEG("leg"),
|
||||
NECK("neck"),
|
||||
RING("ring"),
|
||||
SHIELD("shield"),
|
||||
WEAPON("weapon");
|
||||
|
||||
private final String value;
|
||||
|
||||
ScapeFashionSlotOsrs(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static Optional<ScapeFashionSlotOsrs> matches(String s) {
|
||||
try {
|
||||
var slot = ScapeFashionSlotOsrs.valueOf(s);
|
||||
return Optional.of(slot);
|
||||
} catch (IllegalArgumentException e) {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2020. Aleksei Gryczewski
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
package dev.salmonllama.fsbot.endpoints.scapefashion;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
// Source: https://github.com/ncpierson/fashionscape/blob/master/api/data/tools/slot.js
|
||||
public enum ScapeFashionSlotRs3 {
|
||||
AMMUNITION("ammunition"),
|
||||
BACK("back"),
|
||||
FEET("feet"),
|
||||
HAND("hand"),
|
||||
HEAD("head"),
|
||||
LEG("leg"),
|
||||
MAIN_HAND("main_hand"),
|
||||
NECK("neck"),
|
||||
OFF_HAND("off-hand"),
|
||||
POCKET("pocket"),
|
||||
RING("ring"),
|
||||
SIGIL("sigil"),
|
||||
TORSO("torso"),
|
||||
TWO_HANDED("two-handed");
|
||||
|
||||
private final String value;
|
||||
|
||||
ScapeFashionSlotRs3(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static Optional<ScapeFashionSlotRs3> matches(String s) {
|
||||
try {
|
||||
var slot = ScapeFashionSlotRs3.valueOf(s);
|
||||
return Optional.of(slot);
|
||||
} catch (IllegalArgumentException e) {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package dev.salmonllama.fsbot.endpoints.scapefashion;
|
||||
|
||||
public class ScapeFashionWiki {
|
||||
private String api;
|
||||
private String link;
|
||||
private int pageId;
|
||||
|
||||
public ScapeFashionWiki() {
|
||||
|
||||
}
|
||||
|
||||
public String getApi() {
|
||||
return api;
|
||||
}
|
||||
|
||||
public String getLink() {
|
||||
return link;
|
||||
}
|
||||
|
||||
public int getPageId() {
|
||||
return pageId;
|
||||
}
|
||||
}
|
@ -5,16 +5,16 @@
|
||||
|
||||
package dev.salmonllama.fsbot.guthix;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public abstract class Command {
|
||||
public abstract String name();
|
||||
public abstract String description();
|
||||
public abstract String usage();
|
||||
public abstract String category();
|
||||
public abstract CommandCategory category();
|
||||
public abstract CommandPermission permission();
|
||||
public abstract Collection<String> aliases();
|
||||
public abstract List<String> aliases();
|
||||
|
||||
public abstract void onCommand(CommandContext ctx);
|
||||
|
||||
|
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (c) 2020. Aleksei Gryczewski
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
package dev.salmonllama.fsbot.guthix;
|
||||
|
||||
public enum CommandCategory {
|
||||
DEVELOPER("Developer"),
|
||||
GENERAL("General"),
|
||||
OSRS_ITEM_SEARCH("07Search"),
|
||||
RS3_ITEM_SEARCH("RS3Search"),
|
||||
STAFF("Staff");
|
||||
|
||||
private final String category;
|
||||
|
||||
CommandCategory(String category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
public String getCategory() {
|
||||
return category;
|
||||
}
|
||||
}
|
@ -7,6 +7,8 @@ package dev.salmonllama.fsbot.guthix;
|
||||
|
||||
import dev.salmonllama.fsbot.commands.developer.*;
|
||||
import dev.salmonllama.fsbot.commands.general.*;
|
||||
import dev.salmonllama.fsbot.commands.osrssearch.*;
|
||||
import dev.salmonllama.fsbot.commands.rs3search.*;
|
||||
import dev.salmonllama.fsbot.commands.staff.OutfitInfoCommand;
|
||||
import dev.salmonllama.fsbot.commands.staff.*;
|
||||
import org.javacord.api.DiscordApi;
|
||||
@ -22,10 +24,10 @@ import java.util.HashMap;
|
||||
*/
|
||||
public class Guthix implements MessageCreateListener {
|
||||
@SuppressWarnings("unused")
|
||||
private DiscordApi api;
|
||||
private final DiscordApi api;
|
||||
|
||||
private Registry registry;
|
||||
private PermissionManager manager;
|
||||
private final Registry registry;
|
||||
private final PermissionManager manager;
|
||||
|
||||
public Guthix(DiscordApi api) {
|
||||
this.api = api;
|
||||
@ -55,6 +57,7 @@ public class Guthix implements MessageCreateListener {
|
||||
addCommand(new SetStatusCommand());
|
||||
addCommand(new WelcomeMessageCommand());
|
||||
addCommand(new ShowGalleriesCommand());
|
||||
addCommand(new EditMetaCommand());
|
||||
|
||||
// General Commands
|
||||
addCommand(new PingCommand());
|
||||
@ -64,6 +67,31 @@ public class Guthix implements MessageCreateListener {
|
||||
addCommand(new HelpCommand(this));
|
||||
addCommand(new StatsCommand());
|
||||
addCommand(new PrivacyCommand());
|
||||
|
||||
// Osrs Search Commands
|
||||
addCommand(new OsrsSearchCommand());
|
||||
addCommand(new OsrsHeadCommand());
|
||||
addCommand(new OsrsBodyCommand());
|
||||
addCommand(new OsrsHandCommand());
|
||||
addCommand(new OsrsLegsCommand());
|
||||
addCommand(new OsrsFeetCommand());
|
||||
addCommand(new OsrsCapeCommand());
|
||||
addCommand(new OsrsNeckCommand());
|
||||
addCommand(new OsrsShieldCommand());
|
||||
addCommand(new OsrsWeaponCommand());
|
||||
|
||||
// Rs3 Search Commands
|
||||
addCommand(new Rs3SearchCommand());
|
||||
addCommand(new Rs3HeadCommand());
|
||||
addCommand(new Rs3BodyCommand());
|
||||
addCommand(new Rs3NeckCommand());
|
||||
addCommand(new Rs3HandCommand());
|
||||
addCommand(new Rs3FeetCommand());
|
||||
addCommand(new Rs3LegsCommand());
|
||||
addCommand(new Rs3BackCommand());
|
||||
addCommand(new Rs3MainhandCommand());
|
||||
addCommand(new Rs3OffhandCommand());
|
||||
addCommand(new Rs3TwohandedCommand());
|
||||
}
|
||||
|
||||
public void addCommand(Command cmd) {
|
||||
|
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (c) 2020. Aleksei Gryczewski
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
package dev.salmonllama.fsbot.listeners;
|
||||
|
||||
import dev.salmonllama.fsbot.guthix.CommandContext;
|
||||
import org.javacord.api.event.message.MessageCreateEvent;
|
||||
import org.javacord.api.listener.message.MessageCreateListener;
|
||||
|
||||
public class ForceDeleteAttachedListener implements MessageCreateListener {
|
||||
|
||||
private CommandContext ctx;
|
||||
|
||||
public ForceDeleteAttachedListener(CommandContext ctx) {
|
||||
this.ctx = ctx;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessageCreate(MessageCreateEvent event) {
|
||||
|
||||
}
|
||||
}
|
@ -17,6 +17,7 @@ import org.javacord.api.entity.message.embed.EmbedBuilder;
|
||||
import org.javacord.api.event.message.MessageCreateEvent;
|
||||
import org.javacord.api.listener.message.MessageCreateListener;
|
||||
import org.javacord.api.util.logging.ExceptionLogger;
|
||||
import java.awt.Color;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -50,11 +51,9 @@ public class ImageListener implements MessageCreateListener {
|
||||
|
||||
if (System.getenv("ENVIRONMENT") != null) {
|
||||
// Upload the image(s) to Imgur, store in database, log the stored images.
|
||||
System.out.println("PROD environment, uploading");
|
||||
uploadAndStore(event, channel, image);
|
||||
} else {
|
||||
// Store the image(s) in database, log the stored images.
|
||||
System.out.println("DEV environment, not uploading");
|
||||
store(event, channel, image);
|
||||
}
|
||||
});
|
||||
@ -107,6 +106,7 @@ public class ImageListener implements MessageCreateListener {
|
||||
.setThumbnail(outfit.getLink())
|
||||
.setFooter(String.format("%s | %s", outfit.getTag(), outfit.getId()))
|
||||
.setUrl(outfit.getLink())
|
||||
.setColor(Color.GREEN)
|
||||
.addField("Uploaded:", outfit.getCreated().toString());
|
||||
|
||||
if (!outfit.getMeta().equals("")) {
|
||||
|
@ -7,11 +7,13 @@ package dev.salmonllama.fsbot.listeners;
|
||||
|
||||
import dev.salmonllama.fsbot.config.BotConfig;
|
||||
import dev.salmonllama.fsbot.database.controllers.ServerConfigController;
|
||||
import dev.salmonllama.fsbot.services.MemberRoleService;
|
||||
import org.javacord.api.event.server.member.ServerMemberJoinEvent;
|
||||
import org.javacord.api.listener.server.member.ServerMemberJoinListener;
|
||||
|
||||
public class NewMemberListener implements ServerMemberJoinListener {
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class NewMemberListener implements ServerMemberJoinListener {
|
||||
public void onServerMemberJoin(ServerMemberJoinEvent event) {
|
||||
|
||||
if (!event.getServer().getIdAsString().equals(BotConfig.HOME_SERVER)) {
|
||||
@ -19,10 +21,14 @@ public class NewMemberListener implements ServerMemberJoinListener {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Use the ServerConfig to retrieve the welcome channel as well.
|
||||
// Send the welcome message in the welcome channel
|
||||
event.getApi().getServerTextChannelById(BotConfig.WELCOME_CHANNEL).ifPresent( // Get the Welcome Channel
|
||||
channel -> ServerConfigController.get(event.getServer().getIdAsString()).thenAcceptAsync( // Fetch the server config, if set.
|
||||
possibleConfig -> possibleConfig.ifPresent( // If config exists
|
||||
config -> channel.sendMessage(String.format(config.getWelcomeMessage(), event.getUser().getMentionTag()))))); // Send the welcome message
|
||||
|
||||
// Add the Member role after 5 minutes
|
||||
var memberRoleService = new MemberRoleService(event);
|
||||
event.getApi().getThreadPool().getScheduler().schedule(memberRoleService, 5, TimeUnit.MINUTES);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
package dev.salmonllama.fsbot.services;
|
||||
|
||||
import dev.salmonllama.fsbot.config.BotConfig;
|
||||
|
||||
import org.javacord.api.event.server.member.ServerMemberJoinEvent;
|
||||
|
||||
public class MemberRoleService implements Runnable {
|
||||
|
||||
ServerMemberJoinEvent event;
|
||||
|
||||
public MemberRoleService(ServerMemberJoinEvent event) {
|
||||
this.event = event;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
event.getApi().getRoleById(BotConfig.MEMBER_ROLE).ifPresent(role ->
|
||||
event.getServer().addRoleToUser(event.getUser(), role, "FSBot 5-minute member role")
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2020. Aleksei Gryczewski
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
package dev.salmonllama.fsbot.utilities;
|
||||
|
||||
import dev.salmonllama.fsbot.config.BotConfig;
|
||||
import dev.salmonllama.fsbot.guthix.CommandContext;
|
||||
import org.javacord.api.entity.message.embed.EmbedBuilder;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class DiscordUtilities {
|
||||
public static void handleException(Exception e, CommandContext ctx) {
|
||||
EmbedBuilder embed = new EmbedBuilder()
|
||||
.setTitle("Exception caught in command thread:")
|
||||
.addField("message:", e.getMessage())
|
||||
.setColor(Color.RED);
|
||||
|
||||
logException(e, ctx);
|
||||
ctx.reply(embed);
|
||||
}
|
||||
|
||||
private static void logException(Exception e, CommandContext ctx) {
|
||||
EmbedBuilder embed = new EmbedBuilder()
|
||||
.setTitle("Runtime error:")
|
||||
.addField("Message:", e.getMessage())
|
||||
.setColor(Color.RED);
|
||||
|
||||
ctx.getApi().getTextChannelById(BotConfig.ACTIVITY_LOG).ifPresent(channel -> channel.sendMessage(embed));
|
||||
}
|
||||
|
||||
// public static void report(Class<? extends Throwable>... throwable) {
|
||||
// System.out.println(Arrays.stream(throwable));
|
||||
// }
|
||||
}
|
18
src/main/resources/logback.xml
Normal file
18
src/main/resources/logback.xml
Normal file
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright (c) 2020. Aleksei Gryczewski
|
||||
~ All rights reserved.
|
||||
-->
|
||||
<configuration debug="false">
|
||||
<statusListener class="ch.qos.logback.core.status.NopStatusListener" />
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} %boldCyan(%-34.-34thread) %red(%10.10X{jda.shard}) %boldGreen(%-15.-15logger{0}) %highlight(%-6level) %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
|
||||
</configuration>
|
Loading…
Reference in New Issue
Block a user