MCPcopy Index your code
hub / github.com/Java-Discord/JavaBot

github.com/Java-Discord/JavaBot @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
1,431 symbols 5,715 edges 303 files 774 documented · 54%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

JavaBot — General Utility Bot for the Discord Java Community

Banner

Usage

To start up, run the bot once, and it will generate a config directory. Stop the bot, and set the up all the following values: - in systems.json - jdaBotToken to your bot's token - (some adminUsers which, e.g., can manipulate the database) - in {guildId}.json - moderation.logChannelId to a channelId - moderation.staffRoleId to a roleId - moderation.adminRoleId to a roleId - jam.adminRoleId to a roleId

NOTE: Don't forget to enable the Presence Intent, Server Members Intent and Message Content Intent on the Discord Developer Portal!

Note that this is just what is required for the bot to start. Certain features may require other values to be set.

Configuration

The bot's configuration consists of a collection of simple JSON files: - systems.json contains global settings for the bot's core systems. - For every guild, a {guildId}.json file exists, which contains any guild-specific configuration settings.

At startup, the bot will initially start by loading just the global settings, and then when the Discord ready event is received, the bot will add configuration for each guild it's in, loading it from the matching JSON file, or creating a new file if needed.

Commands

We're using DIH4JDA as our Command/Interaction framework, which makes it quite easy to add new commands.

PingCommand.java

/**
 * <h3>This class represents the /ping command.</h3>
 */
public class PingCommand extends SlashCommand {
    /**
     * The constructor of this class, which sets the corresponding {@link net.dv8tion.jda.api.interactions.commands.build.SlashCommandData}.
     */
    public PingCommand() {
        setCommandData(Commands.slash("ping", "Shows the bot's gateway ping.")
                .setGuildOnly(true)
        );
    }

    @Override
    public void execute(@NotNull SlashCommandInteractionEvent event) {
        event.replyEmbeds(new EmbedBuilder()
                .setAuthor(event.getJDA().getGatewayPing() + "ms", null, event.getJDA().getSelfUser().getAvatarUrl())
                .setColor(Responses.Type.DEFAULT.getColor())
                .build()
        ).queue();
    }
}

For more information on how this works, visit the DIH4JDA Wiki!

API Documentation

GET guilds/{guild_id}/metrics

  • Responds with guild-specific metrics, such as the member- and (approximate) online count.

GET guilds/{guild_id}/users/{user_id}

  • Responds with the specified users' profile which includes some basic info, such as the users' name and avatar url, but also their recent warns, their current help experience and more!

GET guilds/{guild_id}/leaderboard/qotw?page=1

  • A paginated endpoint which responds with an ordered list of users, based on their QOTW points.

GET guilds/{guild_id}/leaderboard/experience?page=1

  • A paginated endpoint which responds with an ordered list of users, based on their help channel experience.

You can try out the API yourself on api.discordjug.net!

Credits

Inspiration we took from other communities:

Extension points exported contracts — how you extend this code

CommandModerationPermissions (Interface)
Interface which adds `setModerationSlashCommandData`. This method simply uses the provided SlashCommandData and [8 implementers]
src/main/java/net/discordjug/javabot/systems/moderation/CommandModerationPermissions.java
TransactionFunction (Interface)
Interface that defines a function that executes using a transaction. It is possible for an exception to be thrown, in wh [82 …
src/main/java/net/discordjug/javabot/data/h2db/TransactionFunction.java
MessageFilter (Interface)
This interface is implemented by all message filters. The MessageContent is processed by every class implementi [7 implementers]
src/main/java/net/discordjug/javabot/listener/filter/MessageFilter.java
PreferenceType (Interface)
Interface used by different Preference Types. This holds the default and allowed choices. [3 implementers]
src/main/java/net/discordjug/javabot/systems/user_preferences/model/PreferenceType.java
ConnectionFunction (Interface)
Functional interface for a function which produces some object using a connection. @param The generic type that is [3 …
src/main/java/net/discordjug/javabot/data/h2db/ConnectionFunction.java

Core symbols most depended-on inside this repo

getGuild
called by 269
src/main/java/net/discordjug/javabot/data/config/GuildConfigItem.java
get
called by 247
src/main/java/net/discordjug/javabot/data/config/BotConfig.java
build
called by 205
src/main/java/net/discordjug/javabot/util/QueryBuilder.java
of
called by 188
src/main/java/net/discordjug/javabot/data/h2db/TableProperty.java
error
called by 182
src/main/java/net/discordjug/javabot/util/Responses.java
addField
called by 131
src/main/java/net/discordjug/javabot/systems/staff_commands/forms/dao/FormsRepository.java
capture
called by 108
src/main/java/net/discordjug/javabot/util/ExceptionLogger.java
getChannel
called by 106
src/main/java/net/discordjug/javabot/listener/ForumPostVoteListener.java

Shape

Method 1,112
Class 296
Enum 12
Interface 11

Languages

Java100%

Modules by API surface

src/main/java/net/discordjug/javabot/systems/moderation/ModerationService.java33 symbols
src/main/java/net/discordjug/javabot/util/Responses.java20 symbols
src/main/java/net/discordjug/javabot/systems/staff_commands/forms/dao/FormsRepository.java20 symbols
src/main/java/net/discordjug/javabot/systems/help/commands/notify/HelpPingSubcommand.java19 symbols
src/main/java/net/discordjug/javabot/systems/help/HelpListener.java16 symbols
src/main/java/net/discordjug/javabot/systems/qotw/submissions/SubmissionManager.java15 symbols
src/main/java/net/discordjug/javabot/data/h2db/message_cache/MessageCache.java15 symbols
src/main/java/net/discordjug/javabot/data/config/guild/ModerationConfig.java15 symbols
src/main/java/net/discordjug/javabot/util/InteractionUtils.java14 symbols
src/main/java/net/discordjug/javabot/systems/moderation/report/ReportManager.java14 symbols
src/main/java/net/discordjug/javabot/systems/staff_commands/tags/CustomTagManager.java13 symbols
src/main/java/net/discordjug/javabot/systems/staff_commands/embeds/EditEmbedSubcommand.java13 symbols

For agents

$ claude mcp add JavaBot \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact