use of de.nikos410.discordbot.framework.annotations.CommandSubscriber in project de-DiscordBot by DACH-Discord.
the class DiscordBot method command_help.
private void command_help(final IMessage message) {
final EmbedBuilder embedBuilder = new EmbedBuilder();
for (final String key : this.loadedModules.keySet()) {
Object module = this.loadedModules.get(key);
String moduleHelp = "";
for (Method method : module.getClass().getMethods()) {
if (method.isAnnotationPresent(CommandSubscriber.class)) {
final CommandSubscriber annotation = method.getDeclaredAnnotationsByType(CommandSubscriber.class)[0];
if (this.getUserPermissionLevel(message.getAuthor(), message.getGuild()) >= annotation.permissionLevel()) {
final String command = annotation.command();
final String help = annotation.help();
moduleHelp = moduleHelp + "`" + command + "` " + help + '\n';
}
}
}
final CommandModule[] annotations = module.getClass().getDeclaredAnnotationsByType(CommandModule.class);
final String moduleName = annotations[0].moduleName();
if (!moduleHelp.isEmpty()) {
embedBuilder.appendField(moduleName, moduleHelp, false);
}
}
final EmbedObject embedObject = embedBuilder.build();
Util.sendEmbed(message.getAuthor().getOrCreatePMChannel(), embedObject);
if (!message.getChannel().isPrivate()) {
Util.sendMessage(message.getChannel(), ":mailbox_with_mail:");
}
}
use of de.nikos410.discordbot.framework.annotations.CommandSubscriber in project de-DiscordBot by DACH-Discord.
the class UserGroups method command_groups.
@CommandSubscriber(command = "groups", help = "Alle Rollen auflisten")
public void command_groups(final IMessage message) {
final StringBuilder stringBuilder = new StringBuilder();
final List<String> keyList = new LinkedList<>();
keyList.addAll(usergroupsJSON.keySet());
Collections.sort(keyList);
for (String key : keyList) {
if (stringBuilder.length() != 0) {
stringBuilder.append('\n');
}
stringBuilder.append(key);
}
if (stringBuilder.length() == 0) {
stringBuilder.append("_Keine_");
}
final EmbedBuilder embedBuilder = new EmbedBuilder();
embedBuilder.appendField("Verfügbare Gruppen:", stringBuilder.toString(), false);
embedBuilder.withFooterText("Weise dir mit '" + bot.configJSON.getString("prefix") + "group <Gruppe>' selbst eine dieser Gruppen zu");
Util.sendEmbed(message.getChannel(), embedBuilder.build());
}
use of de.nikos410.discordbot.framework.annotations.CommandSubscriber in project de-DiscordBot by DACH-Discord.
the class UserLog method command_Userlog_Test.
@CommandSubscriber(command = "userlog_test", help = "Userlog-Ausgabe testen", permissionLevel = CommandPermissions.ADMIN)
public void command_Userlog_Test(final IMessage message) {
final IUser user = message.getAuthor();
userJoinNotify(user);
userLeaveNotify(user);
userBanNotify(user);
}
use of de.nikos410.discordbot.framework.annotations.CommandSubscriber in project de-DiscordBot by DACH-Discord.
the class ModStuff method command_voicelog.
@CommandSubscriber(command = "voicelog", help = "Die letzten 20 Aktivitäten in Sprachkanälen auflisten", pmAllowed = false, permissionLevel = PermissionLevel.MODERATOR, ignoreParameterCount = true)
public void command_voicelog(final IMessage message, final String listCountArg) {
final int listCount;
if (listCountArg == null) {
listCount = 20;
} else {
try {
listCount = Integer.parseInt(listCountArg);
} catch (NumberFormatException e) {
DiscordIO.sendMessage(message.getChannel(), ":x: Die angegebene Anzahl ist keine gültige Zahl!");
return;
}
}
final List<String> guildVoiceLog = getVoiceLogForGuild(message.getGuild());
final StringBuilder stringBuilder = new StringBuilder();
boolean entriesSkipped = false;
for (int i = guildVoiceLog.size() - 1; i > (guildVoiceLog.size() - listCount - 1) && i >= 0; i--) {
final String lineToAdd = guildVoiceLog.get(i);
if (stringBuilder.length() + lineToAdd.length() <= 1024) {
stringBuilder.append(guildVoiceLog.get(i));
stringBuilder.append(String.format("%n"));
} else {
entriesSkipped = true;
}
}
final EmbedBuilder responseBuilder = new EmbedBuilder();
final String content = stringBuilder.length() > 0 ? stringBuilder.toString() : "_keine_";
responseBuilder.appendField(String.format("__Die letzten %s Voice-Interaktionen (von neu nach alt)__", listCount), content, false);
if (entriesSkipped) {
responseBuilder.withFooterText("Einer oder mehrere Einträge wurden ignoriert, weil die maximale Textlänge erreicht wurde.");
}
DiscordIO.sendEmbed(message.getChannel(), responseBuilder.build());
}
use of de.nikos410.discordbot.framework.annotations.CommandSubscriber in project de-DiscordBot by DACH-Discord.
the class ModStuff method command_setModlogChannel.
@CommandSubscriber(command = "setModlogChannel", help = "Kanal in dem die Modlog Nachrichten gesendet werden einstellen", pmAllowed = false, passContext = false, permissionLevel = PermissionLevel.ADMIN)
public void command_setModlogChannel(final IMessage message, final String channelParameter) {
final IChannel modlogChannel = ChannelUtils.getChannelFromMessage(message, channelParameter);
if (modlogChannel == null) {
// No valid channel was specified
DiscordIO.sendMessage(message.getChannel(), "Kein gültiger Kanal angegeben!");
return;
}
final IGuild guild = message.getGuild();
final JSONObject guildJSON;
if (modstuffJSON.has(guild.getStringID())) {
guildJSON = modstuffJSON.getJSONObject(guild.getStringID());
} else {
guildJSON = new JSONObject();
modstuffJSON.put(guild.getStringID(), guildJSON);
}
guildJSON.put("modlogChannel", modlogChannel.getLongID());
saveJSON();
// :white_check_mark:
message.addReaction(ReactionEmoji.of("✅"));
}
Aggregations