Compare commits
3 Commits
000e0e5d5c
...
f043ab906d
Author | SHA1 | Date |
---|---|---|
|
f043ab906d | |
|
6f23b60511 | |
|
1b7d4adeb9 |
|
@ -8,10 +8,8 @@ package moe.nekojimi.chords;
|
||||||
import com.amihaiemil.eoyaml.Yaml;
|
import com.amihaiemil.eoyaml.Yaml;
|
||||||
import com.amihaiemil.eoyaml.YamlMapping;
|
import com.amihaiemil.eoyaml.YamlMapping;
|
||||||
import com.beust.jcommander.JCommander;
|
import com.beust.jcommander.JCommander;
|
||||||
import com.beust.jcommander.Parameter;
|
|
||||||
import com.neovisionaries.ws.client.WebSocketFactory;
|
import com.neovisionaries.ws.client.WebSocketFactory;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FilenameFilter;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.*;
|
import java.net.*;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
|
@ -22,8 +20,6 @@ import java.util.function.BiConsumer;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import javax.net.SocketFactory;
|
|
||||||
import javax.net.ssl.SSLSocketFactory;
|
|
||||||
import javax.security.auth.login.LoginException;
|
import javax.security.auth.login.LoginException;
|
||||||
import moe.nekojimi.chords.commands.*;
|
import moe.nekojimi.chords.commands.*;
|
||||||
import moe.nekojimi.musicsearcher.providers.MetaSearcher;
|
import moe.nekojimi.musicsearcher.providers.MetaSearcher;
|
||||||
|
@ -40,10 +36,11 @@ import net.dv8tion.jda.api.utils.Compression;
|
||||||
import net.dv8tion.jda.api.utils.cache.CacheFlag;
|
import net.dv8tion.jda.api.utils.cache.CacheFlag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* The Chords music Discord bot.
|
||||||
*
|
*
|
||||||
* @author jimj316
|
* @author Nekojimi
|
||||||
*/
|
*/
|
||||||
public final class Main extends ListenerAdapter
|
public final class Chords extends ListenerAdapter
|
||||||
{
|
{
|
||||||
|
|
||||||
private static final CommandOptions options = new CommandOptions();
|
private static final CommandOptions options = new CommandOptions();
|
||||||
|
@ -99,7 +96,7 @@ public final class Main extends ListenerAdapter
|
||||||
// Set activity (like "playing Something")
|
// Set activity (like "playing Something")
|
||||||
builder.setActivity(Activity.playing("music!"));
|
builder.setActivity(Activity.playing("music!"));
|
||||||
|
|
||||||
final Main listener = new Main();
|
final Chords listener = new Chords();
|
||||||
|
|
||||||
builder.addEventListeners(listener);
|
builder.addEventListeners(listener);
|
||||||
builder.setAutoReconnect(true);
|
builder.setAutoReconnect(true);
|
||||||
|
@ -120,7 +117,7 @@ public final class Main extends ListenerAdapter
|
||||||
|
|
||||||
private final BiConsumer<SongRequest, Exception> downloaderMessageHandler = new DownloaderMessageHandler();
|
private final BiConsumer<SongRequest, Exception> downloaderMessageHandler = new DownloaderMessageHandler();
|
||||||
|
|
||||||
public Main() throws IOException
|
public Chords() throws IOException
|
||||||
{
|
{
|
||||||
log("INFO", "Starting up...");
|
log("INFO", "Starting up...");
|
||||||
|
|
||||||
|
@ -362,7 +359,7 @@ public final class Main extends ListenerAdapter
|
||||||
playlists.put(playlist.getName(), playlist);
|
playlists.put(playlist.getName(), playlist);
|
||||||
} catch (IOException ex)
|
} catch (IOException ex)
|
||||||
{
|
{
|
||||||
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(Chords.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -112,7 +112,7 @@ public class MusicHandler implements AudioSendHandler, Closeable
|
||||||
return true;
|
return true;
|
||||||
} catch (UnsupportedAudioFileException | IOException ex)
|
} catch (UnsupportedAudioFileException | IOException ex)
|
||||||
{
|
{
|
||||||
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(Chords.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
} finally
|
} finally
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -215,7 +215,7 @@ public class MusicHandler implements AudioSendHandler, Closeable
|
||||||
// audioBuffer.add(bytes, 0, read);
|
// audioBuffer.add(bytes, 0, read);
|
||||||
// } catch (IOException ex)
|
// } catch (IOException ex)
|
||||||
// {
|
// {
|
||||||
// Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
|
// Logger.getLogger(Chords.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
// return false;
|
// return false;
|
||||||
// } catch (ArrayIndexOutOfBoundsException ex)
|
// } catch (ArrayIndexOutOfBoundsException ex)
|
||||||
// {
|
// {
|
||||||
|
@ -223,7 +223,7 @@ public class MusicHandler implements AudioSendHandler, Closeable
|
||||||
// arrayErr = true;
|
// arrayErr = true;
|
||||||
// else
|
// else
|
||||||
// {
|
// {
|
||||||
// Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
|
// Logger.getLogger(Chords.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
// return false;
|
// return false;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
|
@ -42,8 +42,11 @@ public class QueueManager implements Consumer<Song>
|
||||||
{
|
{
|
||||||
jukeboxQueue.add(t);
|
jukeboxQueue.add(t);
|
||||||
|
|
||||||
if (!handler.isPlaying())
|
if (!handler.isPlaying() || handler.getCurrentSong() == null)
|
||||||
handler.playNext();
|
handler.playNext();
|
||||||
|
|
||||||
|
if (handler.isPlaying() != (handler.getCurrentSong() == null))
|
||||||
|
System.err.println("WARNING: handler isPlaying violates contract! Something dumb going on!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
package moe.nekojimi.chords.commands;
|
package moe.nekojimi.chords.commands;
|
||||||
|
|
||||||
import moe.nekojimi.chords.Main;
|
import moe.nekojimi.chords.Chords;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -14,11 +14,11 @@ import moe.nekojimi.chords.Main;
|
||||||
public abstract class Command
|
public abstract class Command
|
||||||
{
|
{
|
||||||
|
|
||||||
protected final Main bot;
|
protected final Chords bot;
|
||||||
protected final String keyword;
|
protected final String keyword;
|
||||||
protected String documentation;
|
protected String documentation;
|
||||||
|
|
||||||
public Command(Main bot, String keyword)
|
public Command(Chords bot, String keyword)
|
||||||
{
|
{
|
||||||
this.bot = bot;
|
this.bot = bot;
|
||||||
this.keyword = keyword;
|
this.keyword = keyword;
|
||||||
|
|
|
@ -16,12 +16,12 @@
|
||||||
*/
|
*/
|
||||||
package moe.nekojimi.chords.commands;
|
package moe.nekojimi.chords.commands;
|
||||||
|
|
||||||
import moe.nekojimi.chords.Main;
|
import moe.nekojimi.chords.Chords;
|
||||||
|
|
||||||
public class HelpCommand extends Command
|
public class HelpCommand extends Command
|
||||||
{
|
{
|
||||||
|
|
||||||
public HelpCommand(Main bot)
|
public HelpCommand(Chords bot)
|
||||||
{
|
{
|
||||||
super(bot, "help");
|
super(bot, "help");
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,14 +6,14 @@
|
||||||
package moe.nekojimi.chords.commands;
|
package moe.nekojimi.chords.commands;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import moe.nekojimi.chords.Main;
|
import moe.nekojimi.chords.Chords;
|
||||||
import net.dv8tion.jda.api.entities.*;
|
import net.dv8tion.jda.api.entities.*;
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||||
|
|
||||||
public class JoinCommand extends Command
|
public class JoinCommand extends Command
|
||||||
{
|
{
|
||||||
|
|
||||||
public JoinCommand(Main bot)
|
public JoinCommand(Chords bot)
|
||||||
{
|
{
|
||||||
super(bot, "join");
|
super(bot, "join");
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,13 +6,13 @@
|
||||||
package moe.nekojimi.chords.commands;
|
package moe.nekojimi.chords.commands;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import moe.nekojimi.chords.Main;
|
import moe.nekojimi.chords.Chords;
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||||
|
|
||||||
public class LeaveCommand extends Command
|
public class LeaveCommand extends Command
|
||||||
{
|
{
|
||||||
|
|
||||||
public LeaveCommand(Main bot)
|
public LeaveCommand(Chords bot)
|
||||||
{
|
{
|
||||||
super(bot, "leave");
|
super(bot, "leave");
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ import java.net.URL;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import moe.nekojimi.chords.Main;
|
import moe.nekojimi.chords.Chords;
|
||||||
import moe.nekojimi.chords.SongRequest;
|
import moe.nekojimi.chords.SongRequest;
|
||||||
import moe.nekojimi.musicsearcher.Query;
|
import moe.nekojimi.musicsearcher.Query;
|
||||||
import moe.nekojimi.musicsearcher.Result;
|
import moe.nekojimi.musicsearcher.Result;
|
||||||
|
@ -37,7 +37,7 @@ public class PlayCommand extends Command
|
||||||
|
|
||||||
// private List<Result> lastSearchResults;
|
// private List<Result> lastSearchResults;
|
||||||
|
|
||||||
public PlayCommand(Main main)
|
public PlayCommand(Chords main)
|
||||||
{
|
{
|
||||||
super(main, "play");
|
super(main, "play");
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,13 +19,13 @@ package moe.nekojimi.chords.commands;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import moe.nekojimi.chords.Downloader;
|
import moe.nekojimi.chords.Downloader;
|
||||||
import moe.nekojimi.chords.Main;
|
import moe.nekojimi.chords.Chords;
|
||||||
import moe.nekojimi.chords.Song;
|
import moe.nekojimi.chords.Song;
|
||||||
|
|
||||||
public class QueueCommand extends Command
|
public class QueueCommand extends Command
|
||||||
{
|
{
|
||||||
|
|
||||||
public QueueCommand(Main bot)
|
public QueueCommand(Chords bot)
|
||||||
{
|
{
|
||||||
super(bot, "queue");
|
super(bot, "queue");
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,12 +16,12 @@
|
||||||
*/
|
*/
|
||||||
package moe.nekojimi.chords.commands;
|
package moe.nekojimi.chords.commands;
|
||||||
|
|
||||||
import moe.nekojimi.chords.Main;
|
import moe.nekojimi.chords.Chords;
|
||||||
|
|
||||||
public class RemoveCommand extends Command
|
public class RemoveCommand extends Command
|
||||||
{
|
{
|
||||||
|
|
||||||
public RemoveCommand(Main bot)
|
public RemoveCommand(Chords bot)
|
||||||
{
|
{
|
||||||
super(bot, "remove");
|
super(bot, "remove");
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,12 +16,12 @@
|
||||||
*/
|
*/
|
||||||
package moe.nekojimi.chords.commands;
|
package moe.nekojimi.chords.commands;
|
||||||
|
|
||||||
import moe.nekojimi.chords.Main;
|
import moe.nekojimi.chords.Chords;
|
||||||
|
|
||||||
public class RestartCommand extends Command
|
public class RestartCommand extends Command
|
||||||
{
|
{
|
||||||
|
|
||||||
public RestartCommand(Main bot)
|
public RestartCommand(Chords bot)
|
||||||
{
|
{
|
||||||
super(bot, "restart");
|
super(bot, "restart");
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,12 +16,12 @@
|
||||||
*/
|
*/
|
||||||
package moe.nekojimi.chords.commands;
|
package moe.nekojimi.chords.commands;
|
||||||
|
|
||||||
import moe.nekojimi.chords.Main;
|
import moe.nekojimi.chords.Chords;
|
||||||
|
|
||||||
public class SkipCommand extends Command
|
public class SkipCommand extends Command
|
||||||
{
|
{
|
||||||
|
|
||||||
public SkipCommand(Main bot)
|
public SkipCommand(Chords bot)
|
||||||
{
|
{
|
||||||
super(bot, "skip");
|
super(bot, "skip");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue