Added music leave command, fixed lombok problems, moved RixaManager -> RixaGuild.
This commit is contained in:
parent
3ab2627d54
commit
f8adff77c7
Binary file not shown.
Binary file not shown.
@ -13,6 +13,7 @@
|
||||
<orderEntry type="library" name="Gradle: mysql:mysql-connector-java:5.1.38" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.sedmelluq:lavaplayer:1.2.42" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.twitter4j:twitter4j-stream:4.0.6" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.projectlombok:lombok:1.16.18" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.apache.commons:commons-lang3:3.5" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.apache.commons:commons-collections4:4.1" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.json:json:20160810" level="project" />
|
||||
@ -34,7 +35,6 @@
|
||||
<orderEntry type="library" name="Gradle: commons-logging:commons-logging:1.2" level="project" />
|
||||
<orderEntry type="library" name="Gradle: commons-codec:commons-codec:1.9" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.fasterxml.jackson.core:jackson-annotations:2.8.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.projectlombok:lombok:1.16.8" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.apache.httpcomponents:httpcore-nio:4.4.4" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.twitter4j:twitter4j-core:4.0.6" level="project" />
|
||||
</component>
|
||||
|
@ -14,6 +14,7 @@
|
||||
<orderEntry type="library" name="Gradle: mysql:mysql-connector-java:5.1.38" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.sedmelluq:lavaplayer:1.2.42" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.twitter4j:twitter4j-stream:4.0.6" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.projectlombok:lombok:1.16.18" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.apache.commons:commons-lang3:3.5" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.apache.commons:commons-collections4:4.1" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.json:json:20160810" level="project" />
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -29,7 +29,7 @@ dependencies {
|
||||
compile 'com.sedmelluq:lavaplayer:1.2.42'
|
||||
compile 'org.twitter4j:twitter4j-core:4.0.3'
|
||||
compile 'org.twitter4j:twitter4j-stream:4.0.6'
|
||||
compileOnly 'org.projectlombok:lombok:1.16.8'
|
||||
compile 'org.projectlombok:lombok:1.16.18'
|
||||
}
|
||||
|
||||
compileJava.options.encoding = 'UTF-8'
|
||||
|
@ -19,6 +19,7 @@ import me.savvy.rixa.data.filemanager.LanguageManager;
|
||||
import me.savvy.rixa.events.BotEvent;
|
||||
import me.savvy.rixa.events.MemberEvent;
|
||||
import me.savvy.rixa.events.MessageEvent;
|
||||
import me.savvy.rixa.events.VoiceChannel;
|
||||
import me.savvy.rixa.modules.reactions.handlers.React;
|
||||
import me.savvy.rixa.modules.reactions.handlers.ReactionManager;
|
||||
import me.savvy.rixa.modules.reactions.react.ConfigReaction;
|
||||
@ -82,6 +83,7 @@ public class Rixa {
|
||||
.addEventListener(new MessageEvent())
|
||||
.addEventListener(new BotEvent())
|
||||
.addEventListener(new MemberEvent())
|
||||
.addEventListener(new VoiceChannel())
|
||||
.setGame(Game.of(config.getConfig().getString("botGame")))
|
||||
.setAutoReconnect(true)
|
||||
.setStatus(OnlineStatus.ONLINE)
|
||||
|
@ -4,7 +4,6 @@ import me.savvy.rixa.commands.handlers.Command;
|
||||
import me.savvy.rixa.commands.handlers.CommandExec;
|
||||
import me.savvy.rixa.commands.handlers.RixaPermission;
|
||||
import me.savvy.rixa.guild.RixaGuild;
|
||||
import me.savvy.rixa.guild.RixaManager;
|
||||
import me.savvy.rixa.utils.MessageBuilder;
|
||||
import net.dv8tion.jda.core.entities.ChannelType;
|
||||
import net.dv8tion.jda.core.entities.Member;
|
||||
@ -26,7 +25,7 @@ public class BatchMoveCommand implements CommandExec {
|
||||
description = "Move users within one role to another!",
|
||||
channelType = ChannelType.TEXT)
|
||||
public void execute(GuildMessageReceivedEvent event) {
|
||||
RixaGuild rixaGuild = RixaManager.getGuild(event.getGuild());
|
||||
RixaGuild rixaGuild = RixaGuild.getGuild(event.getGuild());
|
||||
if(!rixaGuild.hasPermission(event.getMember(), RixaPermission.BATCH_MOVE)) {
|
||||
new MessageBuilder(event.getMember().getAsMention() + ", you do not have permission for this command.").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
return;
|
||||
|
@ -5,7 +5,7 @@ import me.savvy.rixa.commands.handlers.CommandExec;
|
||||
import me.savvy.rixa.commands.handlers.CommandType;
|
||||
import me.savvy.rixa.commands.handlers.RixaPermission;
|
||||
import me.savvy.rixa.guild.RixaGuild;
|
||||
import me.savvy.rixa.guild.RixaManager;
|
||||
import me.savvy.rixa.guild.RixaGuild;
|
||||
import me.savvy.rixa.utils.MessageBuilder;
|
||||
import net.dv8tion.jda.core.entities.ChannelType;
|
||||
import net.dv8tion.jda.core.entities.Member;
|
||||
@ -56,7 +56,7 @@ public class ConfigCommand implements CommandExec {
|
||||
type = CommandType.ADMIN,
|
||||
channelType = ChannelType.TEXT)
|
||||
public void execute(GuildMessageReceivedEvent event) {
|
||||
RixaGuild rixaGuild = RixaManager.getGuild(event.getGuild());
|
||||
RixaGuild rixaGuild = RixaGuild.getGuild(event.getGuild());
|
||||
if (!rixaGuild.hasPermission(event.getMember(), RixaPermission.ACCESS_CONFIG)) {
|
||||
new MessageBuilder(event.getMember().getAsMention() + ", you do not have permission for this command.")
|
||||
.setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
@ -172,24 +172,24 @@ public class ConfigCommand implements CommandExec {
|
||||
}
|
||||
} else if (messages[1].equalsIgnoreCase("enable")) {
|
||||
if (messages[2].equalsIgnoreCase("music")) {
|
||||
RixaManager.getGuild(event.getGuild()).getMusicModule().setEnabled(true);
|
||||
RixaGuild.getGuild(event.getGuild()).getMusicModule().setEnabled(true);
|
||||
new MessageBuilder("Successfully enabled the music module!").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
} /*else if (messages[2].equalsIgnoreCase("levels")) {
|
||||
GuildManager.getGuild(event.getGuild().getId()).getLevels().setEnabled(true);
|
||||
event.getChannel().sendMessage("Successfully enabled the `Levels` module").queue();
|
||||
}*/ else if (messages[2].equalsIgnoreCase("joinverification")) {
|
||||
RixaManager.getGuild(event.getGuild()).getGuildSettings().setJoinVerification(true);
|
||||
RixaGuild.getGuild(event.getGuild()).getGuildSettings().setJoinVerification(true);
|
||||
new MessageBuilder("Successfully enabled Join Verification!").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
}
|
||||
} else if (messages[1].equalsIgnoreCase("disable")) {
|
||||
if (messages[2].equalsIgnoreCase("music")) {
|
||||
RixaManager.getGuild(event.getGuild()).getMusicModule().setEnabled(false);
|
||||
RixaGuild.getGuild(event.getGuild()).getMusicModule().setEnabled(false);
|
||||
new MessageBuilder("Successfully disabled the music module!").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
}/* else if (messages[2].equalsIgnoreCase("levels")) {
|
||||
GuildManager.getGuild(event.getGuild().getId()).getLevels().setEnabled(false);
|
||||
event.getChannel().sendMessage("Successfully disabled the `Levels` module").queue();
|
||||
}*/ else if (messages[2].equalsIgnoreCase("joinverification")) {
|
||||
RixaManager.getGuild(event.getGuild()).getGuildSettings().setJoinVerification(false);
|
||||
RixaGuild.getGuild(event.getGuild()).getGuildSettings().setJoinVerification(false);
|
||||
new MessageBuilder("Successfully disabled Join Verification!").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
}
|
||||
} else if (messages[1].equalsIgnoreCase("addperm") || messages[1].equalsIgnoreCase("addpermission") || messages[1].equalsIgnoreCase("aperm")) {
|
||||
|
@ -20,7 +20,6 @@ import me.savvy.rixa.commands.handlers.Command;
|
||||
import me.savvy.rixa.commands.handlers.CommandExec;
|
||||
import me.savvy.rixa.commands.handlers.CommandType;
|
||||
import me.savvy.rixa.guild.RixaGuild;
|
||||
import me.savvy.rixa.guild.RixaManager;
|
||||
import me.savvy.rixa.modules.music.MusicManager;
|
||||
import me.savvy.rixa.modules.music.TrackScheduler;
|
||||
import me.savvy.rixa.utils.MessageBuilder;
|
||||
@ -67,7 +66,7 @@ public class MusicCommand implements CommandExec {
|
||||
usage = "%pmusic", mainCommand = "music")
|
||||
public void execute(GuildMessageReceivedEvent event) {
|
||||
Guild guild = event.getGuild();
|
||||
RixaGuild rixaGuild = RixaManager.getGuild(guild);
|
||||
RixaGuild rixaGuild = RixaGuild.getGuild(guild);
|
||||
if(!rixaGuild.getMusicModule().isEnabled()) {
|
||||
new MessageBuilder("Sorry music is not enabled on `" + guild.getName() + "`!").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
return;
|
||||
@ -114,6 +113,10 @@ public class MusicCommand implements CommandExec {
|
||||
} else if (scheduler.queue.isEmpty()) {
|
||||
new MessageBuilder("The audio queue is empty! Add a track to the queue first!").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
}
|
||||
} else if (message[1].equalsIgnoreCase("leave")) {
|
||||
new MessageBuilder("Leaving voice channel.").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
guild.getAudioManager().setSendingHandler(null);
|
||||
guild.getAudioManager().closeAudioConnection();
|
||||
} else if(message[1].equalsIgnoreCase("skip")) {
|
||||
AudioTrack track = scheduler.nextTrack();
|
||||
if(track != null) {
|
||||
|
@ -3,7 +3,6 @@ package me.savvy.rixa.commands.general;
|
||||
import me.savvy.rixa.commands.handlers.Command;
|
||||
import me.savvy.rixa.commands.handlers.CommandExec;
|
||||
import me.savvy.rixa.guild.RixaGuild;
|
||||
import me.savvy.rixa.guild.RixaManager;
|
||||
import net.dv8tion.jda.core.EmbedBuilder;
|
||||
import net.dv8tion.jda.core.entities.ChannelType;
|
||||
import net.dv8tion.jda.core.entities.User;
|
||||
@ -21,7 +20,7 @@ public class ServerInfoCommand implements CommandExec {
|
||||
description = "Receive information about the server!",
|
||||
aliases = "sinfo", mainCommand = "serverinfo")
|
||||
public void execute(GuildMessageReceivedEvent event) {
|
||||
RixaGuild rixaGuild = RixaManager.getGuild(event.getGuild());
|
||||
RixaGuild rixaGuild = RixaGuild.getGuild(event.getGuild());
|
||||
EmbedBuilder messageEmbed = new EmbedBuilder();
|
||||
User owner = event.getGuild().getOwner().getUser();
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy HH:mm:ss");
|
||||
|
@ -25,7 +25,7 @@ public class CommandHandler {
|
||||
return true;
|
||||
} else {
|
||||
for (CommandRegistrar commandRegistrar : getCommands().values()) {
|
||||
for (String string : commandRegistrar.getCommandAnnotation().aliases()) {
|
||||
for (String string : commandRegistrar.getAnnotation().aliases()) {
|
||||
if (string.equalsIgnoreCase(s)) return true;
|
||||
}
|
||||
}
|
||||
@ -38,7 +38,7 @@ public class CommandHandler {
|
||||
return getCommands().get(s);
|
||||
} else {
|
||||
for (CommandRegistrar commandRegistrar : getCommands().values()) {
|
||||
for (String string : commandRegistrar.getCommandAnnotation().aliases()) {
|
||||
for (String string : commandRegistrar.getAnnotation().aliases()) {
|
||||
if (string.equalsIgnoreCase(s)) return commandRegistrar;
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import me.savvy.rixa.commands.handlers.CommandExec;
|
||||
import me.savvy.rixa.commands.handlers.CommandType;
|
||||
import me.savvy.rixa.commands.handlers.RixaPermission;
|
||||
import me.savvy.rixa.guild.RixaGuild;
|
||||
import me.savvy.rixa.guild.RixaManager;
|
||||
import me.savvy.rixa.utils.MessageBuilder;
|
||||
import me.savvy.rixa.utils.Utils;
|
||||
import net.dv8tion.jda.core.entities.ChannelType;
|
||||
@ -29,7 +28,7 @@ public class DeleteMessagesCommand implements CommandExec {
|
||||
type = CommandType.MOD,
|
||||
usage = "%pclear")
|
||||
public void execute(GuildMessageReceivedEvent event) {
|
||||
RixaGuild rixaGuild = RixaManager.getGuild(event.getGuild());
|
||||
RixaGuild rixaGuild = RixaGuild.getGuild(event.getGuild());
|
||||
if(!rixaGuild.hasPermission(event.getMember(), RixaPermission.CLEAR_CHAT)) {
|
||||
new MessageBuilder(event.getMember().getAsMention() + ", you do not have permission for this command.").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
return;
|
||||
|
@ -5,7 +5,6 @@ import me.savvy.rixa.commands.handlers.CommandExec;
|
||||
import me.savvy.rixa.commands.handlers.CommandType;
|
||||
import me.savvy.rixa.commands.handlers.RixaPermission;
|
||||
import me.savvy.rixa.guild.RixaGuild;
|
||||
import me.savvy.rixa.guild.RixaManager;
|
||||
import me.savvy.rixa.utils.MessageBuilder;
|
||||
import net.dv8tion.jda.core.entities.ChannelType;
|
||||
import net.dv8tion.jda.core.entities.Member;
|
||||
@ -26,7 +25,7 @@ public class MuteCommand implements CommandExec {
|
||||
type = CommandType.MOD,
|
||||
channelType = ChannelType.TEXT)
|
||||
public void execute(GuildMessageReceivedEvent event) {
|
||||
RixaGuild rixaGuild = RixaManager.getGuild(event.getGuild());
|
||||
RixaGuild rixaGuild = RixaGuild.getGuild(event.getGuild());
|
||||
if(!rixaGuild.hasPermission(event.getMember(), RixaPermission.MUTE)) {
|
||||
new MessageBuilder(event.getMember().getAsMention() + ", you do not have permission for this command.").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
return;
|
||||
|
@ -5,7 +5,6 @@ import me.savvy.rixa.commands.handlers.CommandExec;
|
||||
import me.savvy.rixa.commands.handlers.CommandType;
|
||||
import me.savvy.rixa.commands.handlers.RixaPermission;
|
||||
import me.savvy.rixa.guild.RixaGuild;
|
||||
import me.savvy.rixa.guild.RixaManager;
|
||||
import me.savvy.rixa.utils.MessageBuilder;
|
||||
import me.savvy.rixa.utils.Utils;
|
||||
import net.dv8tion.jda.core.entities.ChannelType;
|
||||
@ -32,7 +31,7 @@ public class PurgeMessagesCommand implements CommandExec {
|
||||
type = CommandType.MOD,
|
||||
usage = "%ppurge")
|
||||
public void execute(GuildMessageReceivedEvent event) {
|
||||
RixaGuild rixaGuild = RixaManager.getGuild(event.getGuild());
|
||||
RixaGuild rixaGuild = RixaGuild.getGuild(event.getGuild());
|
||||
if(!rixaGuild.hasPermission(event.getMember(), RixaPermission.CLEAR_CHAT)) {
|
||||
new MessageBuilder(event.getMember().getAsMention() + ", you do not have permission for this command.").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
return;
|
||||
|
@ -2,7 +2,6 @@ package me.savvy.rixa.events;
|
||||
|
||||
import me.savvy.rixa.Rixa;
|
||||
import me.savvy.rixa.guild.RixaGuild;
|
||||
import me.savvy.rixa.guild.RixaManager;
|
||||
import net.dv8tion.jda.core.events.ReadyEvent;
|
||||
import net.dv8tion.jda.core.events.guild.GuildJoinEvent;
|
||||
import net.dv8tion.jda.core.events.guild.GuildLeaveEvent;
|
||||
@ -30,6 +29,6 @@ public class BotEvent {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onQuit(GuildLeaveEvent event) {
|
||||
RixaManager.removeGuild(RixaManager.getGuild(event.getGuild()));
|
||||
RixaGuild.removeGuild(RixaGuild.getGuild(event.getGuild()));
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package me.savvy.rixa.events;
|
||||
|
||||
import me.savvy.rixa.guild.RixaGuild;
|
||||
import me.savvy.rixa.guild.RixaManager;
|
||||
import me.savvy.rixa.utils.MessageBuilder;
|
||||
import net.dv8tion.jda.core.entities.Guild;
|
||||
import net.dv8tion.jda.core.entities.Role;
|
||||
@ -22,7 +21,7 @@ public class MemberEvent {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onMember(GuildMemberJoinEvent event) {
|
||||
RixaGuild rixaGuild = RixaManager.getGuild(event.getGuild());
|
||||
RixaGuild rixaGuild = RixaGuild.getGuild(event.getGuild());
|
||||
if(rixaGuild.getGuildSettings().getJoinMessageChannel() != null) {
|
||||
try {
|
||||
new MessageBuilder(rixaGuild.getGuildSettings().getJoinMessage()
|
||||
|
@ -1,19 +1,15 @@
|
||||
package me.savvy.rixa.events;
|
||||
|
||||
import com.mysql.jdbc.StringUtils;
|
||||
import me.savvy.rixa.Rixa;
|
||||
import me.savvy.rixa.commands.handlers.CommandHandler;
|
||||
import me.savvy.rixa.commands.handlers.CommandRegistrar;
|
||||
import me.savvy.rixa.guild.RixaGuild;
|
||||
import me.savvy.rixa.guild.RixaManager;
|
||||
import me.savvy.rixa.modules.reactions.handlers.ReactRegistrar;
|
||||
import me.savvy.rixa.modules.reactions.handlers.ReactionManager;
|
||||
import me.savvy.rixa.utils.MessageBuilder;
|
||||
import net.dv8tion.jda.core.Permission;
|
||||
import net.dv8tion.jda.core.entities.Message;
|
||||
import net.dv8tion.jda.core.entities.MessageEmbed;
|
||||
import net.dv8tion.jda.core.events.guild.member.GuildMemberJoinEvent;
|
||||
import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
|
||||
import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
|
||||
import net.dv8tion.jda.core.events.message.priv.PrivateMessageReceivedEvent;
|
||||
import net.dv8tion.jda.core.events.message.react.MessageReactionAddEvent;
|
||||
@ -32,7 +28,7 @@ public class MessageEvent {
|
||||
@SubscribeEvent
|
||||
public void handle(GuildMessageReceivedEvent event) {
|
||||
if (event.getGuild() == null) return;
|
||||
RixaGuild rixaGuild = RixaManager.getGuild(event.getGuild());
|
||||
RixaGuild rixaGuild = RixaGuild.getGuild(event.getGuild());
|
||||
String prefix = rixaGuild
|
||||
.getGuildSettings()
|
||||
.getPrefix();
|
||||
@ -54,7 +50,7 @@ public class MessageEvent {
|
||||
public void onMemberJoin(PrivateMessageReceivedEvent event) {
|
||||
RixaGuild rixaGuild;
|
||||
if (MemberEvent.joinMembers.containsKey(event.getAuthor().getId())) {
|
||||
rixaGuild = RixaManager.getGuild(MemberEvent.joinMembers.get(event.getAuthor().getId()));
|
||||
rixaGuild = RixaGuild.getGuild(MemberEvent.joinMembers.get(event.getAuthor().getId()));
|
||||
if (event.getMessage().getContent().equalsIgnoreCase("I agree") ||
|
||||
event.getMessage().getContent().equalsIgnoreCase("I accept")
|
||||
|| event.getMessage().getContent().equalsIgnoreCase("Yes")) {
|
||||
|
23
src/main/java/me/savvy/rixa/events/VoiceChannel.java
Normal file
23
src/main/java/me/savvy/rixa/events/VoiceChannel.java
Normal file
@ -0,0 +1,23 @@
|
||||
package me.savvy.rixa.events;
|
||||
|
||||
import net.dv8tion.jda.core.entities.Member;
|
||||
import net.dv8tion.jda.core.events.guild.voice.GuildVoiceLeaveEvent;
|
||||
import net.dv8tion.jda.core.hooks.SubscribeEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by savit on 7/14/2017.
|
||||
*/
|
||||
public class VoiceChannel {
|
||||
|
||||
@SubscribeEvent
|
||||
public void handle(GuildVoiceLeaveEvent event) {
|
||||
List<Member> members = event.getChannelLeft().getMembers();
|
||||
if (members.size() == 1 && members.get(0).getUser().getId().equalsIgnoreCase
|
||||
(event.getJDA().getSelfUser().getId())) {
|
||||
event.getGuild().getAudioManager().setSendingHandler(null);
|
||||
event.getGuild().getAudioManager().closeAudioConnection();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package me.savvy.rixa.guild;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.savvy.rixa.Rixa;
|
||||
@ -15,24 +16,21 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by Timber on 5/23/2017.
|
||||
*/
|
||||
public class RixaGuild {
|
||||
|
||||
@Getter
|
||||
private Guild guild;
|
||||
@Getter private Guild guild;
|
||||
private DatabaseManager db;
|
||||
@Setter
|
||||
private GuildSettings guildSettings;
|
||||
@Getter @Setter
|
||||
private MusicModule musicModule;
|
||||
@Getter @Setter
|
||||
private TwitterModule twitterModule;
|
||||
@Getter
|
||||
private List<String> mutedMembers = new ArrayList<>();
|
||||
@Setter private GuildSettings guildSettings;
|
||||
@Getter @Setter private MusicModule musicModule;
|
||||
@Getter @Setter private TwitterModule twitterModule;
|
||||
@Getter private List<String> mutedMembers = new ArrayList<>();
|
||||
|
||||
public RixaGuild(Guild guild) {
|
||||
this.guild = guild;
|
||||
@ -50,7 +48,7 @@ public class RixaGuild {
|
||||
.replace("%icon%", guild.getIconId()));
|
||||
}
|
||||
setGuildSettings(new GuildSettings(this.guild));
|
||||
RixaManager.addGuild(this);
|
||||
addGuild(this);
|
||||
}
|
||||
|
||||
public GuildSettings getGuildSettings() {
|
||||
@ -135,5 +133,29 @@ public class RixaGuild {
|
||||
if(!isUserMuted(user))
|
||||
mutedMembers.add(user.getId());
|
||||
}
|
||||
|
||||
@Getter
|
||||
private static Map<String, RixaGuild> guilds = new HashMap<>();
|
||||
|
||||
public static void addGuild(RixaGuild guild) {
|
||||
if(check(guild.getGuild())) return;
|
||||
guilds.put(guild.getGuild().getId(), guild);
|
||||
}
|
||||
|
||||
public static RixaGuild getGuild(Guild guild) {
|
||||
if(!check(guild)) {
|
||||
addGuild(new RixaGuild(guild));
|
||||
}
|
||||
return guilds.get(guild.getId());
|
||||
}
|
||||
|
||||
public static void removeGuild(RixaGuild guild) {
|
||||
if(!check(guild.getGuild())) return;
|
||||
guilds.remove(guild.getGuild().getId());
|
||||
}
|
||||
|
||||
private static boolean check(Guild guild) {
|
||||
return guilds.containsKey(guild.getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,39 +0,0 @@
|
||||
package me.savvy.rixa.guild;
|
||||
|
||||
import net.dv8tion.jda.core.entities.Guild;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by Timber on 5/23/2017.
|
||||
*/
|
||||
public class RixaManager {
|
||||
|
||||
private static Map<String, RixaGuild> guilds = new HashMap<>();
|
||||
|
||||
public static Map<String, RixaGuild> getGuilds() {
|
||||
return guilds;
|
||||
}
|
||||
|
||||
public static void addGuild(RixaGuild guild) {
|
||||
if(check(guild.getGuild())) return;
|
||||
guilds.put(guild.getGuild().getId(), guild);
|
||||
}
|
||||
|
||||
public static RixaGuild getGuild(Guild guild) {
|
||||
if(!check(guild)) {
|
||||
addGuild(new RixaGuild(guild));
|
||||
}
|
||||
return guilds.get(guild.getId());
|
||||
}
|
||||
|
||||
public static void removeGuild(RixaGuild guild) {
|
||||
if(!check(guild.getGuild())) return;
|
||||
guilds.remove(guild.getGuild().getId());
|
||||
}
|
||||
|
||||
private static boolean check(Guild guild) {
|
||||
return guilds.containsKey(guild.getId());
|
||||
}
|
||||
}
|
@ -1,19 +1,14 @@
|
||||
package me.savvy.rixa.modules.reactions.react;
|
||||
|
||||
import me.savvy.rixa.commands.admin.ConfigCommand;
|
||||
import me.savvy.rixa.commands.handlers.CommandHandler;
|
||||
import me.savvy.rixa.commands.handlers.CommandType;
|
||||
import me.savvy.rixa.guild.RixaGuild;
|
||||
import me.savvy.rixa.guild.RixaManager;
|
||||
import me.savvy.rixa.modules.reactions.handlers.React;
|
||||
import me.savvy.rixa.modules.reactions.handlers.ReactHandle;
|
||||
import me.savvy.rixa.utils.MessageBuilder;
|
||||
import net.dv8tion.jda.core.EmbedBuilder;
|
||||
import net.dv8tion.jda.core.entities.ChannelType;
|
||||
import net.dv8tion.jda.core.entities.Guild;
|
||||
import net.dv8tion.jda.core.entities.Message;
|
||||
import net.dv8tion.jda.core.events.message.react.MessageReactionAddEvent;
|
||||
import net.dv8tion.jda.core.exceptions.ErrorResponseException;
|
||||
|
||||
/**
|
||||
* Created by Timber on 6/9/2017.
|
||||
@ -35,7 +30,7 @@ public class ConfigReaction implements React {
|
||||
if(guild == null) {
|
||||
return;
|
||||
}
|
||||
RixaGuild rixaGuild = RixaManager.getGuild(guild);
|
||||
RixaGuild rixaGuild = RixaGuild.getGuild(guild);
|
||||
String prefix = rixaGuild.getGuildSettings().getPrefix();
|
||||
MessageBuilder builder = null;
|
||||
int page = 500;
|
||||
|
@ -3,7 +3,7 @@ package me.savvy.rixa.modules.reactions.react;
|
||||
import me.savvy.rixa.commands.handlers.CommandHandler;
|
||||
import me.savvy.rixa.commands.handlers.CommandType;
|
||||
import me.savvy.rixa.guild.RixaGuild;
|
||||
import me.savvy.rixa.guild.RixaManager;
|
||||
import me.savvy.rixa.guild.RixaGuild;
|
||||
import me.savvy.rixa.modules.reactions.handlers.React;
|
||||
import me.savvy.rixa.modules.reactions.handlers.ReactHandle;
|
||||
import net.dv8tion.jda.core.EmbedBuilder;
|
||||
@ -26,7 +26,7 @@ public class HelpReaction implements React {
|
||||
}
|
||||
Message message = event.getChannel().getMessageById(event.getMessageId()).complete();
|
||||
String title = message.getEmbeds().get(0).getTitle().split(": ")[1];
|
||||
RixaGuild rixaGuild = RixaManager.getGuild(event.getJDA().getGuildById(title));
|
||||
RixaGuild rixaGuild = RixaGuild.getGuild(event.getJDA().getGuildById(title));
|
||||
String prefix = rixaGuild.getGuildSettings().getPrefix();
|
||||
EmbedBuilder embedBuilder;
|
||||
try {
|
||||
@ -44,9 +44,9 @@ public class HelpReaction implements React {
|
||||
"Click a number below for information about other commands.";
|
||||
embedBuilder.setTitle(String.format("Help: %s", title));
|
||||
embedBuilder.setDescription(stringBuilder);
|
||||
CommandHandler.getCommands().values().stream().filter(cmd -> cmd.getCommandAnnotation().type() == CommandType.USER)
|
||||
.forEach(cmd -> embedBuilder.addField(prefix + cmd.getCommandAnnotation().mainCommand(),
|
||||
cmd.getCommandAnnotation().description(), false));
|
||||
CommandHandler.getCommands().values().stream().filter(cmd -> cmd.getAnnotation().type() == CommandType.USER)
|
||||
.forEach(cmd -> embedBuilder.addField(prefix + cmd.getAnnotation().mainCommand(),
|
||||
cmd.getAnnotation().description(), false));
|
||||
message.editMessage(embedBuilder.build()).queue();
|
||||
break;
|
||||
case "\u0032\u20E3": // two emoji
|
||||
@ -57,9 +57,9 @@ public class HelpReaction implements React {
|
||||
"Click a number below for information about other commands.";
|
||||
embedBuilder.setTitle(String.format("Help: %s", title));
|
||||
embedBuilder.setDescription(stringBuilder);
|
||||
CommandHandler.getCommands().values().stream().filter(cmd -> cmd.getCommandAnnotation().type() == CommandType.ADMIN
|
||||
|| cmd.getCommandAnnotation().type() == CommandType.MOD)
|
||||
.forEach(cmd -> embedBuilder.addField(prefix + cmd.getCommandAnnotation().mainCommand(), cmd.getCommandAnnotation().description(), false));
|
||||
CommandHandler.getCommands().values().stream().filter(cmd -> cmd.getAnnotation().type() == CommandType.ADMIN
|
||||
|| cmd.getAnnotation().type() == CommandType.MOD)
|
||||
.forEach(cmd -> embedBuilder.addField(prefix + cmd.getAnnotation().mainCommand(), cmd.getAnnotation().description(), false));
|
||||
message.editMessage(embedBuilder.build()).queue();
|
||||
break;
|
||||
case "\u0033\u20E3": // three emoji
|
||||
|
@ -37,10 +37,10 @@ public class TwitterModule {
|
||||
this.accessToken = accessToken;
|
||||
this.accessTokenSecret = accessTokenSecret;
|
||||
configurationBuilder = new ConfigurationBuilder()
|
||||
.setOAuthConsumerKey(getConsumerKey())
|
||||
.setOAuthConsumerSecret(getConsumerSecret())
|
||||
.setOAuthAccessToken(getAccessToken())
|
||||
.setOAuthAccessTokenSecret(getAccessTokenSecret());
|
||||
.setOAuthConsumerKey(consumerKey)
|
||||
.setOAuthConsumerSecret(consumerSecret)
|
||||
.setOAuthAccessToken(accessToken)
|
||||
.setOAuthAccessTokenSecret(accessTokenSecret);
|
||||
twitterFactory = new TwitterFactory(configurationBuilder.build());
|
||||
twitterStream = new TwitterStreamFactory().getInstance();
|
||||
twitter = twitterFactory.getInstance();
|
||||
|
Loading…
Reference in New Issue
Block a user