Skip to content
This repository has been archived by the owner on Mar 5, 2023. It is now read-only.

Commit

Permalink
Merge pull request #52 from BigBotNetwork/greg-dev
Browse files Browse the repository at this point in the history
Nothing special ;)
  • Loading branch information
Skidder authored Nov 5, 2019
2 parents f2d88a7 + da3e81d commit 0e1f278
Show file tree
Hide file tree
Showing 18 changed files with 25 additions and 56 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>Hadder</groupId>
<artifactId>Hadder</artifactId>
<version>0.3-ALPHA</version>
<version>0.7-ALPHA</version>

<name>Hadder</name>

Expand Down
15 changes: 5 additions & 10 deletions src/main/java/com/bbn/hadder/Hadder.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
package com.bbn.hadder;

import com.bbn.hadder.commands.general.*;
import com.bbn.hadder.commands.fun.GifCommand;
import com.bbn.hadder.commands.misc.EqualsCommand;
import com.bbn.hadder.commands.misc.GitHubCommand;
import com.bbn.hadder.commands.misc.ScreenshareCommand;
import com.bbn.hadder.commands.misc.*;
import com.bbn.hadder.commands.moderation.*;
import com.bbn.hadder.commands.owner.RebootCommand;
import com.bbn.hadder.commands.owner.ShutdownCommand;
import com.bbn.hadder.commands.owner.TestCommand;
import com.bbn.hadder.commands.owner.*;
import com.bbn.hadder.commands.fun.GifCommand;
import com.bbn.hadder.commands.settings.PrefixCommand;
import com.bbn.hadder.core.CommandHandler;
import com.bbn.hadder.core.Config;
import com.bbn.hadder.core.*;
import com.bbn.hadder.listener.*;
import net.dv8tion.jda.api.entities.Activity;
import net.dv8tion.jda.api.sharding.DefaultShardManagerBuilder;
Expand Down Expand Up @@ -52,7 +47,7 @@ public static void startBot() {
new ShutdownCommand(),
new KickCommand(),
new PingCommand(),
new GifCommand(),
new GifCommand(config),
new ClearCommand(),
new GitHubCommand(),
new ScreenshareCommand(),
Expand Down
22 changes: 8 additions & 14 deletions src/main/java/com/bbn/hadder/commands/fun/GifCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,25 @@

import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.core.Config;
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.JSONArray;
import org.json.JSONObject;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Random;

public class GifCommand implements Command {

private Config config;

public GifCommand(Config config) {
this.config = config;
}

@Override
public void executed(String[] args, CommandEvent event) {
if (args.length > 0) {
Expand All @@ -32,16 +34,8 @@ public void executed(String[] args, CommandEvent event) {
query = new StringBuilder(query.substring(0, query.length() - 1));
}

File configfile = new File("./config.json");

JSONObject config = null;
try {
config = new JSONObject(new String(Files.readAllBytes(Paths.get(configfile.toURI()))));
} catch (IOException e) {
e.printStackTrace();
}
OkHttpClient caller = new OkHttpClient();
Request request = new Request.Builder().url("http://api.giphy.com/v1/gifs/search?q=" + query + "&api_key=" + config.getString("Giphy")).build();
Request request = new Request.Builder().url("http://api.giphy.com/v1/gifs/search?q=" + query + "&api_key=" + config.getGiphyToken()).build();
try {
Random rand = new Random();
Response response = caller.newCall(request).execute();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.core.CommandHandler;
import com.bbn.hadder.utils.MessageEditor;
import net.dv8tion.jda.api.EmbedBuilder;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.utils.MessageEditor;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;

public class PingCommand implements Command {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.bbn.hadder.utils.EventWaiter;
import com.bbn.hadder.utils.MessageEditor;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;

public class EqualsCommand implements Command {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.bbn.hadder.commands.CommandEvent;
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.bbn.hadder.utils.MessageEditor;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.VoiceChannel;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;

import java.util.List;

Expand All @@ -25,8 +24,8 @@ public void executed(String[] args, CommandEvent event) {
}
} catch (NumberFormatException e) {
event.getChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.Messagetype.ERROR, new EmbedBuilder()
.setTitle("Wait, thats illegal")
.setDescription("This Id is invalid. \nMaybe you entered a wrong Id? \n\nNote: Make sure the Voicechannel is on this Guild.")).build()).queue();
.setTitle("Wait, that's illegal")
.setDescription("This ID is invalid. \nMaybe you entered a wrong ID? \n\nNote: Make sure the Voice Channel is on this Guild.")).build()).queue();
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;

public class BanCommand implements Command {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

import static java.time.temporal.ChronoUnit.DAYS;

public class ClearCommand implements Command {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;

public class KickCommand implements Command {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,11 @@
* @author Skidder / GregTCLTK
*/

import com.bbn.hadder.Rethink;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.utils.MessageEditor;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;

import java.util.Timer;
import java.util.TimerTask;

import static com.bbn.hadder.Hadder.startBot;

public class RebootCommand implements Command {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import com.bbn.hadder.utils.MessageEditor;
import net.dv8tion.jda.api.EmbedBuilder;

import net.dv8tion.jda.api.events.message.MessageReceivedEvent;

public class ShutdownCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/com/bbn/hadder/commands/owner/TestCommand.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
package com.bbn.hadder.commands.owner;

/*
* @author Skidder / GregTCLTK
*/

import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;

/*
* @author Skidder / GregTCLTK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
* @author Skidder / GregTCLTK
*/

import com.bbn.hadder.Rethink;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.utils.MessageEditor;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;


public class PrefixCommand implements Command {
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/com/bbn/hadder/listener/GuildListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ public void onGuildJoin(GuildJoinEvent event) {
rethink.insertServer(event.getGuild().getId());
EmbedBuilder builder = new EmbedBuilder();
event.getJDA().getTextChannelById("475722540140986369").sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.Messagetype.INFO, builder)
.setTitle("Joined Server").setThumbnail(event.getGuild().getIconUrl())
.setTitle("Joined Server")
.setThumbnail(event.getGuild().getIconUrl())
.addField("Name", event.getGuild().getName(), true)
.addField("Guild ID", event.getGuild().getId(), true)
.addField("Guild Owner", event.getGuild().getOwner().getUser().getAsTag(), true)
Expand All @@ -51,7 +52,8 @@ public void onGuildJoin(GuildJoinEvent event) {
public void onGuildLeave(GuildLeaveEvent event) {
EmbedBuilder builder = new EmbedBuilder();
event.getJDA().getTextChannelById("475722540140986369").sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.Messagetype.INFO, builder)
.setTitle("Left Server").setThumbnail(event.getGuild().getIconUrl())
.setTitle("Left Server")
.setThumbnail(event.getGuild().getIconUrl())
.addField("Name", event.getGuild().getName(), true)
.addField("Guild ID", event.getGuild().getId(), true)
.addField("Guild Owner", event.getGuild().getOwner().getUser().getAsTag(), true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ public void onMessageReceived(MessageReceivedEvent event) {
PrivateChannel Skidder = event.getJDA().getUserById("477141528981012511").openPrivateChannel().complete();
PrivateChannel Hax = event.getJDA().getUserById("261083609148948488").openPrivateChannel().complete();

EmbedBuilder message = new EmbedBuilder().setTitle("New DM by " + event.getAuthor().getAsTag()).setAuthor(event.getAuthor().getName(), event.getAuthor().getAvatarUrl(), event.getAuthor().getAvatarUrl()).setDescription(event.getMessage().getContentRaw()).setTimestamp(Instant.now());
EmbedBuilder message = new EmbedBuilder()
.setTitle("New DM by " + event.getAuthor().getAsTag())
.setAuthor(event.getAuthor().getName(), event.getAuthor().getAvatarUrl(), event.getAuthor().getAvatarUrl())
.setDescription(event.getMessage().getContentRaw())
.setTimestamp(Instant.now());

Skidder.sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.Messagetype.INFO, message).build()).queue();
Hax.sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.Messagetype.INFO, message).build()).queue();
Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/bbn/hadder/utils/BotList.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import okhttp3.RequestBody;
import org.json.JSONObject;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
Expand Down

0 comments on commit 0e1f278

Please sign in to comment.