Skip to content

Commit

Permalink
Command conversion #1: Help Command
Browse files Browse the repository at this point in the history
  • Loading branch information
Chew committed Jun 1, 2020
1 parent 3b6eb86 commit bbe7d78
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -3,3 +3,6 @@
.classpath
.settings/
target/
bot.properties
*.rb
*Example*
48 changes: 48 additions & 0 deletions src/main/java/pw/chew/Chewbotcca/Main.java
@@ -1,4 +1,52 @@
package pw.chew.Chewbotcca;

import com.jagrosh.jdautilities.command.CommandClientBuilder;
import com.jagrosh.jdautilities.commons.waiter.EventWaiter;
import net.dv8tion.jda.api.JDABuilder;
import net.dv8tion.jda.api.OnlineStatus;
import net.dv8tion.jda.api.entities.Activity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pw.chew.Chewbotcca.commands.about.HelpCommand;

import javax.security.auth.login.LoginException;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

public class Main {
private static final Logger logger = LoggerFactory.getLogger(Main.class);
static Properties prop = new Properties();

public static void main(String[] args) throws LoginException, IOException {
prop.load(new FileInputStream("bot.properties"));

EventWaiter waiter = new EventWaiter();

CommandClientBuilder client = new CommandClientBuilder();

client.useDefaultGame();
client.setOwnerId(prop.getProperty("owner_id"));

// Set your bot's prefix
logger.info("Setting Prefix to " + prop.getProperty("prefix"));
client.setPrefix(prop.getProperty("prefix"));

client.useHelpBuilder(false);

// Register commands
client.addCommands(
new HelpCommand()
);

// Register listeners

// Register JDA
JDABuilder.createDefault(prop.getProperty("token"))
.setStatus(OnlineStatus.ONLINE)
.setActivity(Activity.playing("Booting..."))
.addEventListeners(waiter, client.build())
.build();

}
}
28 changes: 28 additions & 0 deletions src/main/java/pw/chew/Chewbotcca/commands/about/HelpCommand.java
@@ -0,0 +1,28 @@
package pw.chew.Chewbotcca.commands.about;

import com.jagrosh.jdautilities.command.Command;
import com.jagrosh.jdautilities.command.CommandEvent;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.Permission;

public class HelpCommand extends Command {
public HelpCommand() {
this.name = "help";
this.help = "Get Help with the bot";
this.botPermissions = new Permission[]{Permission.MESSAGE_EMBED_LINKS};
this.guildOnly = false;
}

@Override
protected void execute(CommandEvent commandEvent) {
commandEvent.reply(new EmbedBuilder()
.setTitle("Welcome to the Chewbotcca Discord Bot")
.setColor(0xd084)
.setDescription("Chewbotcca is a multi-purpose, semi-functional, almost always online, discord bot!")
.addField("Commands", "You can find all my commands [here](http://discord.chewbotcca.co/commands)", true)
.addField("Invite me!", "You can invite me to your server with [this link](http://bit.ly/Chewbotcca).", true)
.addField("Help Server", "Click [me](https://discord.gg/Q8TazNz) to join the help server.", true)
.addField("More Bot Stats", "Run `%^stats` to see more stats!", true)
.build());
}
}

0 comments on commit bbe7d78

Please sign in to comment.