Only for you 😏 xD #20
11 changed files with 206 additions and 23 deletions
18
.travis.yml
Normal file
18
.travis.yml
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
language: java
|
||||||
|
jdk:
|
||||||
|
- openjdk12
|
||||||
|
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
packages:
|
||||||
|
- sshpass
|
||||||
|
|
||||||
|
after_success:
|
||||||
|
- wget https://raw.githubusercontent.com/DiscordHooks/travis-ci-discord-webhook/master/send.sh
|
||||||
|
- chmod +x send.sh
|
||||||
|
- ./send.sh success $WEBHOOK_URL
|
||||||
|
|
||||||
|
after_failure:
|
||||||
|
- wget https://raw.githubusercontent.com/DiscordHooks/travis-ci-discord-webhook/master/send.sh
|
||||||
|
- chmod +x send.sh
|
||||||
|
- ./send.sh failure $WEBHOOK_URL
|
||||||
80
CONTRIBUTING.md
Normal file
80
CONTRIBUTING.md
Normal file
|
|
@ -0,0 +1,80 @@
|
||||||
|
# Contributing
|
||||||
|
|
||||||
|
When contributing to this repository, please first discuss the change you wish to make via issue,
|
||||||
|
email, or any other method with the owners of this repository before making a change.
|
||||||
|
|
||||||
|
Please note we have a code of conduct, please follow it in all your interactions with the project.
|
||||||
|
|
||||||
|
## Pull Request Process
|
||||||
|
|
||||||
|
1. Ensure any install or build dependencies are removed before the end of the layer when doing a
|
||||||
|
build.
|
||||||
|
2. You may merge the Pull Request in once you have the sign-off of two other developers, or if you
|
||||||
|
do not have permission to do that, you may request the second reviewer to merge it for you.
|
||||||
|
|
||||||
|
## Code of Conduct
|
||||||
|
|
||||||
|
### Our Pledge
|
||||||
|
|
||||||
|
In the interest of fostering an open and welcoming environment, we as
|
||||||
|
contributors and maintainers pledge to making participation in our project and
|
||||||
|
our community a harassment-free experience for everyone, regardless of age, body
|
||||||
|
size, disability, ethnicity, gender identity and expression, level of experience,
|
||||||
|
nationality, personal appearance, race, religion, or sexual identity and
|
||||||
|
orientation.
|
||||||
|
|
||||||
|
### Our Standards
|
||||||
|
|
||||||
|
Examples of behavior that contributes to creating a positive environment
|
||||||
|
include:
|
||||||
|
|
||||||
|
* Using welcoming and inclusive language
|
||||||
|
* Being respectful of differing viewpoints and experiences
|
||||||
|
* Gracefully accepting constructive criticism
|
||||||
|
* Focusing on what is best for the community
|
||||||
|
* Showing empathy towards other community members
|
||||||
|
|
||||||
|
Examples of unacceptable behavior by participants include:
|
||||||
|
|
||||||
|
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||||
|
advances
|
||||||
|
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||||
|
* Public or private harassment
|
||||||
|
* Publishing others' private information, such as a physical or electronic
|
||||||
|
address, without explicit permission
|
||||||
|
* Other conduct which could reasonably be considered inappropriate in a
|
||||||
|
professional setting
|
||||||
|
|
||||||
|
### Our Responsibilities
|
||||||
|
|
||||||
|
Project maintainers are responsible for clarifying the standards of acceptable
|
||||||
|
behavior and are expected to take appropriate and fair corrective action in
|
||||||
|
response to any instances of unacceptable behavior.
|
||||||
|
|
||||||
|
Project maintainers have the right and responsibility to remove, edit, or
|
||||||
|
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||||
|
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||||
|
permanently any contributor for other behaviors that they deem inappropriate,
|
||||||
|
threatening, offensive, or harmful.
|
||||||
|
|
||||||
|
### Scope
|
||||||
|
|
||||||
|
This Code of Conduct applies both within project spaces and in public spaces
|
||||||
|
when an individual is representing the project or its community. Examples of
|
||||||
|
representing a project or community include using an official project e-mail
|
||||||
|
address, posting via an official social media account, or acting as an appointed
|
||||||
|
representative at an online or offline event. Representation of a project may be
|
||||||
|
further defined and clarified by project maintainers.
|
||||||
|
|
||||||
|
### Enforcement
|
||||||
|
|
||||||
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||||
|
reported by contacting the project team on [Discord](https://discordapp.com/invite/Vf4zCYn). All
|
||||||
|
complaints will be reviewed and investigated and will result in a response that
|
||||||
|
is deemed necessary and appropriate to the circumstances. The project team is
|
||||||
|
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||||
|
Further details of specific enforcement policies may be posted separately.
|
||||||
|
|
||||||
|
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||||
|
faith may face temporary or permanent repercussions as determined by other
|
||||||
|
members of the project's leadership.
|
||||||
|
|
@ -1 +1,3 @@
|
||||||
# Hadder
|
# Hadder
|
||||||
|
|
||||||
|
[](https://travis-ci.com/BigBotNetwork/Hadder)
|
||||||
|
|
|
||||||
10
pom.xml
10
pom.xml
|
|
@ -42,6 +42,16 @@
|
||||||
<artifactId>gson</artifactId>
|
<artifactId>gson</artifactId>
|
||||||
<version>LATEST</version>
|
<version>LATEST</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-api</artifactId>
|
||||||
|
<version>1.7.5</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-simple</artifactId>
|
||||||
|
<version>1.6.4</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
package com.bbn.hadder;
|
package com.bbn.hadder;
|
||||||
|
|
||||||
import com.bbn.hadder.commands.TestCommand;
|
import com.bbn.hadder.commands.general.*;
|
||||||
import com.bbn.hadder.commands.fun.GifCommand;
|
import com.bbn.hadder.commands.fun.GifCommand;
|
||||||
import com.bbn.hadder.commands.general.PingCommand;
|
import com.bbn.hadder.commands.misc.GitHubCommand;
|
||||||
import com.bbn.hadder.commands.moderation.*;
|
import com.bbn.hadder.commands.moderation.*;
|
||||||
import com.bbn.hadder.commands.owner.ShutdownCommand;
|
import com.bbn.hadder.commands.owner.ShutdownCommand;
|
||||||
import com.bbn.hadder.commands.settings.PrefixCommand;
|
import com.bbn.hadder.commands.settings.PrefixCommand;
|
||||||
|
|
@ -46,7 +46,7 @@ public class Hadder {
|
||||||
builder.setToken(config.getString("Token"));
|
builder.setToken(config.getString("Token"));
|
||||||
|
|
||||||
|
|
||||||
CommandHandler.cmdlist.addAll(List.of(new TestCommand(), new BanCommand(), new PrefixCommand(), new ShutdownCommand(), new KickCommand(), new PingCommand(), new GifCommand(), new ClearCommand()));
|
CommandHandler.cmdlist.addAll(List.of(new TestCommand(), new BanCommand(), new PrefixCommand(), new ShutdownCommand(), new KickCommand(), new PingCommand(), new GifCommand(), new ClearCommand(), new GitHubCommand()));
|
||||||
|
|
||||||
builder.addEventListeners(
|
builder.addEventListeners(
|
||||||
new MentionListener(),
|
new MentionListener(),
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,6 @@ public class Rethink {
|
||||||
try {
|
try {
|
||||||
Cursor cursor = r.table("server")
|
Cursor cursor = r.table("server")
|
||||||
.insert(r.hashMap("id", id)
|
.insert(r.hashMap("id", id)
|
||||||
.with("prefix", "h.")
|
|
||||||
).run(conn);
|
).run(conn);
|
||||||
out = cursor.next().toString();
|
out = cursor.next().toString();
|
||||||
} catch (ClassCastException ignored) {}
|
} catch (ClassCastException ignored) {}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,16 @@
|
||||||
package com.bbn.hadder.commands;
|
package com.bbn.hadder.commands.general;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @author Skidder / GregTCLTK
|
* @author Skidder / GregTCLTK
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import com.bbn.hadder.commands.Command;
|
||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @author Skidder / GregTCLTK
|
||||||
|
*/
|
||||||
|
|
||||||
public class TestCommand implements Command {
|
public class TestCommand implements Command {
|
||||||
|
|
||||||
public void executed(String[] args, MessageReceivedEvent event) {
|
public void executed(String[] args, MessageReceivedEvent event) {
|
||||||
|
|
@ -0,0 +1,76 @@
|
||||||
|
package com.bbn.hadder.commands.misc;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @author Skidder / GregTCLTK
|
||||||
|
*/
|
||||||
|
|
||||||
|
import com.bbn.hadder.commands.Command;
|
||||||
|
import com.bbn.hadder.utils.MessageEditor;
|
||||||
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
import okhttp3.Request;
|
||||||
|
import okhttp3.Response;
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class GitHubCommand implements Command {
|
||||||
|
@Override
|
||||||
|
public void executed(String[] args, MessageReceivedEvent event) {
|
||||||
|
if (args.length > 0) {
|
||||||
|
Request request = new Request.Builder().url("https://api.github.com/users/" + args[0]).build();
|
||||||
|
try {
|
||||||
|
|
||||||
|
Response response = new OkHttpClient().newCall(request).execute();
|
||||||
|
JSONObject json = new JSONObject(response.body().string());
|
||||||
|
|
||||||
|
String nickname = json.getString("name");
|
||||||
|
String bio = "None";
|
||||||
|
String location = "Unknown";
|
||||||
|
String website = "None";
|
||||||
|
try {
|
||||||
|
bio = json.getString("bio");
|
||||||
|
} catch (JSONException e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
location = json.getString("location");
|
||||||
|
} catch (JSONException e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!json.getString("blog").equals("")) website = json.getString("blog");
|
||||||
|
|
||||||
|
EmbedBuilder builder = new EmbedBuilder();
|
||||||
|
event.getTextChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.Messagetype.INFO, builder)
|
||||||
|
.setAuthor("Information about " + nickname + " (" + args[0] + ")", "https://github.com/" + args[0] + "", "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png")
|
||||||
|
.setThumbnail(json.getString("avatar_url"))
|
||||||
|
.addField("User bio", bio, false)
|
||||||
|
.addField("Location", location, true)
|
||||||
|
.addField("Website", website, true)
|
||||||
|
.addField("Public repositories", String.valueOf(json.getInt("public_repos")), true)
|
||||||
|
.addField("Public gists", String.valueOf(json.getInt("public_gists")), true)
|
||||||
|
.addField("Followers", String.valueOf(json.getInt("followers")), true)
|
||||||
|
.addField("Following", String.valueOf(json.getInt("following")), true)
|
||||||
|
.build()).queue();
|
||||||
|
|
||||||
|
} catch (IOException | NullPointerException e) {
|
||||||
|
EmbedBuilder builder = new EmbedBuilder();
|
||||||
|
event.getTextChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.Messagetype.ERROR, builder).setDescription("The GitHub API might be down at the moment!").build()).queue();
|
||||||
|
} catch (JSONException e) {
|
||||||
|
EmbedBuilder builder = new EmbedBuilder();
|
||||||
|
event.getTextChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.Messagetype.WARNING, builder).setDescription("This user does not exist!").build()).queue();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
EmbedBuilder builder = new EmbedBuilder();
|
||||||
|
event.getTextChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.Messagetype.WARNING, builder).setDescription("You have to specify a user!").build()).queue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] labels() {
|
||||||
|
return new String[]{"GitHub"};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -14,26 +14,21 @@ import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
||||||
public class PrefixCommand implements Command {
|
public class PrefixCommand implements Command {
|
||||||
public void executed(String[] args, MessageReceivedEvent event) {
|
public void executed(String[] args, MessageReceivedEvent event) {
|
||||||
if (event.getGuild().getMemberById(event.getAuthor().getId()).hasPermission(Permission.MANAGE_SERVER)) {
|
if (args.length == 1) {
|
||||||
if (args.length == 1) {
|
if (!args[0].contains("\"")) {
|
||||||
if (!args[0].contains("\"")) {
|
|
||||||
|
|
||||||
Rethink.update("server", event.getGuild().getId(), "prefix", args[0]);
|
Rethink.update("user", event.getAuthor().getId(), "prefix", args[0]);
|
||||||
|
|
||||||
EmbedBuilder builder = new EmbedBuilder();
|
EmbedBuilder builder = new EmbedBuilder();
|
||||||
|
|
||||||
event.getTextChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.Messagetype.INFO, builder).setTitle("✅ Successfully set ✅").setDescription("I successfully set the new prefix for this server to " + args[0]).build()).queue();
|
event.getTextChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.Messagetype.INFO, builder).setTitle("✅ Successfully set ✅").setDescription("I successfully set the new prefix for you to " + args[0]).build()).queue();
|
||||||
} else {
|
|
||||||
EmbedBuilder builder = new EmbedBuilder();
|
|
||||||
event.getTextChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.Messagetype.WARNING, builder).setDescription("The prefix must not contain **\"**").build()).queue();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
EmbedBuilder builder = new EmbedBuilder();
|
EmbedBuilder builder = new EmbedBuilder();
|
||||||
event.getTextChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.Messagetype.WARNING, builder).setDescription("You have to set a prefix.").build()).queue();
|
event.getTextChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.Messagetype.WARNING, builder).setDescription("The prefix must not contain **\"**").build()).queue();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
EmbedBuilder builder = new EmbedBuilder();
|
EmbedBuilder builder = new EmbedBuilder();
|
||||||
event.getTextChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.Messagetype.NO_PERMISSION, builder).build()).queue();
|
event.getTextChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.Messagetype.WARNING, builder).setDescription("You have to set a prefix.").build()).queue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ import java.util.Collections;
|
||||||
public class CommandParser {
|
public class CommandParser {
|
||||||
public static commandContainer parser(String raw, MessageReceivedEvent event) {
|
public static commandContainer parser(String raw, MessageReceivedEvent event) {
|
||||||
|
|
||||||
String cmd = raw.replaceFirst(Rethink.get("server", "id", event.getGuild().getId(), "prefix"), "");
|
String cmd = raw.replaceFirst(Rethink.get("user", "id", event.getAuthor().getId(), "prefix"), "");
|
||||||
String[] cmdsplit = cmd.split(" ");
|
String[] cmdsplit = cmd.split(" ");
|
||||||
String invoke = cmdsplit[0];
|
String invoke = cmdsplit[0];
|
||||||
ArrayList<String> split = new ArrayList<>();
|
ArrayList<String> split = new ArrayList<>();
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,6 @@ import net.dv8tion.jda.api.entities.ChannelType;
|
||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @author Skidder / GregTCLTK
|
* @author Skidder / GregTCLTK
|
||||||
*/
|
*/
|
||||||
|
|
@ -17,9 +15,9 @@ import javax.annotation.Nonnull;
|
||||||
public class CommandListener extends ListenerAdapter {
|
public class CommandListener extends ListenerAdapter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMessageReceived(@Nonnull MessageReceivedEvent event) {
|
public void onMessageReceived(MessageReceivedEvent event) {
|
||||||
if (event.isFromType(ChannelType.TEXT)) {
|
if (event.isFromType(ChannelType.TEXT)) {
|
||||||
if (event.getMessage().getContentRaw().startsWith(Rethink.get("server", "id", event.getGuild().getId(), "prefix"))) {
|
if (event.getMessage().getContentRaw().startsWith(Rethink.get("user", "id", event.getAuthor().getId(), "prefix"))) {
|
||||||
if (!event.getAuthor().isBot()) {
|
if (!event.getAuthor().isBot()) {
|
||||||
CommandHandler.handleCommand(CommandParser.parser(event.getMessage().getContentRaw(), event));
|
CommandHandler.handleCommand(CommandParser.parser(event.getMessage().getContentRaw(), event));
|
||||||
} else if (event.getGuild().getSelfMember().hasPermission(Permission.MESSAGE_ADD_REACTION)) {
|
} else if (event.getGuild().getSelfMember().hasPermission(Permission.MESSAGE_ADD_REACTION)) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue