Skip to content
This repository was archived by the owner on Dec 21, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public Command[] commands() {
new FunCommand(),
new GameCommand(),
new SettingsCommand(),
new ClearCommand(),
infoCommand
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.github.codedoctorde.linwood.commands;

import com.github.codedoctorde.linwood.entity.GuildEntity;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.Message;
import org.hibernate.Session;
import org.jetbrains.annotations.NotNull;
Expand All @@ -27,10 +29,20 @@ public boolean onCommand(Session session, Message message, GuildEntity entity, S
message.getChannel().sendMessage(bundle.getString("Invalid")).queue();
return true;
}
message.getChannel().getHistory().retrievePast(count).queue(messages -> message.getChannel().sendMessage(MessageFormat.format(bundle.getString("Success"), messages.size())).queue());
if(count <= 0 || count > 100)
message.getChannel().sendMessage(bundle.getString("Between")).queue();
message.getChannel().getHistory().retrievePast(count).queue(messages -> {
messages.forEach(deleteMessage -> deleteMessage.delete().queue());
message.getChannel().sendMessage(MessageFormat.format(bundle.getString("Success"), messages.size())).queue();
});
return true;
}

@Override
public boolean hasPermission(Member member, GuildEntity entity, Session session) {
return member.hasPermission(Permission.MANAGE_CHANNEL);
}

@Override
public @NotNull Set<String> aliases(GuildEntity entity) {
return new HashSet<>(Arrays.asList(
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/locale/commands/Base_de.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Syntax=*Bekomme die Hilfe mit `help <Command...>`*\n**Verfügbare Hilfeseiten:** \n\n`help fun` \n*Spaßbefehlhilfe* \n\n`help settings` \n*Einstellungshilfe* \n\n`help games` \n*(Mini)gameshilfe* \n\n~~ ~~ \n\n**Verfügbare Befehle:** \n\n`info` \n*Bekomme generelle Informationen über den Bot*
Syntax=*Bekomme die Hilfe mit `help <Command...>`*\n**Verfügbare Hilfeseiten:** \n\n`help fun` \n*Spaßbefehlhilfe* \n\n`help settings` \n*Einstellungshilfe* \n\n`help games` \n*(Mini)gameshilfe* \n\n~~ ~~ \n\n**Verfügbare Befehle:** \n\n`info` \n*Bekomme generelle Informationen über den Bot* \n\n`clear <Nachrichten 1-100>` \nLeere den Chat \n__Benötigte Rechte: Kanal verwalten__
Description=Generelle Hilfe Befehl
2 changes: 1 addition & 1 deletion src/main/resources/locale/commands/Base_en.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Syntax=*Get the help with `help <Command...>`*\n**Available help pages:** \n\n`help fun` \n*Fun Commands Help* \n\n`help settings` \n*Settings help* \n\n`help games` \n*(Mini)games help* \n\n~~ ~~ \n\n**Available commands:** \n\n`info` \n*Get the general information of the bot*
Syntax=*Get the help with `help <Command...>`*\n**Available help pages:** \n\n`help fun` \n*Fun Commands Help* \n\n`help settings` \n*Settings help* \n\n`help games` \n*(Mini)games help* \n\n~~ ~~ \n\n**Available commands:** \n\n`info` \n*Get the general information of the bot* \n\n`clear <Messages 1-100>` \nClear the chat \n__Required permissions: Manage channel__
Description=General help command
5 changes: 5 additions & 0 deletions src/main/resources/locale/commands/Clear_de.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Syntax=clear <Nachrichten 1-100>
Description=Leere den derzeitigen Chat
Success=Erfolgreich {0} Nachrichten geleert!
Invalid=Das Argument muss eine Zahl sein!
Between=Das Argument muss zwischen 1 und 100 sein!
5 changes: 5 additions & 0 deletions src/main/resources/locale/commands/Clear_en.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Syntax=clear <Messages 1-100>
Description=Clear the current chat
Success=Successfully {0} messages cleared!
Invalid=The argument should be a number!
Between=The argument should be between 1 and 100!