This commit is contained in:
Tyler Murphy 2022-09-02 13:33:37 -04:00
parent 207b8857e8
commit 7932ef8bc5
14 changed files with 112 additions and 32 deletions

1
docs/_config.yml Normal file
View file

@ -0,0 +1 @@
theme: jekyll-theme-cayman

64
docs/index.md Normal file
View file

@ -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.

19
pom.xml
View file

@ -22,19 +22,24 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<version>3.3.0</version>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>module-info.class</exclude>
<exclude>META-INF/**</exclude>
</excludes>
</filter>
</filters>
<createDependencyReducedPom>false</createDependencyReducedPom>
<minimizeJar>true</minimizeJar>
<shadedArtifactAttached>true</shadedArtifactAttached>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>net.tylermurphy.ken.Ken</mainClass>
</transformer>
</transformers>
</configuration>
<executions>
<execution>
@ -75,12 +80,12 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.36</version>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.36</version>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>com.sedmelluq</groupId>
@ -90,12 +95,12 @@
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-youtube</artifactId>
<version>v3-rev222-1.25.0</version>
<version>v3-rev20220719-2.0.0</version>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.11</version>
<version>0.10.2</version>
</dependency>
<dependency>
<groupId>org.w3c</groupId>
@ -115,7 +120,7 @@
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.39.2.0</version>
<version>3.39.2.1</version>
</dependency>
<dependency>
<groupId>com.zaxxer</groupId>

View file

@ -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(

View file

@ -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 -> {

View file

@ -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");
}

View file

@ -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<SearchResult> 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()

View file

@ -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;
}

View file

@ -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);

View file

@ -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) {

View file

@ -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);

View file

@ -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;

View file

@ -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);

View file

@ -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");