This commit is contained in:
@@ -14,7 +14,8 @@ import wtf.beatrice.hidekobot.objects.commands.SlashCommandImpl;
|
||||
public class AvatarCommand extends SlashCommandImpl
|
||||
{
|
||||
@Override
|
||||
public CommandData getSlashCommandData() {
|
||||
public CommandData getSlashCommandData()
|
||||
{
|
||||
return Commands.slash("avatar", "Get someone's profile picture.")
|
||||
.addOption(OptionType.USER, "user", "User you want to grab the avatar of.")
|
||||
.addOption(OptionType.INTEGER, "size", "The size of the returned image.",
|
||||
@@ -32,26 +33,28 @@ public class AvatarCommand extends SlashCommandImpl
|
||||
int resolution;
|
||||
|
||||
OptionMapping userArg = event.getOption("user");
|
||||
if(userArg != null)
|
||||
if (userArg != null)
|
||||
{
|
||||
user = userArg.getAsUser();
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
user = event.getUser();
|
||||
}
|
||||
|
||||
OptionMapping sizeArg = event.getOption("size");
|
||||
if(sizeArg != null)
|
||||
if (sizeArg != null)
|
||||
{
|
||||
resolution = ProfileImage.parseResolution(sizeArg.getAsInt());
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
resolution = ProfileImage.parseResolution(512);
|
||||
}
|
||||
|
||||
MessageResponse response = ProfileImage.buildResponse(resolution, user, ProfileImage.ImageType.AVATAR);
|
||||
if(response.content() != null)
|
||||
if (response.content() != null)
|
||||
{
|
||||
event.getHook().editOriginal(response.content()).queue();
|
||||
} else if(response.embed() != null)
|
||||
} else if (response.embed() != null)
|
||||
{
|
||||
event.getHook().editOriginalEmbeds(response.embed()).queue();
|
||||
}
|
||||
|
@@ -14,7 +14,8 @@ import wtf.beatrice.hidekobot.objects.commands.SlashCommandImpl;
|
||||
public class BannerCommand extends SlashCommandImpl
|
||||
{
|
||||
@Override
|
||||
public CommandData getSlashCommandData() {
|
||||
public CommandData getSlashCommandData()
|
||||
{
|
||||
return Commands.slash("banner", "Get someone's profile banner.")
|
||||
.addOption(OptionType.USER, "user", "User you want to grab the banner of.")
|
||||
.addOption(OptionType.INTEGER, "size", "The size of the returned image.",
|
||||
@@ -32,26 +33,28 @@ public class BannerCommand extends SlashCommandImpl
|
||||
int resolution;
|
||||
|
||||
OptionMapping userArg = event.getOption("user");
|
||||
if(userArg != null)
|
||||
if (userArg != null)
|
||||
{
|
||||
user = userArg.getAsUser();
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
user = event.getUser();
|
||||
}
|
||||
|
||||
OptionMapping sizeArg = event.getOption("size");
|
||||
if(sizeArg != null)
|
||||
if (sizeArg != null)
|
||||
{
|
||||
resolution = ProfileImage.parseResolution(sizeArg.getAsInt());
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
resolution = ProfileImage.parseResolution(512);
|
||||
}
|
||||
|
||||
MessageResponse response = ProfileImage.buildResponse(resolution, user, ProfileImage.ImageType.BANNER);
|
||||
if(response.content() != null)
|
||||
if (response.content() != null)
|
||||
{
|
||||
event.getHook().editOriginal(response.content()).queue();
|
||||
} else if(response.embed() != null)
|
||||
} else if (response.embed() != null)
|
||||
{
|
||||
event.getHook().editOriginalEmbeds(response.embed()).queue();
|
||||
}
|
||||
|
@@ -16,7 +16,8 @@ import java.util.List;
|
||||
public class BotInfoCommand extends SlashCommandImpl
|
||||
{
|
||||
@Override
|
||||
public CommandData getSlashCommandData() {
|
||||
public CommandData getSlashCommandData()
|
||||
{
|
||||
return Commands.slash("botinfo", "Get info about the bot.");
|
||||
}
|
||||
|
||||
@@ -29,7 +30,7 @@ public class BotInfoCommand extends SlashCommandImpl
|
||||
// get a list of slash commands
|
||||
List<SlashCommand> registeredCommands = Cache.getSlashCommandListener().getRegisteredCommands();
|
||||
LinkedList<String> registeredCommandNames = new LinkedList<>();
|
||||
for(SlashCommand command : registeredCommands)
|
||||
for (SlashCommand command : registeredCommands)
|
||||
{
|
||||
// node: adding slash so people realize that this is specific about slash commands.
|
||||
registeredCommandNames.add("/" + command.getCommandName());
|
||||
|
@@ -17,7 +17,8 @@ public class ClearCommand extends SlashCommandImpl
|
||||
{
|
||||
|
||||
@Override
|
||||
public CommandData getSlashCommandData() {
|
||||
public CommandData getSlashCommandData()
|
||||
{
|
||||
return Commands.slash(ClearChat.getLabel(),
|
||||
ClearChat.getDescription())
|
||||
.addOption(OptionType.INTEGER, "amount", "The amount of messages to delete.")
|
||||
@@ -32,7 +33,7 @@ public class ClearCommand extends SlashCommandImpl
|
||||
|
||||
// check if user is trying to run command in dms.
|
||||
String error = ClearChat.checkDMs(event.getChannel());
|
||||
if(error != null)
|
||||
if (error != null)
|
||||
{
|
||||
event.getHook().editOriginal(error).queue();
|
||||
return;
|
||||
@@ -45,10 +46,10 @@ public class ClearCommand extends SlashCommandImpl
|
||||
int toDeleteAmount = amountOption == null ? 1 : amountOption.getAsInt();
|
||||
|
||||
// cap the amount to avoid abuse.
|
||||
if(toDeleteAmount > ClearChat.getMaxAmount()) toDeleteAmount = 0;
|
||||
if (toDeleteAmount > ClearChat.getMaxAmount()) toDeleteAmount = 0;
|
||||
|
||||
error = ClearChat.checkDeleteAmount(toDeleteAmount);
|
||||
if(error != null)
|
||||
if (error != null)
|
||||
{
|
||||
event.getHook().editOriginal(error).queue();
|
||||
return;
|
||||
|
@@ -29,12 +29,11 @@ public class CoinFlipCommand extends SlashCommandImpl
|
||||
interaction.retrieveOriginal().queue((message) ->
|
||||
{
|
||||
CoinFlip.trackAndRestrict(message, event.getUser());
|
||||
}, (error) -> {});
|
||||
}, (error) -> {});
|
||||
}, (error) -> {
|
||||
});
|
||||
}, (error) -> {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -30,19 +30,19 @@ public class DiceRollCommand extends SlashCommandImpl
|
||||
|
||||
OptionMapping textOption = event.getOption("query");
|
||||
String messageContent = "";
|
||||
if(textOption != null)
|
||||
if (textOption != null)
|
||||
{
|
||||
messageContent = textOption.getAsString();
|
||||
messageContent = textOption.getAsString();
|
||||
}
|
||||
|
||||
String[] args = messageContent.split("\\s");
|
||||
|
||||
MessageResponse response = DiceRoll.buildResponse(event.getUser(), args);
|
||||
|
||||
if(response.content() != null)
|
||||
if (response.content() != null)
|
||||
{
|
||||
event.getHook().editOriginal(response.content()).queue();
|
||||
} else if(response.embed() != null)
|
||||
} else if (response.embed() != null)
|
||||
{
|
||||
event.getHook().editOriginalEmbeds(response.embed()).queue();
|
||||
}
|
||||
|
@@ -16,7 +16,8 @@ import java.util.concurrent.TimeUnit;
|
||||
public class DieCommand extends SlashCommandImpl
|
||||
{
|
||||
@Override
|
||||
public CommandData getSlashCommandData() {
|
||||
public CommandData getSlashCommandData()
|
||||
{
|
||||
return Commands.slash("die", "Stop the bot's process.")
|
||||
.setDefaultPermissions(DefaultMemberPermissions.DISABLED);
|
||||
}
|
||||
@@ -24,12 +25,14 @@ public class DieCommand extends SlashCommandImpl
|
||||
@Override
|
||||
public void runSlashCommand(@NotNull SlashCommandInteractionEvent event)
|
||||
{
|
||||
if(Cache.getBotOwnerId() != event.getUser().getIdLong())
|
||||
if (Cache.getBotOwnerId() != event.getUser().getIdLong())
|
||||
{
|
||||
event.reply("Sorry, only the bot owner can run this command!").setEphemeral(true).queue();
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
event.reply("Going to sleep! Cya ✨").queue();
|
||||
try (ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor()) {
|
||||
try (ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor())
|
||||
{
|
||||
executor.schedule(HidekoBot::shutdown, 3, TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
|
@@ -30,7 +30,7 @@ public class InviteCommand extends SlashCommandImpl
|
||||
ReplyCallbackAction replyCallbackAction = event.deferReply();
|
||||
|
||||
// only make message permanent in DMs
|
||||
if(event.getChannelType() != ChannelType.PRIVATE)
|
||||
if (event.getChannelType() != ChannelType.PRIVATE)
|
||||
{
|
||||
replyCallbackAction = replyCallbackAction.setEphemeral(true);
|
||||
}
|
||||
|
@@ -18,7 +18,7 @@ public class LoveCalculatorCommand extends SlashCommandImpl
|
||||
{
|
||||
|
||||
return Commands.slash("lovecalc",
|
||||
"Calculate how much two people love each other.")
|
||||
"Calculate how much two people love each other.")
|
||||
|
||||
.addOption(OptionType.MENTIONABLE,
|
||||
"first",
|
||||
@@ -37,10 +37,11 @@ public class LoveCalculatorCommand extends SlashCommandImpl
|
||||
User firstUser, secondUser;
|
||||
|
||||
OptionMapping firsUserArg = event.getOption("first");
|
||||
if(firsUserArg != null)
|
||||
if (firsUserArg != null)
|
||||
{
|
||||
firstUser = firsUserArg.getAsUser(); //todo null check?
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
event.reply("\uD83D\uDE22 I need to know who to check! Please mention them.")
|
||||
.setEphemeral(true)
|
||||
.queue();
|
||||
@@ -48,10 +49,11 @@ public class LoveCalculatorCommand extends SlashCommandImpl
|
||||
}
|
||||
|
||||
OptionMapping secondUserArg = event.getOption("second");
|
||||
if(secondUserArg != null)
|
||||
if (secondUserArg != null)
|
||||
{
|
||||
secondUser = secondUserArg.getAsUser(); //todo null check?
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
secondUser = event.getUser();
|
||||
}
|
||||
|
||||
|
@@ -17,7 +17,7 @@ public class MagicBallCommand extends SlashCommandImpl
|
||||
{
|
||||
|
||||
return Commands.slash(MagicBall.getLabels().get(0),
|
||||
"Ask a question to the magic ball.")
|
||||
"Ask a question to the magic ball.")
|
||||
.addOption(OptionType.STRING, "question",
|
||||
"The question to ask.",
|
||||
true,
|
||||
@@ -30,12 +30,12 @@ public class MagicBallCommand extends SlashCommandImpl
|
||||
// get the asked question
|
||||
OptionMapping textOption = event.getOption("question");
|
||||
String question = "";
|
||||
if(textOption != null)
|
||||
if (textOption != null)
|
||||
{
|
||||
question = textOption.getAsString();
|
||||
}
|
||||
|
||||
if(textOption == null || question.isEmpty())
|
||||
if (textOption == null || question.isEmpty())
|
||||
{
|
||||
event.reply("\uD83D\uDE20 Hey, you have to ask me a question!")
|
||||
.setEphemeral(true)
|
||||
|
@@ -33,12 +33,12 @@ public class SayCommand extends SlashCommandImpl
|
||||
// get the text to send
|
||||
OptionMapping textOption = event.getOption("text");
|
||||
String messageContent = "";
|
||||
if(textOption != null)
|
||||
if (textOption != null)
|
||||
{
|
||||
messageContent = textOption.getAsString();
|
||||
messageContent = textOption.getAsString();
|
||||
}
|
||||
|
||||
if(textOption == null || messageContent.isEmpty())
|
||||
if (textOption == null || messageContent.isEmpty())
|
||||
{
|
||||
event.reply("\uD83D\uDE20 Hey, you have to tell me what to say!")
|
||||
.setEphemeral(true)
|
||||
|
@@ -26,13 +26,13 @@ public class TriviaCommand extends SlashCommandImpl
|
||||
{
|
||||
MessageChannel channel = event.getChannel();
|
||||
|
||||
if(!(channel instanceof TextChannel))
|
||||
if (!(channel instanceof TextChannel))
|
||||
{
|
||||
event.reply(Trivia.getNoDMsError()).queue();
|
||||
return;
|
||||
}
|
||||
|
||||
if(Trivia.channelsRunningTrivia.contains(channel.getId()))
|
||||
if (Trivia.channelsRunningTrivia.contains(channel.getId()))
|
||||
{
|
||||
event.reply(Trivia.getTriviaAlreadyRunningError()).setEphemeral(true).queue();
|
||||
return;
|
||||
|
@@ -24,7 +24,7 @@ public class UrbanDictionaryCommand extends SlashCommandImpl
|
||||
{
|
||||
|
||||
return Commands.slash(UrbanDictionary.getCommandLabels().get(0),
|
||||
"Look up a term on Urban Dictionary.")
|
||||
"Look up a term on Urban Dictionary.")
|
||||
.addOption(OptionType.STRING, "term", "The term to look up", true);
|
||||
}
|
||||
|
||||
@@ -36,12 +36,12 @@ public class UrbanDictionaryCommand extends SlashCommandImpl
|
||||
// get the term to look up
|
||||
OptionMapping textOption = event.getOption("term");
|
||||
String term = "";
|
||||
if(textOption != null)
|
||||
if (textOption != null)
|
||||
{
|
||||
term = textOption.getAsString();
|
||||
}
|
||||
|
||||
if(textOption == null || term.isEmpty())
|
||||
if (textOption == null || term.isEmpty())
|
||||
{
|
||||
event.reply(UrbanDictionary.getNoArgsError())
|
||||
.setEphemeral(true)
|
||||
@@ -54,9 +54,11 @@ public class UrbanDictionaryCommand extends SlashCommandImpl
|
||||
|
||||
Document doc;
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
doc = Jsoup.connect(url).get();
|
||||
} catch (IOException e) {
|
||||
} catch (IOException e)
|
||||
{
|
||||
event.reply(UrbanDictionary.getTermNotFoundError())
|
||||
.setEphemeral(true)
|
||||
.queue();
|
||||
@@ -69,7 +71,7 @@ public class UrbanDictionaryCommand extends SlashCommandImpl
|
||||
|
||||
// disable next page if we only have one result
|
||||
Button nextPageBtnLocal = UrbanDictionary.getNextPageButton();
|
||||
if(search.getPages() == 1) nextPageBtnLocal = nextPageBtnLocal.asDisabled();
|
||||
if (search.getPages() == 1) nextPageBtnLocal = nextPageBtnLocal.asDisabled();
|
||||
|
||||
ActionRow actionRow = ActionRow.of(UrbanDictionary.getPreviousPageButton().asDisabled(),
|
||||
//disabled by default because we're on page 0
|
||||
|
Reference in New Issue
Block a user