From 7932ef8bc5ef07b81fe84a718e741e523d0833cc Mon Sep 17 00:00:00 2001 From: Tyler Murphy Date: Fri, 2 Sep 2022 13:33:37 -0400 Subject: [PATCH] release --- docs/_config.yml | 1 + docs/index.md | 64 +++++++++++++++++++ pom.xml | 19 ++++-- src/main/java/net/tylermurphy/ken/Ken.java | 7 +- .../tylermurphy/ken/command/Responder.java | 5 +- .../ken/command/moderation/SetJoining.java | 4 +- .../tylermurphy/ken/command/music/Play.java | 5 +- .../ken/command/selfrole/Roles.java | 7 ++ .../ken/database/EconomyTable.java | 2 +- .../ken/database/GuildSettingsTable.java | 16 ++--- .../ken/database/ModerationTable.java | 2 +- .../ken/database/SelfRoleTable.java | 9 ++- .../tylermurphy/ken/database/UserTable.java | 2 +- .../database/connections/MySQLConnection.java | 1 + 14 files changed, 112 insertions(+), 32 deletions(-) create mode 100644 docs/_config.yml create mode 100644 docs/index.md diff --git a/docs/_config.yml b/docs/_config.yml new file mode 100644 index 0000000..c419263 --- /dev/null +++ b/docs/_config.yml @@ -0,0 +1 @@ +theme: jekyll-theme-cayman \ No newline at end of file diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..4afac6b --- /dev/null +++ b/docs/index.md @@ -0,0 +1,64 @@ +## Ken Discord Bot + +A multipurpose discord bot with many things to do with the bot. It has fun commands to joke around with others such as kill and meme. It has social commands just as hug and highFive, and also allows you to ship people. Ken also has built in games such as black jack and a battle system. It has a music player with a DJ Permission system. Ken also has a XP Leveling system. And Ken also has a very lengthy moderation system with autoMod, and every moderiation command needed under the sun. It has the ability to send messages with a specified profile picture and name. And finally, it has NSFW commands for those types of people. Overall Ken has lots of things put in it, and they are all free to use for anyone who wants it. + +### Terms of Service + +```markdown +1. Using Ken + a. You may use Ken bot in a non commercial fashion, and may not use the bot for financial gain. + This includes using the bot for gambaling, casinos, financially motivated discord servers, or + any type of monetary gain. + b. Unless authorized, you agree not to not to sell, resell, exploit, transfer or upload for any + commercial purposes, for any portion of the discord bot. + c. This bot may not be used in any type of illegal context, such as scamming, blackmail, or any + another type of illegal act. +2. Security + a. We care about your servers security, but cannot guarantee that unauthorized third parties will + not be able to gain control of the bot. Therefore, if you believe the bot is behaving as it + shouldn't, please contact us immediately (contact info below). +3. 3rd party services + a. Our product uses 3rd party services that interface with the application that are not controllable + but us. We do not assume any responsibility for any such 3rd party site that may malfunction and + create any issue on your end. + b. By using this bot, you agree and assume the risk for yourself and your server, that these 3rd party + services may malfunction and send materials, information, or other content that is not suitable for your + environment. + c. We reserve the right to change any 3rd party service at any time. +4. Uploaded Content + a. Our service has sections where contenct can be uploaded to the bot. We withhold the right to delete + any contenct at any time that does not follow Discords Terms of Service. + b. We withhold the right to delete any user contenct ant any time for any reason. +5. Disclaimers + a. The Products and all included content are provided on an "as is" basis without warranty of any kind, + whether expressed or implied. DBOTS SPECIFICALLY DISCLAIMS ANY AND ALL WARRANTIES AND CONDITIONS OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT, AND ANY WARRANTIES ARISING + OUT OF COURSE OF DEALING OR USAGE OF TRADE. Dbots takes no responsibility and assumes no liability + for any User Content that you or any other user or third party posts or transmits using our Products. + You understand and agree that you may be exposed to User Content that is inaccurate, objectionable, + inappropriate for children, or otherwise unsuited to your purpose. Unfortunately, people post bad + stuff on user-generated content sites like Dbots. We take that kind of thing seriously but you still + might run into it before we have a chance to take it down. If you see bad stuff, please report it to us.\ + b. We reserve the right to revoke this license at any time, with or without cause or notice to you. If revoked + you agree to still abide by sections 1-3 of this license. + c. These terms shall be governed by the laws of New York State and the United States of America. + ``` + +### Privacy Policy + +```markdown +1. Information Collection and Use + a. While using our discord bot, we do not collect any personal information. The only information stored + is statistics of using the bot, and the username and ID of a discord user. The username and ID of the + user is only used for identifying what set of information such as a game, or xp, is linked with the + user. + b. No personal information is logged. +2. Lifetime of data + a. All data is stored in the database indentifally unless requested deletion by the user. +3. Requesting deletion of data + a. Data deletion requests must be sent directly to KenshinEto#2116 on discord with the account you want data + deleted from. +``` + +### Support or Contact +Have an issue, bug, security issue, need support, or have a concern with the bot? Contact the developer at tylermurphy534@gmail.com or KenshinEto#2116 on discord. diff --git a/pom.xml b/pom.xml index d4f019a..eafe7fb 100644 --- a/pom.xml +++ b/pom.xml @@ -22,19 +22,24 @@ org.apache.maven.plugins maven-shade-plugin - 3.2.4 + 3.3.0 *:* module-info.class - META-INF/** false true + true + + + net.tylermurphy.ken.Ken + + @@ -75,12 +80,12 @@ org.slf4j slf4j-api - 1.7.36 + 2.0.0 org.slf4j slf4j-simple - 1.7.36 + 2.0.0 com.sedmelluq @@ -90,12 +95,12 @@ com.google.apis google-api-services-youtube - v3-rev222-1.25.0 + v3-rev20220719-2.0.0 org.reflections reflections - 0.9.11 + 0.10.2 org.w3c @@ -115,7 +120,7 @@ org.xerial sqlite-jdbc - 3.39.2.0 + 3.39.2.1 com.zaxxer diff --git a/src/main/java/net/tylermurphy/ken/Ken.java b/src/main/java/net/tylermurphy/ken/Ken.java index 235479a..7c61448 100644 --- a/src/main/java/net/tylermurphy/ken/Ken.java +++ b/src/main/java/net/tylermurphy/ken/Ken.java @@ -1,7 +1,8 @@ package net.tylermurphy.ken; import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport; -import com.google.api.client.json.jackson2.JacksonFactory; + +import com.google.api.client.json.gson.GsonFactory; import com.google.api.services.youtube.YouTube; import net.dv8tion.jda.api.EmbedBuilder; import net.dv8tion.jda.api.JDA; @@ -62,7 +63,7 @@ public class Ken { try { youTube = new YouTube.Builder( GoogleNetHttpTransport.newTrustedTransport(), - JacksonFactory.getDefaultInstance(), + GsonFactory.getDefaultInstance(), null ).setApplicationName("Ken").build(); } catch(Exception e) { @@ -106,8 +107,6 @@ public class Ken { public Guild getGuildById(long id) { return api.getGuildById(id); } - public User getUserById(long id) { return api.getUserById(id); } - public EmbedBuilder getDefaultEmbed() { EmbedBuilder builder = new EmbedBuilder(); builder.setColor(new Color( diff --git a/src/main/java/net/tylermurphy/ken/command/Responder.java b/src/main/java/net/tylermurphy/ken/command/Responder.java index 62a386d..30e24f1 100644 --- a/src/main/java/net/tylermurphy/ken/command/Responder.java +++ b/src/main/java/net/tylermurphy/ken/command/Responder.java @@ -249,7 +249,6 @@ public class Responder extends ListenerAdapter { event.getHook().sendMessageEmbeds(builder.build()).queue(); event.getHook().editOriginalComponents(new ArrayList<>()).queue(); } - } private void reply(Response response, InteractionHook hook){ @@ -318,10 +317,10 @@ public class Responder extends ListenerAdapter { public void onGuildMemberJoin(GuildMemberJoinEvent event) { User user = event.getUser(); Ken.getInstance().getDatabase().getUserTable().setData(user.getIdLong(), user.getName(), Integer.parseInt(user.getDiscriminator())); - boolean setValue = false; + boolean setValue = true; String value = Ken.getInstance().getDatabase().getGuildSettingsTable().getData(event.getGuild().getIdLong(), "closeServer"); if(value != null) setValue = Boolean.parseBoolean(value); - if(setValue){ + if(!setValue){ try { event.getGuild().kick(user, "Server is currently closed").queue(); user.openPrivateChannel().queue(privateChannel -> { diff --git a/src/main/java/net/tylermurphy/ken/command/moderation/SetJoining.java b/src/main/java/net/tylermurphy/ken/command/moderation/SetJoining.java index dda30b0..8e8a8f8 100644 --- a/src/main/java/net/tylermurphy/ken/command/moderation/SetJoining.java +++ b/src/main/java/net/tylermurphy/ken/command/moderation/SetJoining.java @@ -23,9 +23,9 @@ public class SetJoining { if(toggle == setValue){ return Response.error("Server is already set to " + (toggle ? "open" : "closed")); } - boolean success = Ken.getInstance().getDatabase().getGuildSettingsTable().setData(guild.getIdLong(), "closeServer", String.valueOf(Boolean.valueOf(toggle))); + boolean success = Ken.getInstance().getDatabase().getGuildSettingsTable().setData(guild.getIdLong(), "closeServer", String.valueOf(toggle)); if(success) { - return Response.error("Set the server to " + (toggle ? "open" : "closed")); + return Response.success("Set the server to " + (toggle ? "open" : "closed")); } else { return Response.error("Failed to save the change to the database"); } diff --git a/src/main/java/net/tylermurphy/ken/command/music/Play.java b/src/main/java/net/tylermurphy/ken/command/music/Play.java index 554b8dc..e7fd47b 100644 --- a/src/main/java/net/tylermurphy/ken/command/music/Play.java +++ b/src/main/java/net/tylermurphy/ken/command/music/Play.java @@ -12,6 +12,7 @@ import net.tylermurphy.ken.command.Response; import net.tylermurphy.ken.music.PlayerManager; import java.net.URL; +import java.util.Collections; import java.util.List; public class Play { @@ -74,10 +75,10 @@ public class Play { private String searchYoutube(String input) { try { List results = Ken.getInstance().getYouTube().search() - .list("id,snippet") + .list(Collections.singletonList("id,snippet")) .setQ(input) .setMaxResults(1L) - .setType("video") + .setType(Collections.singletonList("video")) .setFields("items(id/kind,id/videoId,snippet/title,snippet/thumbnails/default/url)") .setKey(Ken.getInstance().getConfig().getString("youtubeAPIKey")) .execute() diff --git a/src/main/java/net/tylermurphy/ken/command/selfrole/Roles.java b/src/main/java/net/tylermurphy/ken/command/selfrole/Roles.java index c294d82..3634642 100644 --- a/src/main/java/net/tylermurphy/ken/command/selfrole/Roles.java +++ b/src/main/java/net/tylermurphy/ken/command/selfrole/Roles.java @@ -53,6 +53,9 @@ public class Roles { @SelectMenuCallback(name="roles") public Response onSelect(String choice, Member sender, Guild guild){ long id = Long.parseLong(choice); + if(id == 0L) { + return Response.error("There are no role selections on this page"); + } Role role = Ken.getInstance().getRoleById(id); try { if (sender.getRoles().contains(role)) { @@ -93,6 +96,10 @@ public class Roles { result.add(role.getName()); result.add(role.getId()); } + if(result.isEmpty()){ + result.add("No Roles Listed"); + result.add(String.valueOf(0L)); + } return result; } diff --git a/src/main/java/net/tylermurphy/ken/database/EconomyTable.java b/src/main/java/net/tylermurphy/ken/database/EconomyTable.java index 9a716a5..cad9ae2 100644 --- a/src/main/java/net/tylermurphy/ken/database/EconomyTable.java +++ b/src/main/java/net/tylermurphy/ken/database/EconomyTable.java @@ -43,7 +43,7 @@ public class EconomyTable { } public boolean setData(long guildId, long userId, String data) { - String sql = "INSERT OR REPLACE INTO economy_data (guild_id, user_id, data) VALUES(?,?,?)"; + String sql = "REPLACE INTO economy_data (guild_id, user_id, data) VALUES(?,?,?)"; try(Connection connection = database.connect(); PreparedStatement statement = connection.prepareStatement(sql)) { statement.setLong(1, guildId); statement.setLong(2, userId); diff --git a/src/main/java/net/tylermurphy/ken/database/GuildSettingsTable.java b/src/main/java/net/tylermurphy/ken/database/GuildSettingsTable.java index f21133e..6303861 100644 --- a/src/main/java/net/tylermurphy/ken/database/GuildSettingsTable.java +++ b/src/main/java/net/tylermurphy/ken/database/GuildSettingsTable.java @@ -13,9 +13,9 @@ public class GuildSettingsTable { String sql = """ CREATE TABLE IF NOT EXISTS guild_settings_data ( guild_id BIGINT NOT NULL, - key VARCHAR(64) NOT NULL, + name VARCHAR(64) NOT NULL, value VARCHAR(24) NOT NULL, - PRIMARY KEY (guild_id,key) + PRIMARY KEY (guild_id,name) );"""; try(Connection connection = database.connect(); Statement statement = connection.createStatement()) { @@ -27,11 +27,11 @@ public class GuildSettingsTable { this.database = database; } - public String getData(long guildId, String key){ - String sql = "SELECT * FROM guild_settings_data WHERE guild_id=? AND key=?"; + public String getData(long guildId, String name){ + String sql = "SELECT * FROM guild_settings_data WHERE guild_id=? AND name=?"; try(Connection connection = database.connect(); PreparedStatement statement = connection.prepareStatement(sql)) { statement.setLong(1, guildId); - statement.setString(2, key); + statement.setString(2, name); ResultSet rs = statement.executeQuery(); if(rs.next()) return rs.getString("value"); else return null; @@ -41,11 +41,11 @@ public class GuildSettingsTable { } } - public boolean setData(long guildId, String key, String value){ - String sql = "INSERT OR REPLACE INTO guild_settings_data (guild_id, key, value) VALUES(?,?,?)"; + public boolean setData(long guildId, String name, String value){ + String sql = "REPLACE INTO guild_settings_data (guild_id, name, value) VALUES(?,?,?)"; try(Connection connection = database.connect(); PreparedStatement statement = connection.prepareStatement(sql)) { statement.setLong(1, guildId); - statement.setString(2, key); + statement.setString(2, name); statement.setString(3, value); return statement.executeUpdate() != 0; } catch (SQLException e) { diff --git a/src/main/java/net/tylermurphy/ken/database/ModerationTable.java b/src/main/java/net/tylermurphy/ken/database/ModerationTable.java index 8a29eca..6079c25 100644 --- a/src/main/java/net/tylermurphy/ken/database/ModerationTable.java +++ b/src/main/java/net/tylermurphy/ken/database/ModerationTable.java @@ -60,7 +60,7 @@ public class ModerationTable { } public boolean setData(long guildId, long userId, JSONArray history, String status, long until) { - String sql = "INSERT OR REPLACE INTO moderation_data (guild_id, user_id, history, status, until) VALUES(?,?,?,?,?)"; + String sql = "REPLACE INTO moderation_data (guild_id, user_id, history, status, until) VALUES(?,?,?,?,?)"; try(Connection connection = database.connect(); PreparedStatement statement = connection.prepareStatement(sql)) { statement.setLong(1, guildId); statement.setLong(2, userId); diff --git a/src/main/java/net/tylermurphy/ken/database/SelfRoleTable.java b/src/main/java/net/tylermurphy/ken/database/SelfRoleTable.java index 5411bd7..5ad289c 100644 --- a/src/main/java/net/tylermurphy/ken/database/SelfRoleTable.java +++ b/src/main/java/net/tylermurphy/ken/database/SelfRoleTable.java @@ -42,7 +42,7 @@ public class SelfRoleTable { } public boolean setData(long guildId, int page, String data){ - String sql = "INSERT OR REPLACE INTO self_role_data (guild_id, page, data) VALUES(?,?,?)"; + String sql = "REPLACE INTO self_role_data (guild_id, page, data) VALUES(?,?,?)"; try(Connection connection = database.connect(); PreparedStatement statement = connection.prepareStatement(sql)) { statement.setLong(1, guildId); statement.setInt(2, page); @@ -69,11 +69,14 @@ public class SelfRoleTable { } public int getPages(long guildId) { - String sql = "SELECT MAX(page) AS pageCount FROM self_role_data WHERE guild_id = ?"; + String sql = "SELECT * FROM self_role_data WHERE guild_id = ? ORDER BY page DESC LIMIT 1"; try(Connection connection = database.connect(); PreparedStatement statement = connection.prepareStatement(sql)) { statement.setLong(1, guildId); ResultSet rs = statement.executeQuery(); - return rs.getInt("pageCount"); + if(rs.next()) { + return rs.getInt("page"); + } + return 0; } catch (SQLException e) { Ken.getInstance().getLogger().error("SQL Error: " + e.getMessage()); return -1; diff --git a/src/main/java/net/tylermurphy/ken/database/UserTable.java b/src/main/java/net/tylermurphy/ken/database/UserTable.java index 2dfe231..1b109f6 100644 --- a/src/main/java/net/tylermurphy/ken/database/UserTable.java +++ b/src/main/java/net/tylermurphy/ken/database/UserTable.java @@ -49,7 +49,7 @@ public class UserTable { } public boolean setData(long userId, String username, int discriminator) { - String sql = "INSERT OR REPLACE INTO user_data (user_id, username, discriminator) VALUES(?,?,?)"; + String sql = "REPLACE INTO user_data (user_id, username, discriminator) VALUES(?,?,?)"; try(Connection connection = database.connect(); PreparedStatement statement = connection.prepareStatement(sql)) { statement.setLong(1, userId); statement.setString(2, username); diff --git a/src/main/java/net/tylermurphy/ken/database/connections/MySQLConnection.java b/src/main/java/net/tylermurphy/ken/database/connections/MySQLConnection.java index 4fb7fce..d32490c 100644 --- a/src/main/java/net/tylermurphy/ken/database/connections/MySQLConnection.java +++ b/src/main/java/net/tylermurphy/ken/database/connections/MySQLConnection.java @@ -21,6 +21,7 @@ public class MySQLConnection implements DatabaseConnection { String password = Ken.getInstance().getConfig().getString("database.password"); String databaseName = Ken.getInstance().getConfig().getString("database.databaseName"); + config.setDriverClassName(org.mariadb.jdbc.Driver.class.getName()); config.setJdbcUrl("jdbc:mariadb://"+host+":"+port+"/"+databaseName); config.addDataSourceProperty("cachePrepStmts", "true"); config.addDataSourceProperty("prepStmtCacheSize", "250");