Remove invite command

This commit is contained in:
SebClem 2022-05-16 17:12:59 +02:00
parent fc3b89af9c
commit 97ac19873d
Signed by: sebclem
GPG Key ID: 5A4308F6A359EA50
3 changed files with 0 additions and 168 deletions

View File

@ -93,7 +93,6 @@ public class Init {
jda.addEventListener(new BotListener()); jda.addEventListener(new BotListener());
jda.getPresence().setPresence(OnlineStatus.ONLINE, Activity.playing(MainBot.url)); jda.getPresence().setPresence(OnlineStatus.ONLINE, Activity.playing(MainBot.url));
logger.info("-----------------------END INIT-----------------------"); logger.info("-----------------------END INIT-----------------------");

View File

@ -1,41 +0,0 @@
package net.Broken.SlashCommands;
import net.Broken.SlashCommand;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
import net.dv8tion.jda.api.interactions.commands.build.SubcommandData;
import java.util.List;
public class Invite implements SlashCommand {
@Override
public void action(SlashCommandEvent event) {
event.reply(event.getJDA().setRequiredScopes("bot", "applications.commands").getInviteUrl(Permission.ADMINISTRATOR)).setEphemeral(true).queue();
}
@Override
public String getDescription() {
return "Get the link to invite this bot to your server";
}
@Override
public List<OptionData> getOptions() {
return null;
}
@Override
public List<SubcommandData> getSubcommands() {
return null;
}
@Override
public boolean isBotAdminCmd() {
return false;
}
@Override
public boolean isNSFW() {
return false;
}
}

View File

@ -1,126 +0,0 @@
package net.Broken.Tools;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
/**
* Utils to render table in block code
*/
public class TableRenderer {
private int width;
private List<Object> header;
private List<List<Object>> table = new ArrayList<>();
private String empty = "";
public TableRenderer() {
}
/**
* Set Table header(s)
*
* @param header Header(s) as String
*/
public void setHeader(Object... header) {
this.header = Arrays.asList(header);
if (header.length > this.width)
this.width = header.length;
}
/**
* Add row to table
*
* @param content Content(s) as string
*/
public void addRow(Object... content) {
List<Object> objects = Arrays.asList(content);
table.add(objects);
if (content.length > this.width)
this.width = content.length;
}
/**
* Change default empty string
*
* @param str
*/
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<Object> 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"));
}
}