Compare commits

...

11 Commits

  1. 32
      src/main/java/moe/nekojimi/chords/Chords.java
  2. 27
      src/main/java/moe/nekojimi/chords/Downloader.java
  3. 44
      src/main/java/moe/nekojimi/chords/MusicHandler.java
  4. 8
      src/main/java/moe/nekojimi/chords/Playlist.java
  5. 12
      src/main/java/moe/nekojimi/chords/QueueThing.java
  6. 92
      src/main/java/moe/nekojimi/chords/Soundboard.java
  7. 58
      src/main/java/moe/nekojimi/chords/Track.java
  8. 18
      src/main/java/moe/nekojimi/chords/TrackPlayer.java
  9. 11
      src/main/java/moe/nekojimi/chords/TrackRequest.java
  10. 28
      src/main/java/moe/nekojimi/chords/Util.java
  11. 98
      src/main/java/moe/nekojimi/chords/commands/SoundboardCommand.java

@ -52,11 +52,13 @@ public final class Chords extends ListenerAdapter
private final File dataDirectory; private final File dataDirectory;
private final File playlistsDirectory; private final File playlistsDirectory;
private final File soundboardFile;
private MusicHandler musicHandler; private MusicHandler musicHandler;
private final Downloader downloader; private final Downloader downloader;
private final Searcher searcher; private final Searcher searcher;
private final QueueManager queueManager; private final QueueManager queueManager;
private final Soundboard soundboard;
// private Recommender recommender; // private Recommender recommender;
private JDA jda; private JDA jda;
@ -141,6 +143,7 @@ public final class Chords extends ListenerAdapter
// init dirs // init dirs
dataDirectory = new File(System.getProperty("user.dir")); dataDirectory = new File(System.getProperty("user.dir"));
playlistsDirectory = initDirectory(dataDirectory, "playlists"); playlistsDirectory = initDirectory(dataDirectory, "playlists");
soundboardFile = new File("soundboard.yml");
// init downloader // init downloader
downloader = new Downloader(); downloader = new Downloader();
@ -153,6 +156,10 @@ public final class Chords extends ListenerAdapter
queueManager = new QueueManager(); queueManager = new QueueManager();
queueManager.addSource(downloader); queueManager.addSource(downloader);
// init soundboard
soundboard = new Soundboard(this);
soundboard.loadYAML(soundboardFile);
// init commands // init commands
addCommand(new JoinCommand(this)); addCommand(new JoinCommand(this));
addCommand(new LeaveCommand(this)); addCommand(new LeaveCommand(this));
@ -162,6 +169,7 @@ public final class Chords extends ListenerAdapter
addCommand(new RemoveCommand(this)); addCommand(new RemoveCommand(this));
addCommand(new RestartCommand(this)); addCommand(new RestartCommand(this));
addCommand(new SkipCommand(this)); addCommand(new SkipCommand(this));
addCommand(new SoundboardCommand(this));
helpCommand = new HelpCommand(this); helpCommand = new HelpCommand(this);
addCommand(helpCommand); addCommand(helpCommand);
@ -201,7 +209,7 @@ public final class Chords extends ListenerAdapter
super.onMessageReceived(event); //To change body of generated methods, choose Tools | Templates. super.onMessageReceived(event); //To change body of generated methods, choose Tools | Templates.
Message message = event.getMessage(); Message message = event.getMessage();
User author = message.getAuthor(); User author = message.getAuthor();
String content = message.getContentRaw(); String content = message.getContentRaw().trim();
Guild guild = event.getGuild(); Guild guild = event.getGuild();
// Ignore message if it's not in a music channel // Ignore message if it's not in a music channel
@ -220,7 +228,7 @@ public final class Chords extends ListenerAdapter
{ {
try try
{ {
URL parseURL = new URL(content.trim()); URL parseURL = new URL(content);
invocation = new Invocation(event, List.of(parseURL.toExternalForm())); invocation = new Invocation(event, List.of(parseURL.toExternalForm()));
playCommand.call(invocation); playCommand.call(invocation);
return; return;
@ -268,6 +276,10 @@ public final class Chords extends ListenerAdapter
} }
} }
} }
} else if (soundboard != null)
{
// try looking it up with the soundboard
soundboard.play(cmd);
} }
} catch (Exception ex) } catch (Exception ex)
{ {
@ -445,6 +457,22 @@ public final class Chords extends ListenerAdapter
return playlists; return playlists;
} }
public Soundboard getSoundboard()
{
return soundboard;
}
public void saveSoundboard()
{
try
{
soundboard.saveYAML(soundboardFile);
} catch (IOException ex)
{
}
}
// public Recommender getRecommender() // public Recommender getRecommender()
// { // {
// return recommender; // return recommender;

@ -60,7 +60,8 @@ public class Downloader extends QueueThing<TrackRequest, Track>
// private Consumer<Track> next; // private Consumer<Track> next;
private BiConsumer<TrackRequest, Exception> messageHandler; private BiConsumer<TrackRequest, Exception> messageHandler;
private File downloadDir = null; private File temporaryDownloadDir = null;
private File permanentDownloadDir = null;
private int trackNumber = 1; private int trackNumber = 1;
@ -313,9 +314,24 @@ public class Downloader extends QueueThing<TrackRequest, Track>
private File getDownloadDir() throws IOException private File getDownloadDir() throws IOException
{ {
if (downloadDir == null || !downloadDir.exists() || !downloadDir.canWrite()) return getDownloadDir(false);
downloadDir = Files.createTempDirectory("chords").toFile(); }
return downloadDir;
private File getDownloadDir(boolean permanent) throws IOException
{
if (permanent)
{
if (permanentDownloadDir == null)
permanentDownloadDir = new File("tracks");
if (!permanentDownloadDir.exists())
Files.createDirectory(permanentDownloadDir.toPath());
return permanentDownloadDir;
} else
{
if (temporaryDownloadDir == null || !temporaryDownloadDir.exists() || !temporaryDownloadDir.canWrite())
temporaryDownloadDir = Files.createTempDirectory("chords").toFile();
return temporaryDownloadDir;
}
} }
private Track getTrackFromRequest(TrackRequest request, int idx) private Track getTrackFromRequest(TrackRequest request, int idx)
@ -325,6 +341,7 @@ public class Downloader extends QueueThing<TrackRequest, Track>
{ {
Track track = new Track(request); Track track = new Track(request);
track.setNumber(trackNumber); track.setNumber(trackNumber);
track.setKept(request.isKeepTracks());
trackNumber++; trackNumber++;
request.addTrack(track); request.addTrack(track);
} }
@ -368,7 +385,7 @@ public class Downloader extends QueueThing<TrackRequest, Track>
cmd.add("-"); cmd.add("-");
} else } else
{ {
cmd.add("-o " + getDownloadDir().getAbsolutePath() + "/%(title)s.%(ext)s"); cmd.add("-o" + getDownloadDir(request.isKeepTracks()).getAbsolutePath() + "/%(title)s.%(ext)s");
} }
cmd.add(request.getUrl().toString()); cmd.add(request.getUrl().toString());

@ -38,7 +38,7 @@ public class MusicHandler implements AudioSendHandler, Closeable, Consumer<Track
this.nowPlayingConsumer = nowPlayingConsumer; this.nowPlayingConsumer = nowPlayingConsumer;
} }
private Track currentTrack; // private Track currentTrack;
// private TrackPlayer player; // private TrackPlayer player;
private final List<TrackPlayer> playingTracks = new ArrayList<>(); private final List<TrackPlayer> playingTracks = new ArrayList<>();
@ -61,6 +61,16 @@ public class MusicHandler implements AudioSendHandler, Closeable, Consumer<Track
public void playOver(Track track) public void playOver(Track track)
{ {
if (!isPlaying())
play(track);
try
{
TrackPlayer player = new TrackPlayer(track);
playingTracks.add(player);
} catch (UnsupportedAudioFileException | IOException ex)
{
Logger.getLogger(Chords.class.getName()).log(Level.SEVERE, null, ex);
}
} }
@ -71,7 +81,9 @@ public class MusicHandler implements AudioSendHandler, Closeable, Consumer<Track
public boolean play(Track track, boolean immediate) public boolean play(Track track, boolean immediate)
{ {
if (track == currentTrack) if (playingTracks.stream().anyMatch((t) -> t.getTrack() == track))
return false;
if (track == null)
return false; return false;
if (immediate) if (immediate)
@ -82,30 +94,19 @@ public class MusicHandler implements AudioSendHandler, Closeable, Consumer<Track
try try
{ {
if (currentTrack != null)
{
if (!currentTrack.isKept())
currentTrack.delete();
currentTrack = null;
}
currentTrack = track;
if (nowPlayingConsumer != null) if (nowPlayingConsumer != null)
nowPlayingConsumer.accept(currentTrack); nowPlayingConsumer.accept(track);
if (currentTrack == null)
{
return false;
}
// System.out.println("Playing track " + currentTrack.getLocation().getAbsolutePath()); // System.out.println("Playing track " + currentTrack.getLocation().getAbsolutePath());
arrayErr = false; arrayErr = false;
byteCount = 3840; byteCount = 3840;
TrackPlayer player = new TrackPlayer(currentTrack); TrackPlayer player = new TrackPlayer(track);
playingTracks.add(player); playingTracks.add(player);
// System.out.println("Queue filled to " + audioBuffer.getCurrentNumberOfBytes()); // System.out.println("Queue filled to " + audioBuffer.getCurrentNumberOfBytes());
return true; return true;
} catch (UnsupportedAudioFileException | IOException ex) } catch (UnsupportedAudioFileException | IOException ex)
{ {
Logger.getLogger(Chords.class.getName()).log(Level.SEVERE, null, ex); Logger.getLogger(Chords.class.getName()).log(Level.SEVERE, null, ex);
currentTrack = null;
requestTrack(); requestTrack();
} finally } finally
{ {
@ -179,6 +180,12 @@ public class MusicHandler implements AudioSendHandler, Closeable, Consumer<Track
// outOfInput = true; // outOfInput = true;
} }
} }
for (TrackPlayer emptyPlayer : emptyPlayers)
{
if (!emptyPlayer.getTrack().isKept())
emptyPlayer.getTrack().delete();
emptyPlayer.getTrack().clearInputStream();
}
playingTracks.removeAll(emptyPlayers); playingTracks.removeAll(emptyPlayers);
ret.put(mixBuffers(mixes)); ret.put(mixBuffers(mixes));
if (outOfInput) if (outOfInput)
@ -198,7 +205,9 @@ public class MusicHandler implements AudioSendHandler, Closeable, Consumer<Track
public Track getCurrentTrack() public Track getCurrentTrack()
{ {
return currentTrack; if (playingTracks.isEmpty())
return null;
return playingTracks.get(0).getTrack();
} }
@Override @Override
@ -251,7 +260,6 @@ public class MusicHandler implements AudioSendHandler, Closeable, Consumer<Track
if (!isPlaying()) if (!isPlaying())
return false; return false;
playingTracks.clear(); playingTracks.clear();
currentTrack = null;
requestTrack(); requestTrack();
return true; return true;
} }

@ -62,13 +62,7 @@ public class Playlist implements Consumer<Track>
YamlSequence trackList = yaml.value("tracks").asSequence(); YamlSequence trackList = yaml.value("tracks").asSequence();
for (int i = 0; i < trackList.size(); i++) for (int i = 0; i < trackList.size(); i++)
{ {
try ret.addTrack(Track.fromYaml(trackList.yamlMapping(i)));
{
ret.addTrack(Track.fromYaml(trackList.yamlMapping(i)));
} catch (MalformedURLException ex)
{
Logger.getLogger(Playlist.class.getName()).log(Level.SEVERE, null, ex);
}
} }
return ret; return ret;
} }

@ -74,6 +74,18 @@ public abstract class QueueThing<I, O> implements Consumer<I>
} }
} }
public List<Promise<I, O>> requestSpecific(List<I> inputs, Consumer<O> destination)
{
List<Promise<I, O>> ret = new ArrayList<>();
for (I input : inputs)
{
Promise<I, O> promise = new Promise<>(input, destination);
ret.add(promise);
handlePromise(promise);
}
return ret;
}
public List<Promise<I, O>> request(int count, Consumer<O> destination) public List<Promise<I, O>> request(int count, Consumer<O> destination)
{ {
List<Promise<I, O>> ret = new ArrayList<>(); List<Promise<I, O>> ret = new ArrayList<>();

@ -0,0 +1,92 @@
/*
* Copyright (C) 2024 jimj316
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package moe.nekojimi.chords;
import com.amihaiemil.eoyaml.Yaml;
import com.amihaiemil.eoyaml.YamlInput;
import com.amihaiemil.eoyaml.YamlMapping;
import com.amihaiemil.eoyaml.YamlPrinter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.*;
/**
*
* @author jimj316
*/
public class Soundboard
{
private final Chords bot;
private final Map<String, Track> sounds = new HashMap<>();
public Soundboard(Chords bot)
{
this.bot = bot;
}
public void loadYAML(File file) throws IOException
{
if (!file.exists())
return;
YamlInput input = Yaml.createYamlInput(file);
YamlMapping mapping = input.readYamlMapping();
sounds.putAll(Util.yamlMappingToMap(mapping, (t) -> Track.fromYaml(t.asMapping())));
}
public void saveYAML(File file) throws IOException
{
YamlPrinter printer = Yaml.createYamlPrinter(new FileWriter(file));
printer.print(Util.mapToMapping(sounds, (t) -> t.toYaml()));
}
public void add(String emoji, Track t)
{
t.setKept(true);
sounds.put(emoji, t);
}
public boolean remove(String emoji)
{
if (!sounds.containsKey(emoji))
return false;
Track t = sounds.get(emoji);
t.setKept(false);
t.delete();
sounds.remove(emoji);
return true;
}
public boolean play(String emoji)
{
if (!sounds.containsKey(emoji))
return false;
if (bot.getMusicHandler() == null)
return false;
final Track track = sounds.get(emoji);
track.setKept(true);
bot.getMusicHandler().play(track);
return true;
}
public List<String> getEmoji()
{
return new ArrayList<>(sounds.keySet());
}
}

@ -9,14 +9,13 @@ import com.amihaiemil.eoyaml.Yaml;
import com.amihaiemil.eoyaml.YamlMapping; import com.amihaiemil.eoyaml.YamlMapping;
import com.amihaiemil.eoyaml.YamlSequence; import com.amihaiemil.eoyaml.YamlSequence;
import com.amihaiemil.eoyaml.YamlSequenceBuilder; import com.amihaiemil.eoyaml.YamlSequenceBuilder;
import java.io.File; import java.io.*;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
/** /**
* *
@ -63,31 +62,39 @@ public class Track implements Comparable<Track>
.add("url", url.toExternalForm()) .add("url", url.toExternalForm())
.add("location", location.getAbsolutePath()) .add("location", location.getAbsolutePath())
.add("num", Integer.toString(number)) .add("num", Integer.toString(number))
.add("formats", build.build()) // .add("formats", build.build())
.add("artist", artist)
// .add("requestedBy", requestedBy) // .add("requestedBy", requestedBy)
// .add("requestedIn", requestedIn) // .add("requestedIn", requestedIn)
.add("kept", Boolean.toString(kept)) .add("kept", Boolean.toString(kept))
.build(); .build();
} }
public static Track fromYaml(YamlMapping map) throws MalformedURLException public static Track fromYaml(YamlMapping map)
{ {
Track track = new Track(new URL(map.string("url")), null); try
track.setArtist(map.string("artist")); {
track.setTitle(map.string("title")); Track track = new Track(new URL(map.string("url")), null);
track.setLocation(new File(map.string("location"))); track.setArtist(map.string("artist"));
track.setNumber(map.integer("num")); track.setTitle(map.string("title"));
track.setKept(Boolean.parseBoolean(map.string("kept"))); track.setLocation(new File(map.string("location")));
track.setNumber(map.integer("num"));
track.setKept(Boolean.parseBoolean(map.string("kept")));
// track.setRequestedBy(map.string("requestedBy")); // track.setRequestedBy(map.string("requestedBy"));
// track.setRequestedIn(map.string("requestedIn")); // track.setRequestedIn(map.string("requestedIn"));
List<Format> formats = new ArrayList<>(); // List<Format> formats = new ArrayList<>();
YamlSequence formatSeq = map.yamlSequence("formats"); // YamlSequence formatSeq = map.yamlSequence("formats");
for (int i = 0; i < formats.size(); i++) // for (int i = 0; i < formats.size(); i++)
formats.add(Format.fromYaml(formatSeq.yamlMapping(i))); // formats.add(Format.fromYaml(formatSeq.yamlMapping(i)));
track.setFormats(formats); // track.setFormats(formats);
return track; return track;
} catch (MalformedURLException ex)
{
Logger.getLogger(Track.class.getName()).log(Level.SEVERE, null, ex);
return null;
}
} }
public boolean isDownloaded() public boolean isDownloaded()
@ -152,6 +159,21 @@ public class Track implements Comparable<Track>
this.inputStream = inputStream; this.inputStream = inputStream;
} }
void clearInputStream()
{
if (inputStream != null)
{
try
{
inputStream.close();
} catch (IOException ex)
{
Logger.getLogger(Track.class.getName()).log(Level.SEVERE, null, ex);
}
inputStream = null;
}
}
void delete() void delete()
{ {
if (location != null) if (location != null)

@ -31,13 +31,15 @@ public class TrackPlayer implements Closeable
private static final int RETRY_DELAY = 100; private static final int RETRY_DELAY = 100;
private final CircularByteBuffer audioBuffer = new CircularByteBuffer(3840 * 1024); private final CircularByteBuffer audioBuffer = new CircularByteBuffer(3840 * 1024);
private final Track track;
private final AudioInputStream input; private final AudioInputStream input;
private boolean arrayErr = false; // supresses ArrayIndexOutOfBoundsException after the first time, to prevent spam private boolean arrayErr = false; // supresses ArrayIndexOutOfBoundsException after the first time, to prevent spam
public TrackPlayer(Track track) throws UnsupportedAudioFileException, IOException public TrackPlayer(Track t) throws UnsupportedAudioFileException, IOException
{ {
track = t;
AudioInputStream in = null; AudioInputStream in = null;
AudioFormat decodedFormat = null; AudioFormat decodedFormat = null;
int retry = 0; int retry = 0;
@ -72,11 +74,11 @@ public class TrackPlayer implements Closeable
fillBuffer(false); fillBuffer(false);
} }
public TrackPlayer(AudioInputStream input) throws IOException // public TrackPlayer(AudioInputStream input) throws IOException
{ // {
this.input = input; // this.input = input;
fillBuffer(false); // fillBuffer(false);
} // }
public boolean has(int byteCount) public boolean has(int byteCount)
{ {
@ -168,6 +170,10 @@ public class TrackPlayer implements Closeable
input.close(); //q input.close(); //q
} }
public Track getTrack()
{
return track;
}
public static class OutOfInputException extends RuntimeException public static class OutOfInputException extends RuntimeException

@ -43,6 +43,7 @@ public class TrackRequest implements Comparable<TrackRequest>
private String requestedIn; private String requestedIn;
private double priority = 1.0; private double priority = 1.0;
private boolean keepTracks = false;
public YamlMapping toYAML() public YamlMapping toYAML()
{ {
@ -78,6 +79,16 @@ public class TrackRequest implements Comparable<TrackRequest>
requestedIn = invocation.getRequestMessage().getChannel().getId(); requestedIn = invocation.getRequestMessage().getChannel().getId();
} }
public boolean isKeepTracks()
{
return keepTracks;
}
public void setKeepTracks(boolean keepTracks)
{
this.keepTracks = keepTracks;
}
// public Message getRequestMessage() // public Message getRequestMessage()
// { // {
// return requestMessage; // return requestMessage;

@ -1,6 +1,14 @@
package moe.nekojimi.chords; package moe.nekojimi.chords;
import com.amihaiemil.eoyaml.Yaml;
import com.amihaiemil.eoyaml.YamlMapping;
import com.amihaiemil.eoyaml.YamlMappingBuilder;
import com.amihaiemil.eoyaml.YamlNode;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.function.Function;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -31,6 +39,26 @@ public class Util
private static final Pattern SIZE_PATTERN = Pattern.compile("\\b([0-9]+\\.?[0-9]*)([kkMmGg])i?[bB]\\b"); private static final Pattern SIZE_PATTERN = Pattern.compile("\\b([0-9]+\\.?[0-9]*)([kkMmGg])i?[bB]\\b");
private static final Pattern SAMPLE_RATE_PATTERN = Pattern.compile("\\b([0-9]+)k(b(ps?))?\\b"); private static final Pattern SAMPLE_RATE_PATTERN = Pattern.compile("\\b([0-9]+)k(b(ps?))?\\b");
public static <V> Map<String, V> yamlMappingToMap(YamlMapping mapping, Function<YamlNode, V> fromYamlFunction)
{
Map<String, V> ret = new HashMap<>();
for (YamlNode key : mapping.keys())
{
ret.put(key.asScalar().value(), fromYamlFunction.apply(mapping.value(key)));
}
return ret;
}
public static <K, V> YamlMapping mapToMapping(Map<K, V> map, Function<V, YamlNode> toYamlFunction)
{
YamlMappingBuilder builder = Yaml.createYamlMappingBuilder();
for (Entry<K, V> e : map.entrySet())
{
builder = builder.add(e.getKey().toString(), toYamlFunction.apply(e.getValue()));
}
return builder.build();
}
public static String printSamples(ByteBuffer buf) public static String printSamples(ByteBuffer buf)
{ {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();

@ -0,0 +1,98 @@
/*
* Copyright (C) 2024 jimj316
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package moe.nekojimi.chords.commands;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import moe.nekojimi.chords.Chords;
import moe.nekojimi.chords.TrackRequest;
/**
*
* @author jimj316
*/
public class SoundboardCommand extends Command
{
public SoundboardCommand(Chords bot)
{
super(bot, "board");
}
@Override
public void call(Invocation invocation)
{
String action = invocation.getArgs().isEmpty() ? "" : invocation.getArgs().get(0);
String emoji = invocation.getArgs().size() < 2 ? "" : invocation.getArgs().get(1);
if (action.equals("add"))
{
String urlString = invocation.getArgs().get(2);
if (emoji.isBlank())
{
invocation.respond("You must specify a trigger!");
return;
}
try
{
URL url;
if (invocation.getArgs().size() < 3)
{
invocation.respond("No URL given!");
return;
}
url = new URL(urlString);
TrackRequest request = new TrackRequest();
request.setUrl(url);
request.setInvocation(invocation);
request.setKeepTracks(true);
bot.getDownloader().requestSpecific(List.of(request), (t) ->
{
bot.getSoundboard().add(emoji, t);
bot.saveSoundboard();
});
} catch (MalformedURLException ex)
{
invocation.respond("That's not a valid URL! " + ex.getMessage());
return;
}
} else if (action.equals("remove"))
{
if (emoji.isBlank())
{
invocation.respond("You must specify a trigger!");
return;
}
bot.getSoundboard().remove(emoji);
bot.saveSoundboard();
} else if (action.equals("list"))
{
List<String> list = bot.getSoundboard().getEmoji();
String response = "__Soundboard commands available:__\n";
for (String item : list)
{
response += item + " ";
}
invocation.respond(response);
} else
{
invocation.respond("Specify \"add\" or \"remove\" after the command!");
}
}
}
Loading…
Cancel
Save