Skip to content

Commit

Permalink
Added .mazadeletemessage
Browse files Browse the repository at this point in the history
  • Loading branch information
Mazawrath committed Sep 19, 2018
1 parent a899123 commit cf3891a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/java/com/mazawrath/beanbot/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.mazawrath.beanbot.commands.beancoin.*;
import com.mazawrath.beanbot.commands.copypasta.*;
import com.mazawrath.beanbot.commands.maza.MazaAddBeanCoinCommand;
import com.mazawrath.beanbot.commands.maza.MazaDeleteMessageCommand;
import com.mazawrath.beanbot.commands.maza.MazapostchangelogCommand;
import com.mazawrath.beanbot.utilities.Points;
import de.btobastian.sdcf4j.CommandHandler;
Expand Down Expand Up @@ -41,6 +42,7 @@ public static void main(String[] args) {
cmdHandler.registerCommand(new BeanboardCommand(dbConn));
// Mazawrath commands
cmdHandler.registerCommand(new MazapostchangelogCommand());
cmdHandler.registerCommand(new MazaDeleteMessageCommand());
cmdHandler.registerCommand(new MazaAddBeanCoinCommand(dbConn));
// Copypasta
cmdHandler.registerCommand(new Top500Command(dbConn));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.mazawrath.beanbot.commands.maza;

import de.btobastian.sdcf4j.Command;
import de.btobastian.sdcf4j.CommandExecutor;
import org.javacord.api.DiscordApi;
import org.javacord.api.entity.channel.ServerTextChannel;
import org.javacord.api.entity.server.Server;
import org.javacord.api.entity.user.User;

public class MazaDeleteMessageCommand implements CommandExecutor {
@Command(
aliases = {"mazadeletemessage"},
privateMessages = false,
showInHelpPage = false
)

public void onCommand(String command, String channelID, String messageId, ServerTextChannel serverTextChannel2, DiscordApi api, User author, Server server) {
if (author.isBotOwner()) {
serverTextChannel2.sendMessage(messageId + " deleted.");
server.getTextChannelById(channelID).ifPresent(serverTextChannel -> {
serverTextChannel.deleteMessages(messageId);
});
} else
// There is no better var name than this and if you think otherwise you're wrong.
serverTextChannel2.sendMessage("Only Mazawrath can send this message.");
}
}

0 comments on commit cf3891a

Please sign in to comment.