From db5dd58db201880b10c727b7f31c3a6ed3a30711 Mon Sep 17 00:00:00 2001 From: Mister Fix Date: Sat, 28 Jul 2018 18:35:22 +0300 Subject: [PATCH] Added command MSB --- README.md | 2 -- src/main/java/io/rixa/bot/Rixa.java | 19 +++------------- .../bot/commands/cmds/general/MsbCommand.java | 22 +++++++++++++++++++ .../commands/cmds/general/PingCommand.java | 1 - .../io/rixa/bot/events/MessageListener.java | 2 -- .../module/music/AudioPlayerSendHandler.java | 2 +- .../io/rixa/bot/utils/MessageFactory.java | 2 +- src/main/resources/config.yml | 14 ++++++------ 8 files changed, 34 insertions(+), 30 deletions(-) delete mode 100644 README.md create mode 100644 src/main/java/io/rixa/bot/commands/cmds/general/MsbCommand.java diff --git a/README.md b/README.md deleted file mode 100644 index df68dd6..0000000 --- a/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# Rixa -Rixa Discord Bot diff --git a/src/main/java/io/rixa/bot/Rixa.java b/src/main/java/io/rixa/bot/Rixa.java index 3958acf..621cf69 100644 --- a/src/main/java/io/rixa/bot/Rixa.java +++ b/src/main/java/io/rixa/bot/Rixa.java @@ -4,21 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import io.rixa.bot.commands.cmds.admin.ConfigCommand; import io.rixa.bot.commands.cmds.admin.PMCommand; -import io.rixa.bot.commands.cmds.general.AdviceCommand; -import io.rixa.bot.commands.cmds.general.FeaturesCommand; -import io.rixa.bot.commands.cmds.general.HelpCommand; -import io.rixa.bot.commands.cmds.general.InfoCommand; -import io.rixa.bot.commands.cmds.general.LeaderboardsCommand; -import io.rixa.bot.commands.cmds.general.MinecraftCommand; -import io.rixa.bot.commands.cmds.general.ModulesCommand; -import io.rixa.bot.commands.cmds.general.MusicCommand; -import io.rixa.bot.commands.cmds.general.PingCommand; -import io.rixa.bot.commands.cmds.general.QuoteCommand; -import io.rixa.bot.commands.cmds.general.RankCommand; -import io.rixa.bot.commands.cmds.general.RoleMemberList; -import io.rixa.bot.commands.cmds.general.ServerInfoCommand; -import io.rixa.bot.commands.cmds.general.UrbanDictionaryCommand; -import io.rixa.bot.commands.cmds.general.YoutubeCommand; +import io.rixa.bot.commands.cmds.general.*; import io.rixa.bot.commands.cmds.moderator.BanCommand; import io.rixa.bot.commands.cmds.moderator.ClearCommand; import io.rixa.bot.commands.cmds.moderator.MuteCommand; @@ -103,7 +89,7 @@ public class Rixa { private void loadJDA() { JDABuilder jda = new JDABuilder(AccountType.BOT) .setToken(configuration.getToken()) - .setGame(Game.of(GameType.WATCHING, configuration.getBotGame())) + .setGame(Game.of(GameType.DEFAULT, configuration.getBotGame())) .setEventManager(new AnnotatedEventManager()) .addEventListener(new ReadyListener(), new BotJoinListener(), new MessageListener(), new UserListener()) @@ -155,6 +141,7 @@ public class Rixa { new MusicCommand("music", RixaPermission.NONE, "Listen to music right from discord!", CommandType.USER), new PingCommand("ping", RixaPermission.NONE, "Check Rixa's ping!", CommandType.USER), + new MsbCommand("msb", RixaPermission.NONE, "Create a mocking Spongebob meme", CommandType.USER), new ServerInfoCommand("serverinfo", RixaPermission.NONE, "Review information about the server!", CommandType.USER), new QuoteCommand("quote", RixaPermission.NONE, diff --git a/src/main/java/io/rixa/bot/commands/cmds/general/MsbCommand.java b/src/main/java/io/rixa/bot/commands/cmds/general/MsbCommand.java new file mode 100644 index 0000000..b4258a6 --- /dev/null +++ b/src/main/java/io/rixa/bot/commands/cmds/general/MsbCommand.java @@ -0,0 +1,22 @@ +package io.rixa.bot.commands.cmds.general; + +import io.rixa.bot.commands.Command; +import io.rixa.bot.commands.handler.CommandType; +import io.rixa.bot.commands.perms.RixaPermission; +import io.rixa.bot.utils.MessageFactory; +import net.dv8tion.jda.core.entities.Guild; +import net.dv8tion.jda.core.entities.Member; +import net.dv8tion.jda.core.entities.TextChannel; + +public class MsbCommand extends Command { + + public MsbCommand(String command, RixaPermission rixaPermission, String description, CommandType commandType) { + super(command, rixaPermission, description, commandType); + } + + @Override + public void execute(String commandLabel, Guild guild, Member member, TextChannel channel, String[] args) { + String str = String.join("_", args); + MessageFactory.create("Mocking Spongebob").setImage("https://mockingspongebob.org/"+str+".jpg").queue(channel); + } +} diff --git a/src/main/java/io/rixa/bot/commands/cmds/general/PingCommand.java b/src/main/java/io/rixa/bot/commands/cmds/general/PingCommand.java index 3e96b0e..b095807 100644 --- a/src/main/java/io/rixa/bot/commands/cmds/general/PingCommand.java +++ b/src/main/java/io/rixa/bot/commands/cmds/general/PingCommand.java @@ -7,7 +7,6 @@ import io.rixa.bot.utils.MessageFactory; import net.dv8tion.jda.core.entities.Guild; import net.dv8tion.jda.core.entities.Member; import net.dv8tion.jda.core.entities.TextChannel; -import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent; public class PingCommand extends Command { diff --git a/src/main/java/io/rixa/bot/events/MessageListener.java b/src/main/java/io/rixa/bot/events/MessageListener.java index 910752c..133f846 100644 --- a/src/main/java/io/rixa/bot/events/MessageListener.java +++ b/src/main/java/io/rixa/bot/events/MessageListener.java @@ -102,8 +102,6 @@ public class MessageListener { commandName = commandName.replaceFirst(prefix, ""); try { Command command = Rixa.getInstance().getCommandHandler().getCommand(commandName); - //command.execute(event); - event.getMessage().delete().queueAfter(3, TimeUnit.SECONDS); RixaGuild rixaGuild = GuildManager.getInstance().getGuild(event.getGuild()); if (!event.getGuild().getOwner().getUser().getId().equalsIgnoreCase(event.getAuthor().getId()) && command.getPermission() != null && command.getPermission() != RixaPermission.NONE && diff --git a/src/main/java/io/rixa/bot/guild/modules/module/music/AudioPlayerSendHandler.java b/src/main/java/io/rixa/bot/guild/modules/module/music/AudioPlayerSendHandler.java index 47b8dd3..b671abe 100644 --- a/src/main/java/io/rixa/bot/guild/modules/module/music/AudioPlayerSendHandler.java +++ b/src/main/java/io/rixa/bot/guild/modules/module/music/AudioPlayerSendHandler.java @@ -31,7 +31,7 @@ public class AudioPlayerSendHandler implements AudioSendHandler { lastFrame = audioPlayer.provide(); } - byte[] data = lastFrame != null ? lastFrame.data : null; + byte[] data = lastFrame != null ? lastFrame.getData() : null; lastFrame = null; return data; diff --git a/src/main/java/io/rixa/bot/utils/MessageFactory.java b/src/main/java/io/rixa/bot/utils/MessageFactory.java index 1114683..2371eec 100644 --- a/src/main/java/io/rixa/bot/utils/MessageFactory.java +++ b/src/main/java/io/rixa/bot/utils/MessageFactory.java @@ -32,7 +32,7 @@ public class MessageFactory { public MessageFactory() { this.builder = new EmbedBuilder(); - selfDestruct = 20; + selfDestruct = 0; } public MessageFactory setTitle(String title, String url) { diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index f8ae840..15f19d3 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,13 +1,13 @@ -token: "YOUR_TOKEN_HERE" -botGame: "Rixa 2.0 | http://rixa.io/invite" +token: "kIWC67smb8Ysmxwj_Q1XaqWA4ciNQw2F" +botGame: "Rixa 3.0 beta | Hosted by Mister_Fix" shards: 5 + botAdmins: -- "YOUR_USER_ID_HERE" -- "OTHER_ADMINS" -- "REMOVE_IF_YOU_DONT_WANT" +- "104695503358291968" + sqlCredentials: hostName: "localhost" databaseName: "rixa" - userName: "rixa_users" - password: "password" + userName: "root" + password: "" port: "3306"