Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
151 commits
Select commit Hold shift + click to select a range
0ce0c77
added ban and kick command
RealYusufIsmail Oct 16, 2021
bc393fc
Update Commands.java
RealYusufIsmail Oct 16, 2021
aa83502
fixed typos
RealYusufIsmail Oct 16, 2021
2467335
Update KickCommand.java
RealYusufIsmail Oct 16, 2021
551ec76
Update BanCommand.java
RealYusufIsmail Oct 16, 2021
f8d59ac
Update BanCommand.java
RealYusufIsmail Oct 16, 2021
a7e19c1
Update KickCommand.java
RealYusufIsmail Oct 16, 2021
c0b796f
Update KickCommand.java
RealYusufIsmail Oct 16, 2021
73e2517
Update KickCommand.java
RealYusufIsmail Oct 16, 2021
605a680
Update KickCommand.java
RealYusufIsmail Oct 16, 2021
7910cce
Update KickCommand.java
RealYusufIsmail Oct 16, 2021
44ed0bd
Update KickCommand.java
RealYusufIsmail Oct 16, 2021
3226043
Fix the rest tomorrow
RealYusufIsmail Oct 16, 2021
b628811
Update KickCommand.java
RealYusufIsmail Oct 16, 2021
f1a4aa5
Update KickCommand.java
RealYusufIsmail Oct 16, 2021
a46b4c2
Update KickCommand.java
RealYusufIsmail Oct 16, 2021
e3dc6de
Update BanCommand.java
RealYusufIsmail Oct 16, 2021
2aba8c2
Update BanCommand.java
RealYusufIsmail Oct 16, 2021
111eec4
Update KickCommand.java
RealYusufIsmail Oct 16, 2021
05694be
Update BanCommand.java
RealYusufIsmail Oct 16, 2021
b966304
added UnBan Command
RealYusufIsmail Oct 16, 2021
0c92c3e
Update UnBanCommand.java
RealYusufIsmail Oct 16, 2021
9f7dc06
Apply suggestions from code review
RealYusufIsmail Oct 17, 2021
dbe0a35
Update UnBanCommand.java
RealYusufIsmail Oct 17, 2021
01d8069
fixed all commands
RealYusufIsmail Oct 17, 2021
b8fd360
Merge branch 'feature/kick_and_ban_commands' of https://github.com/Yu…
RealYusufIsmail Oct 17, 2021
a55ecc0
spotlessApply
RealYusufIsmail Oct 17, 2021
0daad10
The bot will dm the user now.
RealYusufIsmail Oct 17, 2021
12fc55a
spotlessApply
RealYusufIsmail Oct 17, 2021
fe59425
Update BanCommand.java
RealYusufIsmail Oct 17, 2021
867147f
changed user id from string to long
RealYusufIsmail Oct 17, 2021
365ff7e
it will log the author.
RealYusufIsmail Oct 17, 2021
606793b
Update UnBanCommand.java
RealYusufIsmail Oct 17, 2021
c9b2f25
added delete messages command
RealYusufIsmail Oct 17, 2021
8cac495
Update DeleteMessageCommand.java
RealYusufIsmail Oct 17, 2021
df8bb90
Update Commands.java
RealYusufIsmail Oct 17, 2021
019bec3
Update BanCommand.java
RealYusufIsmail Oct 17, 2021
516ffcf
Update KickCommand.java
RealYusufIsmail Oct 17, 2021
c3f3c9a
Create WarnCommand.java
RealYusufIsmail Oct 17, 2021
1f369ab
Update DeleteMessageCommand.java
RealYusufIsmail Oct 17, 2021
a7c2aa0
update
RealYusufIsmail Oct 17, 2021
23a6c2e
changed from UnBanCommand to UnbanCommand. Allowed to delete messages…
RealYusufIsmail Oct 17, 2021
fd0802d
Update BanCommand.java
RealYusufIsmail Oct 17, 2021
48f9863
Update BanCommand.java
RealYusufIsmail Oct 17, 2021
8b96b3a
I checked the jda guild and its says it has to be between one and 7 days
RealYusufIsmail Oct 17, 2021
d054f3a
Update V1__Database_Listener.sql
RealYusufIsmail Oct 17, 2021
2e503f3
Update V1__Database_Listener.sql
RealYusufIsmail Oct 17, 2021
76a12f2
Create V2_ADD_WARN_TABLE.sql
RealYusufIsmail Oct 17, 2021
fc92173
Update Commands.java
RealYusufIsmail Oct 17, 2021
4b75bcd
Merge branch 'feature/kick_and_ban_commands' into feature/warn_and_de…
RealYusufIsmail Oct 17, 2021
a29dc68
Update Commands.java
RealYusufIsmail Oct 17, 2021
380bd04
Update V2_Add_Warn_Table.sql
RealYusufIsmail Oct 17, 2021
92eb572
Update V1_Add_Warn_Table.sql
RealYusufIsmail Oct 17, 2021
5f1a55d
update
RealYusufIsmail Oct 18, 2021
917658f
Update WarnCommand.java
RealYusufIsmail Oct 18, 2021
7dae25c
Update .gitignore
RealYusufIsmail Oct 18, 2021
9d6c4be
fixed everything
RealYusufIsmail Oct 18, 2021
336d567
Update BanCommand.java
RealYusufIsmail Oct 18, 2021
64d7c66
Fixed everything apart from https://github.com/Together-Java/TJ-Bot/p…
RealYusufIsmail Oct 19, 2021
9ae3477
Update BanCommand.java
RealYusufIsmail Oct 19, 2021
d31f7c4
Update UnbanCommand.java
RealYusufIsmail Oct 19, 2021
30eb8ae
Update KickCommand.java
RealYusufIsmail Oct 19, 2021
d9bf30b
I think i have solved the problem
RealYusufIsmail Oct 19, 2021
b5d9a87
Merge branch 'develop' into feature/kick_and_ban_commands
RealYusufIsmail Oct 19, 2021
e842a70
Merge branch 'feature/kick_and_ban_commands' into feature/warn_and_de…
RealYusufIsmail Oct 19, 2021
b698534
update
RealYusufIsmail Oct 19, 2021
c531c09
Update PurgeCommand.java
RealYusufIsmail Oct 19, 2021
abfb624
Update BanCommand.java
RealYusufIsmail Oct 19, 2021
3466ddb
Merge branch 'feature/kick_and_ban_commands' into feature/purge_command
RealYusufIsmail Oct 19, 2021
6e11024
Update PurgeCommand.java
RealYusufIsmail Oct 19, 2021
02cf3be
Cleaned the code
RealYusufIsmail Oct 19, 2021
84a5b24
Cleaned the code
RealYusufIsmail Oct 19, 2021
15ba489
Merge branch 'develop' into feature/kick_and_ban_commands
RealYusufIsmail Oct 20, 2021
a8a1ecf
continue later
RealYusufIsmail Oct 20, 2021
b17ef98
Update BanCommand.java
RealYusufIsmail Oct 20, 2021
c825f78
Fixed everything + spotlessApply
RealYusufIsmail Oct 20, 2021
59b7dff
Update BanCommand.java
RealYusufIsmail Oct 20, 2021
7226800
Update BanCommand.java
RealYusufIsmail Oct 20, 2021
7687186
Fixed it
RealYusufIsmail Oct 21, 2021
8775730
Update BanCommand.java
RealYusufIsmail Oct 21, 2021
7aee287
Update application/src/main/java/org/togetherjava/tjbot/commands/mode…
RealYusufIsmail Oct 21, 2021
5550872
changed some things
RealYusufIsmail Oct 21, 2021
73f30e6
Update BanCommand.java
RealYusufIsmail Oct 21, 2021
81e3f17
a bit cleaner
RealYusufIsmail Oct 21, 2021
c6722da
Update BanCommand.java
RealYusufIsmail Oct 21, 2021
1663113
added choices
RealYusufIsmail Oct 21, 2021
fe7f1d3
Update BanCommand.java
RealYusufIsmail Oct 21, 2021
edc42ed
Update BanCommand.java
RealYusufIsmail Oct 21, 2021
2fb352e
Update BanCommand.java
RealYusufIsmail Oct 21, 2021
bd27130
Update application/src/main/java/org/togetherjava/tjbot/commands/mode…
RealYusufIsmail Oct 21, 2021
46c2ecb
Update application/src/main/java/org/togetherjava/tjbot/commands/mode…
RealYusufIsmail Oct 21, 2021
3a328ff
Update application/src/main/java/org/togetherjava/tjbot/commands/mode…
RealYusufIsmail Oct 21, 2021
107e536
Update BanHelperMethods.java
RealYusufIsmail Oct 21, 2021
de1b36e
Update application/src/main/java/org/togetherjava/tjbot/commands/mode…
RealYusufIsmail Oct 21, 2021
90b88fe
Update BanHelperMethods.java
RealYusufIsmail Oct 21, 2021
198c720
Update BanHelperMethods.java
RealYusufIsmail Oct 21, 2021
fa89b64
spotlessApply
RealYusufIsmail Oct 21, 2021
97a4aac
tweaked the ban command. Removed unneeded string in kick command
RealYusufIsmail Oct 22, 2021
7e165f9
spotlessJavaApply
RealYusufIsmail Oct 22, 2021
35b9939
Update BanCommand.java
RealYusufIsmail Oct 22, 2021
350ada4
Merge branch 'feature/kick_and_ban_commands' into feature/purge_command
RealYusufIsmail Oct 22, 2021
5d42005
Fixed the command
RealYusufIsmail Oct 22, 2021
af1fe46
I have fixed what you told me to fix
RealYusufIsmail Oct 22, 2021
563998a
Update BanCommand.java
RealYusufIsmail Oct 22, 2021
c6dd085
Update BanCommand.java
RealYusufIsmail Oct 22, 2021
57e89f9
Update BanCommand.java
RealYusufIsmail Oct 22, 2021
6a4f39a
Update BanCommand.java
RealYusufIsmail Oct 22, 2021
2105989
Update BanCommand.java
RealYusufIsmail Oct 22, 2021
1532d75
Update BanCommand.java
RealYusufIsmail Oct 22, 2021
bc90bd4
Update BanCommand.java
RealYusufIsmail Oct 22, 2021
f7aac63
Fixed everything
RealYusufIsmail Oct 22, 2021
08be698
Fixed the loggers
RealYusufIsmail Oct 22, 2021
cdc8389
Update .gitignore
RealYusufIsmail Oct 22, 2021
26442db
Merge branch 'feature/kick_and_ban_commands' into feature/purge_command
RealYusufIsmail Oct 22, 2021
aa55b9c
Update PurgeCommand.java
RealYusufIsmail Oct 22, 2021
0832398
Update PurgeCommand.java
RealYusufIsmail Oct 22, 2021
1f18590
Update PurgeCommand.java
RealYusufIsmail Oct 22, 2021
12f6a40
fixed kick and unban command
RealYusufIsmail Oct 22, 2021
5309601
Merge branch 'feature/kick_and_ban_commands' into feature/purge_command
RealYusufIsmail Oct 22, 2021
75a4916
Update application/src/main/java/org/togetherjava/tjbot/commands/mode…
RealYusufIsmail Oct 23, 2021
3a1c045
Update application/src/main/java/org/togetherjava/tjbot/commands/mode…
RealYusufIsmail Oct 23, 2021
3a9f44d
Update PurgeCommand.java
RealYusufIsmail Oct 23, 2021
22d7674
Update PurgeCommand.java
RealYusufIsmail Oct 23, 2021
e6d5239
Update application/src/main/java/org/togetherjava/tjbot/commands/mode…
RealYusufIsmail Oct 23, 2021
4d3f4c1
Update KickCommand.java
RealYusufIsmail Oct 23, 2021
19e7b57
Update UnbanCommand.java
RealYusufIsmail Oct 23, 2021
3d50737
Merge branch 'feature/kick_and_ban_commands' into feature/purge_command
RealYusufIsmail Oct 23, 2021
2d7d2df
Update application/src/main/java/org/togetherjava/tjbot/commands/mode…
RealYusufIsmail Oct 23, 2021
b0bcec7
Update UnbanCommand.java
RealYusufIsmail Oct 23, 2021
18e0588
Update UnbanCommand.java
RealYusufIsmail Oct 23, 2021
9e91a86
Update PurgeCommand.java
RealYusufIsmail Oct 23, 2021
39c8c12
Update BanCommand.java
RealYusufIsmail Oct 23, 2021
7f2389f
Update BanCommand.java
RealYusufIsmail Oct 23, 2021
431d488
Update BanCommand.java
RealYusufIsmail Oct 23, 2021
47f9f28
Update BanCommand.java
RealYusufIsmail Oct 23, 2021
e3d2a5e
Update KickCommand.java
RealYusufIsmail Oct 23, 2021
5cef333
Update UnbanCommand.java
RealYusufIsmail Oct 23, 2021
7bfb288
fixed everything that i was told to fix
RealYusufIsmail Oct 23, 2021
547536f
Update UnbanCommand.java
RealYusufIsmail Oct 23, 2021
08c42dc
Update UnbanCommand.java
RealYusufIsmail Oct 23, 2021
b44f3af
Tweaking the commands
RealYusufIsmail Oct 23, 2021
6c4f3ed
improving the sentecences
RealYusufIsmail Oct 23, 2021
ec26837
added some loggers
RealYusufIsmail Oct 23, 2021
9d199d9
spotlessApply
RealYusufIsmail Oct 23, 2021
1131196
Merge branch 'feature/kick_and_ban_commands' into feature/purge_command
RealYusufIsmail Oct 23, 2021
6cee7d6
Update PurgeCommand.java
RealYusufIsmail Oct 23, 2021
9b12e96
Update PurgeCommand.java
RealYusufIsmail Oct 23, 2021
c463d99
fixed
RealYusufIsmail Oct 23, 2021
49d6928
Update V1__Database_Listener.sql
RealYusufIsmail Oct 23, 2021
323f04a
Update V1__Database_Listener.sql
RealYusufIsmail Oct 23, 2021
5ba27a7
Update V1__Database_Listener.sql
RealYusufIsmail Oct 23, 2021
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,6 @@ logviewer/types.d.ts
logviewer/pnpm-lock.yaml
logviewer/webpack.config.js
logviewer/webpack.generated.js

### Mac Patch ###
.DS_Store
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.jetbrains.annotations.NotNull;
import org.togetherjava.tjbot.commands.basic.DatabaseCommand;
import org.togetherjava.tjbot.commands.basic.PingCommand;
import org.togetherjava.tjbot.commands.moderation.*;
import org.togetherjava.tjbot.commands.mathcommands.TeXCommand;
import org.togetherjava.tjbot.commands.tags.TagCommand;
import org.togetherjava.tjbot.commands.tags.TagManageCommand;
Expand Down Expand Up @@ -41,6 +42,6 @@ public enum Commands {
// available.
return List.of(new PingCommand(), new DatabaseCommand(database), new TeXCommand(),
new TagCommand(tagSystem), new TagManageCommand(tagSystem),
new TagsCommand(tagSystem));
new TagsCommand(tagSystem), new PurgeCommand());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package org.togetherjava.tjbot.commands.moderation;

import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.TextChannel;
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
import net.dv8tion.jda.api.interactions.commands.OptionType;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.togetherjava.tjbot.commands.SlashCommandAdapter;
import org.togetherjava.tjbot.commands.SlashCommandVisibility;

import java.util.Objects;


/**
* When triggered with {@code /prune "number_of_messages"}, the bot will check if the user has
* perms. Then it will check if itself has perms to delete messages. If it does the bot will delete
* that amount of messages. {@code I have deleted this amount of message + amount}.
*
*/
public final class PurgeCommand extends SlashCommandAdapter {
private static final Logger logger = LoggerFactory.getLogger(PurgeCommand.class);
private static final String NUMBER_OF_MESSAGES_TO_DELETE = "number_of_messages";
private static final String USER_MESSAGES = "user";

public PurgeCommand() {
super("purge", "Use this command to delete a batch of messages",
SlashCommandVisibility.GUILD);

getData()
.addOption(OptionType.INTEGER, NUMBER_OF_MESSAGES_TO_DELETE,
"The number of messages you want to delete. 1 to 100", true);
}

@Override
public void onSlashCommand(@NotNull SlashCommandEvent event) {
final Member author = event.getMember();
final TextChannel channel = event.getTextChannel();

if (!Objects.requireNonNull(author).hasPermission(Permission.MESSAGE_MANAGE)) {
event.reply("You are missing MESSAGE_MANAGE permission to delete these the message")
.setEphemeral(true)
.queue();
return;
}

final Member bot = Objects.requireNonNull(event.getGuild()).getSelfMember();

if (!bot.hasPermission(Permission.MESSAGE_MANAGE)) {
event.reply("I am missing MESSAGE_MANAGE permission which means I am unable to delete messages in this server.")
.setEphemeral(true)
.queue();

logger.error("The bot does not have MESSAGE_MANAGE permission on the server '{}' ",
event.getGuild().getId());
return;
}

int amount = Math.toIntExact(
Objects.requireNonNull(event.getOption(NUMBER_OF_MESSAGES_TO_DELETE)).getAsLong());
if (amount > 100 || amount < 1) {
event.reply("You can only delete 1 to 200 messages").setEphemeral(true).queue();
} else {
channel.getHistory().retrievePast(amount).queue(channel::purgeMessages);
event.reply("I have deleted this amount of messages " + amount)
.setEphemeral(true)
.queue();
logger.info(" '{}' deleted this amount of messages '{}'", author, amount);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* This package offers all the moderation commands in the application.
*/
package org.togetherjava.tjbot.commands.moderation;