Skip to content

Commit

Permalink
point to wiki for commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Chew committed Oct 11, 2023
1 parent 098a424 commit d254717
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2022 Chewbotcca
* Copyright (C) 2023 Chewbotcca
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -59,7 +59,7 @@ private MessageEmbed generateHelpEmbed(String prefix) {
Chewbotcca is a multi-purpose, semi-functional, almost always online, Discord bot!
This bot is powered by [SkySilk Cloud Services](https://www.skysilk.com/ref/4PRQpuQraD)!""")
.addField("Commands", "You can find all my commands [here](https://chew.pw/chewbotcca/discord/commands)", true)
.addField("Commands", "You can find all my commands [here](https:/help.chew.pro/bots/discord/chewbotcca/commands)", true)
.addField("Invite me!", "You can invite me to your server with [this link](https://discord.com/oauth2/authorize?client_id=604362556668248095&scope=bot&permissions=0).", true)
.addField("Help Server", "Click [me](https://discord.gg/UjxQ3Bh) to join the help server.", true)
.addField("More Bot Stats", "Run `" + prefix + "stats` to see more stats!", true)
Expand Down
41 changes: 7 additions & 34 deletions src/main/java/pw/chew/chewbotcca/commands/info/InfoCommand.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2022 Chewbotcca
* Copyright (C) 2023 Chewbotcca
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -16,7 +16,6 @@
*/
package pw.chew.chewbotcca.commands.info;

import com.jagrosh.jdautilities.command.CommandEvent;
import com.jagrosh.jdautilities.command.SlashCommand;
import com.jagrosh.jdautilities.command.SlashCommandEvent;
import net.dv8tion.jda.api.EmbedBuilder;
Expand All @@ -33,7 +32,6 @@
import org.json.JSONArray;
import org.json.JSONObject;
import pw.chew.chewbotcca.objects.Memory;
import pw.chew.chewbotcca.util.PropertiesManager;
import pw.chew.chewbotcca.util.ResponseHelper;
import pw.chew.chewbotcca.util.RestClient;

Expand Down Expand Up @@ -63,7 +61,7 @@ protected void execute(SlashCommandEvent event) {
if (e.getMessage().contains("Did you mean? ")) {
SelectMenu menu = buildSuggestionMenu(e.getMessage());

event.reply("Invalid command! See <https://chew.pw/chewbotcca/discord/commands> for a list of commands.")
event.reply("Invalid command! See <https://help.chew.pro/bots/discord/chewbotcca/commands> for a list of commands.")
.addActionRow(menu)
.queue();
} else {
Expand All @@ -72,32 +70,6 @@ protected void execute(SlashCommandEvent event) {
}
}

@Override
protected void execute(CommandEvent event) {
// Make sure there's an arg
String command = event.getArgs();
if (command.isBlank()) {
event.reply("Please specify a command to find info for!");
return;
}

try {
event.reply(gatherData(command));
} catch (IllegalArgumentException e) {
if (e.getMessage().contains("Did you mean? ")) {
SelectMenu menu = buildSuggestionMenu(e.getMessage());

event.getChannel().sendMessage("Invalid command! See <https://chew.pw/chewbotcca/discord/commands> for a list of commands.")
.setActionRow(menu)
.queue();

return;
}

event.replyWarning(e.getMessage());
}
}

/**
* Update the "Did you mean?" embed with their selection
*
Expand Down Expand Up @@ -154,16 +126,17 @@ private static MessageEmbed gatherData(String command) {
for (int i = 0; i < didYouMean.length(); i++) {
predictions.add(didYouMean.getString(i));
}
if (predictions.size() > 0) {
throw new IllegalArgumentException("Invalid command! See <https://chew.pw/chewbotcca/discord/commands> for a list of commands. Did you mean? " + String.join(", ", predictions));
if (!predictions.isEmpty()) {
throw new IllegalArgumentException("Invalid command! See <https://help.chew.pro/bots/discord/chewbotcca/commands> for a list of commands. Did you mean? " + String.join(", ", predictions));
} else {
throw new IllegalArgumentException("Invalid command! See <https://chew.pw/chewbotcca/discord/commands> for a list of commands.");
throw new IllegalArgumentException("Invalid command! See <https://help.chew.pro/bots/discord/chewbotcca/commands> for a list of commands.");
}
}

// Gather the data and make an embed with it
EmbedBuilder e = new EmbedBuilder()
.setTitle("**Info For**: `" + PropertiesManager.getPrefix() + data.getString("command") + "`")
.setTitle("**Info For**: `/" + data.getString("command") + "`",
"https://help.chew.pro/bots/discord/chewbotcca/commands/" + data.getString("command"))
.setDescription(data.getString("description"));

e.addField("Arguments", data.optString("args", "No Arguments"), true);
Expand Down

0 comments on commit d254717

Please sign in to comment.