use of de.nikos410.discordbot.framework.PermissionLevel in project de-DiscordBot by DACH-Discord.
the class ModStuff method command_channelMute.
@CommandSubscriber(command = "channelMute", help = "Nutzer in einem Channel für eine bestimmte Zeit stummschalten", pmAllowed = false, permissionLevel = PermissionLevel.MODERATOR)
public void command_channelMute(final IMessage message, final String userInput, final String channelInput, final String muteDurationInput) {
// Parse user
final IUser muteUser = UserUtils.getUserFromMessage(message, userInput);
if (muteUser == null) {
DiscordIO.sendMessage(message.getChannel(), ":x: Fehler: Kein gültiger Nutzer angegeben!");
return;
}
// Parse channel
final IChannel muteChannel = ChannelUtils.getChannelFromMessage(message, channelInput);
if (muteChannel == null) {
DiscordIO.sendMessage(message.getChannel(), ":x: Fehler: Kein gültiger Kanal angegeben!");
return;
}
// Parse mute duration and message
final CommandUtils.DurationParameters durationParameters = CommandUtils.parseDurationParameters(muteDurationInput);
if (durationParameters == null) {
DiscordIO.sendMessage(message.getChannel(), "Ungültige Dauer angegeben. Mögliche Einheiten sind: s, m, h, d");
return;
}
final int muteDuration = durationParameters.getDuration();
final ChronoUnit muteDurationUnit = durationParameters.getDurationUnit();
String customMessage = durationParameters.getMessage();
if (customMessage == null || customMessage.isEmpty()) {
customMessage = "kein";
}
// Mute user and schedule unmute
final String output = muteUserForChannel(muteUser, muteChannel, muteDuration, muteDurationUnit);
if (output.isEmpty()) {
// :mute:
message.addReaction(ReactionEmoji.of("\uD83D\uDD07"));
} else {
DiscordIO.sendMessage(message.getChannel(), output);
return;
}
final IGuild guild = message.getGuild();
// Do not notify a bot user
if (!muteUser.isBot()) {
final List<String> muteMessage = new ArrayList<>();
muteMessage.add(String.format("**Du wurdest für %s %s für den Kanal %s auf dem Server %s gemuted!**", muteDuration, muteDurationUnit.name(), muteChannel.getName(), guild.getName()));
muteMessage.add(String.format("Hinweis: _%s_", customMessage));
DiscordIO.sendMessage(muteUser.getOrCreatePMChannel(), muteMessage);
}
// Modlog
LOG.info("Guild '{}': User {} was muted for {} {} for the channel {}. Message: {}", guild.getName(), UserUtils.makeUserString(muteUser, guild), muteDuration, muteDurationUnit.name(), muteChannel.getName(), customMessage);
final IChannel modLogChannel = getModlogChannelForGuild(guild);
if (modLogChannel != null) {
final List<String> modLogMessage = new ArrayList<>();
modLogMessage.add(String.format("Nutzer **%s** wurde im Kanal %s für %s %s für den Kanal %s **gemuted**.", UserUtils.makeUserString(muteUser, message.getGuild()), message.getChannel().mention(), muteDuration, muteDurationUnit.name(), muteChannel.mention()));
modLogMessage.add(String.format("Hinweis: _%s _", customMessage));
DiscordIO.sendMessage(modLogChannel, modLogMessage);
}
}
use of de.nikos410.discordbot.framework.PermissionLevel in project de-DiscordBot by DACH-Discord.
the class ModStuff method command_mute.
@CommandSubscriber(command = "mute", help = "Einen Nutzer für eine bestimmte Zeit muten", pmAllowed = false, permissionLevel = PermissionLevel.MODERATOR, ignoreParameterCount = true)
public void command_mute(final IMessage message, final String userString, final String muteDurationInput) {
// Find the user to mute
final IUser muteUser = UserUtils.getUserFromMessage(message, userString);
if (muteUser == null) {
DiscordIO.sendMessage(message.getChannel(), ":x: Fehler: Nutzer nicht gefunden!");
return;
}
// Check if mute duration was specified
if (muteDurationInput == null) {
DiscordIO.sendMessage(message.getChannel(), "Fehler! Es muss eine Mute-Dauer angegeben werden.");
return;
}
// Parse mute duration
final CommandUtils.DurationParameters durationParameters = CommandUtils.parseDurationParameters(muteDurationInput);
if (durationParameters == null) {
DiscordIO.sendMessage(message.getChannel(), "Ungültige Dauer angegeben. Mögliche Einheiten sind: s, m, h, d");
return;
}
final int muteDuration = durationParameters.getDuration();
final ChronoUnit muteDurationUnit = durationParameters.getDurationUnit();
String customMessage = durationParameters.getMessage();
if (customMessage == null || customMessage.isEmpty()) {
customMessage = "kein";
}
final IGuild guild = message.getGuild();
// Mute the user and schedule unmute
muteUserForGuild(muteUser, guild, muteDuration, muteDurationUnit, message.getChannel());
// :mute:
message.addReaction(ReactionEmoji.of("\uD83D\uDD07"));
// Do not notify a bot user
if (!muteUser.isBot()) {
final List<String> muteMessage = Arrays.asList(String.format("**Du wurdest auf dem Server %s für %s %s gemuted!**", guild.getName(), muteDuration, muteDurationUnit.name()), String.format("Hinweis: _%s_", customMessage));
DiscordIO.sendMessage(muteUser.getOrCreatePMChannel(), muteMessage);
}
// Modlog
LOG.info("Guild '{}': User {} was muted for {} {}. Message: {}", guild.getName(), UserUtils.makeUserString(muteUser, message.getGuild()), muteDuration, muteDurationUnit.name(), customMessage);
final IChannel modLogChannel = getModlogChannelForGuild(guild);
if (modLogChannel != null) {
final List<String> modLogMessage = new ArrayList<>();
modLogMessage.add(String.format("Nutzer **%s** wurde im Kanal %s für %s %s **gemuted**.", UserUtils.makeUserString(muteUser, guild), message.getChannel().mention(), muteDuration, muteDurationUnit.name()));
modLogMessage.add(String.format("Hinweis: _%s_", customMessage));
DiscordIO.sendMessage(modLogChannel, modLogMessage);
}
saveUserMutes();
}
use of de.nikos410.discordbot.framework.PermissionLevel in project de-DiscordBot by DACH-Discord.
the class UserGroups method command_createGroup.
@CommandSubscriber(command = "createGroup", help = "Neue Gruppe erstellen", pmAllowed = false, permissionLevel = PermissionLevel.MODERATOR)
public void command_createGroup(final IMessage message, final String groupName) {
final IGuild guild = message.getGuild();
final JSONObject guildJSON = getJSONForGuild(guild);
if (guildJSON.has(groupName)) {
DiscordIO.sendMessage(message.getChannel(), ":x: Gruppe existiert bereits!");
return;
}
final IRole role = message.getGuild().createRole();
role.changePermissions(EnumSet.noneOf(Permissions.class));
role.changeName(groupName);
if (!groupName.startsWith(NON_GAME_GROUP_NAME_PREFIX)) {
role.changeMentionable(true);
}
guildJSON.put(groupName, role.getLongID());
saveJSON();
DiscordIO.sendMessage(message.getChannel(), String.format(":white_check_mark: Gruppe `%s` erstellt.", groupName));
LOG.info(String.format("%s created new group %s.", UserUtils.makeUserString(message.getAuthor(), guild), groupName));
}
use of de.nikos410.discordbot.framework.PermissionLevel in project de-DiscordBot by DACH-Discord.
the class UserGroups method command_removeGroup.
@CommandSubscriber(command = "removeGroup", help = "Gruppe entfernen", pmAllowed = false, permissionLevel = PermissionLevel.MODERATOR)
public void command_removeGroup(final IMessage message, final String groupName) {
final IGuild guild = message.getGuild();
// Validate group first
validateGroup(guild, groupName);
final JSONObject guildJSON = getJSONForGuild(guild);
if (!guildJSON.has(groupName)) {
DiscordIO.sendMessage(message.getChannel(), String.format(":x: Gruppe `%s` nicht gefunden!", groupName));
return;
}
final IRole role = guild.getRoleByID(guildJSON.getLong(groupName));
role.delete();
guildJSON.remove(groupName);
saveJSON();
DiscordIO.sendMessage(message.getChannel(), String.format(":white_check_mark: Gruppe `%s` entfernt.", groupName));
LOG.info(String.format("%s deleted group %s.", UserUtils.makeUserString(message.getAuthor(), guild), groupName));
}
use of de.nikos410.discordbot.framework.PermissionLevel in project de-DiscordBot by DACH-Discord.
the class Rules method command_enableWelcome.
@CommandSubscriber(command = "enableWelcome", help = "Begrüßungsnachricht aktivieren", permissionLevel = PermissionLevel.ADMIN, pmAllowed = false)
public void command_enableWelcome(final IMessage message) {
final IGuild guild = message.getGuild();
final JSONObject guildJSON = getJSONForGuild(guild);
guildJSON.put("on", true);
saveJSON();
DiscordIO.sendMessage(message.getChannel(), ":white_check_mark: Aktiviert!");
LOG.info(String.format("%s enabled welcome messages for server %s (ID: %s)", UserUtils.makeUserString(message.getAuthor(), message.getGuild()), guild.getName(), guild.getStringID()));
}
Aggregations