Make clear command also delete the sender's message
This commit is contained in:
parent
1e07ede83e
commit
1f6f23e917
@ -3,6 +3,7 @@ package wtf.beatrice.hidekobot.commands.base;
|
|||||||
import net.dv8tion.jda.api.Permission;
|
import net.dv8tion.jda.api.Permission;
|
||||||
import net.dv8tion.jda.api.entities.Message;
|
import net.dv8tion.jda.api.entities.Message;
|
||||||
import net.dv8tion.jda.api.entities.MessageHistory;
|
import net.dv8tion.jda.api.entities.MessageHistory;
|
||||||
|
import net.dv8tion.jda.api.entities.User;
|
||||||
import net.dv8tion.jda.api.entities.channel.Channel;
|
import net.dv8tion.jda.api.entities.channel.Channel;
|
||||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||||
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
|
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
|
||||||
@ -46,7 +47,9 @@ public class ClearChat
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int delete(int toDeleteAmount, long startingMessageId, MessageChannel channel)
|
public static int delete(int toDeleteAmount,
|
||||||
|
long startingMessageId,
|
||||||
|
MessageChannel channel)
|
||||||
{
|
{
|
||||||
// int to keep track of how many messages we actually deleted.
|
// int to keep track of how many messages we actually deleted.
|
||||||
int deleted = 0;
|
int deleted = 0;
|
||||||
@ -155,6 +158,7 @@ public class ClearChat
|
|||||||
|
|
||||||
public static String parseAmount(int deleted)
|
public static String parseAmount(int deleted)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(deleted < 1)
|
if(deleted < 1)
|
||||||
{
|
{
|
||||||
return "\uD83D\uDE22 Couldn't clear any message!";
|
return "\uD83D\uDE22 Couldn't clear any message!";
|
||||||
|
@ -75,11 +75,16 @@ public class ClearCommand implements MessageCommand
|
|||||||
// ^ todo: maybe the dismiss button should also delete the original message sent by the user?
|
// ^ todo: maybe the dismiss button should also delete the original message sent by the user?
|
||||||
// todo: but then, we need to differentiate between command type in the database, and store
|
// todo: but then, we need to differentiate between command type in the database, and store
|
||||||
// todo: that message's id too.
|
// todo: that message's id too.
|
||||||
botMessage = botMessage.editMessage(content).setActionRow(dismiss).complete();
|
Message finalMessage = event.getChannel().sendMessage(content).setActionRow(dismiss).complete();
|
||||||
|
|
||||||
// add the message to database.
|
// add the message to database.
|
||||||
Cache.getDatabaseSource().queueDisabling(botMessage);
|
Cache.getDatabaseSource().queueDisabling(finalMessage);
|
||||||
Cache.getDatabaseSource().trackRanCommandReply(botMessage, event.getAuthor());
|
Cache.getDatabaseSource().trackRanCommandReply(finalMessage, event.getAuthor());
|
||||||
|
|
||||||
|
// delete the sender's message.
|
||||||
|
event.getMessage().delete().queue();
|
||||||
|
// delete the "clearing" info message.
|
||||||
|
botMessage.delete().queue();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user