addSearchPath

fun addSearchPath(packageName: String)(source)

Adds this package for class discovery. All services, commands, handlers, listeners, etc... will be read from these packages.

Tip: For your commands, you can have your package structure such as:

commands/
├─ common/
│ ├─ fun/
│ │ ├─ CommonFish.java
│ │ ├─ CommonMeme.java
│ ├─ moderation/
│ │ ├─ CommonBan.java
├─ slash/
│ ├─ fun/
│ │ ├─ SlashFish.java
│ │ ├─ SlashMeme.java
│ ├─ moderation/
│ │ ├─ SlashBan.java
├─ text/
│ ├─ fun/
│ │ ├─ TextFish.java
│ │ ├─ TextMeme.java
│ ├─ moderation/
│ │ ├─ TextBan.java

The common package would have code that works for both the text and the slash commands, such as the methods that take the event's data (the command caller, guild, channel, parameters... instead of the event itself), and then return a MessageCreateData that lets you generate the message output, without actually knowing how to send the reply.

This is only beneficial if you plan on having the same logic for multiple input types (text / slash commands, for example).

Parameters

packageName

The package name such as io.github.freya022.bot.commands

See also