+Started music integration
Voice channel join/disconnect
This commit is contained in:
+6
-1
@@ -1,7 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="lib/commons-codec-1.11.jar"/>
|
||||
<classpathentry kind="lib" path="lib/commons-logging-1.2.jar"/>
|
||||
<classpathentry kind="lib" path="lib/gson-2.6.2.jar"/>
|
||||
@@ -20,5 +24,6 @@
|
||||
<classpathentry kind="lib" path="lib/commons-collections4-4.3.jar"/>
|
||||
<classpathentry kind="lib" path="lib/commons-lang3-3.9.jar"/>
|
||||
<classpathentry kind="lib" path="lib/commons-text-1.6.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Rin/Documents/Java/KittyBot/lib/google-api-services-youtube-v3-rev212-1.25.0.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
"Localized Commands","leaderboard",""
|
||||
"Localized Commands","map",""
|
||||
"Localized Commands","mod",""
|
||||
"Localized Commands","music",""
|
||||
"Localized Commands","perish, thenperish",""
|
||||
"Localized Commands","ping",""
|
||||
"Localized Commands","poll",""
|
||||
@@ -191,6 +192,7 @@
|
||||
"Localized Strings","MapSeed","Seed"
|
||||
"Localized Strings","MapVersion","Using mapgen v0.1"
|
||||
"Localized Strings","MapWidth",""
|
||||
"Localized Strings","MusicInfo",""
|
||||
"Localized Strings","PerishInfo","Adds a red, 'a n g e r y' overlay to your icon or the icon of a friend you mentioned"
|
||||
"Localized Strings","PingInfo","Will respond with Pong!"
|
||||
"Localized Strings","PingResponse","Pong!"
|
||||
@@ -296,6 +298,7 @@
|
||||
"Command Enabler","leaderboard","1"
|
||||
"Command Enabler","map","1"
|
||||
"Command Enabler","mod","1"
|
||||
"Command Enabler","music","1"
|
||||
"Command Enabler","perish, thenperish","1"
|
||||
"Command Enabler","ping","1"
|
||||
"Command Enabler","poll","1"
|
||||
|
||||
|
Binary file not shown.
@@ -11,7 +11,7 @@ import dataStructures.UserInput;
|
||||
|
||||
public class SubCommandBan extends SubCommand
|
||||
{
|
||||
public SubCommandBan(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
public SubCommandBan(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package commands.music;
|
||||
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
import core.SubCommandFramework;
|
||||
import dataStructures.*;
|
||||
|
||||
public class CommandMusicMain extends Command
|
||||
{
|
||||
SubCommandFramework framework = new SubCommandFramework();
|
||||
public CommandMusicMain(KittyRole level, KittyRating rating)
|
||||
{
|
||||
super(level, rating);
|
||||
framework.addCommand("join", new SubCommandJoin(KittyRole.General, KittyRating.Safe));
|
||||
framework.addCommand("leave", new SubCommandLeave(KittyRole.General, KittyRating.Safe));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("MusicInfo"); }
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
framework.run(guild, channel, user, input).Call(res);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package commands.music;
|
||||
|
||||
import core.SubCommand;
|
||||
import core.SubCommandFormattable;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class SubCommandJoin extends SubCommand
|
||||
{
|
||||
public SubCommandJoin(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||
{
|
||||
return new SubCommandFormattable("" + guild.audio.joinChannel(input.args));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package commands.music;
|
||||
|
||||
import core.SubCommand;
|
||||
import core.SubCommandFormattable;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class SubCommandLeave extends SubCommand
|
||||
{
|
||||
public SubCommandLeave(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
|
||||
{
|
||||
return new SubCommandFormattable("" + guild.audio.leaveChannel());
|
||||
}
|
||||
}
|
||||
@@ -48,6 +48,7 @@ import commands.general.CommandWolfram;
|
||||
import commands.general.CommandYeet;
|
||||
import commands.guildrole.CommandGuildRoleMain;
|
||||
import commands.mod.CommandModMain;
|
||||
import commands.music.CommandMusicMain;
|
||||
import commands.poll.CommandPollMain;
|
||||
import commands.raffle.CommandRaffleMain;
|
||||
import dataStructures.KittyChannel;
|
||||
@@ -152,7 +153,7 @@ public class CommandManager
|
||||
this.register(LocCommands.stub("character"), new CommandCharacterMain(KittyRole.General, KittyRating.Safe));
|
||||
this.register(LocCommands.stub("raffle"), new CommandRaffleMain(KittyRole.General, KittyRating.Safe));
|
||||
this.register(LocCommands.stub("poll"), new CommandPollMain(KittyRole.General, KittyRating.Safe));
|
||||
|
||||
this.register(LocCommands.stub("music"), new CommandMusicMain(KittyRole.General, KittyRating.Safe));
|
||||
}
|
||||
|
||||
// Allows the command manager to keep track of a command. Takes a pair (the un-localized and localzied commands)
|
||||
|
||||
@@ -17,6 +17,7 @@ import net.dv8tion.jda.core.entities.*;
|
||||
import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
|
||||
import offline.Ref;
|
||||
import utils.AdminControl;
|
||||
import utils.AudioUtils;
|
||||
import utils.GlobalLog;
|
||||
import utils.LogFilter;
|
||||
|
||||
@@ -140,7 +141,7 @@ public class ObjectBuilderFactory
|
||||
else
|
||||
{
|
||||
// Construct a new guild with defaults
|
||||
guild = new KittyGuild(uid, new AdminControl(event.getGuild()), emotesString);
|
||||
guild = new KittyGuild(uid, new AdminControl(event.getGuild()), emotesString, new AudioUtils(event.getGuild()));
|
||||
DatabaseManager.instance.globalRegister(guild);
|
||||
guildCache.put(uid, guild);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.ArrayList;
|
||||
import core.DatabaseManager;
|
||||
import core.DatabaseTrackedObject;
|
||||
import utils.AdminControl;
|
||||
import utils.AudioUtils;
|
||||
|
||||
// Context for a given guild for kittybot. Primarily designed to hold guild-specific settings.
|
||||
public class KittyGuild extends DatabaseTrackedObject
|
||||
@@ -21,6 +22,7 @@ public class KittyGuild extends DatabaseTrackedObject
|
||||
public ArrayList<String> emoji = new ArrayList<String>();
|
||||
public ArrayList <KittyPoll> choices = new ArrayList<KittyPoll>();
|
||||
public AdminControl control;
|
||||
public AudioUtils audio;
|
||||
public ArrayList <KittyUser> raffleUsersUnchosen = new ArrayList<KittyUser>();
|
||||
public ArrayList <KittyUser> raffleUsersChosen = new ArrayList<KittyUser>();
|
||||
|
||||
@@ -40,7 +42,7 @@ public class KittyGuild extends DatabaseTrackedObject
|
||||
}
|
||||
|
||||
// Default content for a guild
|
||||
public KittyGuild(String uniqueID, AdminControl adminControl, ArrayList <String> emoji)
|
||||
public KittyGuild(String uniqueID, AdminControl adminControl, ArrayList <String> emoji, AudioUtils audio)
|
||||
{
|
||||
super(uniqueID);
|
||||
this.uniqueID = uniqueID;
|
||||
@@ -52,6 +54,7 @@ public class KittyGuild extends DatabaseTrackedObject
|
||||
this.contentRating = KittyRating.Safe;
|
||||
this.polling = false;
|
||||
this.emoji = emoji;
|
||||
this.audio = audio;
|
||||
setCommandIndicator("!");
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package utils;
|
||||
|
||||
import net.dv8tion.jda.core.entities.Guild;
|
||||
import net.dv8tion.jda.core.entities.VoiceChannel;
|
||||
import net.dv8tion.jda.core.managers.AudioManager;
|
||||
|
||||
public class AudioUtils
|
||||
{
|
||||
private Guild guild;
|
||||
AudioManager audio;
|
||||
public AudioUtils(Guild guild)
|
||||
{
|
||||
this.guild = guild;
|
||||
audio = guild.getAudioManager();
|
||||
}
|
||||
|
||||
public boolean joinChannel(String channelName)
|
||||
{
|
||||
VoiceChannel channel = null;
|
||||
channel = guild.getVoiceChannelsByName(channelName, true).get(0);
|
||||
if(channel != null)
|
||||
{
|
||||
audio.openAudioConnection(channel);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean leaveChannel()
|
||||
{
|
||||
if(audio.isConnected())
|
||||
{
|
||||
audio.closeAudioConnection();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user