From bdab3d11417682787c9c9ebc97a0549fefb1c1e9 Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 27 Feb 2018 11:28:28 +0100 Subject: [PATCH 1/8] Added the english translation of the help --- src/main/resources/Help/Cat/en/main.md | 4 ++++ src/main/resources/Help/Default/en/main.md | 2 ++ src/main/resources/Help/Flush/en/main.md | 3 +++ src/main/resources/Help/Move/en/main.md | 2 ++ src/main/resources/Help/Move/fr/main.md | 2 +- src/main/resources/Help/Music/en/main.md | 26 +++++++++++++++++++++ src/main/resources/Help/Music/fr/main.md | 8 +++---- src/main/resources/Help/Ping/en/main.md | 2 ++ src/main/resources/Help/Spam/en/main.md | 8 +++++++ src/main/resources/Help/SpamInfo/en/main.md | 2 ++ 10 files changed, 54 insertions(+), 5 deletions(-) create mode 100644 src/main/resources/Help/Cat/en/main.md create mode 100644 src/main/resources/Help/Default/en/main.md create mode 100644 src/main/resources/Help/Flush/en/main.md create mode 100644 src/main/resources/Help/Move/en/main.md create mode 100644 src/main/resources/Help/Music/en/main.md create mode 100644 src/main/resources/Help/Ping/en/main.md create mode 100644 src/main/resources/Help/Spam/en/main.md create mode 100644 src/main/resources/Help/SpamInfo/en/main.md diff --git a/src/main/resources/Help/Cat/en/main.md b/src/main/resources/Help/Cat/en/main.md new file mode 100644 index 0000000..2286675 --- /dev/null +++ b/src/main/resources/Help/Cat/en/main.md @@ -0,0 +1,4 @@ + +Hey look! A cat! +And he's different everytime ! +That is so cute! :cat: \ No newline at end of file diff --git a/src/main/resources/Help/Default/en/main.md b/src/main/resources/Help/Default/en/main.md new file mode 100644 index 0000000..01cb3d1 --- /dev/null +++ b/src/main/resources/Help/Default/en/main.md @@ -0,0 +1,2 @@ +This command doesn't have any help at the moment. +To help us improve: https://github.com/BrokenFire/BrokenDiscordBot \ No newline at end of file diff --git a/src/main/resources/Help/Flush/en/main.md b/src/main/resources/Help/Flush/en/main.md new file mode 100644 index 0000000..fa13949 --- /dev/null +++ b/src/main/resources/Help/Flush/en/main.md @@ -0,0 +1,3 @@ + +`//flush ` +:arrow_right: *Erase the n last posts (Max = 100)* \ No newline at end of file diff --git a/src/main/resources/Help/Move/en/main.md b/src/main/resources/Help/Move/en/main.md new file mode 100644 index 0000000..5d9aa92 --- /dev/null +++ b/src/main/resources/Help/Move/en/main.md @@ -0,0 +1,2 @@ +`//move <@user> <@targeted_role>` +:arrow_right: *Move an user to the targeted role.* \ No newline at end of file diff --git a/src/main/resources/Help/Move/fr/main.md b/src/main/resources/Help/Move/fr/main.md index 2018738..85416c0 100644 --- a/src/main/resources/Help/Move/fr/main.md +++ b/src/main/resources/Help/Move/fr/main.md @@ -1,2 +1,2 @@ `//move <@utilisateur> <@rôleCible>` -:arrow_right: *Deplacement d'un utilisateur vers un rôle cible, attention à bien faire des montions.* \ No newline at end of file +:arrow_right: *Deplacement d'un utilisateur vers un rôle cible, attention à bien faire les mentions.* \ No newline at end of file diff --git a/src/main/resources/Help/Music/en/main.md b/src/main/resources/Help/Music/en/main.md new file mode 100644 index 0000000..95b1f97 --- /dev/null +++ b/src/main/resources/Help/Music/en/main.md @@ -0,0 +1,26 @@ +`//music play ` +:arrow_right: *Let's dance! Sets the vocal chat to use.* + +`//music pause` +:arrow_right: *Pause the current track.* + +`//music resume` +:arrow_right: *Resume the current track.* + +`//music next` +:arrow_right: *Skip the current track.* + +`//music stop` +:arrow_right: *Stop the current track and empty the playlist.* + +`//music info` +:arrow_right: *Show info of the current track.* + +`//music flush` +:arrow_right: *Delete the current playlist.* + +`//music list` +:arrow_right: *Show information of the current playlist.* + +`//music add(Next) ` +:arrow_right: *Add the url to the current playlist.* \ No newline at end of file diff --git a/src/main/resources/Help/Music/fr/main.md b/src/main/resources/Help/Music/fr/main.md index 11382e9..b45586b 100644 --- a/src/main/resources/Help/Music/fr/main.md +++ b/src/main/resources/Help/Music/fr/main.md @@ -1,5 +1,5 @@ `//music play ` -:arrow_right: *Let's dance! Deffinit le chat vocal à utiliser.* +:arrow_right: *Let's dance! Definit le chat vocal à utiliser.* `//music pause` :arrow_right: *Mise en pause de la piste en cours.* @@ -8,10 +8,10 @@ :arrow_right: *Reprise de la lecture de la piste en cours.* `//music next` -:arrow_right: *Change le piste en cours.* +:arrow_right: *Change la piste en cours.* `//music stop` -:arrow_right: *Arrête la piste en cours.* +:arrow_right: *Arrête la piste en cours et supprime la playlist.* `//music info` :arrow_right: *Affiche les infos de la piste en cours.* @@ -23,4 +23,4 @@ :arrow_right: *Affiche la playlist en cours.* `//music add(Next) ` -:arrow_right: *Ajoute l'url à la playlist en cour.* \ No newline at end of file +:arrow_right: *Ajoute l'url à la playlist en cours.* \ No newline at end of file diff --git a/src/main/resources/Help/Ping/en/main.md b/src/main/resources/Help/Ping/en/main.md new file mode 100644 index 0000000..7b60747 --- /dev/null +++ b/src/main/resources/Help/Ping/en/main.md @@ -0,0 +1,2 @@ +`//ping` + :arrow_right: *Send back the bot's ping* \ No newline at end of file diff --git a/src/main/resources/Help/Spam/en/main.md b/src/main/resources/Help/Spam/en/main.md new file mode 100644 index 0000000..0a84002 --- /dev/null +++ b/src/main/resources/Help/Spam/en/main.md @@ -0,0 +1,8 @@ +`//spam extermine <@user> ` +:arrow_right: *Penalize a spammer.* + +`//spam pardon <@user>` +:arrow_right: *Forgive a spammer* + +`//spam reset <@user>` +:arrow_right: *Reset the user's multiplier.* diff --git a/src/main/resources/Help/SpamInfo/en/main.md b/src/main/resources/Help/SpamInfo/en/main.md new file mode 100644 index 0000000..9c1e79b --- /dev/null +++ b/src/main/resources/Help/SpamInfo/en/main.md @@ -0,0 +1,2 @@ +`//spaminfo <@user> ` +:arrow_right: *Show punishment's information against the spam of the mentioned user (the author if there is no mention)* \ No newline at end of file From d12cd04f36627ccf86584bacdac8ea257bec2243 Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 27 Feb 2018 11:28:28 +0100 Subject: [PATCH 2/8] Added the english translation of the help #10 --- src/main/resources/Help/Cat/en/main.md | 4 ++++ src/main/resources/Help/Default/en/main.md | 2 ++ src/main/resources/Help/Flush/en/main.md | 3 +++ src/main/resources/Help/Move/en/main.md | 2 ++ src/main/resources/Help/Move/fr/main.md | 2 +- src/main/resources/Help/Music/en/main.md | 26 +++++++++++++++++++++ src/main/resources/Help/Music/fr/main.md | 8 +++---- src/main/resources/Help/Ping/en/main.md | 2 ++ src/main/resources/Help/Spam/en/main.md | 8 +++++++ src/main/resources/Help/SpamInfo/en/main.md | 2 ++ 10 files changed, 54 insertions(+), 5 deletions(-) create mode 100644 src/main/resources/Help/Cat/en/main.md create mode 100644 src/main/resources/Help/Default/en/main.md create mode 100644 src/main/resources/Help/Flush/en/main.md create mode 100644 src/main/resources/Help/Move/en/main.md create mode 100644 src/main/resources/Help/Music/en/main.md create mode 100644 src/main/resources/Help/Ping/en/main.md create mode 100644 src/main/resources/Help/Spam/en/main.md create mode 100644 src/main/resources/Help/SpamInfo/en/main.md diff --git a/src/main/resources/Help/Cat/en/main.md b/src/main/resources/Help/Cat/en/main.md new file mode 100644 index 0000000..2286675 --- /dev/null +++ b/src/main/resources/Help/Cat/en/main.md @@ -0,0 +1,4 @@ + +Hey look! A cat! +And he's different everytime ! +That is so cute! :cat: \ No newline at end of file diff --git a/src/main/resources/Help/Default/en/main.md b/src/main/resources/Help/Default/en/main.md new file mode 100644 index 0000000..01cb3d1 --- /dev/null +++ b/src/main/resources/Help/Default/en/main.md @@ -0,0 +1,2 @@ +This command doesn't have any help at the moment. +To help us improve: https://github.com/BrokenFire/BrokenDiscordBot \ No newline at end of file diff --git a/src/main/resources/Help/Flush/en/main.md b/src/main/resources/Help/Flush/en/main.md new file mode 100644 index 0000000..fa13949 --- /dev/null +++ b/src/main/resources/Help/Flush/en/main.md @@ -0,0 +1,3 @@ + +`//flush ` +:arrow_right: *Erase the n last posts (Max = 100)* \ No newline at end of file diff --git a/src/main/resources/Help/Move/en/main.md b/src/main/resources/Help/Move/en/main.md new file mode 100644 index 0000000..5d9aa92 --- /dev/null +++ b/src/main/resources/Help/Move/en/main.md @@ -0,0 +1,2 @@ +`//move <@user> <@targeted_role>` +:arrow_right: *Move an user to the targeted role.* \ No newline at end of file diff --git a/src/main/resources/Help/Move/fr/main.md b/src/main/resources/Help/Move/fr/main.md index 2018738..85416c0 100644 --- a/src/main/resources/Help/Move/fr/main.md +++ b/src/main/resources/Help/Move/fr/main.md @@ -1,2 +1,2 @@ `//move <@utilisateur> <@rôleCible>` -:arrow_right: *Deplacement d'un utilisateur vers un rôle cible, attention à bien faire des montions.* \ No newline at end of file +:arrow_right: *Deplacement d'un utilisateur vers un rôle cible, attention à bien faire les mentions.* \ No newline at end of file diff --git a/src/main/resources/Help/Music/en/main.md b/src/main/resources/Help/Music/en/main.md new file mode 100644 index 0000000..95b1f97 --- /dev/null +++ b/src/main/resources/Help/Music/en/main.md @@ -0,0 +1,26 @@ +`//music play ` +:arrow_right: *Let's dance! Sets the vocal chat to use.* + +`//music pause` +:arrow_right: *Pause the current track.* + +`//music resume` +:arrow_right: *Resume the current track.* + +`//music next` +:arrow_right: *Skip the current track.* + +`//music stop` +:arrow_right: *Stop the current track and empty the playlist.* + +`//music info` +:arrow_right: *Show info of the current track.* + +`//music flush` +:arrow_right: *Delete the current playlist.* + +`//music list` +:arrow_right: *Show information of the current playlist.* + +`//music add(Next) ` +:arrow_right: *Add the url to the current playlist.* \ No newline at end of file diff --git a/src/main/resources/Help/Music/fr/main.md b/src/main/resources/Help/Music/fr/main.md index 11382e9..b45586b 100644 --- a/src/main/resources/Help/Music/fr/main.md +++ b/src/main/resources/Help/Music/fr/main.md @@ -1,5 +1,5 @@ `//music play ` -:arrow_right: *Let's dance! Deffinit le chat vocal à utiliser.* +:arrow_right: *Let's dance! Definit le chat vocal à utiliser.* `//music pause` :arrow_right: *Mise en pause de la piste en cours.* @@ -8,10 +8,10 @@ :arrow_right: *Reprise de la lecture de la piste en cours.* `//music next` -:arrow_right: *Change le piste en cours.* +:arrow_right: *Change la piste en cours.* `//music stop` -:arrow_right: *Arrête la piste en cours.* +:arrow_right: *Arrête la piste en cours et supprime la playlist.* `//music info` :arrow_right: *Affiche les infos de la piste en cours.* @@ -23,4 +23,4 @@ :arrow_right: *Affiche la playlist en cours.* `//music add(Next) ` -:arrow_right: *Ajoute l'url à la playlist en cour.* \ No newline at end of file +:arrow_right: *Ajoute l'url à la playlist en cours.* \ No newline at end of file diff --git a/src/main/resources/Help/Ping/en/main.md b/src/main/resources/Help/Ping/en/main.md new file mode 100644 index 0000000..7b60747 --- /dev/null +++ b/src/main/resources/Help/Ping/en/main.md @@ -0,0 +1,2 @@ +`//ping` + :arrow_right: *Send back the bot's ping* \ No newline at end of file diff --git a/src/main/resources/Help/Spam/en/main.md b/src/main/resources/Help/Spam/en/main.md new file mode 100644 index 0000000..0a84002 --- /dev/null +++ b/src/main/resources/Help/Spam/en/main.md @@ -0,0 +1,8 @@ +`//spam extermine <@user> ` +:arrow_right: *Penalize a spammer.* + +`//spam pardon <@user>` +:arrow_right: *Forgive a spammer* + +`//spam reset <@user>` +:arrow_right: *Reset the user's multiplier.* diff --git a/src/main/resources/Help/SpamInfo/en/main.md b/src/main/resources/Help/SpamInfo/en/main.md new file mode 100644 index 0000000..9c1e79b --- /dev/null +++ b/src/main/resources/Help/SpamInfo/en/main.md @@ -0,0 +1,2 @@ +`//spaminfo <@user> ` +:arrow_right: *Show punishment's information against the spam of the mentioned user (the author if there is no mention)* \ No newline at end of file From 1a1c508cf4a600861c3de223356220d406f282bf Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 27 Feb 2018 11:56:27 +0100 Subject: [PATCH 3/8] Corrected typo --- src/main/resources/MessagesTemplates/RegisterMessage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/MessagesTemplates/RegisterMessage.md b/src/main/resources/MessagesTemplates/RegisterMessage.md index 630fbf3..04eac35 100644 --- a/src/main/resources/MessagesTemplates/RegisterMessage.md +++ b/src/main/resources/MessagesTemplates/RegisterMessage.md @@ -1,5 +1,5 @@ -Une tentative d'association à etait demandé. +Une tentative d'association a été demandée. Voici le code de vérification: **%code** From aede68e521fba43230bf24f486999f1f6c5ef237 Mon Sep 17 00:00:00 2001 From: BrokenFire Date: Tue, 27 Feb 2018 12:12:37 +0100 Subject: [PATCH 4/8] Show private usable command in help #10 --- src/main/java/net/Broken/Commands/Help.java | 30 ++++- .../net/Broken/Tools/EmbedMessageUtils.java | 6 +- .../java/net/Broken/Tools/TableRenderer.java | 108 ++++++++++++++++++ src/main/resources/Help/main.md | 5 + 4 files changed, 141 insertions(+), 8 deletions(-) create mode 100644 src/main/java/net/Broken/Tools/TableRenderer.java create mode 100644 src/main/resources/Help/main.md diff --git a/src/main/java/net/Broken/Commands/Help.java b/src/main/java/net/Broken/Commands/Help.java index a732e19..4871874 100644 --- a/src/main/java/net/Broken/Commands/Help.java +++ b/src/main/java/net/Broken/Commands/Help.java @@ -6,6 +6,7 @@ import net.Broken.RestApi.CommandInterface; import net.Broken.Tools.EmbedMessageUtils; import net.Broken.Tools.MessageTimeOut; import net.Broken.Tools.PrivateMessage; +import net.Broken.Tools.TableRenderer; import net.dv8tion.jda.core.EmbedBuilder; import net.dv8tion.jda.core.Permission; import net.dv8tion.jda.core.entities.ChannelType; @@ -26,6 +27,7 @@ import java.util.Map; */ public class Help implements Commande { Logger logger = LogManager.getLogger(); + private int cellLenght = 25; @Override public boolean called(String[] args, MessageReceivedEvent event) { return true; @@ -114,7 +116,9 @@ public class Help implements Commande { } else { - StringBuilder txt= new StringBuilder(); + TableRenderer table = new TableRenderer(); + List noPu = new ArrayList<>(); + table.setHeader("Command","PU"); boolean isAdmin; if(event.isFromType(ChannelType.PRIVATE)) @@ -124,10 +128,21 @@ public class Help implements Commande { for (Map.Entry e : MainBot.commandes.entrySet()) { - if(!e.getValue().isAdminCmd() || isAdmin) - txt.append("\n- ").append(e.getKey()); + if(!e.getValue().isAdminCmd() || isAdmin){ + if(e.getValue().isPrivateUsable()) + table.addRow(e.getKey(), "XX"); + else + noPu.add(e.getKey()); + } + + } + for(String key : noPu) + table.addRow(key, ""); + + String txt = table.build(); + if(!event.isFromType(ChannelType.PRIVATE)){ Message rest = event.getTextChannel().sendMessage(new EmbedBuilder().setTitle("Command envoyées par message privé").setColor(Color.green).build()).complete(); List messages = new ArrayList(){{ @@ -144,10 +159,13 @@ public class Help implements Commande { else role = "Non Admin"; - PrivateMessage.send(event.getAuthor(),EmbedMessageUtils.getHelpList(role, txt.toString()),logger); - - + try { + PrivateMessage.send(event.getAuthor(),EmbedMessageUtils.getHelpList(role, txt),logger); + } catch (FileNotFoundException e) { + logger.catching(e); + PrivateMessage.send(event.getAuthor(),EmbedMessageUtils.getInternalError(), logger); + } } diff --git a/src/main/java/net/Broken/Tools/EmbedMessageUtils.java b/src/main/java/net/Broken/Tools/EmbedMessageUtils.java index 05c793d..ecfeaef 100644 --- a/src/main/java/net/Broken/Tools/EmbedMessageUtils.java +++ b/src/main/java/net/Broken/Tools/EmbedMessageUtils.java @@ -98,8 +98,10 @@ public class EmbedMessageUtils { return buildStandar(getError("Vous n'avez pas l'autorisation de faire ça!")); } - public static MessageEmbed getHelpList(String role, String list){ - return new EmbedBuilder().setTitle("Command du bot ("+role+")").setDescription(list).setFooter("Utilise '//help ' pour plus de détails.",null).setColor(Color.green).setThumbnail(MainBot.jda.getSelfUser().getAvatarUrl()).build(); + public static MessageEmbed getHelpList(String role, String list) throws FileNotFoundException { + String message = new ResourceLoader().getFile("Help/main.md"); + message = message.replace("@list", list); + return new EmbedBuilder().setTitle("Command du bot ("+role+")").setDescription(message).setFooter("Utilise '//help ' pour plus de détails.",null).setColor(Color.green).setThumbnail(MainBot.jda.getSelfUser().getAvatarUrl()).build(); } diff --git a/src/main/java/net/Broken/Tools/TableRenderer.java b/src/main/java/net/Broken/Tools/TableRenderer.java new file mode 100644 index 0000000..37aa2b3 --- /dev/null +++ b/src/main/java/net/Broken/Tools/TableRenderer.java @@ -0,0 +1,108 @@ +package net.Broken.Tools; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +import org.apache.commons.lang3.StringUtils; + +public class TableRenderer { + + private int width; + private List header; + private List> table = new ArrayList<>(); + + private String empty = ""; + + public TableRenderer() { + + } + + public void setHeader(Object... header) { + this.header = Arrays.asList(header); + if (header.length > this.width) + this.width = header.length; + } + + public void addRow(Object... header) { + List objects = Arrays.asList(header); + table.add(objects); + if (header.length > this.width) + this.width = header.length; + } + + public void setEmptyString(String str) { + this.empty = str; + } + + private String[][] normalizeTable() { + int height = header == null ? table.size() : (table.size() + 1); + String[][] normalized = new String[height][width]; + + int vIndex = 0; + if (header != null) { + for (int hIndex = 0; hIndex < width; hIndex++) { + if (header.size() > hIndex) + normalized[vIndex][hIndex] = header.get(hIndex).toString(); + else + normalized[vIndex][hIndex] = this.empty; + } + vIndex++; + } + + for (List obj : table) { + for (int hIndex = 0; hIndex < width; hIndex++) { + if (obj.size() > hIndex) + normalized[vIndex][hIndex] = obj.get(hIndex).toString(); + else + normalized[vIndex][hIndex] = this.empty+"s"; + } + vIndex++; + } + + return normalized; + } + + private int[] getCollumnWidths(String[][] table, int padding) { + int collums[] = new int[width]; + for (int vIndex = 0; vIndex < table.length; vIndex++) + for (int hIndex = 0; hIndex < width; hIndex++) + if (table[vIndex][hIndex].length() + padding > collums[hIndex]) + collums[hIndex] = table[vIndex][hIndex].length() + padding; + collums[collums.length-1] -= padding; + return collums; + } + + + private String buildElement(String element, int width, String emptyChar) { + String result = element; + if (result.length() < width) + result += StringUtils.repeat(emptyChar, width - result.length()); + return result; + } + + private String buildLine(String[] strings, int[] widths, boolean header) { + String line = IntStream.range(0, strings.length) + .mapToObj((i) -> buildElement(strings[i], widths[i], " ")) + .collect(Collectors.joining("│ ")); + line = "│ "+ line + " │"; + if (header) { + String seperator = IntStream.range(0, strings.length) + .mapToObj((i) -> buildElement("", widths[i], "═")) + .collect(Collectors.joining("╪")); + line += "\n" + "╪═" + seperator + "══╪"; + } + + return line; + } + + public String build() { + String[][] table = normalizeTable(); + int[] widths = getCollumnWidths(table, 1); + return IntStream.range(0, table.length) + .mapToObj(i -> buildLine(table[i], widths, header != null && i==0)) + .collect(Collectors.joining("\n")); + } +} diff --git a/src/main/resources/Help/main.md b/src/main/resources/Help/main.md new file mode 100644 index 0000000..7492f4d --- /dev/null +++ b/src/main/resources/Help/main.md @@ -0,0 +1,5 @@ +``` +@list +``` + +_PU = Private Usable (Utilisable en Message Privée)_ \ No newline at end of file From 7354971f55ac0af34cab8f40eb000244f06afd70 Mon Sep 17 00:00:00 2001 From: BrokenFire Date: Tue, 27 Feb 2018 12:16:34 +0100 Subject: [PATCH 5/8] Forget dependency --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index abd2e38..98878b5 100644 --- a/build.gradle +++ b/build.gradle @@ -42,7 +42,7 @@ dependencies { // Use MySQL Connector-J compile 'mysql:mysql-connector-java' compile 'org.reflections:reflections:0.9.11' - + compile 'org.apache.commons:commons-lang3:3.7' testCompile('org.springframework.boot:spring-boot-starter-test') testCompile('com.jayway.jsonpath:json-path') From 5d50c66842f95e00fab5097d38445f22d2ef1716 Mon Sep 17 00:00:00 2001 From: BrokenFire Date: Tue, 27 Feb 2018 12:28:59 +0100 Subject: [PATCH 6/8] edit branch on devel --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 062f651..fbd958c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,7 +2,7 @@ node { def app stage('Clone') { // for display purposes // Get some code from a GitHub repository - git 'https://github.com/BrokenFire/BrokenDiscordBot.git' + git url: 'https://github.com/BrokenFire/BrokenDiscordBot.git', branch: 'devel' } stage('Build image') { /* This builds the actual image; synonymous to From 318379459977e25fb1451d67a259397f678062d4 Mon Sep 17 00:00:00 2001 From: BrokenFire Date: Tue, 27 Feb 2018 15:17:00 +0100 Subject: [PATCH 7/8] Change NSFW command detection --- src/main/java/net/Broken/Commande.java | 1 + src/main/java/net/Broken/Commands/Cat.java | 5 + .../java/net/Broken/Commands/DayTrigger.java | 5 + src/main/java/net/Broken/Commands/Error.java | 5 + src/main/java/net/Broken/Commands/Flush.java | 5 + src/main/java/net/Broken/Commands/Help.java | 15 +-- src/main/java/net/Broken/Commands/Move.java | 5 + src/main/java/net/Broken/Commands/Music.java | 5 + .../java/net/Broken/Commands/Over18/Ass.java | 5 + .../net/Broken/Commands/Over18/Boobs.java | 5 + .../net/Broken/Commands/Over18/Madame.java | 91 ++++++-------- .../java/net/Broken/Commands/Over18/Pipe.java | 39 +----- .../java/net/Broken/Commands/Over18/SM.java | 17 +-- src/main/java/net/Broken/Commands/Ping.java | 12 +- src/main/java/net/Broken/Commands/Spam.java | 5 + .../java/net/Broken/Commands/SpamInfo.java | 5 + src/main/java/net/Broken/MainBot.java | 18 +-- .../Tools/Command/NumberedCommande.java | 113 ++++++++---------- .../net/Broken/Tools/EmbedMessageUtils.java | 4 +- .../java/net/Broken/Tools/MessageTimeOut.java | 7 ++ 20 files changed, 182 insertions(+), 185 deletions(-) diff --git a/src/main/java/net/Broken/Commande.java b/src/main/java/net/Broken/Commande.java index f77c709..e34f4be 100644 --- a/src/main/java/net/Broken/Commande.java +++ b/src/main/java/net/Broken/Commande.java @@ -12,6 +12,7 @@ public interface Commande { void executed(boolean success, MessageReceivedEvent event); boolean isPrivateUsable(); boolean isAdminCmd(); + boolean isNSFW(); } diff --git a/src/main/java/net/Broken/Commands/Cat.java b/src/main/java/net/Broken/Commands/Cat.java index f49037e..dba4a54 100644 --- a/src/main/java/net/Broken/Commands/Cat.java +++ b/src/main/java/net/Broken/Commands/Cat.java @@ -77,4 +77,9 @@ public class Cat implements Commande { public boolean isAdminCmd() { return false; } + + @Override + public boolean isNSFW() { + return false; + } } diff --git a/src/main/java/net/Broken/Commands/DayTrigger.java b/src/main/java/net/Broken/Commands/DayTrigger.java index 9133892..e9045be 100644 --- a/src/main/java/net/Broken/Commands/DayTrigger.java +++ b/src/main/java/net/Broken/Commands/DayTrigger.java @@ -44,4 +44,9 @@ public class DayTrigger implements Commande{ public boolean isAdminCmd() { return true; } + + @Override + public boolean isNSFW() { + return false; + } } diff --git a/src/main/java/net/Broken/Commands/Error.java b/src/main/java/net/Broken/Commands/Error.java index 5c5e7b7..7e07e27 100644 --- a/src/main/java/net/Broken/Commands/Error.java +++ b/src/main/java/net/Broken/Commands/Error.java @@ -38,4 +38,9 @@ public class Error implements Commande{ public boolean isAdminCmd() { return true; } + + @Override + public boolean isNSFW() { + return false; + } } diff --git a/src/main/java/net/Broken/Commands/Flush.java b/src/main/java/net/Broken/Commands/Flush.java index 5a0d8f0..054cf56 100644 --- a/src/main/java/net/Broken/Commands/Flush.java +++ b/src/main/java/net/Broken/Commands/Flush.java @@ -68,4 +68,9 @@ public class Flush implements Commande{ public boolean isAdminCmd() { return false; } + + @Override + public boolean isNSFW() { + return false; + } } diff --git a/src/main/java/net/Broken/Commands/Help.java b/src/main/java/net/Broken/Commands/Help.java index 4871874..83cada3 100644 --- a/src/main/java/net/Broken/Commands/Help.java +++ b/src/main/java/net/Broken/Commands/Help.java @@ -145,11 +145,7 @@ public class Help implements Commande { if(!event.isFromType(ChannelType.PRIVATE)){ Message rest = event.getTextChannel().sendMessage(new EmbedBuilder().setTitle("Command envoyées par message privé").setColor(Color.green).build()).complete(); - List messages = new ArrayList(){{ - add(rest); - add(event.getMessage()); - }}; - new MessageTimeOut(messages,MainBot.messageTimeOut).start(); + new MessageTimeOut(MainBot.messageTimeOut, rest, event.getMessage()).start(); } @@ -160,10 +156,10 @@ public class Help implements Commande { role = "Non Admin"; try { - PrivateMessage.send(event.getAuthor(),EmbedMessageUtils.getHelpList(role, txt),logger); + PrivateMessage.send(event.getAuthor(), EmbedMessageUtils.getHelpList(role, txt),logger); } catch (FileNotFoundException e) { logger.catching(e); - PrivateMessage.send(event.getAuthor(),EmbedMessageUtils.getInternalError(), logger); + PrivateMessage.send(event.getAuthor(), EmbedMessageUtils.getInternalError(), logger); } @@ -187,4 +183,9 @@ public class Help implements Commande { public boolean isAdminCmd() { return false; } + + @Override + public boolean isNSFW() { + return false; + } } diff --git a/src/main/java/net/Broken/Commands/Move.java b/src/main/java/net/Broken/Commands/Move.java index 78d2e2a..887312b 100644 --- a/src/main/java/net/Broken/Commands/Move.java +++ b/src/main/java/net/Broken/Commands/Move.java @@ -209,4 +209,9 @@ public class Move implements Commande { public boolean isAdminCmd() { return true; } + + @Override + public boolean isNSFW() { + return false; + } } diff --git a/src/main/java/net/Broken/Commands/Music.java b/src/main/java/net/Broken/Commands/Music.java index e9d2307..7b98f59 100644 --- a/src/main/java/net/Broken/Commands/Music.java +++ b/src/main/java/net/Broken/Commands/Music.java @@ -172,6 +172,11 @@ public class Music implements Commande { return false; } + @Override + public boolean isNSFW() { + return false; + } + public AudioM getAudioManager(){ return audio; } diff --git a/src/main/java/net/Broken/Commands/Over18/Ass.java b/src/main/java/net/Broken/Commands/Over18/Ass.java index c866a5d..3d3beb0 100644 --- a/src/main/java/net/Broken/Commands/Over18/Ass.java +++ b/src/main/java/net/Broken/Commands/Over18/Ass.java @@ -26,4 +26,9 @@ public class Ass extends NumberedCommande { public boolean isAdminCmd() { return false; } + + @Override + public boolean isNSFW() { + return true; + } } diff --git a/src/main/java/net/Broken/Commands/Over18/Boobs.java b/src/main/java/net/Broken/Commands/Over18/Boobs.java index 3f69bce..c5ecb0d 100644 --- a/src/main/java/net/Broken/Commands/Over18/Boobs.java +++ b/src/main/java/net/Broken/Commands/Over18/Boobs.java @@ -25,4 +25,9 @@ public class Boobs extends NumberedCommande { public boolean isAdminCmd() { return false; } + + @Override + public boolean isNSFW() { + return true; + } } diff --git a/src/main/java/net/Broken/Commands/Over18/Madame.java b/src/main/java/net/Broken/Commands/Over18/Madame.java index 497398b..82b69dc 100644 --- a/src/main/java/net/Broken/Commands/Over18/Madame.java +++ b/src/main/java/net/Broken/Commands/Over18/Madame.java @@ -26,50 +26,41 @@ public class Madame implements Commande{ @Override public void action(String[] args, MessageReceivedEvent event) { this.event = event; - - if(event.getTextChannel().isNSFW()) { - Redirection redirect = new Redirection(); - boolean success=false; - boolean error=false; - int errorCp=0; - while(!success && !error) - { - try { - - String url = redirect.get("http://dites.bonjourmadame.fr/random"); - logger.debug("URL: "+url); - if(scanPageForTipeee(url)){ - logger.debug("Advertisement detected! Retry! ("+url+")"); - } - else{ - event.getTextChannel().sendMessage(url).queue(); - success=true; - } - - } catch (IOException e) { - errorCp++; - logger.warn("Erreur de redirection. (Essais n°"+errorCp+")"); - if(errorCp>5) - { - logger.error("5 Erreur de redirection."); - error=true; - event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:warning: **__Erreur de redirection (5 essais), Réessayez__**:warning: ").queue(); - - } - - }catch (StringIndexOutOfBoundsException e){ - logger.catching(e); - event.getTextChannel().sendMessage(EmbedMessageUtils.getInternalError()).queue(); - } - } - - } - else + Redirection redirect = new Redirection(); + boolean success=false; + boolean error=false; + int errorCp=0; + while(!success && !error) { - event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n:warning: **__Channel règlementé! Go sur over18!__**:warning: ").queue(); + try { - logger.warn("Erreur chanel."); + String url = redirect.get("http://dites.bonjourmadame.fr/random"); + logger.debug("URL: "+url); + if(scanPageForTipeee(url)){ + logger.debug("Advertisement detected! Retry! ("+url+")"); + } + else{ + event.getTextChannel().sendMessage(url).queue(); + success=true; + } + + } catch (IOException e) { + errorCp++; + logger.warn("Erreur de redirection. (Essais n°"+errorCp+")"); + if(errorCp>5) + { + logger.error("5 Erreur de redirection."); + error=true; + event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:warning: **__Erreur de redirection (5 essais), Réessayez__**:warning: ").queue(); + + } + + }catch (StringIndexOutOfBoundsException e){ + logger.catching(e); + event.getTextChannel().sendMessage(EmbedMessageUtils.getInternalError()).queue(); + } } + } @Override @@ -87,23 +78,11 @@ public class Madame implements Commande{ return false; } - - private boolean isAdvertisementUrl(String url){ - //Scan url - if(url.toLowerCase().contains("club") && (url.toLowerCase().contains("rejoindre") || url.toLowerCase().contains("rejoignez"))){ - logger.debug("Advertisement detected with \"club\" and \"rejoidre\" or \"rejoignez\""); - return true; - } - else if(url.contains("samedi") && url.contains("dimanche")){ - logger.debug("Advertisement detected with \"samedi\" and \"dimanche\""); - return true; - } - else{ - return false; - } + @Override + public boolean isNSFW() { + return true; } - private boolean scanPageForTipeee(String url) throws StringIndexOutOfBoundsException, IOException{ String content = FindContentOnWebPage.getUrlSource(url); String imgClickLink = content.substring(content.indexOf("photo post")); diff --git a/src/main/java/net/Broken/Commands/Over18/Pipe.java b/src/main/java/net/Broken/Commands/Over18/Pipe.java index 3cd69ee..accc717 100644 --- a/src/main/java/net/Broken/Commands/Over18/Pipe.java +++ b/src/main/java/net/Broken/Commands/Over18/Pipe.java @@ -11,40 +11,6 @@ public class Pipe extends NumberedCommande { super(LogManager.getLogger(), "http://feelation.com/","featured-img","img"); } - /* - System.out.println("ok"); - String pipeLine=null; - URL pipeURL = new URL(redirect.get("http://feelation.com/random")); - URLConnection cc = pipeURL.openConnection(); - BufferedReader in = new BufferedReader(new InputStreamReader(cc.getInputStream(), "UTF-8")); - String inputLine; - - - while ((inputLine = in.readLine()) != null) - { - System.out.println(inputLine); - if(inputLine.contains("class=\"post photo\"")) - { - String[] splited = inputLine.split("<"); - for(String aString:splited) - { - if(aString.startsWith(" messages = new ArrayList(){{ - add(rest); - add(event.getMessage()); - }}; - new MessageTimeOut(messages, MainBot.messageTimeOut).start(); + new MessageTimeOut(MainBot.messageTimeOut, event.getMessage(), rest).start(); } LogManager.getLogger().debug("pong"); } @@ -41,7 +37,6 @@ public class Ping implements Commande { @Override public void executed(boolean success, MessageReceivedEvent event) { - return; } @@ -54,4 +49,9 @@ public class Ping implements Commande { public boolean isAdminCmd() { return false; } + + @Override + public boolean isNSFW() { + return false; + } } diff --git a/src/main/java/net/Broken/Commands/Spam.java b/src/main/java/net/Broken/Commands/Spam.java index c4f198d..59883f7 100644 --- a/src/main/java/net/Broken/Commands/Spam.java +++ b/src/main/java/net/Broken/Commands/Spam.java @@ -92,6 +92,11 @@ public class Spam implements Commande { return true; } + @Override + public boolean isNSFW() { + return false; + } + public void pardon(MessageReceivedEvent event, String[] args){ Guild serveur = event.getGuild(); diff --git a/src/main/java/net/Broken/Commands/SpamInfo.java b/src/main/java/net/Broken/Commands/SpamInfo.java index d43f954..2e3ee82 100644 --- a/src/main/java/net/Broken/Commands/SpamInfo.java +++ b/src/main/java/net/Broken/Commands/SpamInfo.java @@ -109,6 +109,11 @@ public class SpamInfo implements Commande{ return false; } + @Override + public boolean isNSFW() { + return false; + } + public String formatSecond(int second){ long days = TimeUnit.SECONDS.toDays(second); second -= TimeUnit.DAYS.toSeconds(days); diff --git a/src/main/java/net/Broken/MainBot.java b/src/main/java/net/Broken/MainBot.java index e44286b..50d67df 100644 --- a/src/main/java/net/Broken/MainBot.java +++ b/src/main/java/net/Broken/MainBot.java @@ -101,6 +101,7 @@ public class MainBot { { Commande cmdObj = commandes.get(cmd.commande); if(!cmdObj.isAdminCmd() || cmd.event.getMember().hasPermission(Permission.ADMINISTRATOR)){ + if(cmd.event.isFromType(ChannelType.PRIVATE) && commandes.get(cmd.commande).isPrivateUsable()) { @@ -109,8 +110,15 @@ public class MainBot { } else if (!cmd.event.isFromType(ChannelType.PRIVATE)) { - commandes.get(cmd.commande).action(cmd.args, cmd.event); - commandes.get(cmd.commande).executed(true, cmd.event); + if(!cmdObj.isNSFW() || cmd.event.getTextChannel().isNSFW()){ + commandes.get(cmd.commande).action(cmd.args, cmd.event); + commandes.get(cmd.commande).executed(true, cmd.event); + } + else{ + Message msg = cmd.event.getTextChannel().sendMessage(cmd.event.getAuthor().getAsMention() + "\n:warning: **__Channel règlementé! Go sur over18!__**:warning: ").complete(); + new MessageTimeOut(messageTimeOut, msg, cmd.event.getMessage()).start(); + } + } else cmd.event.getPrivateChannel().sendMessage(EmbedMessageUtils.getNoPrivate()).queue(); @@ -121,11 +129,7 @@ public class MainBot { } else{ Message msg = cmd.event.getTextChannel().sendMessage(EmbedMessageUtils.getUnautorized()).complete(); - List messages = new ArrayList(){{ - add(msg); - add(cmd.event.getMessage()); - }}; - new MessageTimeOut(messages, messageTimeOut).start(); + new MessageTimeOut(messageTimeOut, msg, cmd.event.getMessage()).start(); } } diff --git a/src/main/java/net/Broken/Tools/Command/NumberedCommande.java b/src/main/java/net/Broken/Tools/Command/NumberedCommande.java index c932bfd..c8ab314 100644 --- a/src/main/java/net/Broken/Tools/Command/NumberedCommande.java +++ b/src/main/java/net/Broken/Tools/Command/NumberedCommande.java @@ -15,7 +15,7 @@ import java.net.URL; * Created by seb65 on 07/11/2016. */ public abstract class NumberedCommande implements Commande{ - Logger logger = LogManager.getLogger(); + private Logger logger = LogManager.getLogger(); public String HELP="T'es sérieux la?"; int minNumber = 1; int maxNumber = -1; @@ -49,76 +49,65 @@ public abstract class NumberedCommande implements Commande{ { if(args.length == 0) { - if(event.getTextChannel().getName().equals("nsfw-over18")) { - Redirection redirect= new Redirection(); - int randomResult = (int) (minNumber + (Math.random() * (maxNumber - minNumber))); - String result = FindContentOnWebPage.doYourJob(baseURL + randomResult + "-2", divClass, htmlType); - event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n"+result).queue(); - } - else - { - event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n:warning: **__Channel règlementé! Go sur over18!__**:warning: ").queue(); + int randomResult = (int) (minNumber + (Math.random() * (maxNumber - minNumber))); + String result = FindContentOnWebPage.doYourJob(baseURL + randomResult + "-2", divClass, htmlType); + event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n"+result).queue(); - logger.warn("Erreur chanel."); - } } else { - if(args[0].toLowerCase().equals("update")) - { - logger.info("update commande from "+event.getMessage().getAuthor().getName()); - event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n:arrow_right: Updating...").queue(); + switch (args[0].toLowerCase()) { + case "update": + logger.info("update commande from " + event.getMessage().getAuthor().getName()); + event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:arrow_right: Updating...").queue(); - int newNumber = maxNumber; - try { - newNumber = LimitChecker.doYourJob(baseURL,maxNumber); - } catch (IOException e) { - e.printStackTrace(); - } - if(newNumber == maxNumber) - { - event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n:arrow_right: Aucune nouvelle image n'a était trouver :cry:").queue(); - } - else if(newNumber-maxNumber == 1) event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n:arrow_right: "+(newNumber-maxNumber)+" nouvelle image a été trouvé :kissing_heart:").queue(); - else - event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n:arrow_right: "+(newNumber-maxNumber)+" nouvelles images on été trouvé :kissing_heart:").queue(); - logger.info((newNumber-maxNumber)+" new image(s) found."); - maxNumber = newNumber; - } - else if(args[0].toLowerCase().equals("get")) { - if (args.length >= 2) - { - - int number = -1; + int newNumber = maxNumber; try { - number = Integer.parseInt(args[1]); - URL url = new URL(baseURL + number + "-2/"); - HttpURLConnection huc = (HttpURLConnection) url.openConnection(); - huc.setRequestMethod("GET"); - huc.connect(); - int result = huc.getResponseCode(); - if (result == 200) { - event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n" + baseURL + number + "-2/").queue(); - } else { - event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:warning: **__Erreur__** :warning:\n:arrow_right: Page introuvable (404)").queue(); - } - - } catch (NumberFormatException e) { - event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:warning: **__Erreur__** :warning:\n:arrow_right: Erreur d'argument. `//help " + this.toString().toLowerCase() + "` pour plus d'info ").queue(); + newNumber = LimitChecker.doYourJob(baseURL, maxNumber); } catch (IOException e) { - logger.catching(e); - event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:warning: **__Erreur__** :warning:\n:arrow_right: Erreur interne...").queue(); + e.printStackTrace(); } - } - else{ + if (newNumber == maxNumber) { + event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:arrow_right: Aucune nouvelle image n'a était trouver :cry:").queue(); + } else if (newNumber - maxNumber == 1) + event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:arrow_right: " + (newNumber - maxNumber) + " nouvelle image a été trouvé :kissing_heart:").queue(); + else + event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:arrow_right: " + (newNumber - maxNumber) + " nouvelles images on été trouvé :kissing_heart:").queue(); + logger.info((newNumber - maxNumber) + " new image(s) found."); + maxNumber = newNumber; + break; + case "get": + if (args.length >= 2) { + + int number = -1; + try { + number = Integer.parseInt(args[1]); + URL url = new URL(baseURL + number + "-2/"); + HttpURLConnection huc = (HttpURLConnection) url.openConnection(); + huc.setRequestMethod("GET"); + huc.connect(); + int result = huc.getResponseCode(); + if (result == 200) { + event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n" + baseURL + number + "-2/").queue(); + } else { + event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:warning: **__Erreur__** :warning:\n:arrow_right: Page introuvable (404)").queue(); + } + + } catch (NumberFormatException e) { + event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:warning: **__Erreur__** :warning:\n:arrow_right: Erreur d'argument. `//help " + this.toString().toLowerCase() + "` pour plus d'info ").queue(); + } catch (IOException e) { + logger.catching(e); + event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:warning: **__Erreur__** :warning:\n:arrow_right: Erreur interne...").queue(); + } + } else { + event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:warning: **__Erreur__** :warning:\n:arrow_right: Erreur d'argument. `//help " + this.toString().toLowerCase() + "` pour plus d'info ").queue(); + logger.warn("Bad Argument: " + event.getMessage().getContent() + " From " + event.getAuthor().getName()); + } + break; + default: event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + "\n:warning: **__Erreur__** :warning:\n:arrow_right: Erreur d'argument. `//help " + this.toString().toLowerCase() + "` pour plus d'info ").queue(); - logger.warn("Bad Argument: "+event.getMessage().getContent()+" From "+event.getAuthor().getName()); - } - } - else - { - event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n:warning: **__Erreur__** :warning:\n:arrow_right: Erreur d'argument. `//help "+this.toString().toLowerCase()+"` pour plus d'info ").queue(); - logger.warn("Bad Argument: "+event.getMessage().getContent()+" From "+event.getAuthor().getName()); + logger.warn("Bad Argument: " + event.getMessage().getContent() + " From " + event.getAuthor().getName()); + break; } } } catch (IOException e) { diff --git a/src/main/java/net/Broken/Tools/EmbedMessageUtils.java b/src/main/java/net/Broken/Tools/EmbedMessageUtils.java index ecfeaef..5bada04 100644 --- a/src/main/java/net/Broken/Tools/EmbedMessageUtils.java +++ b/src/main/java/net/Broken/Tools/EmbedMessageUtils.java @@ -15,6 +15,7 @@ public class EmbedMessageUtils { return new EmbedBuilder().setTitle(":warning: Commande inconnue! :warning:").setDescription(":arrow_right: Utilisez `//help` pour voirs les commandes disponible.").setColor(Color.orange).setFooter("bot.seb6596.ovh", MainBot.jda.getSelfUser().getAvatarUrl()).build(); } + public static EmbedBuilder getError(String message) { EmbedBuilder temp = new EmbedBuilder().setTitle(":warning: Error! :warning:").setColor(Color.red).setDescription(message); return temp; @@ -45,7 +46,6 @@ public class EmbedMessageUtils { return new EmbedBuilder().setTitle(":mute: Spam Hunter :mute:").setDescription(autor.getAsMention() + " est de retour, fais gaffe!\nJe te surveille!").setImage("https://media.giphy.com/media/3o7TKwBctlv08kY08M/giphy.gif").setFooter("Spam info disponible via '//spaminfo' en privé", null).setColor(Color.orange).build(); } - public static MessageEmbed getHelp(String command) throws FileNotFoundException { String name = command.substring(0, 1).toUpperCase() + command.substring(1).toLowerCase(); String message = new ResourceLoader().getFile("Help/"+name+"/fr/main.md"); @@ -79,7 +79,6 @@ public class EmbedMessageUtils { return new EmbedBuilder().setTitle(":warning: Flush Error :warning: ").setDescription(message).setColor(Color.red).setFooter("'//help flush' pour plus d'info ", MainBot.jda.getSelfUser().getAvatarUrl()).build(); } - public static MessageEmbed getRegister(String message) { return new EmbedBuilder().setTitle(":pencil: Web Registration :pencil:").setDescription(message).setColor(Color.green).setFooter("bot.seb6596.ovh", MainBot.jda.getSelfUser().getAvatarUrl()).build(); } @@ -105,4 +104,5 @@ public class EmbedMessageUtils { } + } \ No newline at end of file diff --git a/src/main/java/net/Broken/Tools/MessageTimeOut.java b/src/main/java/net/Broken/Tools/MessageTimeOut.java index 3286df0..df33d1e 100644 --- a/src/main/java/net/Broken/Tools/MessageTimeOut.java +++ b/src/main/java/net/Broken/Tools/MessageTimeOut.java @@ -5,6 +5,8 @@ import net.dv8tion.jda.core.exceptions.ErrorResponseException; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import java.util.ArrayList; +import java.util.Arrays; import java.util.List; public class MessageTimeOut extends Thread{ @@ -16,6 +18,11 @@ public class MessageTimeOut extends Thread{ this.second = second; } + public MessageTimeOut(int second, Message... messages) { + this.messages = Arrays.asList(messages); + this.second = second; + } + @Override public void run() { logger.debug("Timer for message deletion stated..."); From 9e73cf016df2734283984f62587d2ae24d0eb81b Mon Sep 17 00:00:00 2001 From: BrokenFire Date: Tue, 27 Feb 2018 15:38:12 +0100 Subject: [PATCH 8/8] Change help for NSFW command --- src/main/java/net/Broken/Commands/Help.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/Broken/Commands/Help.java b/src/main/java/net/Broken/Commands/Help.java index 83cada3..08c5af1 100644 --- a/src/main/java/net/Broken/Commands/Help.java +++ b/src/main/java/net/Broken/Commands/Help.java @@ -117,9 +117,12 @@ public class Help implements Commande { else { TableRenderer table = new TableRenderer(); - List noPu = new ArrayList<>(); table.setHeader("Command","PU"); + TableRenderer nsfwTable = new TableRenderer(); + nsfwTable.setHeader("NSFW Only\u00A0", "PU"); + List noPu = new ArrayList<>(); + boolean isAdmin; if(event.isFromType(ChannelType.PRIVATE)) isAdmin = event.getJDA().getGuilds().get(0).getMember(event.getAuthor()).hasPermission(Permission.ADMINISTRATOR); @@ -131,6 +134,8 @@ public class Help implements Commande { if(!e.getValue().isAdminCmd() || isAdmin){ if(e.getValue().isPrivateUsable()) table.addRow(e.getKey(), "XX"); + else if(e.getValue().isNSFW()) + nsfwTable.addRow(e.getKey(),""); else noPu.add(e.getKey()); } @@ -142,6 +147,8 @@ public class Help implements Commande { table.addRow(key, ""); String txt = table.build(); + txt += "\n\n"; + txt += nsfwTable.build(); if(!event.isFromType(ChannelType.PRIVATE)){ Message rest = event.getTextChannel().sendMessage(new EmbedBuilder().setTitle("Command envoyées par message privé").setColor(Color.green).build()).complete();