Skip to content

Commit

Permalink
Merge pull request #2 from TrulyFree/master
Browse files Browse the repository at this point in the history
Various optimizations and A E S T H E T I C changes
  • Loading branch information
Moudoux authored May 16, 2017
2 parents a2fc9f8 + c534c25 commit 7f91a62
Show file tree
Hide file tree
Showing 9 changed files with 186 additions and 184 deletions.
23 changes: 1 addition & 22 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,53 +3,32 @@
<modelVersion>4.0.0</modelVersion>
<groupId>me.alexander.datbot</groupId>
<artifactId>datdiscordbot</artifactId>
<version>0.0.1-SNAPSHOT</version>

<version>0.4.1</version>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<discordselfbot.main>me.alexander.discordbot.Main</discordselfbot.main>
</properties>

<repositories>

<repository>
<id>javacord-repo</id>
<url>http://repo.bastian-oppermann.de</url>
</repository>

<repository>
<id>central</id>
<name>bintray</name>
<url>http://jcenter.bintray.com</url>
</repository>

</repositories>

<dependencies>

<dependency>
<groupId>de.btobastian.javacord</groupId>
<artifactId>javacord</artifactId>
<version>2.0.14</version>
<!-- This will use the shaded javacord which contains all required dependencies -->
<classifier>shaded</classifier>
</dependency>
<!-- A SLF4J comaptible logging framework. I would recommend to use logback -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.3</version>
</dependency>

<dependency>
<groupId>com.sedmelluq</groupId>
<artifactId>lavaplayer</artifactId>
<version>1.2.34</version>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
Expand Down
37 changes: 0 additions & 37 deletions src/main/java/me/alexander/discordbot/Logger.java

This file was deleted.

10 changes: 6 additions & 4 deletions src/main/java/me/alexander/discordbot/Main.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package me.alexander.discordbot;

import me.alexander.discordbot.Logger.LogType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import me.alexander.discordbot.SelfBot.SelfBot;

public class Main {
Expand All @@ -18,7 +20,7 @@ public class Main {
/**
* Logger instance
*/
private static Logger logger = new Logger();
private static Logger logger = LoggerFactory.getLogger(Main.class);

/**
* Main function, provide your discord account token as a CLI argument
Expand All @@ -28,10 +30,10 @@ public class Main {
*/
public static void main(final String[] args) throws InterruptedException {
if (args.length == 0) {
Main.logger.log("Please provide your Discord account token as a command line argument.", LogType.CRITICAL);
Main.logger.error("Please provide your Discord account token as a command line argument.");
return;
}
Main.logger.log("Starting SelfBot version " + version, LogType.INFO);
Main.logger.info("Starting SelfBot version " + version);
Main.bot = new SelfBot(args[0]);
Main.bot.setup();
}
Expand Down
21 changes: 14 additions & 7 deletions src/main/java/me/alexander/discordbot/SelfBot/ICommandSelfBot.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package me.alexander.discordbot.SelfBot;

import static me.alexander.discordbot.SelfBot.Utils.deleteMessageLater;

import java.awt.Color;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;

import de.btobastian.javacord.entities.User;
import de.btobastian.javacord.entities.message.Message;
import de.btobastian.javacord.entities.message.embed.EmbedBuilder;
import de.btobastian.javacord.entities.permissions.PermissionType;
import me.alexander.discordbot.SelfBot.Messages.AutoDeleteMessage;
import me.alexander.discordbot.SelfBot.Messages.EmbeddedMessage;
import me.alexander.discordbot.SelfBot.Messages.EmbeddedMessageUtil;

/**
* Takes input and interprets it
Expand Down Expand Up @@ -38,31 +40,36 @@ public static void doCmd(final String in, final Message message, final SelfBot b
bot.disconnect();
break;
case "/ban":
message.delete();
if (args.equals("")) {
new AutoDeleteMessage("Invalid argument", 2, message.getChannelReceiver());
EmbedBuilder emb = EmbeddedMessageUtil.getEmbeddedMessage("Usage Warning", "Invalid argument", "", "", "", Color.RED);
deleteMessageLater(message.reply("", emb), 2, TimeUnit.SECONDS);
break;
}
User user = Utils.getUser(args, message.getChannelReceiver().getServer(), bot);
if (user == null) {
new AutoDeleteMessage("User not found", 2, message.getChannelReceiver());
EmbedBuilder emb = EmbeddedMessageUtil.getEmbeddedMessage("Usage Warning", "User not found", "", "", "", Color.RED);
deleteMessageLater(message.reply("", emb), 2, TimeUnit.SECONDS);
break;
}
// Make sure we have permission to ban in this discord server
if (!Utils.hasPermission(bot.getAPI().getYourself(), message.getChannelReceiver().getServer(),
PermissionType.BAN_MEMBERS)) {
new AutoDeleteMessage("You are not authorized to ban", 2, message.getChannelReceiver());
EmbedBuilder emb = EmbeddedMessageUtil.getEmbeddedMessage("Usage Warning", "You are not permitted to ban others!", "", "", "", Color.RED);
deleteMessageLater(message.reply("", emb), 2, TimeUnit.SECONDS);
break;
}
// All checks passed, let's ban the user
message.getChannelReceiver().getServer().banUser(user).get();
EmbedBuilder emb = EmbeddedMessage.getEmbeddedMessage(
EmbedBuilder emb = EmbeddedMessageUtil.getEmbeddedMessage(
":hammer: **Banned:** " + user.getMentionTag() + " (" + user.getId() + ")", "", "", "", "",
Color.YELLOW);
message.reply("", emb);
break;
case "/user":
case "/embed":
message.delete();
EmbeddedMessage.embed(message, bot);
EmbeddedMessageUtil.embed(message, bot);
break;
}
}
Expand Down

This file was deleted.

Loading

0 comments on commit 7f91a62

Please sign in to comment.