Comments (12)
Please share the coresponding code of the command
from jda-commands.
it is terribly coded and theres a lot of stuff that doesnt need to be there, but here ya go
@SlashCommand(value = "package search")
public void onPackageGet(CommandEvent event,
@Param(name = "community", value = "The community to retrieve from") String community,
@Optional @Param(name = "search", value = "The search") String search) {
if (!ServerConfig.configs.get(event.getGuild().getId()).get("community").equals(""))
community = ServerConfig.configs.get(event.getGuild().getId()).get("community", String.class);
PackageListing[] result;
if (!TestCommands.checkExecute(event, e ->
!ServerConfig.configs.get(event.getGuild().getId()).get("disabledChannels", List.class).contains(e.getChannel().getId())
&& !ServerConfig.configs.get(event.getGuild().getId()).get("disabledUsers", List.class).contains(e.getUser().getId())))
return;
if (search!=null)
if (search.length()>100) {
event.reply("Search query too long.");
return;
}
if (community!=null)
if (community.length()>100) {
event.reply("Community name too long.");
return;
}
if (search!=null)
search = MarkdownSanitizer.sanitize(search).replace(" ", "_");
if (community!=null) {
community = community.toLowerCase().replace(" ", "-");
community = MarkdownSanitizer.sanitize(community);
boolean success = false;
for (var c : Bot.bot.tsja.getCommunities()) {
if (c.getIdentifier().equals(community)) {
success=true;
break;
}
}
if (!success) {
event.reply("Invalid Community. Do `/community all` for a list of valid communities.");
return;
}
} else {
community = "all";
}
if (search != null) {
result = new TSJAUtils().getPackagesByName(Bot.bot.tsja, community, search);
} else {
result = Bot.bot.tsja.getPackages(community, null);
}
PaginatedMenuHandler.Menu menu;
List<PaginatedMenuHandler.Page> pages = new ArrayList<>();
PaginatedMenuHandler.Page currentPage =
new PaginatedMenuHandler.Page(MessageCreateData.fromContent("# Mods\nSearch: " + search + "\n\n\n"));
StringBuilder builder = new StringBuilder();
for (PackageListing p : result) {
if (builder.length() > 1500) {
currentPage.append(builder.toString()); // Append builder to the current page
builder.setLength(0); // Clear the builder
pages.add(currentPage); // Add the current page to the list of pages
currentPage = new PaginatedMenuHandler.Page(MessageCreateData.fromContent("")); // Create a new page
}
String packageName = p.isDeprecated() ? "~~" + p.getName() + "~~" : p.getName();
String packageLink = MarkdownUtil.maskedLink(packageName, "<" + p.getPackageUrl() + ">");
String ownerLink = MarkdownUtil.maskedLink(p.getOwner(), "<" + TSJA.getTeamUrl(community, p.getOwner()) + ">");
String downloadLink = MarkdownUtil.maskedLink("here", "<" + p.getVersions()[0].getDownloadUrl() + ">");
String content = String.format("%s by %s, download %s (%s)\n", packageLink, ownerLink, downloadLink, p.getUniqueId());
builder.append(content);
}
currentPage.append(builder.toString());
pages.add(currentPage);
event.reply("MENU LOADING...", msg -> {
PaginatedMenuHandler.addMenu(PaginatedMenuHandler.buildMenu(msg, pages.stream().map(page -> page.content).toList().toArray(
MessageCreateData[]::new)));
});
}
from jda-commands.
If it helps, this has been happening for a while.
Its not a new update thing.
from jda-commands.
Using the latest commit to the development and the following command class and logback config, I get perfectly fine error handling:
@Interaction
public class ExceptionTest {
@SlashCommand(value = "exception")
public void onCommand(CommandEvent event) {
throw new RuntimeException("test");
}
}
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root level="info">
<appender-ref ref="STDOUT"/>
</root>
</configuration>
It's virtually impossible for me to reproduce this bug and I'm not even sure if it's related to jda-commands. Please consider the following steps to help me tackle down this bug:
- Check and preferably share your logging configuration
- Create a test command that directly throws an exception like I did and see if it's logged correctly
- Execute your command code outside of a jda-commands environment so we can find the spot where the NPE occurs. This would help me with trying to reproduce the bug
from jda-commands.
using the same logback.xml as you, no log, yet theres an error in discord, see below.
@SlashCommand(value = "test")
public void onTest(CommandEvent event) {
throw new RuntimeException("Test");
}
as well as
@SlashCommand(value = "test")
public void onTest(CommandEvent event) throws RuntimeException {
throw new RuntimeException("Test");
}
No output to console
If this is needed, ill do it.
although it doesnt seem like it, as even directly throwing a runtime exception doesnt print to the log
from jda-commands.
which version of jda-commands are you using?
from jda-commands.
4.0.0 beta.1
from jda-commands.
can you test if exceptions get logged when they are thrown outside of jda-commands?
from jda-commands.
logs perfectly.
from jda-commands.
I'm unable to reproduce the bug. Is your repository public?
from jda-commands.
from jda-commands.
looking at your pom.xml it seems like you haven't configured logback correctly. You also need to add the logback dependency:
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.8</version>
</dependency>
I've cloned your repo, added logback and exceptions were logged perfectly fine
from jda-commands.
Related Issues (20)
- [FEATURE] ReplyContext queue / reply consumer
- [BUG] Reply message always ephemeral HOT 1
- [FEATURE] make Dependency Injector an interface
- [FEATURE] add setErrorConsumer
- [BUG] reimplement CooldownFilter
- [QUESTION] How to handle expired buttons? HOT 10
- [FEATURE] Handle unknown interactions HOT 2
- Add support for command groups & Modals HOT 4
- No function to send modals HOT 1
- [BUG] Some commands are not registering HOT 13
- [BUG] Command execution fails with IndexOutOfBoundsException HOT 3
- [QUESTION] How do I make commandautocompleteevent work? HOT 15
- [BUG] DefaultValues have no effect on SelectMenus
- Would be nice to have more documentation on buttons and modals
- [FEATURE] Ignore non-jda-commands interactions
- [FEATURE] Add components API for usage outside of commands
- [FEATURE] Implement static interactions
- [FEATURE] Add i18n for EmbedCache
- [BUG] Member parser does not work in other channels then default text HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jda-commands.