Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.tfkjake.projectaltis;
- import me.tfkjake.projectaltis.commands.*;
- import me.tfkjake.projectaltis.event.Message;
- import me.tfkjake.projectaltis.handlers.CommandHandler;
- import net.dv8tion.jda.core.AccountType;
- import net.dv8tion.jda.core.JDA;
- import net.dv8tion.jda.core.JDABuilder;
- import net.dv8tion.jda.core.entities.*;
- import java.io.*;
- import java.net.InetAddress;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Properties;
- /**
- * Created by jakebooy on 10/03/17.
- */
- public class Cog extends CommandHandler {
- public static JDA api = null;
- private String token;
- public static void main(String args[]){
- try{
- // local
- System.out.println(InetAddress.getLocalHost().getHostAddress().toString());
- if(InetAddress.getLocalHost().getHostAddress().toString().equalsIgnoreCase("127.0.1.1")){
- new Cog();
- }else{
- System.out.println("Whoa there! You're trying to host me yourself? How dare you.");
- }
- /* live
- if(InetAddress.getLocalHost().getHostAddress().toString().equalsIgnoreCase("VPS_IP")){
- }else{
- System.out.println("Whoa there! You're trying to host me yourself? How dare you.");
- }
- */
- }catch(Exception e){}
- }
- public static Properties getStaticConfig(){
- Properties prop = new Properties();
- InputStream input = null;
- try{
- input = new FileInputStream("config.properties");
- prop.load(input);
- }catch(IOException e){
- e.printStackTrace();
- }finally{
- if (input != null) {
- try {
- input.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- return prop;
- }
- public Properties getConfig(){
- Properties prop = new Properties();
- InputStream input = null;
- try{
- input = new FileInputStream("config.properties");
- prop.load(input);
- }catch(IOException e){
- e.printStackTrace();
- }finally{
- if (input != null) {
- try {
- input.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- return prop;
- }
- public void writeConfig(String key, String value){
- Properties prop = getConfig();
- OutputStream output = null;
- try {
- output = new FileOutputStream("config.properties");
- prop.setProperty(key, value);
- prop.store(output, null);
- } catch (IOException io) {
- io.printStackTrace();
- } finally {
- if (output != null) {
- try {
- output.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- }
- public Cog(){
- try {
- BufferedReader br = new BufferedReader(new FileReader("token.txt"));
- String line;
- while ((line = br.readLine()) != null) {
- token = line;
- }
- br.close();
- }catch(Exception e){}
- cog(token);
- }
- public void cog(String token){
- try{
- api = new JDABuilder(AccountType.BOT).setToken(token).addListener(new Message(this)).buildBlocking();
- register(new Help(this));
- register(new Disable(this));
- register(new Enable(this));
- // register(new RequestDubito(this));
- register(new Ban(this));
- register(new Kick(this));
- //register(new Set(this));
- register(new AddCom(this));
- register(new DelCom(this));
- register(new EditCom(this));
- register(new Status(this));
- setStatus();
- }catch(Exception e){
- e.printStackTrace();
- cog(token);
- }
- }
- public boolean userHasRole(Member user, String role){
- for(Role r : user.getRoles()){
- if(r.getName().equalsIgnoreCase(role))
- return true;
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement