{"id":16377761,"url":"https://github.com/walshydev/jba","last_synced_at":"2025-04-19T23:54:31.647Z","repository":{"id":130663440,"uuid":"84651775","full_name":"WalshyDev/JBA","owner":"WalshyDev","description":"Allows you to easily create a JDA bot with a command system fully built in!","archived":false,"fork":false,"pushed_at":"2019-04-19T08:46:44.000Z","size":162,"stargazers_count":4,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-19T23:54:27.629Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WalshyDev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-03-11T13:27:09.000Z","updated_at":"2021-02-20T10:07:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"509963e2-bc37-4d99-ae86-277a6ced4603","html_url":"https://github.com/WalshyDev/JBA","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WalshyDev%2FJBA","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WalshyDev%2FJBA/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WalshyDev%2FJBA/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WalshyDev%2FJBA/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WalshyDev","download_url":"https://codeload.github.com/WalshyDev/JBA/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249830852,"owners_count":21331357,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T03:43:55.757Z","updated_at":"2025-04-19T23:54:31.630Z","avatar_url":"https://github.com/WalshyDev.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JBA\nAllows you to easily create a JDA bot with a command system fully built in!\n\nJBA is a wrapper for JDA, it allows you to create a JDA bot with ease (especially for sharding) and it also has an in-built command system so that you can just sit back and make only the command classes and not worry about the users input to get the command or aliases!\n\n# Setup\n\nIf you use Maven you will want to put this in your pom.xml\n```xml\n\u003crepositories\u003e\n    \u003crepository\u003e\n        \u003cid\u003eJBA-mvn-repo\u003c/id\u003e\n        \u003curl\u003ehttps://raw.github.com/WalshyDev/JBA/mvn-repo/\u003c/url\u003e\n    \u003c/repository\u003e\n\u003c/repositories\u003e\n...\n\u003cdependencies\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003ecom.walshydev.jba\u003c/groupId\u003e\n        \u003cartifactId\u003eJBA\u003c/artifactId\u003e\n        \u003cversion\u003e1.3\u003c/version\u003e\n    \u003c/dependency\u003e\n\u003c/dependencies\u003e\n```\n\n# Creating the JDA object\n\n```java\n// To make a new JDA object you will need to be in your JBA class and use the method init\n\n// The AccountType of your bot, BOT or CLIENT\n// The token of your bot or client\n// Prefix you want to use for the command system (Don't include if you don't want to use the in-built system)\nnew YourBotClass().init(AccountType.BOT, \"\u003ctoken\u003e\", \"\u003cprefix\u003e\");\n\n// If you want to do something like set the game using the builder you can also pass JDABuilder instead of AccountType and the token like so\nnew YourBotClass().init(new JDABuilder(AccountType.BOT).setToken(\"\u003ctoken\u003e\").setGame(Game.playing(\"Game of Thrones\"), \"\u003cprefix\u003e\");\n```\n\n# Using the command system\nTo use the command system it is very easy, just make a class and implement Command like so, that will then generate the default methods that you can use.\n\n```java\npublic class PingCommand implements Command {\n\n    @Override\n    public void onCommand(User sender, TextChannel channel, Message message, String[] args, Member member) {\n        // Get the time since the message sent by the user was created.\n        long pongTime = message.getCreationTime().until(LocalDateTime.now().atOffset(ZoneOffset.UTC), ChronoUnit.MILLIS);\n        channel.sendMessage(\"Pong! `\" + pongTime + \"ms`\").queue();\n    }\n\n    @Override\n    public String getCommand() {\n        return \"ping\";\n    }\n\n    @Override\n    public String getDescription() {\n        return \"Ping pong goes the bot\";\n    }\n}\n```\nYou do not need to set the description, that just makes it easier for help commands.\n\nYou can also override the method String[] getAliases() this allows you to set an alias for the command for example `p` instead of `ping`.\n\n# Setting up MySQL\nFor ease of use, JBA comes built in with a few classes to help you use MySQL as a database system. You can set up the database for usage in the pre-generated `public void run()` method made on implementing the JBA class. Inside that run method, simply enter the code below, replacing each String with your details for your MySQL DB.\n\n```java\nsetupMySQL(\"mysql_user\", \"mysql_pass\", \"mysql_address\", \"mysql_dbname\");\n```\n\nThis can be easily configured with the Config system in JBA, which you can see [here.](#config-and-mysql)\nYou can then query the database like so:\n\n```java\npublic class Clazz {\n    private String id;\n    private String message;\n\n    public Clazz(String id, String message) {\n        this.id = id;\n        this.id = message;\n    }\n}\n\npublic Clazz getClazzById(String id) {\n    final Clazz[] c = {null};\n    try {\n        SQLController.runSqlTask((conn) -\u003e {\n            PreparedStatement statement = conn.prepareStatement(\"SELECT * FROM dbname WHERE id = ?\");\n            statement.setString(1, id);\n            ResultSet set = statement.executeQuery();\n            if(set.next()) c[0] = new Clazz(id, set.getString(\"message\"));\n            else c[0] = new Clazz(id, null);\n        });\n    } catch (SQLException e) {\n        c[0] = new Clazz(id, null);\n    }\n    return c[0];\n}\n```\n\n# Config\nJBA also comes with a `Config` class to make it easier to make configs.\nYou create it like this:\n\n```java\nConfig config = new Config(\"config\");\n```\n\nThis creates a new file called `config.json.` You can then write in your config, following the template found in the Example Config area below.\nYou can check if a value exists using `config.exists(String path)`, and you can recall values from the config using one of the methods below, and a few others.\n\n```java\nconfig.getString(\"token\"); // Returns \"botToken\"\nconfig.getString(\"prefix\"); // Returns \"!~\"\nconfig.getString(\"mysql.user\"); // Returns \"user\"\n```\n## Config and MySQL\nYou also could use this with the `setupMySQL()` method mentioned earlier for a more secure and more configurable setup.\n\n```java\nsetupMySQL(config.getString(\"mysql.user\"), config.getString(\"mysql.password\"), config.getString(\"mysql.address\"), config.getString(\"mysql.dbname\"));\n```\n\n## Example Config\n```\n{\n  \"token\": \"botToken\",\n  \"prefix\": \"!~\",\n  \"mysql\": {\n    \"user\": \"user\",\n    \"password\": \"password\",\n    \"address\": \"127.0.0.1\",\n    \"dbname\": \"botdatabase\"\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwalshydev%2Fjba","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwalshydev%2Fjba","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwalshydev%2Fjba/lists"}