Petite mise à jour des évenements
This commit is contained in:
parent
59f22e5edb
commit
c456837148
@ -73,14 +73,14 @@ dependencies {
|
|||||||
|
|
||||||
compile 'org.slf4j:slf4j-nop:1.7.25'
|
compile 'org.slf4j:slf4j-nop:1.7.25'
|
||||||
|
|
||||||
compile 'net.dv8tion:JDA:3.8.1_439'
|
compile 'net.dv8tion:JDA:4.2.0_189'
|
||||||
|
|
||||||
compile 'com.thedeanda:lorem:2.1'
|
compile 'com.thedeanda:lorem:2.1'
|
||||||
|
|
||||||
compile 'commons-io:commons-io:2.6'
|
compile 'commons-io:commons-io:2.6'
|
||||||
|
|
||||||
// https://mvnrepository.com/artifact/mysql/mysql-connector-java
|
// https://mvnrepository.com/artifact/mysql/mysql-connector-java
|
||||||
compile group: 'mysql', name: 'mysql-connector-java', version: '8.0.15'
|
compile group: 'mysql', name: 'mysql-connector-java', version: '8.0.21'
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -1,9 +1,29 @@
|
|||||||
package com.bernard.juliabot;
|
package com.bernard.juliabot;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.BufferedReader;
|
||||||
import java.lang.reflect.*;
|
import java.io.File;
|
||||||
import java.sql.*;
|
import java.io.FileNotFoundException;
|
||||||
import java.util.*;
|
import java.io.FileReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.PrintStream;
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
import java.util.Scanner;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.Timer;
|
||||||
|
import java.util.TimerTask;
|
||||||
import java.util.jar.JarEntry;
|
import java.util.jar.JarEntry;
|
||||||
import java.util.jar.JarFile;
|
import java.util.jar.JarFile;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -12,11 +32,15 @@ import org.apache.commons.io.output.TeeOutputStream;
|
|||||||
|
|
||||||
import com.bernard.juliabot.JuliaAddon.JarWithMultipleAddonsException;
|
import com.bernard.juliabot.JuliaAddon.JarWithMultipleAddonsException;
|
||||||
import com.bernard.juliabot.JuliaAddon.JuliaClassLoader;
|
import com.bernard.juliabot.JuliaAddon.JuliaClassLoader;
|
||||||
import com.bernard.juliabot.api.*;
|
import com.bernard.juliabot.api.CCommande;
|
||||||
|
import com.bernard.juliabot.api.Command;
|
||||||
|
import com.bernard.juliabot.api.Discord;
|
||||||
import com.thedeanda.lorem.LoremIpsum;
|
import com.thedeanda.lorem.LoremIpsum;
|
||||||
|
|
||||||
import net.dv8tion.jda.core.*;
|
import net.dv8tion.jda.api.JDA;
|
||||||
import net.dv8tion.jda.core.events.Event;
|
import net.dv8tion.jda.api.JDABuilder;
|
||||||
|
import net.dv8tion.jda.api.events.Event;
|
||||||
|
import net.dv8tion.jda.api.events.GenericEvent;
|
||||||
|
|
||||||
public class Julia {
|
public class Julia {
|
||||||
|
|
||||||
@ -24,20 +48,20 @@ public class Julia {
|
|||||||
|
|
||||||
public static final String sysinPipe = "/home/julia/entree";
|
public static final String sysinPipe = "/home/julia/entree";
|
||||||
|
|
||||||
private static final String token = "";
|
public static final String CONNECTION_DATA_FILEPATH = "/var/julia/julia.conn";
|
||||||
|
|
||||||
static Julia theJulia;
|
static Julia theJulia;
|
||||||
|
|
||||||
public JDA jda;
|
JDA jda;
|
||||||
|
|
||||||
Map<String,JuliaAddon> avalivableAddons;//pkg+version->addon
|
Map<String,JuliaAddon> avalivableAddons;// pkg+version->addon
|
||||||
Map<Long,Character> laboratoriesIdentifieurs;//Store channels IDs ...
|
Map<Long,Character> laboratoriesIdentifieurs;//Store channels IDs ...
|
||||||
|
|
||||||
public Map<Character,Laboratory> laboratoires;
|
Map<Character,Laboratory> laboratoires;
|
||||||
|
|
||||||
Map<String,Long> fileTrack;//<File name in juliaddonFolder, lastModified>
|
Map<String,Long> fileTrack;//<File name in juliaddonFolder, lastModified>
|
||||||
|
|
||||||
public EcouteurDEvents lecouteur;
|
EcouteurDEvents lecouteur;
|
||||||
ReadLoop sysinator;
|
ReadLoop sysinator;
|
||||||
|
|
||||||
Connection eventDatabase;
|
Connection eventDatabase;
|
||||||
@ -57,52 +81,75 @@ public class Julia {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void startup() {
|
public synchronized void startup() {
|
||||||
//Set up mysql cnnections (events & data)
|
|
||||||
Properties connectionProps = new Properties();
|
BufferedReader bis;
|
||||||
connectionProps.put("user", "julia");
|
|
||||||
connectionProps.put("password", "juliabestbotever");
|
|
||||||
connectionProps.put("serverTimezone", "UTC");
|
|
||||||
connectionProps.put("verifyServerCertificate", "false");
|
|
||||||
connectionProps.put("useSSL", "true");
|
|
||||||
connectionProps.put("requireSSL", "true");
|
|
||||||
try {
|
try {
|
||||||
eventDatabase = DriverManager.getConnection("jdbc:mysql://192.168.1.41:3306/juliaEvents", connectionProps);
|
bis = new BufferedReader(new FileReader(CONNECTION_DATA_FILEPATH));
|
||||||
juliaDatabase = DriverManager.getConnection("jdbc:mysql://192.168.1.41:3306/julia", connectionProps);
|
String token = bis.readLine();
|
||||||
} catch (SQLException e) {
|
|
||||||
System.err.println("Impossible de se connecter a la BDD, ca ne sers a rien de lancer JuL'IA du coup ... Bonne nuit");
|
//Set up mysql cnnections (events & data)
|
||||||
e.printStackTrace();
|
Properties connectionProps = new Properties();
|
||||||
syserr.flush();
|
connectionProps.put("user", bis.readLine());
|
||||||
return;
|
connectionProps.put("password", bis.readLine());
|
||||||
|
connectionProps.put("serverTimezone", "UTC");
|
||||||
|
connectionProps.put("verifyServerCertificate", "false");
|
||||||
|
connectionProps.put("useSSL", "true");
|
||||||
|
connectionProps.put("requireSSL", "true");
|
||||||
|
String urlAndPort = bis.readLine();
|
||||||
|
try {
|
||||||
|
eventDatabase = DriverManager.getConnection("jdbc:mysql://"+urlAndPort+"/juliaEvents", connectionProps);
|
||||||
|
juliaDatabase = DriverManager.getConnection("jdbc:mysql://"+urlAndPort+"/julia", connectionProps);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
System.err.println("Impossible de se connecter a la BDD, ca ne sers a rien de lancer JuL'IA du coup ... Bonne nuit");
|
||||||
|
e.printStackTrace();
|
||||||
|
syserr.flush();
|
||||||
|
bis.close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("La BDD est chargée" + eventDatabase+","+juliaDatabase);
|
||||||
|
|
||||||
|
|
||||||
|
// Démarrage de JDA et du Bot
|
||||||
|
try {
|
||||||
|
lecouteur = new EcouteurDEvents(this);
|
||||||
|
jda = JDABuilder.createDefault(token).addEventListeners(getLecouteur()).build();
|
||||||
|
getJda().awaitReady();
|
||||||
|
} catch(Exception e) {
|
||||||
|
System.err.println("Impossible de démarrer JuL'IA");
|
||||||
|
e.printStackTrace();
|
||||||
|
syserr.flush();
|
||||||
|
bis.close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
long guildHello = Long.parseLong(bis.readLine());
|
||||||
|
long textChannelHello = Long.parseLong(bis.readLine());
|
||||||
|
getJda().getGuildById(guildHello).getTextChannelById(textChannelHello).sendMessage(LoremIpsum.getInstance().getWords(10, 15)).complete();
|
||||||
|
|
||||||
|
long guildErr = Long.parseLong(bis.readLine());
|
||||||
|
long textChannelErr = Long.parseLong(bis.readLine());
|
||||||
|
|
||||||
|
syserr = new JuliaErrPrintStream(getJda().getGuildById(guildErr).getTextChannelById(textChannelErr));
|
||||||
|
|
||||||
|
TeeOutputStream tos = new TeeOutputStream(System.err, syserr.printStream());
|
||||||
|
System.setErr(new PrintStream(tos));
|
||||||
|
|
||||||
|
Timer syserrtimer = new Timer("Syserr-refresh", true);
|
||||||
|
syserrtimer.schedule(new TimerTask() {
|
||||||
|
@Override
|
||||||
|
public void run() {Julia.theJulia().syserr.flushMessage();}
|
||||||
|
} , 0, 1000);
|
||||||
|
|
||||||
|
bis.close();
|
||||||
|
} catch (FileNotFoundException e1) {
|
||||||
|
System.err.println("Euhhhhh je n'ai pas trouvé le fichier "+CONNECTION_DATA_FILEPATH+" et je ne peux donc pas lire ma carte d'identitée");
|
||||||
|
e1.printStackTrace();
|
||||||
|
} catch (IOException e1) {
|
||||||
|
System.err.println("Euhhhhh je n'ai pas réussi à lire le fichier "+CONNECTION_DATA_FILEPATH+" et je ne peux donc pas lire ma carte d'identitée");
|
||||||
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("La BDD est chargée" + eventDatabase+","+juliaDatabase);
|
|
||||||
|
|
||||||
|
|
||||||
// Démarrage de JDA et du Bot
|
|
||||||
try {
|
|
||||||
lecouteur = new EcouteurDEvents(this);
|
|
||||||
jda = new JDABuilder(AccountType.BOT).setToken(token).addEventListener(lecouteur).build();
|
|
||||||
jda.awaitReady();
|
|
||||||
} catch(Exception e) {
|
|
||||||
System.err.println("Impossible de démarrer JuL'IA");
|
|
||||||
e.printStackTrace();
|
|
||||||
syserr.flush();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
jda.getGuildById(222947179017404416L).getTextChannelById(460935684669046784L).sendMessage(LoremIpsum.getInstance().getWords(10, 15)).complete();
|
|
||||||
|
|
||||||
syserr = new JuliaErrPrintStream(jda.getGuildById(222947179017404416L).getTextChannelById(576469792735756309L));
|
|
||||||
|
|
||||||
TeeOutputStream tos = new TeeOutputStream(System.err, syserr.printStream());
|
|
||||||
System.setErr(new PrintStream(tos));
|
|
||||||
|
|
||||||
Timer syserrtimer = new Timer("Syserr-refresh", true);
|
|
||||||
syserrtimer.schedule(new TimerTask() {
|
|
||||||
@Override
|
|
||||||
public void run() {Julia.theJulia().syserr.flushMessage();}
|
|
||||||
} , 0, 1000);
|
|
||||||
|
|
||||||
//Launch update to see every addon in juliaddon/
|
//Launch update to see every addon in juliaddon/
|
||||||
update();//Va remplir la map avalivableAddons
|
update();//Va remplir la map avalivableAddons
|
||||||
|
|
||||||
@ -143,9 +190,9 @@ public class Julia {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for(String l : toLoad) {
|
for(String l : toLoad) {
|
||||||
if(!laboratoires.containsKey(l.charAt(0)))
|
if(!getLaboratoires().containsKey(l.charAt(0)))
|
||||||
laboratoires.put(l.charAt(0), new Laboratory(l.charAt(0)));
|
getLaboratoires().put(l.charAt(0), new Laboratory(l.charAt(0)));
|
||||||
Laboratory labo = laboratoires.get(l.charAt(0));
|
Laboratory labo = getLaboratoires().get(l.charAt(0));
|
||||||
labo.loadAddon(l.substring(1, l.lastIndexOf(":")), l.substring(l.lastIndexOf(":")+1), false);//Pas besoin d'update, il viens d'etre fait
|
labo.loadAddon(l.substring(1, l.lastIndexOf(":")), l.substring(l.lastIndexOf(":")+1), false);//Pas besoin d'update, il viens d'etre fait
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -402,7 +449,7 @@ public class Julia {
|
|||||||
params[i] = Julia.this.juliaDatabase;
|
params[i] = Julia.this.juliaDatabase;
|
||||||
break;
|
break;
|
||||||
case "net.dv8tion.jda.core.JDA":
|
case "net.dv8tion.jda.core.JDA":
|
||||||
params[i] = Julia.this.jda;
|
params[i] = Julia.this.getJda();
|
||||||
break;
|
break;
|
||||||
//TODO completer les paramètres
|
//TODO completer les paramètres
|
||||||
|
|
||||||
@ -426,8 +473,8 @@ public class Julia {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void trigger(Event event) {
|
public void trigger(GenericEvent event) {
|
||||||
Class<? extends Event> eventClass = event.getClass();
|
Class<? extends GenericEvent> eventClass = event.getClass();
|
||||||
Set<Method> toCall = loadedEvents.get(eventClass);
|
Set<Method> toCall = loadedEvents.get(eventClass);
|
||||||
for(Method m : toCall) {
|
for(Method m : toCall) {
|
||||||
Object callable = callerObjects.get(m.getDeclaringClass());
|
Object callable = callerObjects.get(m.getDeclaringClass());
|
||||||
@ -542,4 +589,16 @@ public class Julia {
|
|||||||
return theJulia;
|
return theJulia;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public JDA getJda() {
|
||||||
|
return jda;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<Character,Laboratory> getLaboratoires() {
|
||||||
|
return laboratoires;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EcouteurDEvents getLecouteur() {
|
||||||
|
return lecouteur;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -161,7 +161,7 @@ public class JuliaAddon {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Toutes les classes du Jar ont <EFBFBD><EFBFBD>t<EFBFBD><EFBFBD> lues : Si plusieurs addons, on rentre
|
//Toutes les classes du Jar ont été lues : Si plusieurs addons, on rentre
|
||||||
//dans le if pour lever l'exception, sinon, on initialise le JuliaClassLoader
|
//dans le if pour lever l'exception, sinon, on initialise le JuliaClassLoader
|
||||||
if(juliaddons.size() > 1) {
|
if(juliaddons.size() > 1) {
|
||||||
Set<Set<JarEntry>> addonsEntries = new HashSet<>();//<pkg,Enum of classes associated with this plugin>
|
Set<Set<JarEntry>> addonsEntries = new HashSet<>();//<pkg,Enum of classes associated with this plugin>
|
||||||
@ -227,7 +227,7 @@ public class JuliaAddon {
|
|||||||
try {
|
try {
|
||||||
return cl.loadClass(name, resolve);
|
return cl.loadClass(name, resolve);
|
||||||
}catch(ClassNotFoundException e) {
|
}catch(ClassNotFoundException e) {
|
||||||
throw new ClassNotFoundException("J'ai d<EFBFBD><EFBFBD>l<EFBFBD><EFBFBD>gu<EFBFBD><EFBFBD> le chargement de la classe mais j'aurais pas du ... cette classe ne doit pas exister dans l'addon "+cl.getAddon().getName(),e);
|
throw new ClassNotFoundException("J'ai délégué le chargement de la classe mais j'aurais pas du ... cette classe ne doit pas exister dans l'addon "+cl.getAddon().getName(),e);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
try {
|
try {
|
||||||
@ -248,7 +248,7 @@ public class JuliaAddon {
|
|||||||
Collections.addAll(toWatch, loadClass(clazz.getName()).getMethods());//loadClass(clazz.getName()) poir eviter les references cassees par les classloaders
|
Collections.addAll(toWatch, loadClass(clazz.getName()).getMethods());//loadClass(clazz.getName()) poir eviter les references cassees par les classloaders
|
||||||
} catch (SecurityException | ClassNotFoundException e) {
|
} catch (SecurityException | ClassNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
System.err.println("L'addon "+JuliaAddon.this.addonClass.getName()+" sp<EFBFBD><EFBFBD>cifie la classe "+clazz.getName());
|
System.err.println("L'addon "+JuliaAddon.this.addonClass.getName()+" spécifie la classe "+clazz.getName());
|
||||||
}
|
}
|
||||||
for(Method m : toWatch) {
|
for(Method m : toWatch) {
|
||||||
Command c = m.getAnnotation(Command.class);
|
Command c = m.getAnnotation(Command.class);
|
||||||
|
|||||||
@ -6,8 +6,8 @@ import java.io.PrintStream;
|
|||||||
import java.util.concurrent.locks.Lock;
|
import java.util.concurrent.locks.Lock;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
import net.dv8tion.jda.core.MessageBuilder;
|
import net.dv8tion.jda.api.MessageBuilder;
|
||||||
import net.dv8tion.jda.core.entities.MessageChannel;
|
import net.dv8tion.jda.api.entities.MessageChannel;
|
||||||
|
|
||||||
public class JuliaErrPrintStream extends OutputStream {
|
public class JuliaErrPrintStream extends OutputStream {
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,10 @@ package com.bernard.juliabot.api;
|
|||||||
|
|
||||||
import java.time.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
|
|
||||||
import net.dv8tion.jda.core.entities.*;
|
import net.dv8tion.jda.api.JDA;
|
||||||
|
import net.dv8tion.jda.api.entities.Message;
|
||||||
|
import net.dv8tion.jda.api.entities.MessageChannel;
|
||||||
|
import net.dv8tion.jda.api.entities.User;
|
||||||
|
|
||||||
public interface DiscordCCommande extends StringCCommande {
|
public interface DiscordCCommande extends StringCCommande {
|
||||||
|
|
||||||
@ -12,6 +15,8 @@ public interface DiscordCCommande extends StringCCommande {
|
|||||||
|
|
||||||
public User getUser();
|
public User getUser();
|
||||||
|
|
||||||
|
public JDA getJDA();
|
||||||
|
|
||||||
public String getContentStripped();
|
public String getContentStripped();
|
||||||
|
|
||||||
public OffsetDateTime getPostDate();
|
public OffsetDateTime getPostDate();
|
||||||
|
|||||||
@ -11,9 +11,20 @@ import java.lang.annotation.Target;
|
|||||||
@Retention(RUNTIME)
|
@Retention(RUNTIME)
|
||||||
@Target(TYPE)
|
@Target(TYPE)
|
||||||
public @interface JuLIAddon {
|
public @interface JuLIAddon {
|
||||||
|
/**
|
||||||
|
* Le nom de l'addon
|
||||||
|
*/
|
||||||
String name();
|
String name();
|
||||||
|
/**
|
||||||
|
* La version de l'addon
|
||||||
|
*/
|
||||||
String version() default "";
|
String version() default "";
|
||||||
|
/**
|
||||||
|
* Différentes classes, en plus de celle là, dans laquelle chercher des méthodes définissant des événements ou des commandes
|
||||||
|
*/
|
||||||
Class<?>[] searchPath() default {};
|
Class<?>[] searchPath() default {};
|
||||||
|
/**
|
||||||
|
* La liste des personnes ayant dévellopé cet addon
|
||||||
|
*/
|
||||||
public String[] devs();
|
public String[] devs();
|
||||||
public boolean important() default false;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,12 +4,12 @@ import java.sql.Connection;
|
|||||||
|
|
||||||
import com.bernard.juliabot.Julia;
|
import com.bernard.juliabot.Julia;
|
||||||
|
|
||||||
import net.dv8tion.jda.core.JDA;
|
import net.dv8tion.jda.api.JDA;
|
||||||
|
|
||||||
public class Trukilie {
|
public class Trukilie {
|
||||||
|
|
||||||
public static JDA jda() {
|
public static JDA jda() {
|
||||||
return Julia.theJulia().jda;
|
return Julia.theJulia().getJda();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Connection juliaDB() {
|
public static Connection juliaDB() {
|
||||||
|
|||||||
@ -22,12 +22,14 @@ import com.bernard.juliabot.api.JuLIAddon;
|
|||||||
import com.bernard.juliabot.api.StringCCommande;
|
import com.bernard.juliabot.api.StringCCommande;
|
||||||
import com.thedeanda.lorem.LoremIpsum;
|
import com.thedeanda.lorem.LoremIpsum;
|
||||||
|
|
||||||
import net.dv8tion.jda.core.entities.Message;
|
import net.dv8tion.jda.api.JDA;
|
||||||
import net.dv8tion.jda.core.entities.MessageChannel;
|
import net.dv8tion.jda.api.MessageBuilder;
|
||||||
import net.dv8tion.jda.core.entities.User;
|
import net.dv8tion.jda.api.entities.Message;
|
||||||
import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.api.entities.MessageChannel;
|
||||||
|
import net.dv8tion.jda.api.entities.User;
|
||||||
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
||||||
@JuLIAddon(name="internaddon", devs = "Bernard", version="beta", important=true)
|
@JuLIAddon(name="internaddon", devs = "Bernard", version="beta")
|
||||||
public class Internaddon {
|
public class Internaddon {
|
||||||
|
|
||||||
public static final String COMMANDEUR = "!!";
|
public static final String COMMANDEUR = "!!";
|
||||||
@ -37,7 +39,7 @@ public class Internaddon {
|
|||||||
if(e.getMessage().getContentRaw().startsWith(COMMANDEUR)) {
|
if(e.getMessage().getContentRaw().startsWith(COMMANDEUR)) {
|
||||||
String name = e.getMessage().getContentRaw().split(" ")[0].substring(COMMANDEUR.length());
|
String name = e.getMessage().getContentRaw().split(" ")[0].substring(COMMANDEUR.length());
|
||||||
|
|
||||||
Laboratory labo = Julia.theJulia().laboratoires.get(Julia.theJulia().lecouteur.getLabo(e));//Récupére le labo de l'évent
|
Laboratory labo = Julia.theJulia().getLaboratoires().get(Julia.theJulia().getLecouteur().getLabo(e));//Récupére le labo de l'évent
|
||||||
InternalddonCCommande ccommande = new InternalddonCCommande(e,labo);
|
InternalddonCCommande ccommande = new InternalddonCCommande(e,labo);
|
||||||
try {
|
try {
|
||||||
CommandCalled called = labo.executeCommand(name, ccommande);
|
CommandCalled called = labo.executeCommand(name, ccommande);
|
||||||
@ -133,6 +135,17 @@ public class Internaddon {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Command(name="guilds", description = "Liste les guildes disponibles",admin=true)
|
||||||
|
public void guilds(DiscordCCommande commande) {
|
||||||
|
MessageBuilder mb = new MessageBuilder();
|
||||||
|
mb.append("Liste des serveurs :\n");
|
||||||
|
Julia.theJulia().getJda().getGuilds()
|
||||||
|
.stream()
|
||||||
|
.map(g -> g.getName() + "(" + g.getMemberCount() + " membres, id:" + g.getId() + ")\n")
|
||||||
|
.forEach(mb::append);;
|
||||||
|
commande.getChannel().sendMessage(mb.build()).complete();
|
||||||
|
}
|
||||||
|
|
||||||
@Command(name="update",description = "Met a jour le dossier des addons",admin=true)
|
@Command(name="update",description = "Met a jour le dossier des addons",admin=true)
|
||||||
public void update(StringCCommande commande) {
|
public void update(StringCCommande commande) {
|
||||||
|
|
||||||
@ -220,6 +233,11 @@ public class Internaddon {
|
|||||||
return m.getAuthor();
|
return m.getAuthor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JDA getJDA() {
|
||||||
|
return m.getJDA();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getContentStripped() {
|
public String getContentStripped() {
|
||||||
return m.getContentStripped();
|
return m.getContentStripped();
|
||||||
@ -227,7 +245,7 @@ public class Internaddon {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OffsetDateTime getPostDate() {
|
public OffsetDateTime getPostDate() {
|
||||||
return m.getCreationTime();
|
return m.getTimeCreated();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -235,6 +253,7 @@ public class Internaddon {
|
|||||||
return labo;
|
return labo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CommandArguments parseCommandArguments(String raw) {
|
public static CommandArguments parseCommandArguments(String raw) {
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
package com.bernard.juliabot.internaddon;
|
package com.bernard.juliabot.internaddon;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import net.dv8tion.jda.core.entities.Message;
|
import net.dv8tion.jda.api.entities.Message;
|
||||||
|
|
||||||
public class UnstableMessage extends OutputStream{
|
public class UnstableMessage extends OutputStream{
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user