Skip to content

Commit

Permalink
release 0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
phost1111 committed May 19, 2017
1 parent 4143a89 commit 2beb4e6
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 11 deletions.
9 changes: 7 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.phost</groupId>
<artifactId>discordbot</artifactId>
<version>0.5</version>
<version>0.6</version>

<repositories>
<repository>
Expand All @@ -27,7 +27,12 @@
<dependency>
<groupId>com.github.austinv11</groupId>
<artifactId>Discord4j</artifactId>
<version>dev-SNAPSHOT</version>
<version>2.8.1</version>
</dependency>
<dependency>
<groupId>com.github.phost1111</groupId>
<artifactId>CC4J</artifactId>
<version>master-15561dd968-1</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/client/ClientManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class ClientManager {
public static boolean isDeveloperMode;
public static IDiscordClient theClient;
public static EventDispatcher theDispatcher;
public static String Version = "0.5";
public static String Version = "0.6";
public static String BotAdminID = "139354514091147264";


Expand Down
22 changes: 18 additions & 4 deletions src/main/java/commands/CommandManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,15 @@ public static void commandIn(String command, IMessage message) throws RateLimitE
while(scanner.hasNext()){
args.add(scanner.next());
}
if(message.getGuild().getRolesByName("PhostBotAdmin").size() <= 0){
MessageSender.sendMessage("There is no PhostBotAdmin role on this server. You need this role to use admin commands", message.getChannel());
try {
if (message.getGuild().getRolesByName("PhostBotAdmin").size() <= 0) {
MessageSender.sendMessage("There is no PhostBotAdmin role on this server. You need this role to use admin commands", message.getChannel());
guildHasAdminRole = false;
} else {
guildHasAdminRole = true;
}
}catch (Exception e){
guildHasAdminRole = false;
}else{
guildHasAdminRole = true;
}
if(args.get(0).equals("botworking")){
Commands.botWorkingCommand(message.getChannel());
Expand Down Expand Up @@ -130,6 +134,16 @@ public static void commandIn(String command, IMessage message) throws RateLimitE
return;
}

if(args.get(0).equals("CCTrade") && args.size() == 7){
Commands.ccTradeCommand(args.get(1), args.get(2), args.get(3), args.get(4), args.get(5), args.get(6));
return;
}

if(args.get(0).equals("CCAcceptTrades")){
Commands.acceptTradesCommand();
return;
}

}

}
43 changes: 43 additions & 0 deletions src/main/java/commands/Commands.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
package commands;

import client.ClientManager;
import object.iItemToSend;
import object.iTrade;
import sx.blah.discord.handle.obj.*;
import sx.blah.discord.util.*;
import util.TradeUtil;
import utils.FileManager;
import utils.MessageSender;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.time.LocalDateTime;
import java.time.ZoneId;
Expand Down Expand Up @@ -217,4 +223,41 @@ public static void removeRoleCommand(ArrayList<String> args, IMessage message) {
mentions.get(i).removeRole(role);
}
}

public static String ccTradeCommand(String targetPlayer, String type, String pattern, String id, String stattrak, String quality) throws IOException {
File playerIDFile = new File("playerIDs.txt");
if(!playerIDFile.exists())
playerIDFile.createNewFile();
List<String> playerIDs = new ArrayList<String>();
List<String> canTrade = new ArrayList<String>();
BufferedReader br2 = new BufferedReader(new FileReader(playerIDFile));
String temp2;
while((temp2 = br2.readLine()) != null){
playerIDs.add(temp2);
canTrade.add(temp2);
}
br2.close();
for(int i = playerIDs.size(); i > 0; i--){
TradeUtil.acceptAllPendingTrades(playerIDs.get(i - 1));
}
iTrade trade = TradeUtil.createTrade(canTrade.get(0), targetPlayer);
TradeUtil.fillTradeWIthItem(canTrade.get(0), trade.getId(), new iItemToSend(Integer.parseInt(type), Integer.parseInt(pattern), Integer.parseInt(id), Integer.parseInt(stattrak), Integer.parseInt(quality), "Cheat DiscordPhost9115"));
return trade.getId();
}

public static void acceptTradesCommand() throws IOException {
File playerIDFile = new File("playerIDs.txt");
if(!playerIDFile.exists())
playerIDFile.createNewFile();
List<String> playerIDs = new ArrayList<String>();;
BufferedReader br2 = new BufferedReader(new FileReader(playerIDFile));
String temp2;
while((temp2 = br2.readLine()) != null){
playerIDs.add(temp2);
}
br2.close();
for(int i = playerIDs.size(); i > 0; i--){
TradeUtil.acceptAllPendingTrades(playerIDs.get(i - 1));
}
}
}
5 changes: 1 addition & 4 deletions src/main/java/events/MessageReceivedEventListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ public void onMessageReceivedEvent(MessageReceivedEvent event) throws RateLimitE
return;
}
if(event.getMessage().getContent().startsWith("♥")){
CommandManager.commandIn(new StringBuilder(event.getMessage().getContent()).deleteCharAt(0).toString(), event.getMessage());
System.out.println("Command received: " + event.getMessage().getContent() + " by: " + event.getMessage().getAuthor().getName() + " in Channel: " + event.getMessage().getChannel().getName() + " in Guild: " + event.getMessage().getGuild().getName());
}else{
System.out.println("Message received: " + event.getMessage().getContent() + " by: " + event.getMessage().getAuthor().getName() + " in Channel: " + event.getMessage().getChannel().getName() + " in Guild: " + event.getMessage().getGuild().getName());
CommandManager.commandIn(new StringBuilder(event.getMessage().getContent()).deleteCharAt(0).toString(), event.getMessage());
}
if(event.getMessage().getContent().toLowerCase().contains("zombe") || event.getMessage().getContent().toLowerCase().contains("z0mbey") || event.getMessage().getContent().toLowerCase().contains("zomb3y") || event.getMessage().getContent().toLowerCase().contains("z0mb3y") || event.getMessage().getContent().toLowerCase().contains("zimbel") || event.getMessage().getContent().toLowerCase().contains("zumbel")){
event.getMessage().addReaction(EmojiParser.parseToUnicode(":sparkling_heart:"));
Expand Down
1 change: 1 addition & 0 deletions src/main/java/utils/MessageSender.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import sx.blah.discord.util.DiscordException;
import sx.blah.discord.util.MissingPermissionsException;
import sx.blah.discord.util.RateLimitException;
import sx.blah.discord.util.RequestBuffer;

/**
* Created by Phost on 21.01.2017.
Expand Down

0 comments on commit 2beb4e6

Please sign in to comment.