Giter Site home page Giter Site logo

kaktushose / jda-commands Goto Github PK

View Code? Open in Web Editor NEW
66.0 5.0 11.0 5.3 MB

A declarative, annotation driven command library for JDA

Home Page: https://github.com/Kaktushose/jda-commands/wiki

License: Apache License 2.0

Java 100.00%
java jda discord commands utility framework hacktoberfest

jda-commands's Introduction

JDA-Version Generic badge Java CI Codacy Badge Codacy Badge license-shield

JDA-Commands

A lightweight, easy-to-use command framework for building Discord bots with JDA with full support for interactions. JDA-Commands goal is to remove any boilerplate code, so you can focus solely on the business logic of your bot - writing bots has never been easier!

Version Overview

jda-commands JDA Text Commands Interactions Stable
4.0.0-beta.2 5
3.0.0 5
2.2.0 4

Features

  • Simple and intuitive syntax following an annotation-driven and declarative style

  • Built-in support for slash commands, components, context menus and modals

  • Type adapting of parameters

  • Expandable execution chain including type adapters, filters, permissions and constraints

  • Built-in support for ephemeral replies, permissions, localization


The following example will demonstrate how easy it is not only to write commands, but also to integrate components with them:

@Interaction
public class CookieClicker {

    private int count;

    @SlashCommand(value = "cookie clicker", desc = "Play cookie clicker")
    public void onCommand(CommandEvent event) {
        event.withButtons("onClick").reply("You have %d cookies(s)!", count);
    }

    @Button(value = "Click me!", emoji = "🍪")
    public void onClick(ComponentEvent event) {
        count++;
        event.reply("You have %d cookies(s)!", count);
    }
}

Additionally, let's rebuild the official slash commands example from the JDA Readme as a more complex example:

@Interaction
public class BanCommand {

    @Permissions("BAN_MEMBERS")
    @SlashCommand(value = "ban", enabledFor = Permission.BAN_MEMBERS, desc = "Bans a user", ephemeral = true)
    public void onBan(CommandEvent event, @Param("The member to ban") Member target, @Optional("no reason") @Param("The ban reason") String reason) {
        event.getGuild().ban(target, 0, TimeUnit.SECONDS).reason(reason).queue(
                success -> event.reply("**%s** was banned by **%s**", target.getAsMention(), event.getUser().getAsMention()),
                error -> event.reply("Some error occurred, try again!")
        );
    }
}

Finally, start the framework by calling:

JDACommands.start(jda, Main.class, "com.package");

You can find a detailed list of all features down below (click on the ▶ for details):

Execution

Request-scoped Instances

For every command execution a new instance of the controller class is created. Subsequent executions of components are executed in the same instance. This allows you to store stateful objects, like the target of a ban command, inside the controller class.

Private Channel Support

If enabled, commands can also be executed in direct messages.

Parameters

Type Adapting

As seen in the example, the method signature will be translated into a command syntax. When a command gets called, this framework will adapt the raw String input to the types specified in the method signature. As a result all the boilerplate code for parsing parameters becomes obsolete.

Parameter Validation

Parameters can have additional constraints, such as min or max value, etc. When a constraint fails, an error message will be sent automatically. You can also define your own constraints.

embed

Constraints

Permissions System

Besides the default permissions system of slash commands, this framework comes in with an own system, supporting both discord and custom permissions. By default, you can use all permissions defined inside JDAs Permission Embed. By adding your own permission validator, you can use custom permission strings and bind permissions to certain roles or members.

Filter Chain

You can define filters that will run before each command execution. This can be useful to perform additional checks, which aren't supported by this framework by default.

Cooldown System

Commands can have a per-user cooldown to rate limit the execution of commands.

Misc

Error Messages

There are default error embeds for all validation systems of this framework, i.e. parameter constraints, permissions, etc.

Localization

This framework supports the use of JDAs LocalizationFunction for localizing slash commands.

Furthermore, you can adapt the auto generated bot responses. All embeds sent can also be loaded from a json file, which uses placeholders. example

Embed Deserialization

You can serialize and deserialize JDAs EmbedBuilder object to json. This comes in pretty handy, because for example you don't have to recompile the whole project if you find one typo inside your embed. example

Dependency Injection

This framework has a basic implementation of dependency injection, since you don't construct your command classes on your own.

Reflect API

Just like Javas Reflect API this framework also supports accessing and modifying command definitions at runtime.

If you want to learn more, check out the Wiki or the Javadoc.

Download

You can download the latest version here.

Maven

<repository>
    <id>jitpack.io</id>
    <url>https://jitpack.io</url>
</repository>
<dependency>
    <groupId>com.github.kaktushose</groupId>
    <artifactId>jda-commands</artifactId>
    <version>VERSION</version>
</dependency>

Gradle

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}
dependencies {
    implementation 'com.github.kaktushose:jda-commands:VERSION'
}

Contributing

If you think that something is missing, and you want to add it yourself, feel free to open a pull request. Please try to keep your code quality as good as mine and stick to the core concepts of this framework.

Special thanks to all contributors <3

Contributors Display

jda-commands's People

Contributors

aless2003 avatar dependabot[bot] avatar github-actions[bot] avatar goldmensch avatar kaktushose avatar lus avatar oleggtro avatar prevaure avatar stijnb1234 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

jda-commands's Issues

Button Questions

So I'm in the process of preparing my Bot for JDA 5. So naturally I'm also updating the jda-commands version to 2.3.0-alpha.2. And while I've gotten most things to work I have a few Questions about the JDA-Commands Buttons.

  1. Is there a way to just have a label?
    As it stands right now, it just gets replaced by "empty label", but in some cases I simply don't want a label to be present (e.g. Music Player Controls)

  2. Why can't I set the Emoji for Buttons as literal Emojis (e.g. ⏩instead of U+23E9), because as far as the Emoji Interface from JDA goes, it should be possible according to the JavaDocs.

  3. This one is just out of curiosity, but the Button Annotation's JavaDocs say something about "retruns an Optional hold the x", even though none of the methods return an Optional

Cooldown system

Hello, is there any way to setup a cooldown annotation and let the dependency manage command cooldowns ?

Problems with latest JDA alpha

I get an error when upgrading to the latest (15) JDA alpha build. I'm using the latest commit of the dev-jda5 branch.

java.lang.NoSuchMethodError: 'net.dv8tion.jda.api.entities.MessageChannel net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent.getChannel()'
	at com.github.kaktushose.jda.commands.dispatching.parser.impl.DefaultSlashCommandParser.parse(DefaultSlashCommandParser.java:47)
	at com.github.kaktushose.jda.commands.dispatching.parser.impl.DefaultSlashCommandParser.parse(DefaultSlashCommandParser.java:23)
	at com.github.kaktushose.jda.commands.dispatching.parser.Parser.parseInternal(Parser.java:19)
	at com.github.kaktushose.jda.commands.dispatching.parser.ParserSupervisor.onGenericEvent(ParserSupervisor.java:95)
	at net.dv8tion.jda.api.hooks.ListenerAdapter.onEvent(ListenerAdapter.java:365)
	at net.dv8tion.jda.api.hooks.InterfacedEventManager.handle(InterfacedEventManager.java:96)
	at net.dv8tion.jda.internal.hooks.EventManagerProxy.handleInternally(EventManagerProxy.java:88)
	at net.dv8tion.jda.internal.hooks.EventManagerProxy.handle(EventManagerProxy.java:70)
	at net.dv8tion.jda.internal.JDAImpl.handleEvent(JDAImpl.java:170)
	at net.dv8tion.jda.internal.handle.InteractionCreateHandler.handleCommand(InteractionCreateHandler.java:109)
	at net.dv8tion.jda.internal.handle.InteractionCreateHandler.handleInternally(InteractionCreateHandler.java:80)
	at net.dv8tion.jda.internal.handle.SocketHandler.handle(SocketHandler.java:39)
	at net.dv8tion.jda.internal.requests.WebSocketClient.onDispatch(WebSocketClient.java:953)
	at net.dv8tion.jda.internal.requests.WebSocketClient.onEvent(WebSocketClient.java:840)
	at net.dv8tion.jda.internal.requests.WebSocketClient.handleEvent(WebSocketClient.java:818)
	at net.dv8tion.jda.internal.requests.WebSocketClient.onBinaryMessage(WebSocketClient.java:992)
	at com.neovisionaries.ws.client.ListenerManager.callOnBinaryMessage(ListenerManager.java:385)
	at com.neovisionaries.ws.client.ReadingThread.callOnBinaryMessage(ReadingThread.java:276)
	at com.neovisionaries.ws.client.ReadingThread.handleBinaryFrame(ReadingThread.java:996)
	at com.neovisionaries.ws.client.ReadingThread.handleFrame(ReadingThread.java:755)
	at com.neovisionaries.ws.client.ReadingThread.main(ReadingThread.java:108)
	at com.neovisionaries.ws.client.ReadingThread.runMain(ReadingThread.java:64)
	at com.neovisionaries.ws.client.WebSocketThread.run(WebSocketThread.java:45)

No choice support?

Hello,
I love this API so far, it has great features, but my question is that I don't quite see any choice support for commands. If I am incorrect I would like to know please as I am kinda oblivious sometimes.

If(ChoiceSupport == null){
tellMe();
possiblyAddChoiceSupport();
thanks();
}

[FEATURE] Interpolate message sending

So, I have two quick questions about the new version of jda-commands, as I'm currently in the process of migrating my Bots structure to Version 2.0.0

  1. I can't figure out how to give it the packages where my commands reside in. In the example you do it like this:
    image
    but the only methods I can find in the library have Strings there.
    image
    What pattern would I have to use for example to find all Commands in say example.commands?

  2. Is there no way anymore to customize how the help Command gets sent? Because I until now have written my own custom help sending mechanism:
    image
    This was easy in the prior versions, but I can't seem to find a way to do it in Version 2.0.0 (I could very well have overseen something, but as of right now I can't find anything)

Plugin Support

Hey, wanted to ask if there is any sort of Plugin Support for this Framework, as it would be quite useful.

Doesn't find Commands when packaged

When I package my Bot to a .jar file it doesn't find any Commands anymore. The Program itself and the help Command works without problems, it's just the custom Commands that don't work.

Class Categories

Hello, is there a way to set the category of all commands in a, as a CommandController annotated, Class once?

For example, if I had something like this:

@CommandController
public class SecurityCommands {

@Command(value = "aCommand", category = "Security")
public void aCommand(CommandEvent event) {...}

@Command(value = "AnotherCommand", category "Security)
public void anotherCommand(CommandEvent event) {...}
}

would it be possible to set the category once for all the Commands instead of applying the category on each Command individually?

[Feature] Optional parameter in two functions

It would be great to have support for splitting a command into two functions if a parameter is optional.

Something like this:

@Command(value = "verify", name = "Verify yourself", usage = "{prefix}verify", desc = "Verify your account.", category = "Customers")
public void onVerify(CommandEvent event) {}

@Command(value = "verify", name = "Verify yourself", usage = "{prefix}verify <Token>", desc = "Verify your account.", category = "Customers", hidden = true)
//TODO Implement the hidden option, so that the command with parameter will not be added to the help command.
public void onVerifyToken(CommandEvent event, String token) {}

That way, you can organize your code event better. Now I have to add an optional parameter, and check if it is empty or not.

Make embed cache loading more intuitive

I'm currently using this code, but it does not work. It still responds with the default embeds.

final JDACommands jdaCommands = JDACommands.start(jda, MyBotClass.class, "nl.sbdeveloper.mypackage.commands");
final EmbedCache embeds = new EmbedCache(MyBotClass.class.getClassLoader().getResourceAsStream("embeds.json"));
jdaCommands.getImplementationRegistry().setHelpMessageFactory(new JsonHelpMessageFactory(embeds));
jdaCommands.getImplementationRegistry().setErrorMessageFactory(new JsonErrorMessageFactory(embeds));

Issue pulling dependency

Hey, I wanted to push a fix for my bot yesterday, but my CI/CD pipeline couldn't compile it because it couldn't resolve "com.github.Kaktushose:jda-commands:v.2.2.0". Naturally I thought I accidentally changed that line and copy pasted the line from the release in it again, but it seems like it is not usable. Was there any change in naming I'm not aware of?

[BUG] DM message error

When I send a message to a user in DM, I get this error:

java.lang.IllegalStateException: This message event did not happen in a guild
	at net.dv8tion.jda.api.events.message.GenericMessageEvent.getGuild(GenericMessageEvent.java:155)
	at com.github.kaktushose.jda.commands.dispatching.GenericEvent.fromEvent(GenericEvent.java:54)
	at com.github.kaktushose.jda.commands.dispatching.CommandContext.<init>(CommandContext.java:88)
	at com.github.kaktushose.jda.commands.dispatching.parser.impl.MigratingMessageParser.parse(MigratingMessageParser.java:33)
	at com.github.kaktushose.jda.commands.dispatching.parser.impl.MigratingMessageParser.parse(MigratingMessageParser.java:26)
	at com.github.kaktushose.jda.commands.dispatching.parser.Parser.parseInternal(Parser.java:19)
	at com.github.kaktushose.jda.commands.dispatching.parser.ParserSupervisor.onGenericEvent(ParserSupervisor.java:95)
	at net.dv8tion.jda.api.hooks.ListenerAdapter.onEvent(ListenerAdapter.java:365)
	at net.dv8tion.jda.api.hooks.InterfacedEventManager.handle(InterfacedEventManager.java:96)
	at net.dv8tion.jda.internal.hooks.EventManagerProxy.handleInternally(EventManagerProxy.java:88)
	at net.dv8tion.jda.internal.hooks.EventManagerProxy.handle(EventManagerProxy.java:70)
	at net.dv8tion.jda.internal.JDAImpl.handleEvent(JDAImpl.java:169)
	at net.dv8tion.jda.internal.handle.MessageCreateHandler.handleInternally(MessageCreateHandler.java:127)
	at net.dv8tion.jda.internal.handle.SocketHandler.handle(SocketHandler.java:36)
	at net.dv8tion.jda.internal.requests.WebSocketClient.onDispatch(WebSocketClient.java:954)
	at net.dv8tion.jda.internal.requests.WebSocketClient.onEvent(WebSocketClient.java:841)
	at net.dv8tion.jda.internal.requests.WebSocketClient.handleEvent(WebSocketClient.java:819)
	at net.dv8tion.jda.internal.requests.WebSocketClient.onBinaryMessage(WebSocketClient.java:993)
	at com.neovisionaries.ws.client.ListenerManager.callOnBinaryMessage(ListenerManager.java:385)
	at com.neovisionaries.ws.client.ReadingThread.callOnBinaryMessage(ReadingThread.java:276)
	at com.neovisionaries.ws.client.ReadingThread.handleBinaryFrame(ReadingThread.java:996)
	at com.neovisionaries.ws.client.ReadingThread.handleFrame(ReadingThread.java:755)
	at com.neovisionaries.ws.client.ReadingThread.main(ReadingThread.java:108)
	at com.neovisionaries.ws.client.ReadingThread.runMain(ReadingThread.java:64)
	at com.neovisionaries.ws.client.WebSocketThread.run(WebSocketThread.java:45)

I'm on JDA alpha 13 and on commit e9c1d76c6b of the dev-jda5 branch (latest).

[BUG] Default help description prefix not updating when using custom embeds

When I change the prefix of a guild from & to mp! with getJDACommands().getGuildSettings().put(guild.getIdLong(), commandSettings);, and then type mp!help, I will get an embed like this:

image

So, the prefix in the commands changes, but not in the description of the embed.

The defaultHelp part of the embed.json I'm using:

{
  "defaultHelp": {
    "title": "Help",
    "description": "De volgende commando's zijn beschikbaar. Typ `{prefix}{helpLabel} <command>` om specifieke hulp te krijgen",
    "color": "#00ff00"
  },
}

Can you look into this issue for me? With the default embeds it's working fine.

Missing pattern escaping in EmbedDTO

The expected input Pagination$CurrencyType for JsonErrorMessageFactory#getSyntaxErrorMessage throws the following exception

java.lang.IllegalArgumentException: Illegal group reference
   at java.base/java.util.regex.Matcher.appendExpandedReplacement(Matcher.java:1067)
   at java.base/java.util.regex.Matcher.appendReplacement(Matcher.java:997)
   at java.base/java.util.regex.Matcher.replaceAll(Matcher.java:1181)
   at java.base/java.lang.String.replaceAll(String.java:2938)
   at com.github.kaktushose.jda.commands.embeds.EmbedDTO.injectValue(EmbedDTO.java:333)
   at com.github.kaktushose.jda.commands.embeds.error.JsonErrorMessageFactory.getSyntaxErrorMessage(JsonErrorMessageFactory.java:138)
   at com.github.kaktushose.jda.commands.dispatching.adapter.TypeAdapterRegistry.adapt(TypeAdapterRegistry.java:179)
   at com.github.kaktushose.jda.commands.dispatching.CommandDispatcher.onEvent(CommandDispatcher.java:187)
   at com.github.kaktushose.jda.commands.dispatching.parser.ParserSupervisor.onGenericEvent(ParserSupervisor.java:107)
   at net.dv8tion.jda.api.hooks.ListenerAdapter.onEvent(ListenerAdapter.java:365)
   at net.dv8tion.jda.api.hooks.InterfacedEventManager.handle(InterfacedEventManager.java:96)
   at net.dv8tion.jda.internal.hooks.EventManagerProxy.handleInternally(EventManagerProxy.java:88)
   at net.dv8tion.jda.internal.hooks.EventManagerProxy.handle(EventManagerProxy.java:70)
   at net.dv8tion.jda.internal.JDAImpl.handleEvent(JDAImpl.java:169)
   at net.dv8tion.jda.internal.handle.InteractionCreateHandler.handleCommand(InteractionCreateHandler.java:109)
   at net.dv8tion.jda.internal.handle.InteractionCreateHandler.handleInternally(InteractionCreateHandler.java:80)
   at net.dv8tion.jda.internal.handle.SocketHandler.handle(SocketHandler.java:36)
   at net.dv8tion.jda.internal.requests.WebSocketClient.onDispatch(WebSocketClient.java:954)
   at net.dv8tion.jda.internal.requests.WebSocketClient.onEvent(WebSocketClient.java:841)
   at net.dv8tion.jda.internal.requests.WebSocketClient.handleEvent(WebSocketClient.java:819)
   at net.dv8tion.jda.internal.requests.WebSocketClient.onBinaryMessage(WebSocketClient.java:993)
   at com.neovisionaries.ws.client.ListenerManager.callOnBinaryMessage(ListenerManager.java:385)
   at com.neovisionaries.ws.client.ReadingThread.callOnBinaryMessage(ReadingThread.java:276)
   at com.neovisionaries.ws.client.ReadingThread.handleBinaryFrame(ReadingThread.java:996)
   at com.neovisionaries.ws.client.ReadingThread.handleFrame(ReadingThread.java:755)
   at com.neovisionaries.ws.client.ReadingThread.main(ReadingThread.java:108)
   at com.neovisionaries.ws.client.ReadingThread.runMain(ReadingThread.java:64)
   at com.neovisionaries.ws.client.WebSocketThread.run(WebSocketThread.java:45)

[FEATURE] Reply with files

Is it possible to reply with files at the CommandEvent? If not, can you add this?

EDIT: This works, but here should be a better way...

event.reply("My message.", message -> message.editMessage(message).addFile(file).queue());

Concat is ignored when using slash commands

I have this command:

@Command(value = "reminder", desc = "Set a reminder")
public void onReminder(CommandEvent event, @Param("The time to send the reminder at") String time, @Concat @Param("The message to send with the reminder") String message) {
}

And when I use /reminder 3h Hello there! the message variable only contains Hello.

I'm on v2.3.0-alpha-1.

Comand settings

None of the command settings class appears to be working for me making me unable to set command permissions etc.
Cannot make a static reference to the non-static method getPermissionHolders(String) from the type CommandSettings

i18n support

Hello, is there any way you could add i18n to the error/info messages that are hardcoded into the lib? For example having a different language per server the same way prefixes work.
Thank you :)

Question about jdav5 version

Hi !

I've seen you're currently working on a major update supporting interactions.
Do you have a release date for now ? Or is it already functionnal, so we can build it ourselves ?

Thanks for your incredible work and have a nice day

SlashCommandUpdater throws exception when no commands are available

Exception in thread "main" java.lang.IllegalArgumentException: Name may not be empty
	at net.dv8tion.jda.internal.utils.Checks.notEmpty(Checks.java:84)
	at net.dv8tion.jda.api.interactions.commands.build.OptionData.addChoice(OptionData.java:698)
	at net.dv8tion.jda.api.interactions.commands.build.OptionData.addChoices(OptionData.java:746)
	at net.dv8tion.jda.api.interactions.commands.build.OptionData.addChoices(OptionData.java:778)
	at com.github.kaktushose.jda.commands.interactions.commands.SlashCommandUpdater.addHelpCommands(SlashCommandUpdater.java:83)
	at com.github.kaktushose.jda.commands.interactions.commands.SlashCommandUpdater.update(SlashCommandUpdater.java:73)
	at com.github.kaktushose.jda.commands.dispatching.CommandDispatcher.<init>(CommandDispatcher.java:100)
	at com.github.kaktushose.jda.commands.JDACommands.<init>(JDACommands.java:46)
	at com.github.kaktushose.jda.commands.JDACommandsSlashBuilder.startGuild(JDACommandsSlashBuilder.java:90)
	at com.github.kaktushose.languagebot.Bot.start(Bot.java:26)
	at com.github.kaktushose.languagebot.Bootstrapper.main(Bootstrapper.java:29)
	

Not finding commands in jar

So, as I'm preparing my bot for JDA 5 and 2.3.0 of JDA-Commands, I have noticed that my current CI/CD breaks when packaging the bot in a jar file (runs normally when not running it as a jar file). It breaks in form of not finding any Commands anymore. In Version 2.2.0 this wasn't an issue and worked flawlessly.

Here's the code with which I start my Bot:

String[] packages = {"main.discord.commands", "main.api.jdaCommands"};
JDACommands commands = JDACommands.start(manager, Main.class, packages);

I've also included my debug level log file as well as my info level log file in case you need it. (Bot related stuff should start after "Starting JDA-Commands")

debug.log
info.log

A way to disable Command Not Found Embed

It would be great if I somehow could disable this behaviour, as it sometimes appears in a conversation.
As how it is currently, I would need to write a completely own CommandDispatcher and since this is a final class, which is needed by JDACommands and JDACommandsBuilder, I would need to make new Versions of both of these classes, just to disable the CommandNotFound embeds from sending.

Improve embed cache injecting

The EmbedCache should also accept standard String patterns. Example:

{
  "description": "You have %d %s"
}
embedDTO.inject(20, "coins");

Storing prefixes for the servers.

I think there should be option too choose a option where we want to store our data, like mysql, moongose, sqlite, yaml, json etc.

Improve exception handling SlashCommandUpdater

When the construction of a CommandData throws an exception, e.g. IllegalArgumentException for names, the exception should be caught and rethrown with information about the command causing the error. Currently the exception just get passed through, which makes debugging hard

Show users the name of the argument that is missing

Code:

@Command("reactionmsg")
    public void onTellAge(CommandEvent event, int age) {
        event.reply(String.format("You are %s years old.", age));
    }

Expected Behavior

Tells the user that the missing argument was "age" of type "INTEGER"

Specified prefix only works for the help command.

This is the code I'm using to start my bot, in this case the config option is "!blue ".
https://pastebin.com/JPm6pEER
If I try use that above prefix by itself, or with any command, it tells me to to use "!help" instead of the prefix I set.
And then all the commands only work with "!<command"> as listed in the help menu.
Not sure why this started happening, worked fine before.

980b17e58a8845644dddb3047d3c85a9

Multiple prefixes

Hey, I didn't find an option for multiple prefixes in the Framework (correct me if I'm wrong). This would be useful for Prefixes which should be independent of the Case (example: miku and Miku) or where a name gets shortened (m! instead of Miku)

Resolving User/Member from parameters not working due to usage of getUserById / getMemberById

Currently you are using getUserById / getMemberById to resolve the users / members. But if the cache is empty, this will always return null.

You should use retrieveUserById / retrieveMemberById to fix these issues. This will load into cache and return the correct object.

https://ci.dv8tion.net/job/JDA/javadoc/net/dv8tion/jda/api/JDA.html#retrieveUserById(java.lang.String)
https://ci.dv8tion.net/job/JDA/javadoc/net/dv8tion/jda/api/entities/Guild.html#retrieveMemberById(java.lang.String)

Private Messages Support

As only onGuildMessageReceived events are getting used by the Command Framework I wondered if there was a way to enable private Messages for certain Commands, without having to write a whole own CommandDispatcher and by extension a whole own JDACommandsBuilder class. It would be quite nice for, as an example, authentication of a user for a third-party service.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.