Some music bot functionality added
This commit is contained in:
parent
4838eee050
commit
82a25dbe09
|
@ -3,7 +3,7 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.fpghoti</groupId>
|
<groupId>com.fpghoti</groupId>
|
||||||
<artifactId>Biscuit</artifactId>
|
<artifactId>Biscuit</artifactId>
|
||||||
<version>1.6.3</version>
|
<version>1.7</version>
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>src/main/java</sourceDirectory>
|
<sourceDirectory>src/main/java</sourceDirectory>
|
||||||
<resources>
|
<resources>
|
||||||
|
@ -53,6 +53,12 @@
|
||||||
<include>**</include>
|
<include>**</include>
|
||||||
</includes>
|
</includes>
|
||||||
</filter>
|
</filter>
|
||||||
|
<filter>
|
||||||
|
<artifact>commons-logging:commons-logging</artifact>
|
||||||
|
<includes>
|
||||||
|
<include>**</include>
|
||||||
|
</includes>
|
||||||
|
</filter>
|
||||||
</filters>
|
</filters>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
|
@ -109,55 +115,6 @@
|
||||||
<version>1.15-SNAPSHOT</version>
|
<version>1.15-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>net.java.dev.jna</groupId>
|
|
||||||
<artifactId>jna</artifactId>
|
|
||||||
<version>4.5.0</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.json</groupId>
|
|
||||||
<artifactId>json</artifactId>
|
|
||||||
<version>20171018</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.sf.trove4j</groupId>
|
|
||||||
<artifactId>trove4j</artifactId>
|
|
||||||
<version>3.0.3</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.commons</groupId>
|
|
||||||
<artifactId>commons-collections4</artifactId>
|
|
||||||
<version>4.1</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.commons</groupId>
|
|
||||||
<artifactId>commons-lang3</artifactId>
|
|
||||||
<version>3.6</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.squareup.okhttp</groupId>
|
|
||||||
<artifactId>okhttp</artifactId>
|
|
||||||
<version>2.7.5</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.neovisionaries</groupId>
|
|
||||||
<artifactId>nv-websocket-client</artifactId>
|
|
||||||
<version>2.3</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<properties>
|
<properties>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
|
|
56
pom.xml
56
pom.xml
|
@ -5,7 +5,7 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.fpghoti</groupId>
|
<groupId>com.fpghoti</groupId>
|
||||||
<artifactId>Biscuit</artifactId>
|
<artifactId>Biscuit</artifactId>
|
||||||
<version>1.6.3</version>
|
<version>1.7</version>
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>src/main/java</sourceDirectory>
|
<sourceDirectory>src/main/java</sourceDirectory>
|
||||||
<resources>
|
<resources>
|
||||||
|
@ -57,6 +57,12 @@
|
||||||
<include>**</include>
|
<include>**</include>
|
||||||
</includes>
|
</includes>
|
||||||
</filter>
|
</filter>
|
||||||
|
<filter>
|
||||||
|
<artifact>commons-logging:commons-logging</artifact>
|
||||||
|
<includes>
|
||||||
|
<include>**</include>
|
||||||
|
</includes>
|
||||||
|
</filter>
|
||||||
</filters>
|
</filters>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
|
@ -108,7 +114,6 @@
|
||||||
<groupId>org.tuxdude.logback.extensions</groupId>
|
<groupId>org.tuxdude.logback.extensions</groupId>
|
||||||
<artifactId>logback-colorizer</artifactId>
|
<artifactId>logback-colorizer</artifactId>
|
||||||
<version>1.0.1</version>
|
<version>1.0.1</version>
|
||||||
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.CrabMustard</groupId>
|
<groupId>com.github.CrabMustard</groupId>
|
||||||
|
@ -174,48 +179,6 @@
|
||||||
<artifactId>cage</artifactId>
|
<artifactId>cage</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>net.java.dev.jna</groupId>
|
|
||||||
<artifactId>jna</artifactId>
|
|
||||||
<version>4.5.0</version>
|
|
||||||
<type>pom</type>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.json</groupId>
|
|
||||||
<artifactId>json</artifactId>
|
|
||||||
<version>20171018</version>
|
|
||||||
<type>pom</type>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.sf.trove4j</groupId>
|
|
||||||
<artifactId>trove4j</artifactId>
|
|
||||||
<version>3.0.3</version>
|
|
||||||
<type>pom</type>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.commons</groupId>
|
|
||||||
<artifactId>commons-collections4</artifactId>
|
|
||||||
<version>4.1</version>
|
|
||||||
<type>pom</type>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.commons</groupId>
|
|
||||||
<artifactId>commons-lang3</artifactId>
|
|
||||||
<version>3.6</version>
|
|
||||||
<type>pom</type>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.squareup.okhttp</groupId>
|
|
||||||
<artifactId>okhttp</artifactId>
|
|
||||||
<version>2.7.5</version>
|
|
||||||
<type>pom</type>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.neovisionaries</groupId>
|
|
||||||
<artifactId>nv-websocket-client</artifactId>
|
|
||||||
<version>2.3</version>
|
|
||||||
<type>pom</type>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.activation</groupId>
|
<groupId>javax.activation</groupId>
|
||||||
<artifactId>activation</artifactId>
|
<artifactId>activation</artifactId>
|
||||||
|
@ -226,5 +189,10 @@
|
||||||
<artifactId>mail</artifactId>
|
<artifactId>mail</artifactId>
|
||||||
<version>1.4.7</version>
|
<version>1.4.7</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.sedmelluq</groupId>
|
||||||
|
<artifactId>lavaplayer</artifactId>
|
||||||
|
<version>1.3.50</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
|
@ -2,39 +2,48 @@ package com.fpghoti.biscuit;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
import org.fusesource.jansi.AnsiConsole;
|
import org.fusesource.jansi.AnsiConsole;
|
||||||
|
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.BaseCommand;
|
|
||||||
import com.fpghoti.biscuit.commands.CommandListener;
|
|
||||||
import com.fpghoti.biscuit.commands.CommandManager;
|
import com.fpghoti.biscuit.commands.CommandManager;
|
||||||
import com.fpghoti.biscuit.commands.client.AddCommand;
|
import com.fpghoti.biscuit.commands.client.AddCommand;
|
||||||
import com.fpghoti.biscuit.commands.client.ChanIDCommand;
|
import com.fpghoti.biscuit.commands.client.ChanIDCommand;
|
||||||
import com.fpghoti.biscuit.commands.client.DivideCommand;
|
import com.fpghoti.biscuit.commands.client.DivideCommand;
|
||||||
|
import com.fpghoti.biscuit.commands.client.ForceSkipCommand;
|
||||||
import com.fpghoti.biscuit.commands.client.GetConfigCommand;
|
import com.fpghoti.biscuit.commands.client.GetConfigCommand;
|
||||||
import com.fpghoti.biscuit.commands.client.GuildIDCommand;
|
import com.fpghoti.biscuit.commands.client.GuildIDCommand;
|
||||||
import com.fpghoti.biscuit.commands.client.ToggleRoleCommand;
|
import com.fpghoti.biscuit.commands.client.ToggleRoleCommand;
|
||||||
import com.fpghoti.biscuit.commands.client.HelpCommand;
|
import com.fpghoti.biscuit.commands.client.HelpCommand;
|
||||||
|
import com.fpghoti.biscuit.commands.client.LoopMusicCommand;
|
||||||
import com.fpghoti.biscuit.commands.client.MultiplyCommand;
|
import com.fpghoti.biscuit.commands.client.MultiplyCommand;
|
||||||
import com.fpghoti.biscuit.commands.client.NotSpammerCommand;
|
import com.fpghoti.biscuit.commands.client.NotSpammerCommand;
|
||||||
|
import com.fpghoti.biscuit.commands.client.NowPlayingCommand;
|
||||||
|
import com.fpghoti.biscuit.commands.client.PauseCommand;
|
||||||
|
import com.fpghoti.biscuit.commands.client.TogglePauseCommand;
|
||||||
import com.fpghoti.biscuit.commands.client.MakeInviteCommand;
|
import com.fpghoti.biscuit.commands.client.MakeInviteCommand;
|
||||||
import com.fpghoti.biscuit.commands.client.PingCommand;
|
import com.fpghoti.biscuit.commands.client.PingCommand;
|
||||||
|
import com.fpghoti.biscuit.commands.client.PlayCommand;
|
||||||
|
import com.fpghoti.biscuit.commands.client.PlayFirstCommand;
|
||||||
import com.fpghoti.biscuit.commands.client.PowerCommand;
|
import com.fpghoti.biscuit.commands.client.PowerCommand;
|
||||||
|
import com.fpghoti.biscuit.commands.client.QueueCommand;
|
||||||
import com.fpghoti.biscuit.commands.client.RecentSpammersCommand;
|
import com.fpghoti.biscuit.commands.client.RecentSpammersCommand;
|
||||||
import com.fpghoti.biscuit.commands.client.SaveConfigCommand;
|
import com.fpghoti.biscuit.commands.client.SaveConfigCommand;
|
||||||
|
import com.fpghoti.biscuit.commands.client.SkipCommand;
|
||||||
import com.fpghoti.biscuit.commands.client.SoftMuteCommand;
|
import com.fpghoti.biscuit.commands.client.SoftMuteCommand;
|
||||||
import com.fpghoti.biscuit.commands.client.SquareRootCommand;
|
import com.fpghoti.biscuit.commands.client.SquareRootCommand;
|
||||||
import com.fpghoti.biscuit.commands.client.SubtractCommand;
|
import com.fpghoti.biscuit.commands.client.SubtractCommand;
|
||||||
import com.fpghoti.biscuit.commands.client.UIDCommand;
|
import com.fpghoti.biscuit.commands.client.UIDCommand;
|
||||||
import com.fpghoti.biscuit.commands.client.UnSoftMuteCommand;
|
import com.fpghoti.biscuit.commands.client.UnSoftMuteCommand;
|
||||||
|
import com.fpghoti.biscuit.commands.client.UnpauseCommand;
|
||||||
import com.fpghoti.biscuit.commands.client.WikiCommand;
|
import com.fpghoti.biscuit.commands.client.WikiCommand;
|
||||||
|
import com.fpghoti.biscuit.commands.client.WipeQueueCommand;
|
||||||
import com.fpghoti.biscuit.commands.console.GuildSayCommand;
|
import com.fpghoti.biscuit.commands.console.GuildSayCommand;
|
||||||
import com.fpghoti.biscuit.commands.console.SayCommand;
|
import com.fpghoti.biscuit.commands.console.SayCommand;
|
||||||
import com.fpghoti.biscuit.commands.console.ShutdownConsoleCommand;
|
import com.fpghoti.biscuit.commands.console.ShutdownConsoleCommand;
|
||||||
|
import com.fpghoti.biscuit.listener.CommandListener;
|
||||||
import com.fpghoti.biscuit.listener.DMListener;
|
import com.fpghoti.biscuit.listener.DMListener;
|
||||||
import com.fpghoti.biscuit.listener.GuildListener;
|
import com.fpghoti.biscuit.listener.GuildListener;
|
||||||
import com.fpghoti.biscuit.listener.JoinListener;
|
import com.fpghoti.biscuit.listener.JoinListener;
|
||||||
|
@ -46,19 +55,24 @@ import com.fpghoti.biscuit.listener.ReactionListener;
|
||||||
import com.fpghoti.biscuit.listener.RoleListener;
|
import com.fpghoti.biscuit.listener.RoleListener;
|
||||||
import com.fpghoti.biscuit.logging.BColor;
|
import com.fpghoti.biscuit.logging.BColor;
|
||||||
import com.fpghoti.biscuit.logging.BiscuitLog;
|
import com.fpghoti.biscuit.logging.BiscuitLog;
|
||||||
|
import com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager;
|
||||||
|
import com.sedmelluq.discord.lavaplayer.player.DefaultAudioPlayerManager;
|
||||||
|
import com.sedmelluq.discord.lavaplayer.source.AudioSourceManagers;
|
||||||
|
|
||||||
import ch.qos.logback.core.rolling.RollingFileAppender;
|
import ch.qos.logback.core.rolling.RollingFileAppender;
|
||||||
import ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy;
|
import ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy;
|
||||||
import net.dv8tion.jda.api.JDA;
|
import net.dv8tion.jda.api.JDA;
|
||||||
import net.dv8tion.jda.api.JDABuilder;
|
|
||||||
import net.dv8tion.jda.api.entities.Guild;
|
import net.dv8tion.jda.api.entities.Guild;
|
||||||
import net.dv8tion.jda.api.requests.GatewayIntent;
|
import net.dv8tion.jda.api.requests.GatewayIntent;
|
||||||
|
import net.dv8tion.jda.api.sharding.DefaultShardManagerBuilder;
|
||||||
|
import net.dv8tion.jda.api.sharding.ShardManager;
|
||||||
import net.dv8tion.jda.api.utils.ChunkingFilter;
|
import net.dv8tion.jda.api.utils.ChunkingFilter;
|
||||||
import net.dv8tion.jda.api.utils.MemberCachePolicy;
|
import net.dv8tion.jda.api.utils.MemberCachePolicy;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
|
|
||||||
private static JDA jda;
|
private static JDA jda;
|
||||||
|
private static ShardManager shardm;
|
||||||
|
|
||||||
public RollingFileAppender<String> we;
|
public RollingFileAppender<String> we;
|
||||||
public SizeAndTimeBasedRollingPolicy<String> wes;
|
public SizeAndTimeBasedRollingPolicy<String> wes;
|
||||||
|
@ -72,6 +86,8 @@ public class Main {
|
||||||
public static boolean isPlugin = false;
|
public static boolean isPlugin = false;
|
||||||
public static boolean shutdownStarted = false;
|
public static boolean shutdownStarted = false;
|
||||||
|
|
||||||
|
private static AudioPlayerManager playerManager;
|
||||||
|
|
||||||
public static void main(String[] args){
|
public static void main(String[] args){
|
||||||
final Properties properties = new Properties();
|
final Properties properties = new Properties();
|
||||||
try {
|
try {
|
||||||
|
@ -84,8 +100,13 @@ public class Main {
|
||||||
AnsiConsole.systemInstall();
|
AnsiConsole.systemInstall();
|
||||||
log.info(BColor.CYAN_BOLD + "========================= WELCOME TO BISCUIT =========================");
|
log.info(BColor.CYAN_BOLD + "========================= WELCOME TO BISCUIT =========================");
|
||||||
log.info("Running version: " + BColor.MAGENTA_BOLD + version);
|
log.info("Running version: " + BColor.MAGENTA_BOLD + version);
|
||||||
|
|
||||||
|
playerManager = new DefaultAudioPlayerManager();
|
||||||
|
AudioSourceManagers.registerRemoteSources(playerManager);
|
||||||
|
|
||||||
mainBiscuit = new Biscuit(null, null, log);
|
mainBiscuit = new Biscuit(null, null, log);
|
||||||
startJDA();
|
startJDA();
|
||||||
|
|
||||||
jda.addEventListener(new GuildListener());
|
jda.addEventListener(new GuildListener());
|
||||||
jda.addEventListener(new MessageReceiveListener());
|
jda.addEventListener(new MessageReceiveListener());
|
||||||
jda.addEventListener(new MessageEditListener());
|
jda.addEventListener(new MessageEditListener());
|
||||||
|
@ -103,36 +124,45 @@ public class Main {
|
||||||
|
|
||||||
String link = "NULL";
|
String link = "NULL";
|
||||||
|
|
||||||
List<BaseCommand> commands = CommandManager.getCommands();
|
|
||||||
|
|
||||||
//Client
|
//Client
|
||||||
|
|
||||||
commands.add(new HelpCommand());
|
CommandManager.addCommand(new HelpCommand());
|
||||||
commands.add(new PingCommand());
|
CommandManager.addCommand(new PingCommand());
|
||||||
commands.add(new SoftMuteCommand());
|
CommandManager.addCommand(new SoftMuteCommand());
|
||||||
commands.add(new UnSoftMuteCommand());
|
CommandManager.addCommand(new UnSoftMuteCommand());
|
||||||
commands.add(new NotSpammerCommand());
|
CommandManager.addCommand(new NotSpammerCommand());
|
||||||
commands.add(new RecentSpammersCommand());
|
CommandManager.addCommand(new RecentSpammersCommand());
|
||||||
commands.add(new ChanIDCommand());
|
CommandManager.addCommand(new ChanIDCommand());
|
||||||
commands.add(new UIDCommand());
|
CommandManager.addCommand(new UIDCommand());
|
||||||
commands.add(new ToggleRoleCommand());
|
CommandManager.addCommand(new ToggleRoleCommand());
|
||||||
commands.add(new SquareRootCommand());
|
CommandManager.addCommand(new SquareRootCommand());
|
||||||
commands.add(new AddCommand());
|
CommandManager.addCommand(new AddCommand());
|
||||||
commands.add(new SubtractCommand());
|
CommandManager.addCommand(new SubtractCommand());
|
||||||
commands.add(new MultiplyCommand());
|
CommandManager.addCommand(new MultiplyCommand());
|
||||||
commands.add(new DivideCommand());
|
CommandManager.addCommand(new DivideCommand());
|
||||||
commands.add(new PowerCommand());
|
CommandManager.addCommand(new PowerCommand());
|
||||||
commands.add(new MakeInviteCommand());
|
CommandManager.addCommand(new MakeInviteCommand());
|
||||||
commands.add(new GetConfigCommand());
|
CommandManager.addCommand(new GetConfigCommand());
|
||||||
commands.add(new SaveConfigCommand());
|
CommandManager.addCommand(new SaveConfigCommand());
|
||||||
commands.add(new GuildIDCommand());
|
CommandManager.addCommand(new GuildIDCommand());
|
||||||
commands.add(new WikiCommand());
|
CommandManager.addCommand(new WikiCommand());
|
||||||
|
CommandManager.addCommand(new PlayCommand());
|
||||||
|
CommandManager.addCommand(new PlayFirstCommand());
|
||||||
|
CommandManager.addCommand(new ForceSkipCommand());
|
||||||
|
CommandManager.addCommand(new PauseCommand());
|
||||||
|
CommandManager.addCommand(new UnpauseCommand());
|
||||||
|
CommandManager.addCommand(new TogglePauseCommand());
|
||||||
|
CommandManager.addCommand(new QueueCommand());
|
||||||
|
CommandManager.addCommand(new SkipCommand());
|
||||||
|
CommandManager.addCommand(new NowPlayingCommand());
|
||||||
|
CommandManager.addCommand(new WipeQueueCommand());
|
||||||
|
CommandManager.addCommand(new LoopMusicCommand());
|
||||||
|
|
||||||
//Console
|
//Console
|
||||||
|
|
||||||
commands.add(new SayCommand());
|
CommandManager.addCommand(new SayCommand());
|
||||||
commands.add(new GuildSayCommand());
|
CommandManager.addCommand(new GuildSayCommand());
|
||||||
commands.add(new ShutdownConsoleCommand());
|
CommandManager.addCommand(new ShutdownConsoleCommand());
|
||||||
|
|
||||||
link = "https://discord.com/oauth2/authorize?&client_id=" + jda.getSelfUser().getId() + "&permissions=8&scope=bot";
|
link = "https://discord.com/oauth2/authorize?&client_id=" + jda.getSelfUser().getId() + "&permissions=8&scope=bot";
|
||||||
log.info("Connection successful!");
|
log.info("Connection successful!");
|
||||||
|
@ -148,12 +178,13 @@ public class Main {
|
||||||
String token = mainBiscuit.getProperties().getToken();
|
String token = mainBiscuit.getProperties().getToken();
|
||||||
log.info("Connecting bot to Discord.");
|
log.info("Connecting bot to Discord.");
|
||||||
try{
|
try{
|
||||||
jda = JDABuilder.createDefault(token)
|
shardm = DefaultShardManagerBuilder.createDefault(token)
|
||||||
.setChunkingFilter(ChunkingFilter.ALL)
|
.setChunkingFilter(ChunkingFilter.ALL)
|
||||||
.setMemberCachePolicy(MemberCachePolicy.ALL)
|
.setMemberCachePolicy(MemberCachePolicy.ALL)
|
||||||
.enableIntents(GatewayIntent.getIntents(GatewayIntent.DEFAULT))
|
.enableIntents(GatewayIntent.getIntents(GatewayIntent.DEFAULT))
|
||||||
.enableIntents(GatewayIntent.GUILD_MEMBERS)
|
.enableIntents(GatewayIntent.GUILD_MEMBERS)
|
||||||
.build();
|
.build();
|
||||||
|
jda = shardm.getShardById(0);
|
||||||
try {
|
try {
|
||||||
jda.awaitReady();
|
jda.awaitReady();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
@ -186,7 +217,11 @@ public class Main {
|
||||||
public static ArrayList<Biscuit> getBiscuits() {
|
public static ArrayList<Biscuit> getBiscuits() {
|
||||||
return biscuits;
|
return biscuits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static AudioPlayerManager getPlayerManager() {
|
||||||
|
return playerManager;
|
||||||
|
}
|
||||||
|
|
||||||
public static void shutdown() {
|
public static void shutdown() {
|
||||||
if(!shutdownStarted) {
|
if(!shutdownStarted) {
|
||||||
shutdownStarted = true;
|
shutdownStarted = true;
|
||||||
|
@ -213,11 +248,11 @@ public class Main {
|
||||||
public static BiscuitLog getLogger() {
|
public static BiscuitLog getLogger() {
|
||||||
return log;
|
return log;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerBiscuit(Biscuit b) {
|
public static void registerBiscuit(Biscuit b) {
|
||||||
biscuits.add(b);
|
biscuits.add(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void unregisterBiscuit(Biscuit b) {
|
public static void unregisterBiscuit(Biscuit b) {
|
||||||
biscuits.remove(b);
|
biscuits.remove(b);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
package com.fpghoti.biscuit.audio;
|
||||||
|
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
|
import com.sedmelluq.discord.lavaplayer.player.AudioPlayer;
|
||||||
|
import com.sedmelluq.discord.lavaplayer.track.playback.AudioFrame;
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.audio.AudioSendHandler;
|
||||||
|
|
||||||
|
public class AudioHandler implements AudioSendHandler {
|
||||||
|
|
||||||
|
private final AudioPlayer audioPlayer;
|
||||||
|
private AudioFrame lastFrame;
|
||||||
|
|
||||||
|
public AudioHandler(AudioPlayer audioPlayer) {
|
||||||
|
this.audioPlayer = audioPlayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canProvide() {
|
||||||
|
lastFrame = audioPlayer.provide();
|
||||||
|
return lastFrame != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ByteBuffer provide20MsAudio() {
|
||||||
|
return ByteBuffer.wrap(lastFrame.getData());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isOpus() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,104 @@
|
||||||
|
package com.fpghoti.biscuit.audio;
|
||||||
|
|
||||||
|
import com.fpghoti.biscuit.Main;
|
||||||
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
|
import com.fpghoti.biscuit.util.Util;
|
||||||
|
import com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler;
|
||||||
|
import com.sedmelluq.discord.lavaplayer.tools.FriendlyException;
|
||||||
|
import com.sedmelluq.discord.lavaplayer.track.AudioPlaylist;
|
||||||
|
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.entities.TextChannel;
|
||||||
|
|
||||||
|
public class AudioResultHandler implements AudioLoadResultHandler {
|
||||||
|
|
||||||
|
private Biscuit biscuit;
|
||||||
|
private String uid;
|
||||||
|
private TextChannel channel;
|
||||||
|
private String searchPhrase;
|
||||||
|
private boolean search;
|
||||||
|
private boolean first;
|
||||||
|
private boolean stop;
|
||||||
|
|
||||||
|
public AudioResultHandler(Biscuit biscuit, String uid, TextChannel channel, boolean search,
|
||||||
|
String searchPhrase, boolean first, boolean stop) {
|
||||||
|
this.biscuit = biscuit;
|
||||||
|
this.uid = uid;
|
||||||
|
this.channel = channel;
|
||||||
|
this.search = search;
|
||||||
|
this.searchPhrase = searchPhrase;
|
||||||
|
this.first = first;
|
||||||
|
this.stop = stop;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AudioResultHandler(Biscuit biscuit, String uid, TextChannel channel, boolean search,
|
||||||
|
String searchPhrase, boolean first) {
|
||||||
|
this.biscuit = biscuit;
|
||||||
|
this.uid = uid;
|
||||||
|
this.channel = channel;
|
||||||
|
this.search = search;
|
||||||
|
this.searchPhrase = searchPhrase;
|
||||||
|
this.first = first;
|
||||||
|
this.stop = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AudioResultHandler(Biscuit biscuit, String uid, TextChannel channel, boolean search, String searchPhrase) {
|
||||||
|
this.biscuit = biscuit;
|
||||||
|
this.uid = uid;
|
||||||
|
this.channel = channel;
|
||||||
|
this.search = search;
|
||||||
|
this.searchPhrase = searchPhrase;
|
||||||
|
this.first = false;
|
||||||
|
this.stop = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void trackLoaded(AudioTrack track) {
|
||||||
|
if(!stop) {
|
||||||
|
//TODO fix vevo
|
||||||
|
//Try to avoid Vevo results if possible.
|
||||||
|
String title = track.getInfo().title;
|
||||||
|
if(title.toLowerCase().contains("vevo") || track.getInfo().author.toLowerCase().contains("vevo")) {
|
||||||
|
title = title.toLowerCase().replace("vevo", "") + " lyrics";
|
||||||
|
channel.sendMessage("You tried to load a Vevo video. These are not compatible with the music player."
|
||||||
|
+ " Trying to find alternate song...").queue();
|
||||||
|
Main.getPlayerManager().loadItemOrdered(biscuit.getGuild(),"ytsearch:" + title, new AudioResultHandler(biscuit, uid, channel, true, title, first, true));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
channel.sendMessage("**Adding to queue: **\n```" + track.getInfo().title + "\nBy: "
|
||||||
|
+ track.getInfo().author + "\nLength: " + Util.getTime(track.getDuration()) +"```").queue();
|
||||||
|
if(first) {
|
||||||
|
biscuit.getAudioScheduler().queueFirst(track, uid, channel);
|
||||||
|
}else {
|
||||||
|
biscuit.getAudioScheduler().queue(track, uid, channel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void playlistLoaded(AudioPlaylist playlist) {
|
||||||
|
AudioTrack track = playlist.getTracks().get(0);
|
||||||
|
channel.sendMessage("**Adding to queue: **\n" + track.getInfo().uri + "\n```" + track.getInfo().title + "\nBy: "
|
||||||
|
+ track.getInfo().author + "\nLength: " + Util.getTime(track.getDuration()) +"```").queue();
|
||||||
|
biscuit.getAudioScheduler().queue(track, uid);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void noMatches() {
|
||||||
|
if(!search) {
|
||||||
|
biscuit.log("Exact match not found. Searching instead...");
|
||||||
|
Main.getPlayerManager().loadItemOrdered(biscuit.getGuild(),"ytsearch:" + searchPhrase, new AudioResultHandler(biscuit, uid, channel, true, searchPhrase));
|
||||||
|
}else {
|
||||||
|
channel.sendMessage("Song match not found.").queue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loadFailed(FriendlyException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
channel.sendMessage("An error was encountered while attempting to load audio.").queue();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,216 @@
|
||||||
|
package com.fpghoti.biscuit.audio;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import com.fpghoti.biscuit.audio.queue.AudioQueue;
|
||||||
|
import com.fpghoti.biscuit.audio.queue.QueuedTrack;
|
||||||
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
|
import com.fpghoti.biscuit.util.Util;
|
||||||
|
import com.sedmelluq.discord.lavaplayer.player.AudioPlayer;
|
||||||
|
import com.sedmelluq.discord.lavaplayer.player.event.AudioEventAdapter;
|
||||||
|
import com.sedmelluq.discord.lavaplayer.tools.FriendlyException;
|
||||||
|
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
|
||||||
|
import com.sedmelluq.discord.lavaplayer.track.AudioTrackEndReason;
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.entities.TextChannel;
|
||||||
|
|
||||||
|
public class AudioScheduler extends AudioEventAdapter {
|
||||||
|
|
||||||
|
private Biscuit biscuit;
|
||||||
|
private AudioQueue queue;
|
||||||
|
private ArrayList<String> skips;
|
||||||
|
private boolean loop;
|
||||||
|
|
||||||
|
public AudioScheduler(Biscuit biscuit) {
|
||||||
|
this.biscuit = biscuit;
|
||||||
|
this.queue = new AudioQueue();
|
||||||
|
this.skips = new ArrayList<String>();
|
||||||
|
this.loop = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlayerPause(AudioPlayer player) {
|
||||||
|
log("The current track was paused.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlayerResume(AudioPlayer player) {
|
||||||
|
log("The current track was unpaused.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTrackStart(AudioPlayer player, AudioTrack track) {
|
||||||
|
log("Starting track " + track.getInfo().title + ".");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTrackEnd(AudioPlayer player, AudioTrack track, AudioTrackEndReason endReason) {
|
||||||
|
|
||||||
|
QueuedTrack qt = queue.getLastTrack();
|
||||||
|
String title = track.getInfo().title;
|
||||||
|
|
||||||
|
switch(endReason) {
|
||||||
|
|
||||||
|
case LOAD_FAILED:
|
||||||
|
warn("Something went wrong while trying to load the current track. The next track will be played instead if available.");
|
||||||
|
if(qt != null && qt.getCommandChannel() != null)
|
||||||
|
qt.getCommandChannel().sendMessage("There was an error loading **" + title + "**.").queue();
|
||||||
|
break;
|
||||||
|
case CLEANUP:
|
||||||
|
log("A track stopped playing due to audio player cleanup.");
|
||||||
|
if(qt != null && qt.getCommandChannel() != null)
|
||||||
|
qt.getCommandChannel().sendMessage("Track **" + track.getInfo().title + "** stopped playing due to audio player cleanup.").queue();
|
||||||
|
break;
|
||||||
|
case FINISHED:
|
||||||
|
log("Finished playing track " + title + ".");
|
||||||
|
break;
|
||||||
|
case REPLACED:
|
||||||
|
log("Skipped track " + title + ".");
|
||||||
|
break;
|
||||||
|
case STOPPED:
|
||||||
|
log("Stopped playing track " + title + ".");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (endReason.mayStartNext) {
|
||||||
|
if(loop) {
|
||||||
|
queueFirst(track.makeClone(), qt.getUserId(), qt.getCommandChannel());
|
||||||
|
}
|
||||||
|
startPlaying();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTrackException(AudioPlayer player, AudioTrack track, FriendlyException exception) {
|
||||||
|
//TODO fix vevo
|
||||||
|
if(track.getInfo().title.toLowerCase().contains("vevo") || track.getInfo().author.toLowerCase().contains("vevo")) {
|
||||||
|
QueuedTrack qt = queue.getPreviousTrack(track);
|
||||||
|
qt.getCommandChannel().sendMessage("**" + track.getInfo().title + "** could not be loaded, because it is a Vevo video.").queue();
|
||||||
|
}
|
||||||
|
biscuit.error("An exception occurred while trying to play a certain track. The next track will be played instead if available.");
|
||||||
|
startPlaying();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTrackStuck(AudioPlayer player, AudioTrack track, long thresholdMs) {
|
||||||
|
QueuedTrack qt = queue.getPreviousTrack(track);
|
||||||
|
if(qt != null && qt.getCommandChannel() != null) {
|
||||||
|
qt.getCommandChannel().sendMessage("The current track has become stuck and will be skipped.").queue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void queue(AudioTrack track, String uid) {
|
||||||
|
queue(track, uid, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void queue(AudioTrack track, String uid, TextChannel channel) {
|
||||||
|
if(queue.isEmpty() && biscuit.getAudioPlayer().getPlayingTrack() == null) {
|
||||||
|
queue.addPreviousTrack(new QueuedTrack(biscuit, track, uid, channel));
|
||||||
|
biscuit.getAudioPlayer().playTrack(track);
|
||||||
|
}else {
|
||||||
|
queue.add(new QueuedTrack(biscuit, track, uid, channel));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void queueFirst(AudioTrack track, String uid, TextChannel channel) {
|
||||||
|
if(queue.isEmpty() && biscuit.getAudioPlayer().getPlayingTrack() == null) {
|
||||||
|
queue.addPreviousTrack(new QueuedTrack(biscuit, track, uid, channel));
|
||||||
|
biscuit.getAudioPlayer().playTrack(track);
|
||||||
|
}else {
|
||||||
|
queue.addAtPlace(new QueuedTrack(biscuit, track, uid, channel), 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startPlaying() {
|
||||||
|
if(queue.isEmpty()) {
|
||||||
|
if(loop) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
biscuit.getGuild().getAudioManager().closeAudioConnection();
|
||||||
|
skips.clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
queue.playNext();
|
||||||
|
skips.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLooping(boolean b) {
|
||||||
|
loop = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isLooping() {
|
||||||
|
return loop;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasSkipped(String id) {
|
||||||
|
return skips.contains(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean voteSkip(String id) {
|
||||||
|
if(!hasSkipped(id)) {
|
||||||
|
skips.add(id);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getVotes() {
|
||||||
|
return skips.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public AudioQueue getQueue(){
|
||||||
|
return queue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void skip() {
|
||||||
|
biscuit.getAudioPlayer().stopTrack();
|
||||||
|
startPlaying();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNextMessage() {
|
||||||
|
if(queue.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
AudioTrack track = queue.getNext().getTrack();
|
||||||
|
return getMessage(track);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage(AudioTrack track) {
|
||||||
|
return getMessage(track, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage(AudioTrack track, Boolean showRemaining) {
|
||||||
|
String msg ="**Now Playing: **\n" + track.getInfo().uri + "\n```" + track.getInfo().title + "\nBy: "
|
||||||
|
+ track.getInfo().author + "\nLength: " + Util.getTime(track.getDuration());
|
||||||
|
if(showRemaining) {
|
||||||
|
msg = msg + "\nTime Remaining: " + Util.getTime(track.getDuration() - track.getPosition()) + "```";
|
||||||
|
}else {
|
||||||
|
msg = msg + "```";
|
||||||
|
}
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void wipeQueue() {
|
||||||
|
queue.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Biscuit getBiscuit() {
|
||||||
|
return biscuit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void log(String message) {
|
||||||
|
if(biscuit.getProperties().logMusicPlayer()) {
|
||||||
|
biscuit.log(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void warn(String message) {
|
||||||
|
if(biscuit.getProperties().logMusicPlayer()) {
|
||||||
|
biscuit.warn(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,132 @@
|
||||||
|
package com.fpghoti.biscuit.audio.queue;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
|
||||||
|
|
||||||
|
public class AudioQueue {
|
||||||
|
|
||||||
|
private ArrayList<QueuedTrack> tracks;
|
||||||
|
private ArrayList<QueuedTrack> previousTracks;
|
||||||
|
|
||||||
|
public AudioQueue() {
|
||||||
|
this.tracks = new ArrayList<QueuedTrack>();
|
||||||
|
this.previousTracks = new ArrayList<QueuedTrack>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<QueuedTrack> getUserTracks(String userId){
|
||||||
|
ArrayList<QueuedTrack> tracks = new ArrayList<QueuedTrack>();
|
||||||
|
for(QueuedTrack qt : tracks) {
|
||||||
|
if(qt.getUserId().equals(userId)) {
|
||||||
|
tracks.add(qt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return tracks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeUserTracks(String userId) {
|
||||||
|
for(QueuedTrack qt : getUserTracks(userId)) {
|
||||||
|
tracks.remove(qt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void playNext() {
|
||||||
|
QueuedTrack next = tracks.iterator().next();
|
||||||
|
tracks.remove(next);
|
||||||
|
addPreviousTrack(next);
|
||||||
|
next.getBiscuit().getAudioPlayer().playTrack(next.getTrack());
|
||||||
|
}
|
||||||
|
|
||||||
|
public QueuedTrack getTrack(int index){
|
||||||
|
return tracks.get(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
public QueuedTrack getTrack(AudioTrack track) {
|
||||||
|
for(QueuedTrack qt : tracks) {
|
||||||
|
if(qt.getTrack() == track) {
|
||||||
|
return qt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public QueuedTrack getPreviousTrack(AudioTrack track) {
|
||||||
|
for(QueuedTrack qt : previousTracks) {
|
||||||
|
if(qt.getTrack() == track) {
|
||||||
|
return qt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public QueuedTrack getLastTrack() {
|
||||||
|
if(previousTracks.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return previousTracks.get(previousTracks.size() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addPreviousTrack(QueuedTrack track) {
|
||||||
|
//AudioQueue will remember up to three
|
||||||
|
//previous tracks for the purposes of
|
||||||
|
//reporting errors ect.
|
||||||
|
previousTracks.add(track);
|
||||||
|
if(previousTracks.size() > 3) {
|
||||||
|
previousTracks.remove(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add(QueuedTrack track) {
|
||||||
|
tracks.add(track);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Goes by viewable place rather than index for
|
||||||
|
//easy implementation into command.
|
||||||
|
public boolean addAtPlace(QueuedTrack track, int place) {
|
||||||
|
if(place < 1 || place > tracks.size()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
int index = place - 1;
|
||||||
|
tracks.add(index, track);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Goes by viewable place rather than index for
|
||||||
|
//easy implementation into command.
|
||||||
|
public boolean moveToPlace(int oldPlace, int newPlace) {
|
||||||
|
QueuedTrack track = tracks.get(oldPlace - 1);
|
||||||
|
if(track == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
tracks.remove(track);
|
||||||
|
return addAtPlace(track, newPlace);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Goes by viewable place rather than index for
|
||||||
|
//easy implementation into command.
|
||||||
|
public boolean removeTrack(int place) {
|
||||||
|
QueuedTrack track = tracks.get(place - 1);
|
||||||
|
if(track == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
tracks.remove(track);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public QueuedTrack getNext() {
|
||||||
|
return tracks.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return tracks.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clear() {
|
||||||
|
tracks.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int size() {
|
||||||
|
return tracks.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
package com.fpghoti.biscuit.audio.queue;
|
||||||
|
|
||||||
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
|
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
|
import net.dv8tion.jda.api.entities.TextChannel;
|
||||||
|
|
||||||
|
public class QueuedTrack {
|
||||||
|
|
||||||
|
private Biscuit biscuit;
|
||||||
|
private AudioTrack track;
|
||||||
|
private String userId;
|
||||||
|
private TextChannel channel;
|
||||||
|
|
||||||
|
public QueuedTrack(Biscuit biscuit, AudioTrack track, String userId, TextChannel channel) {
|
||||||
|
this.biscuit = biscuit;
|
||||||
|
this.track = track;
|
||||||
|
this.userId = userId;
|
||||||
|
this.channel = channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Biscuit getBiscuit() {
|
||||||
|
return biscuit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AudioTrack getTrack() {
|
||||||
|
return track;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserId() {
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Member getMember() {
|
||||||
|
return biscuit.getGuild().getMemberById(userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextChannel getCommandChannel() {
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -9,6 +9,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.PluginCore;
|
import com.fpghoti.biscuit.PluginCore;
|
||||||
|
import com.fpghoti.biscuit.audio.AudioScheduler;
|
||||||
import com.fpghoti.biscuit.captcha.BCage;
|
import com.fpghoti.biscuit.captcha.BCage;
|
||||||
import com.fpghoti.biscuit.config.BiscuitConfig;
|
import com.fpghoti.biscuit.config.BiscuitConfig;
|
||||||
import com.fpghoti.biscuit.config.BiscuitProperties;
|
import com.fpghoti.biscuit.config.BiscuitProperties;
|
||||||
|
@ -20,6 +21,7 @@ import com.fpghoti.biscuit.timer.task.DecrementTimer;
|
||||||
import com.fpghoti.biscuit.timer.task.SoftMuteTimer;
|
import com.fpghoti.biscuit.timer.task.SoftMuteTimer;
|
||||||
import com.fpghoti.biscuit.user.PreUser;
|
import com.fpghoti.biscuit.user.PreUser;
|
||||||
import com.github.cage.Cage;
|
import com.github.cage.Cage;
|
||||||
|
import com.sedmelluq.discord.lavaplayer.player.AudioPlayer;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.JDA;
|
import net.dv8tion.jda.api.JDA;
|
||||||
import net.dv8tion.jda.api.Permission;
|
import net.dv8tion.jda.api.Permission;
|
||||||
|
@ -85,6 +87,8 @@ public class Biscuit {
|
||||||
private BiscuitConfig config;
|
private BiscuitConfig config;
|
||||||
private BiscuitProperties properties;
|
private BiscuitProperties properties;
|
||||||
private BiscuitMessageStore messageStore;
|
private BiscuitMessageStore messageStore;
|
||||||
|
private AudioPlayer player;
|
||||||
|
private AudioScheduler scheduler;
|
||||||
|
|
||||||
private CopyOnWriteArrayList<PreUser> users = new CopyOnWriteArrayList<PreUser>();
|
private CopyOnWriteArrayList<PreUser> users = new CopyOnWriteArrayList<PreUser>();
|
||||||
private HashMap<Member, Role> rolequeue;
|
private HashMap<Member, Role> rolequeue;
|
||||||
|
@ -99,6 +103,11 @@ public class Biscuit {
|
||||||
config.generateConfig();
|
config.generateConfig();
|
||||||
this.properties = new BiscuitProperties(this);
|
this.properties = new BiscuitProperties(this);
|
||||||
this.rolequeue = new HashMap<Member, Role>();
|
this.rolequeue = new HashMap<Member, Role>();
|
||||||
|
this.player = Main.getPlayerManager().createPlayer();
|
||||||
|
|
||||||
|
scheduler = new AudioScheduler(this);
|
||||||
|
player.addListener(scheduler);
|
||||||
|
|
||||||
timer = new Timer();
|
timer = new Timer();
|
||||||
timers = new ArrayList<BiscuitTimer>();
|
timers = new ArrayList<BiscuitTimer>();
|
||||||
if(!Main.isPlugin) {
|
if(!Main.isPlugin) {
|
||||||
|
@ -143,6 +152,14 @@ public class Biscuit {
|
||||||
return guild.getSelfMember().hasPermission(Permission.MANAGE_SERVER);
|
return guild.getSelfMember().hasPermission(Permission.MANAGE_SERVER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AudioPlayer getAudioPlayer() {
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AudioScheduler getAudioScheduler() {
|
||||||
|
return scheduler;
|
||||||
|
}
|
||||||
|
|
||||||
public void log(String message) {
|
public void log(String message) {
|
||||||
if(properties == null) {
|
if(properties == null) {
|
||||||
logger.info(message);
|
logger.info(message);
|
||||||
|
|
|
@ -5,6 +5,10 @@ import java.util.List;
|
||||||
|
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
|
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||||
|
import com.fpghoti.biscuit.commands.base.ConsoleCommand;
|
||||||
|
import com.fpghoti.biscuit.commands.base.CustomCommand;
|
||||||
|
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
||||||
import com.fpghoti.biscuit.util.PermUtil;
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
import com.fpghoti.biscuit.util.Util;
|
import com.fpghoti.biscuit.util.Util;
|
||||||
|
|
||||||
|
@ -69,6 +73,11 @@ public class CommandManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(match != null) {
|
if(match != null) {
|
||||||
|
|
||||||
|
if(match instanceof MusicClientCommand && !b.getProperties().allowMusicBot()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (trimmedArgs == null || (trimmedArgs.length > 0 && trimmedArgs[0].equals("?"))) {
|
if (trimmedArgs == null || (trimmedArgs.length > 0 && trimmedArgs[0].equals("?"))) {
|
||||||
commandReply(e, "``Command:" + " " + match.getName() + "``");
|
commandReply(e, "``Command:" + " " + match.getName() + "``");
|
||||||
commandReply(e, "``Description:" + " " + match.getDescription() + "``");
|
commandReply(e, "``Description:" + " " + match.getDescription() + "``");
|
||||||
|
@ -118,6 +127,9 @@ public class CommandManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addCommand(BaseCommand command) {
|
public static void addCommand(BaseCommand command) {
|
||||||
|
if(command instanceof MusicClientCommand && !Main.getMainBiscuit().getProperties().musicBotEnabled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
commands.add(command);
|
commands.add(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
package com.fpghoti.biscuit.commands;
|
package com.fpghoti.biscuit.commands.base;
|
||||||
|
|
||||||
|
import com.fpghoti.biscuit.commands.BaseCommand;
|
||||||
|
import com.fpghoti.biscuit.commands.CommandType;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
package com.fpghoti.biscuit.commands;
|
package com.fpghoti.biscuit.commands.base;
|
||||||
|
|
||||||
|
import com.fpghoti.biscuit.commands.BaseCommand;
|
||||||
|
import com.fpghoti.biscuit.commands.CommandType;
|
||||||
|
|
||||||
public abstract class ConsoleCommand extends BaseCommand{
|
public abstract class ConsoleCommand extends BaseCommand{
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package com.fpghoti.biscuit.commands;
|
package com.fpghoti.biscuit.commands.base;
|
||||||
|
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
|
import com.fpghoti.biscuit.commands.BaseCommand;
|
||||||
|
import com.fpghoti.biscuit.commands.CommandType;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
package com.fpghoti.biscuit.commands.base;
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
||||||
|
public abstract class MusicClientCommand extends ClientCommand{
|
||||||
|
|
||||||
|
public abstract void execute(String[] args, MessageReceivedEvent event);
|
||||||
|
|
||||||
|
}
|
|
@ -2,7 +2,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
|
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||||
import com.fpghoti.biscuit.util.Util;
|
import com.fpghoti.biscuit.util.Util;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
|
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
|
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||||
import com.fpghoti.biscuit.util.Util;
|
import com.fpghoti.biscuit.util.Util;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
package com.fpghoti.biscuit.commands.client;
|
||||||
|
|
||||||
|
import com.fpghoti.biscuit.Main;
|
||||||
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
|
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
||||||
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
||||||
|
public class ForceSkipCommand extends MusicClientCommand{
|
||||||
|
|
||||||
|
public ForceSkipCommand() {
|
||||||
|
name = "Force Skip";
|
||||||
|
description = "Forces the current song to be skipped.";
|
||||||
|
usage = Main.getMainBiscuit().getProperties().getCommandSignifier() + "forceskip";
|
||||||
|
minArgs = 0;
|
||||||
|
maxArgs = 0;
|
||||||
|
identifiers.add("forceskip");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(String[] args, MessageReceivedEvent event) {
|
||||||
|
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||||
|
b.log(event.getAuthor().getName() + " issued a command: -forceskip");
|
||||||
|
if(PermUtil.isMod(event.getMember())) {
|
||||||
|
event.getChannel().sendMessage("Force skipping current song.").queue();
|
||||||
|
if(b.getAudioScheduler().getNextMessage() != null ) {
|
||||||
|
event.getChannel().sendMessage(b.getAudioScheduler().getNextMessage()).queue();
|
||||||
|
}
|
||||||
|
b.getAudioScheduler().skip();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -5,7 +5,7 @@ import java.util.function.Consumer;
|
||||||
|
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||||
import com.fpghoti.biscuit.logging.BColor;
|
import com.fpghoti.biscuit.logging.BColor;
|
||||||
import com.fpghoti.biscuit.util.PermUtil;
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
|
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||||
import com.fpghoti.biscuit.util.PermUtil;
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
|
@ -6,9 +6,10 @@ import java.util.List;
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.BaseCommand;
|
import com.fpghoti.biscuit.commands.BaseCommand;
|
||||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
|
||||||
import com.fpghoti.biscuit.commands.CommandManager;
|
import com.fpghoti.biscuit.commands.CommandManager;
|
||||||
import com.fpghoti.biscuit.commands.CustomCommand;
|
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||||
|
import com.fpghoti.biscuit.commands.base.CustomCommand;
|
||||||
|
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
||||||
import com.fpghoti.biscuit.util.Util;
|
import com.fpghoti.biscuit.util.Util;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
@ -38,7 +39,7 @@ public class HelpCommand extends ClientCommand {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<BaseCommand> commands = new ArrayList<BaseCommand>();
|
List<BaseCommand> commands = new ArrayList<BaseCommand>();
|
||||||
|
|
||||||
String[] ccs = biscuit.getProperties().getCustomCmds();
|
String[] ccs = biscuit.getProperties().getCustomCmds();
|
||||||
for(String s : ccs) {
|
for(String s : ccs) {
|
||||||
if(!Util.contains(biscuit.getProperties().disabledCommands(), s)) {
|
if(!Util.contains(biscuit.getProperties().disabledCommands(), s)) {
|
||||||
|
@ -53,11 +54,17 @@ public class HelpCommand extends ClientCommand {
|
||||||
commands.add(cc);
|
commands.add(cc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(BaseCommand bc : CommandManager.getCommands()) {
|
for(BaseCommand bc : CommandManager.getCommands()) {
|
||||||
String bclabel = bc.getUsage().split(" ")[0];
|
String bclabel = bc.getUsage().split(" ")[0];
|
||||||
if(!Util.contains(biscuit.getProperties().disabledCommands(), bclabel.replace(Main.getMainBiscuit().getProperties().getCommandSignifier(), ""))) {
|
if(!Util.contains(biscuit.getProperties().disabledCommands(), bclabel.replace(Main.getMainBiscuit().getProperties().getCommandSignifier(), ""))) {
|
||||||
commands.add(bc);
|
if(bc instanceof MusicClientCommand) {
|
||||||
|
if(biscuit.getProperties().allowMusicBot()) {
|
||||||
|
commands.add(bc);
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
commands.add(bc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int pageCount = (int) Math.ceil((double) commands.size() / 8);
|
int pageCount = (int) Math.ceil((double) commands.size() / 8);
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.fpghoti.biscuit.commands.client;
|
||||||
|
|
||||||
|
import com.fpghoti.biscuit.Main;
|
||||||
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
|
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
||||||
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
||||||
|
public class LoopMusicCommand extends MusicClientCommand{
|
||||||
|
|
||||||
|
public LoopMusicCommand() {
|
||||||
|
name = "Loop Music";
|
||||||
|
description = "Enables looping of all songs played.";
|
||||||
|
usage = Main.getMainBiscuit().getProperties().getCommandSignifier() + "loopmusic";
|
||||||
|
minArgs = 0;
|
||||||
|
maxArgs = 0;
|
||||||
|
identifiers.add("loopmusic");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(String[] args, MessageReceivedEvent event) {
|
||||||
|
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||||
|
b.log(event.getAuthor().getName() + " issued a command: -loopmusic");
|
||||||
|
if(PermUtil.isMod(event.getMember())) {
|
||||||
|
if(!b.getAudioScheduler().isLooping()) {
|
||||||
|
event.getChannel().sendMessage("Setting all music to loop.").queue();
|
||||||
|
b.getAudioScheduler().setLooping(true);
|
||||||
|
}else {
|
||||||
|
event.getChannel().sendMessage("Disabling music looping.").queue();
|
||||||
|
b.getAudioScheduler().setLooping(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -2,7 +2,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
|
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||||
import com.fpghoti.biscuit.util.PermUtil;
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
import com.fpghoti.biscuit.util.Util;
|
import com.fpghoti.biscuit.util.Util;
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
|
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||||
import com.fpghoti.biscuit.util.Util;
|
import com.fpghoti.biscuit.util.Util;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
|
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||||
import com.fpghoti.biscuit.util.PermUtil;
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
package com.fpghoti.biscuit.commands.client;
|
||||||
|
|
||||||
|
import com.fpghoti.biscuit.Main;
|
||||||
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
|
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
||||||
|
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
||||||
|
public class NowPlayingCommand extends MusicClientCommand{
|
||||||
|
|
||||||
|
public NowPlayingCommand() {
|
||||||
|
name = "Now Playing";
|
||||||
|
description = "Displays the currently playing song.";
|
||||||
|
usage = Main.getMainBiscuit().getProperties().getCommandSignifier() + "nowplaying";
|
||||||
|
minArgs = 0;
|
||||||
|
maxArgs = 0;
|
||||||
|
identifiers.add("nowplaying");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(String[] args, MessageReceivedEvent event) {
|
||||||
|
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||||
|
b.log(event.getAuthor().getName() + " issued a command: -nowplaying");
|
||||||
|
if(b.getAudioPlayer().getPlayingTrack() != null) {
|
||||||
|
AudioTrack track = b.getAudioPlayer().getPlayingTrack();
|
||||||
|
event.getChannel().sendMessage(b.getAudioScheduler().getMessage(track, true)).queue();
|
||||||
|
}else {
|
||||||
|
event.getChannel().sendMessage("No song is currently playing.").queue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.fpghoti.biscuit.commands.client;
|
||||||
|
|
||||||
|
import com.fpghoti.biscuit.Main;
|
||||||
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
|
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
||||||
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
||||||
|
public class PauseCommand extends MusicClientCommand{
|
||||||
|
|
||||||
|
public PauseCommand() {
|
||||||
|
name = "Pause";
|
||||||
|
description = "Pauses the current track.";
|
||||||
|
usage = Main.getMainBiscuit().getProperties().getCommandSignifier() + "pause";
|
||||||
|
minArgs = 0;
|
||||||
|
maxArgs = 0;
|
||||||
|
identifiers.add("pause");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(String[] args, MessageReceivedEvent event) {
|
||||||
|
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||||
|
b.log(event.getAuthor().getName() + " issued a command: -pause");
|
||||||
|
if(PermUtil.isMod(event.getMember())) {
|
||||||
|
if(!b.getAudioPlayer().isPaused()) {
|
||||||
|
b.getAudioPlayer().setPaused(true);
|
||||||
|
event.getChannel().sendMessage("Paused the current track.").queue();
|
||||||
|
}else {
|
||||||
|
event.getChannel().sendMessage("The music player is already paused.").queue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -2,7 +2,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
|
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,89 @@
|
||||||
|
package com.fpghoti.biscuit.commands.client;
|
||||||
|
|
||||||
|
import com.fpghoti.biscuit.Main;
|
||||||
|
import com.fpghoti.biscuit.audio.AudioHandler;
|
||||||
|
import com.fpghoti.biscuit.audio.AudioResultHandler;
|
||||||
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
|
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
||||||
|
import com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager;
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.entities.Guild;
|
||||||
|
import net.dv8tion.jda.api.entities.TextChannel;
|
||||||
|
import net.dv8tion.jda.api.entities.VoiceChannel;
|
||||||
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
import net.dv8tion.jda.api.managers.AudioManager;
|
||||||
|
|
||||||
|
public class PlayCommand extends MusicClientCommand{
|
||||||
|
|
||||||
|
public PlayCommand() {
|
||||||
|
name = "Play";
|
||||||
|
description = "Plays the specified song or plays a song found using search parameters.";
|
||||||
|
usage = Main.getMainBiscuit().getProperties().getCommandSignifier() + "play <YouTube link OR Search Phrase>";
|
||||||
|
minArgs = 1;
|
||||||
|
maxArgs = 2000;
|
||||||
|
identifiers.add("play");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(String[] args, MessageReceivedEvent event) {
|
||||||
|
Guild guild = event.getGuild();
|
||||||
|
Biscuit b = Biscuit.getBiscuit(guild);
|
||||||
|
TextChannel tchannel = event.getTextChannel();
|
||||||
|
|
||||||
|
String searchPhrase = args[0];
|
||||||
|
if(args.length > 1) {
|
||||||
|
for(int i = 1; i < args.length; i++) {
|
||||||
|
searchPhrase = searchPhrase + " " + args[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
b.log(event.getAuthor().getName() + " issued a command: -play " + searchPhrase);
|
||||||
|
|
||||||
|
String vcname = "";
|
||||||
|
if(!event.getMember().getVoiceState().inVoiceChannel()) {
|
||||||
|
tchannel.sendMessage("You must be in a voice channel to do this!").queue();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
vcname = event.getMember().getVoiceState().getChannel().getName();
|
||||||
|
String[] musicChannels = b.getProperties().getMusicChannels();
|
||||||
|
if(musicChannels.length >= 1) {
|
||||||
|
boolean found = false;
|
||||||
|
for(String cname : musicChannels) {
|
||||||
|
if(event.getMember().getVoiceState().getChannel().getName().equalsIgnoreCase(cname)) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(found == false) {
|
||||||
|
tchannel.sendMessage("You are not in a channel that is authorized to use the music player.").queue();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(b.getAudioPlayer().getPlayingTrack() != null && guild.getAudioManager().isConnected() && !guild.getAudioManager().getConnectedChannel().getMembers().contains(event.getMember())) {
|
||||||
|
tchannel.sendMessage("Music is already playing in a voice channel. Connect to "
|
||||||
|
+ "that channel, then queue your song.").queue();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
VoiceChannel channel = guild.getVoiceChannelsByName(vcname, true).get(0);
|
||||||
|
AudioManager manager = guild.getAudioManager();
|
||||||
|
|
||||||
|
manager.setSendingHandler(new AudioHandler(b.getAudioPlayer()));
|
||||||
|
manager.openAudioConnection(channel);
|
||||||
|
|
||||||
|
AudioPlayerManager playerManager = Main.getPlayerManager();
|
||||||
|
String vidid = getID(event.getMessage().getContentRaw().split(" ")[1]);
|
||||||
|
|
||||||
|
playerManager.loadItemOrdered(guild, vidid, new AudioResultHandler(b,event.getAuthor().getId(), tchannel, false, searchPhrase));
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getID(String url) {
|
||||||
|
String[] s = url.split("=");
|
||||||
|
if(s.length > 1) {
|
||||||
|
return s[1].split("&")[0];
|
||||||
|
}
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,96 @@
|
||||||
|
package com.fpghoti.biscuit.commands.client;
|
||||||
|
|
||||||
|
import com.fpghoti.biscuit.Main;
|
||||||
|
import com.fpghoti.biscuit.audio.AudioHandler;
|
||||||
|
import com.fpghoti.biscuit.audio.AudioResultHandler;
|
||||||
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
|
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
||||||
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
|
import com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager;
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.entities.Guild;
|
||||||
|
import net.dv8tion.jda.api.entities.TextChannel;
|
||||||
|
import net.dv8tion.jda.api.entities.VoiceChannel;
|
||||||
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
import net.dv8tion.jda.api.managers.AudioManager;
|
||||||
|
|
||||||
|
public class PlayFirstCommand extends MusicClientCommand{
|
||||||
|
|
||||||
|
public PlayFirstCommand() {
|
||||||
|
name = "Play First";
|
||||||
|
description = "Places specified song at the front of the queue.";
|
||||||
|
usage = Main.getMainBiscuit().getProperties().getCommandSignifier() + "playfirst <YouTube link OR Search Phrase>";
|
||||||
|
minArgs = 1;
|
||||||
|
maxArgs = 2000;
|
||||||
|
identifiers.add("playfirst");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(String[] args, MessageReceivedEvent event) {
|
||||||
|
Guild guild = event.getGuild();
|
||||||
|
Biscuit b = Biscuit.getBiscuit(guild);
|
||||||
|
TextChannel tchannel = event.getTextChannel();
|
||||||
|
|
||||||
|
String searchPhrase = args[0];
|
||||||
|
if(args.length > 1) {
|
||||||
|
for(int i = 1; i < args.length; i++) {
|
||||||
|
searchPhrase = searchPhrase + " " + args[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
b.log(event.getAuthor().getName() + " issued a command: -play " + searchPhrase);
|
||||||
|
|
||||||
|
String vcname = "";
|
||||||
|
|
||||||
|
if(!PermUtil.isMod(event.getMember())) {
|
||||||
|
tchannel.sendMessage("You do not have permission to do this!").queue();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!event.getMember().getVoiceState().inVoiceChannel()) {
|
||||||
|
tchannel.sendMessage("You must be in a voice channel to do this!").queue();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
vcname = event.getMember().getVoiceState().getChannel().getName();
|
||||||
|
String[] musicChannels = b.getProperties().getMusicChannels();
|
||||||
|
if(musicChannels.length >= 1) {
|
||||||
|
boolean found = false;
|
||||||
|
for(String cname : musicChannels) {
|
||||||
|
if(event.getMember().getVoiceState().getChannel().getName().equalsIgnoreCase(cname)) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(found == false) {
|
||||||
|
tchannel.sendMessage("You are not in a channel that is authorized to use the music player.").queue();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(b.getAudioPlayer().getPlayingTrack() != null && guild.getAudioManager().isConnected() && !guild.getAudioManager().getConnectedChannel().getMembers().contains(event.getMember())) {
|
||||||
|
tchannel.sendMessage("Music is already playing in a voice channel. Connect to "
|
||||||
|
+ "that channel, then queue your song.").queue();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
VoiceChannel channel = guild.getVoiceChannelsByName(vcname, true).get(0);
|
||||||
|
AudioManager manager = guild.getAudioManager();
|
||||||
|
|
||||||
|
manager.setSendingHandler(new AudioHandler(b.getAudioPlayer()));
|
||||||
|
manager.openAudioConnection(channel);
|
||||||
|
|
||||||
|
AudioPlayerManager playerManager = Main.getPlayerManager();
|
||||||
|
String vidid = getID(event.getMessage().getContentRaw().split(" ")[1]);
|
||||||
|
|
||||||
|
playerManager.loadItemOrdered(guild, vidid, new AudioResultHandler(b,event.getAuthor().getId(), tchannel, false, searchPhrase, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getID(String url) {
|
||||||
|
String[] s = url.split("=");
|
||||||
|
if(s.length > 1) {
|
||||||
|
return s[1].split("&")[0];
|
||||||
|
}
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -2,7 +2,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
|
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||||
import com.fpghoti.biscuit.util.Util;
|
import com.fpghoti.biscuit.util.Util;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
|
@ -0,0 +1,83 @@
|
||||||
|
package com.fpghoti.biscuit.commands.client;
|
||||||
|
|
||||||
|
import com.fpghoti.biscuit.Main;
|
||||||
|
import com.fpghoti.biscuit.audio.queue.AudioQueue;
|
||||||
|
import com.fpghoti.biscuit.audio.queue.QueuedTrack;
|
||||||
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
|
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
||||||
|
import com.fpghoti.biscuit.util.Util;
|
||||||
|
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
||||||
|
public class QueueCommand extends MusicClientCommand{
|
||||||
|
|
||||||
|
public QueueCommand() {
|
||||||
|
name = "Queue";
|
||||||
|
description = "Displays the upcoming songs in the music queue.";
|
||||||
|
usage = Main.getMainBiscuit().getProperties().getCommandSignifier() + "queue [Page #]";
|
||||||
|
minArgs = 0;
|
||||||
|
maxArgs = 1;
|
||||||
|
identifiers.add("queue");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(String[] args, MessageReceivedEvent event) {
|
||||||
|
|
||||||
|
Biscuit biscuit = Biscuit.getBiscuit(event.getGuild());
|
||||||
|
biscuit.log(event.getAuthor().getName() + " issued a command: -queue");
|
||||||
|
int pg = 1;
|
||||||
|
if (args.length > 0) {
|
||||||
|
if(Util.isDigit(args[0])) {
|
||||||
|
pg = Integer.parseInt(args[0]);
|
||||||
|
}else {
|
||||||
|
event.getTextChannel().sendMessage("Usage: ``" + usage + "``").queue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AudioQueue queue = biscuit.getAudioScheduler().getQueue();
|
||||||
|
|
||||||
|
int pageCount = (int) Math.ceil((double) queue.size() / 8);
|
||||||
|
if (pg > pageCount) {
|
||||||
|
pg = pageCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(queue.size() == 0) {
|
||||||
|
if(biscuit.getAudioPlayer().getPlayingTrack() == null) {
|
||||||
|
event.getTextChannel().sendMessage("There is currently no song playing.").queue();
|
||||||
|
}else {
|
||||||
|
event.getTextChannel().sendMessage("Nothing is queued to play after the current track.").queue();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.getTextChannel().sendMessage("**Use " + Main.getMainBiscuit().getProperties().getCommandSignifier() + "queue [Page #] to navigate the different pages.**").queue();
|
||||||
|
event.getTextChannel().sendMessage("[" + Integer.toString(pg) + "/" + Integer.toString(pageCount) + "] ** Upcoming Music Tracks:**").queue();
|
||||||
|
String msg = "";
|
||||||
|
for (int i = 0; i < 8; i++) {
|
||||||
|
int index = (pg - 1) * 8 + i;
|
||||||
|
int count = index + 1;
|
||||||
|
String line = "";
|
||||||
|
if (index < queue.size()) {
|
||||||
|
QueuedTrack track = queue.getTrack(index);
|
||||||
|
AudioTrack a = track.getTrack();
|
||||||
|
Member m = track.getMember();
|
||||||
|
line = "**" + count + ".** " + a.getInfo().title + " [" + Util.getTime(a.getInfo().length) + "]";
|
||||||
|
if(m != null) {
|
||||||
|
line = line + " Added by: **" + m.getEffectiveName() + "**";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!(index + 1 >= queue.size() || index == 7)) {
|
||||||
|
line = line + "\n";
|
||||||
|
}
|
||||||
|
if (index < queue.size()) {
|
||||||
|
msg = msg + line;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
event.getTextChannel().sendMessage(msg).queue();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -2,7 +2,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
|
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import java.util.function.Consumer;
|
||||||
|
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||||
import com.fpghoti.biscuit.logging.BColor;
|
import com.fpghoti.biscuit.logging.BColor;
|
||||||
import com.fpghoti.biscuit.util.PermUtil;
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
package com.fpghoti.biscuit.commands.client;
|
||||||
|
|
||||||
|
import com.fpghoti.biscuit.Main;
|
||||||
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
|
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
||||||
|
public class SkipCommand extends MusicClientCommand{
|
||||||
|
|
||||||
|
public SkipCommand() {
|
||||||
|
name = "Skip";
|
||||||
|
description = "Sends a vote to skip the song that is currently playing.";
|
||||||
|
usage = Main.getMainBiscuit().getProperties().getCommandSignifier() + "skip";
|
||||||
|
minArgs = 0;
|
||||||
|
maxArgs = 0;
|
||||||
|
identifiers.add("skip");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(String[] args, MessageReceivedEvent event) {
|
||||||
|
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||||
|
b.log(event.getAuthor().getName() + " issued a command: -skip");
|
||||||
|
|
||||||
|
if(b.getAudioPlayer().getPlayingTrack() == null) {
|
||||||
|
event.getChannel().sendMessage("There is not a song playing for you to skip!").queue();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!event.getGuild().getAudioManager().getConnectedChannel().getMembers().contains(event.getMember())) {
|
||||||
|
event.getChannel().sendMessage("You need to be in the same voice channel in order to skip!").queue();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(b.getAudioScheduler().getVotes() >= (event.getGuild().getAudioManager().getConnectedChannel().getMembers().size() - 1) / 2) {
|
||||||
|
event.getChannel().sendMessage("Skip vote status: **[" + ( b.getAudioScheduler().getVotes() + 1) + "/"
|
||||||
|
+ (event.getGuild().getAudioManager().getConnectedChannel().getMembers().size() - 1) + "]**"
|
||||||
|
+ "\nSkipping current track.").queue();
|
||||||
|
if(b.getAudioScheduler().getNextMessage() != null ) {
|
||||||
|
event.getChannel().sendMessage(b.getAudioScheduler().getNextMessage()).queue();
|
||||||
|
}
|
||||||
|
b.getAudioScheduler().skip();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(b.getAudioScheduler().voteSkip(event.getAuthor().getId())) {
|
||||||
|
event.getChannel().sendMessage("You voted to skip the current track.").queue();
|
||||||
|
}else {
|
||||||
|
event.getChannel().sendMessage("You cannot vote to skip this track again."
|
||||||
|
+ "\nSkip vote status: **[" + b.getAudioScheduler().getVotes() + "/"
|
||||||
|
+ (event.getGuild().getAudioManager().getConnectedChannel().getMembers().size() - 1) + "]**").queue();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(b.getAudioScheduler().getVotes() >= (event.getGuild().getAudioManager().getConnectedChannel().getMembers().size() - 1) / 2) {
|
||||||
|
event.getChannel().sendMessage("Skip vote status: **[" + b.getAudioScheduler().getVotes() + "/"
|
||||||
|
+ event.getGuild().getAudioManager().getConnectedChannel().getMembers().size() + "]**"
|
||||||
|
+ "\nSkipping current track.").queue();
|
||||||
|
if(b.getAudioScheduler().getNextMessage() != null ) {
|
||||||
|
event.getChannel().sendMessage(b.getAudioScheduler().getNextMessage()).queue();
|
||||||
|
}
|
||||||
|
b.getAudioScheduler().skip();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -5,7 +5,7 @@ import java.util.function.Consumer;
|
||||||
|
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||||
import com.fpghoti.biscuit.util.PermUtil;
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
|
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||||
import com.fpghoti.biscuit.util.Util;
|
import com.fpghoti.biscuit.util.Util;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
|
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||||
import com.fpghoti.biscuit.util.Util;
|
import com.fpghoti.biscuit.util.Util;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.fpghoti.biscuit.commands.client;
|
||||||
|
|
||||||
|
import com.fpghoti.biscuit.Main;
|
||||||
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
|
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
||||||
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
||||||
|
public class TogglePauseCommand extends MusicClientCommand{
|
||||||
|
|
||||||
|
public TogglePauseCommand() {
|
||||||
|
name = "Toggle Pause";
|
||||||
|
description = "Toggles the pause status of the current track.";
|
||||||
|
usage = Main.getMainBiscuit().getProperties().getCommandSignifier() + "togglepause";
|
||||||
|
minArgs = 0;
|
||||||
|
maxArgs = 0;
|
||||||
|
identifiers.add("togglepause");
|
||||||
|
identifiers.add("tp");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(String[] args, MessageReceivedEvent event) {
|
||||||
|
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||||
|
b.log(event.getAuthor().getName() + " issued a command: -togglepause");
|
||||||
|
if(PermUtil.isMod(event.getMember())) {
|
||||||
|
if(b.getAudioPlayer().isPaused()) {
|
||||||
|
b.getAudioPlayer().setPaused(false);
|
||||||
|
event.getChannel().sendMessage("Unpaused the current track.").queue();
|
||||||
|
}else {
|
||||||
|
b.getAudioPlayer().setPaused(true);
|
||||||
|
event.getChannel().sendMessage("Paused the current track.").queue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -2,7 +2,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
|
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||||
import com.fpghoti.biscuit.util.PermUtil;
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.entities.Emote;
|
import net.dv8tion.jda.api.entities.Emote;
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
|
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||||
import com.fpghoti.biscuit.util.PermUtil;
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
|
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||||
import com.fpghoti.biscuit.util.PermUtil;
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.fpghoti.biscuit.commands.client;
|
||||||
|
|
||||||
|
import com.fpghoti.biscuit.Main;
|
||||||
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
|
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||||
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
||||||
|
public class UnpauseCommand extends ClientCommand{
|
||||||
|
|
||||||
|
public UnpauseCommand() {
|
||||||
|
name = "Unpause";
|
||||||
|
description = "Unpauses the current track.";
|
||||||
|
usage = Main.getMainBiscuit().getProperties().getCommandSignifier() + "unpause";
|
||||||
|
minArgs = 0;
|
||||||
|
maxArgs = 0;
|
||||||
|
identifiers.add("unpause");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(String[] args, MessageReceivedEvent event) {
|
||||||
|
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||||
|
b.log(event.getAuthor().getName() + " issued a command: -unpause");
|
||||||
|
if(PermUtil.isMod(event.getMember())) {
|
||||||
|
if(b.getAudioPlayer().isPaused()) {
|
||||||
|
b.getAudioPlayer().setPaused(false);
|
||||||
|
event.getChannel().sendMessage("Unpaused the current track.").queue();
|
||||||
|
}else {
|
||||||
|
event.getChannel().sendMessage("The music player is not paused.").queue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -2,7 +2,7 @@ package com.fpghoti.biscuit.commands.client;
|
||||||
|
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.ClientCommand;
|
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||||
import com.fpghoti.biscuit.util.PermUtil;
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.fpghoti.biscuit.commands.client;
|
||||||
|
|
||||||
|
import com.fpghoti.biscuit.Main;
|
||||||
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
|
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
||||||
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
||||||
|
public class WipeQueueCommand extends MusicClientCommand{
|
||||||
|
|
||||||
|
public WipeQueueCommand() {
|
||||||
|
name = "Wipe Queue";
|
||||||
|
description = "Removes all upcoming tracks from the queue.";
|
||||||
|
usage = Main.getMainBiscuit().getProperties().getCommandSignifier() + "wipequeue";
|
||||||
|
minArgs = 0;
|
||||||
|
maxArgs = 0;
|
||||||
|
identifiers.add("wipequeue");
|
||||||
|
identifiers.add("wipeq");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(String[] args, MessageReceivedEvent event) {
|
||||||
|
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||||
|
b.log(event.getAuthor().getName() + " issued a command: -wipequeue");
|
||||||
|
if(PermUtil.isMod(event.getMember())) {
|
||||||
|
b.getAudioScheduler().wipeQueue();
|
||||||
|
event.getChannel().sendMessage("Removed upcoming songs from the music queue.").queue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -2,7 +2,7 @@ package com.fpghoti.biscuit.commands.console;
|
||||||
|
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.ConsoleCommand;
|
import com.fpghoti.biscuit.commands.base.ConsoleCommand;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.entities.Guild;
|
import net.dv8tion.jda.api.entities.Guild;
|
||||||
import net.dv8tion.jda.api.entities.TextChannel;
|
import net.dv8tion.jda.api.entities.TextChannel;
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.fpghoti.biscuit.commands.console;
|
||||||
|
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
import com.fpghoti.biscuit.commands.ConsoleCommand;
|
import com.fpghoti.biscuit.commands.base.ConsoleCommand;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.entities.Guild;
|
import net.dv8tion.jda.api.entities.Guild;
|
||||||
import net.dv8tion.jda.api.entities.TextChannel;
|
import net.dv8tion.jda.api.entities.TextChannel;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.fpghoti.biscuit.commands.console;
|
package com.fpghoti.biscuit.commands.console;
|
||||||
|
|
||||||
import com.fpghoti.biscuit.Main;
|
import com.fpghoti.biscuit.Main;
|
||||||
import com.fpghoti.biscuit.commands.ConsoleCommand;
|
import com.fpghoti.biscuit.commands.base.ConsoleCommand;
|
||||||
|
|
||||||
public class ShutdownConsoleCommand extends ConsoleCommand{
|
public class ShutdownConsoleCommand extends ConsoleCommand{
|
||||||
|
|
||||||
|
|
|
@ -132,6 +132,8 @@ public class BiscuitConfig {
|
||||||
if(isMain) {
|
if(isMain) {
|
||||||
added = addProperty("Command-Signifier", "-", prop, added, silent);
|
added = addProperty("Command-Signifier", "-", prop, added, silent);
|
||||||
added = addProperty("Bot-Token", "", prop, added, silent);
|
added = addProperty("Bot-Token", "", prop, added, silent);
|
||||||
|
added = addProperty("Enable-Music-Bot", "true", prop, added, silent);
|
||||||
|
added = addProperty("Log-Music-Player", "true", prop, added, silent);
|
||||||
}
|
}
|
||||||
|
|
||||||
added = addProperty("Guild-Identifier", name, prop, added, silent);
|
added = addProperty("Guild-Identifier", name, prop, added, silent);
|
||||||
|
@ -175,6 +177,8 @@ public class BiscuitConfig {
|
||||||
added = addProperty("Custom-Command-Names", "", prop, added, silent);
|
added = addProperty("Custom-Command-Names", "", prop, added, silent);
|
||||||
added = addProperty("DM-Before-Kick", "true", prop, added, silent);
|
added = addProperty("DM-Before-Kick", "true", prop, added, silent);
|
||||||
added = addProperty("Kick-DM-Invite", "", prop, added, silent);
|
added = addProperty("Kick-DM-Invite", "", prop, added, silent);
|
||||||
|
added = addProperty("Allow-Music-Bot", "true", prop, added, silent);
|
||||||
|
added = addProperty("Music-Channels", "", prop, added, silent);
|
||||||
|
|
||||||
if(!isMain) {
|
if(!isMain) {
|
||||||
if(code != null) {
|
if(code != null) {
|
||||||
|
|
|
@ -22,6 +22,28 @@ public class BiscuitProperties {
|
||||||
return Main.getMainBiscuit().getConfig().getFromConfig(key, Main.getMainBiscuit());
|
return Main.getMainBiscuit().getConfig().getFromConfig(key, Main.getMainBiscuit());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean musicBotEnabled(){
|
||||||
|
String key = "Enable-Music-Bot";
|
||||||
|
return Main.getMainBiscuit().getConfig().getFromConfig(key, Main.getMainBiscuit()).equalsIgnoreCase("true");
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean logMusicPlayer(){
|
||||||
|
String key = "Log-Music-Player";
|
||||||
|
return Main.getMainBiscuit().getConfig().getFromConfig(key, Main.getMainBiscuit()).equalsIgnoreCase("true");
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean allowMusicBot(){
|
||||||
|
if(!musicBotEnabled()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
String key = "Allow-Music-Bot";
|
||||||
|
if(biscuit.getConfig().getFromConfig(key, biscuit).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) {
|
||||||
|
return Main.getMainBiscuit().getProperties().allowMusicBot();
|
||||||
|
}
|
||||||
|
String value = biscuit.getConfig().getFromConfig(key, biscuit);
|
||||||
|
return value.equalsIgnoreCase("true");
|
||||||
|
}
|
||||||
|
|
||||||
public String getGuildCode(){
|
public String getGuildCode(){
|
||||||
String key = "Guild-Code";
|
String key = "Guild-Code";
|
||||||
if(biscuit.getGuild() == null) {
|
if(biscuit.getGuild() == null) {
|
||||||
|
@ -268,6 +290,19 @@ public class BiscuitProperties {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String[] getMusicChannels(){
|
||||||
|
String key = "Music-Channels";
|
||||||
|
if(biscuit.getConfig().getFromConfig(key, biscuit).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) {
|
||||||
|
return Main.getMainBiscuit().getProperties().getMusicChannels();
|
||||||
|
}
|
||||||
|
String [] list = biscuit.getConfig().getFromConfig(key, biscuit).replace(" , ", ",").replace(", ", ",").split(",");
|
||||||
|
if(list.length == 1 && list[0].equals("")) {
|
||||||
|
String[] blank = {};
|
||||||
|
return blank;
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
public String[] blockedUnicodeEmotes(){
|
public String[] blockedUnicodeEmotes(){
|
||||||
String key = "Block-Unicode-Emotes";
|
String key = "Block-Unicode-Emotes";
|
||||||
if(biscuit.getConfig().getFromConfig(key, biscuit).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) {
|
if(biscuit.getConfig().getFromConfig(key, biscuit).equalsIgnoreCase("[global]") && biscuit.getGuild() != null) {
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package com.fpghoti.biscuit.commands;
|
package com.fpghoti.biscuit.listener;
|
||||||
|
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||||
|
import com.fpghoti.biscuit.commands.CommandManager;
|
||||||
import com.fpghoti.biscuit.logging.BiscuitLog;
|
import com.fpghoti.biscuit.logging.BiscuitLog;
|
||||||
import com.fpghoti.biscuit.util.PermUtil;
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
|
|
|
@ -9,56 +9,53 @@ import com.fpghoti.biscuit.logging.BColor;
|
||||||
import com.fpghoti.biscuit.util.ChatFilter;
|
import com.fpghoti.biscuit.util.ChatFilter;
|
||||||
import com.fpghoti.biscuit.util.PermUtil;
|
import com.fpghoti.biscuit.util.PermUtil;
|
||||||
import com.fpghoti.biscuit.util.Util;
|
import com.fpghoti.biscuit.util.Util;
|
||||||
import net.dv8tion.jda.api.entities.ChannelType;
|
|
||||||
import net.dv8tion.jda.api.entities.Message;
|
import net.dv8tion.jda.api.entities.Message;
|
||||||
import net.dv8tion.jda.api.entities.Message.Attachment;
|
import net.dv8tion.jda.api.entities.Message.Attachment;
|
||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||||
|
|
||||||
public class MessageReceiveListener extends ListenerAdapter{
|
public class MessageReceiveListener extends ListenerAdapter{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMessageReceived(MessageReceivedEvent event){
|
public void onGuildMessageReceived(GuildMessageReceivedEvent event){
|
||||||
if (event.isFromType(ChannelType.TEXT)) {
|
Biscuit biscuit = Biscuit.getBiscuit(event.getGuild());
|
||||||
Biscuit biscuit = Biscuit.getBiscuit(event.getGuild());
|
if(event.getAuthor().isBot()) {
|
||||||
if(event.getAuthor().isBot()) {
|
logBot(event, biscuit);
|
||||||
logBot(event, biscuit);
|
return;
|
||||||
return;
|
}
|
||||||
}
|
PermUtil.clearUndeservedRoles(event.getMember());
|
||||||
PermUtil.clearUndeservedRoles(event.getMember());
|
|
||||||
|
|
||||||
logUser(event, biscuit);
|
logUser(event, biscuit);
|
||||||
|
|
||||||
if(isNaughty(event)) {
|
if(isNaughty(event)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(handleSoftmuted(event, biscuit)) {
|
if(handleSoftmuted(event, biscuit)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(!handleSpammer(event, biscuit) && biscuit.getProperties().spamPunishAllow()){
|
if(!handleSpammer(event, biscuit) && biscuit.getProperties().spamPunishAllow()){
|
||||||
checkNewSpammer(event, biscuit);
|
checkNewSpammer(event, biscuit);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void logBot(MessageReceivedEvent event, Biscuit biscuit) {
|
private void logBot(GuildMessageReceivedEvent event, Biscuit biscuit) {
|
||||||
if(Util.isLoggable(event.getTextChannel())) {
|
if(Util.isLoggable(event.getChannel())) {
|
||||||
if(biscuit.getProperties().logChat()) {
|
if(biscuit.getProperties().logChat()) {
|
||||||
biscuit.log("[" + BColor.BLACK_BOLD + "BOT" + BColor.RESET + "] [" + BColor.RED + "#" + event.getChannel().getName() + BColor.RESET + "] "
|
biscuit.log("[" + BColor.BLACK_BOLD + "BOT" + BColor.RESET + "] [" + BColor.RED + "#" + event.getChannel().getName() + BColor.RESET + "] "
|
||||||
+ BColor.RED_BOLD + event.getAuthor().getName() + ": " + BColor.RESET + event.getMessage().getContentDisplay());
|
+ BColor.RED_BOLD + event.getAuthor().getName() + ": " + BColor.RESET + event.getMessage().getContentDisplay());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void logUser(MessageReceivedEvent event, Biscuit biscuit) {
|
private void logUser(GuildMessageReceivedEvent event, Biscuit biscuit) {
|
||||||
if(Util.isLoggable(event.getTextChannel())) {
|
if(Util.isLoggable(event.getChannel())) {
|
||||||
if(biscuit.getProperties().logChat()) {
|
if(biscuit.getProperties().logChat()) {
|
||||||
biscuit.log("[" + BColor.CYAN_BOLD + "MSG" + BColor.RESET + "] " + BColor.GREEN + "ID: " + BColor.RESET +
|
biscuit.log("[" + BColor.CYAN_BOLD + "MSG" + BColor.RESET + "] " + BColor.GREEN + "ID: " + BColor.RESET +
|
||||||
event.getMessageId() + BColor.GREEN + " Sender: " + BColor.RESET + event.getAuthor().getAsMention() +
|
event.getMessageId() + BColor.GREEN + " Sender: " + BColor.RESET + event.getAuthor().getAsMention() +
|
||||||
BColor.GREEN + " Channel: " + BColor.RESET + event.getChannel().getName());
|
BColor.GREEN + " Channel: " + BColor.RESET + event.getChannel().getName());
|
||||||
String msg = event.getMessage().getContentDisplay();
|
String msg = event.getMessage().getContentDisplay();
|
||||||
|
|
||||||
if(event.getMessage().getAttachments().size() >= 1) {
|
if(event.getMessage().getAttachments().size() >= 1) {
|
||||||
String tail = BColor.CYAN + "[ATTACHMENT(S)]: ";
|
String tail = BColor.CYAN + "[ATTACHMENT(S)]: ";
|
||||||
if(!msg.equals("")) {
|
if(!msg.equals("")) {
|
||||||
|
@ -69,16 +66,16 @@ public class MessageReceiveListener extends ListenerAdapter{
|
||||||
}
|
}
|
||||||
msg = msg + tail;
|
msg = msg + tail;
|
||||||
}
|
}
|
||||||
|
|
||||||
biscuit.log(BColor.GREEN_BOLD + event.getAuthor().getName() + ": " + BColor.WHITE_BOLD + msg);
|
biscuit.log(BColor.GREEN_BOLD + event.getAuthor().getName() + ": " + BColor.WHITE_BOLD + msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isNaughty(MessageReceivedEvent event) {
|
private boolean isNaughty(GuildMessageReceivedEvent event) {
|
||||||
// TODO make staff filter configurable
|
// TODO make staff filter configurable
|
||||||
if(!event.getChannel().getName().toLowerCase().contains("staff") && ChatFilter.filter(event, false)){
|
if(!event.getChannel().getName().toLowerCase().contains("staff") && ChatFilter.filter(event, false)){
|
||||||
event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + " This message contains words not appropriate for this channel.").queue(new Consumer<Message>()
|
event.getChannel().sendMessage(event.getAuthor().getAsMention() + " This message contains words not appropriate for this channel.").queue(new Consumer<Message>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void accept(Message msg){
|
public void accept(Message msg){
|
||||||
|
@ -91,7 +88,7 @@ public class MessageReceiveListener extends ListenerAdapter{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean handleSpammer(MessageReceivedEvent event, Biscuit biscuit) {
|
private boolean handleSpammer(GuildMessageReceivedEvent event, Biscuit biscuit) {
|
||||||
//TODO make numbers configurable
|
//TODO make numbers configurable
|
||||||
BiscuitMessageStore store = biscuit.getMessageStore();
|
BiscuitMessageStore store = biscuit.getMessageStore();
|
||||||
String mention = event.getAuthor().getAsMention();
|
String mention = event.getAuthor().getAsMention();
|
||||||
|
@ -113,7 +110,7 @@ public class MessageReceiveListener extends ListenerAdapter{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean handleSoftmuted(MessageReceivedEvent event, Biscuit biscuit) {
|
private boolean handleSoftmuted(GuildMessageReceivedEvent event, Biscuit biscuit) {
|
||||||
//TODO make numbers configurable
|
//TODO make numbers configurable
|
||||||
BiscuitMessageStore store = biscuit.getMessageStore();
|
BiscuitMessageStore store = biscuit.getMessageStore();
|
||||||
String mention = event.getAuthor().getAsMention();
|
String mention = event.getAuthor().getAsMention();
|
||||||
|
@ -135,7 +132,7 @@ public class MessageReceiveListener extends ListenerAdapter{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkNewSpammer(MessageReceivedEvent event, Biscuit biscuit) {
|
private void checkNewSpammer(GuildMessageReceivedEvent event, Biscuit biscuit) {
|
||||||
BiscuitMessageStore store = biscuit.getMessageStore();
|
BiscuitMessageStore store = biscuit.getMessageStore();
|
||||||
String mention = event.getAuthor().getAsMention();
|
String mention = event.getAuthor().getAsMention();
|
||||||
|
|
||||||
|
@ -152,7 +149,7 @@ public class MessageReceiveListener extends ListenerAdapter{
|
||||||
store.addSpammer(event.getAuthor());
|
store.addSpammer(event.getAuthor());
|
||||||
store.removeSpamWarned(event.getAuthor());
|
store.removeSpamWarned(event.getAuthor());
|
||||||
event.getMessage().delete().submit();
|
event.getMessage().delete().submit();
|
||||||
event.getTextChannel().sendMessage("*Flagging " + mention + " as spam!*").queue(new Consumer<Message>()
|
event.getChannel().sendMessage("*Flagging " + mention + " as spam!*").queue(new Consumer<Message>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void accept(Message msg){
|
public void accept(Message msg){
|
||||||
|
@ -165,7 +162,7 @@ public class MessageReceiveListener extends ListenerAdapter{
|
||||||
}else if(!store.isSpammer(event.getAuthor()) && !store.isSpamWarned(event.getAuthor())){
|
}else if(!store.isSpammer(event.getAuthor()) && !store.isSpamWarned(event.getAuthor())){
|
||||||
store.removeMessageCount(event.getAuthor());
|
store.removeMessageCount(event.getAuthor());
|
||||||
store.addSpamWarned(event.getAuthor());
|
store.addSpamWarned(event.getAuthor());
|
||||||
event.getTextChannel().sendMessage("**STOP spamming, " + mention + "! You have been warned!**").queue(new Consumer<Message>()
|
event.getChannel().sendMessage("**STOP spamming, " + mention + "! You have been warned!**").queue(new Consumer<Message>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void accept(Message msg){
|
public void accept(Message msg){
|
||||||
|
|
|
@ -5,17 +5,17 @@ import com.fpghoti.biscuit.logging.BColor;
|
||||||
import com.vdurmont.emoji.EmojiParser;
|
import com.vdurmont.emoji.EmojiParser;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.entities.Emote;
|
import net.dv8tion.jda.api.entities.Emote;
|
||||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||||
|
|
||||||
public class ChatFilter {
|
public class ChatFilter {
|
||||||
|
|
||||||
public static String[] suffixes = {"ing","s","ed","er","es","y","ers","ier","iest","ies","ys"};
|
public static String[] suffixes = {"ing","s","ed","er","es","y","ers","ier","iest","ies","ys"};
|
||||||
|
|
||||||
public static boolean filter(MessageReceivedEvent event) {
|
public static boolean filter(GuildMessageReceivedEvent event) {
|
||||||
return filter(event, true);
|
return filter(event, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean filter(MessageReceivedEvent event, boolean silent) {
|
public static boolean filter(GuildMessageReceivedEvent event, boolean silent) {
|
||||||
Biscuit biscuit = Biscuit.getBiscuit(event.getGuild());
|
Biscuit biscuit = Biscuit.getBiscuit(event.getGuild());
|
||||||
String msg = event.getMessage().getContentDisplay();
|
String msg = event.getMessage().getContentDisplay();
|
||||||
|
|
||||||
|
|
|
@ -59,5 +59,23 @@ public class Util {
|
||||||
}
|
}
|
||||||
return s2.replace(".", "").matches("[0-9]+");
|
return s2.replace(".", "").matches("[0-9]+");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getTime(long t) {
|
||||||
|
long rawseconds = Math.round(t / 1000);
|
||||||
|
long rawminutes = Math.round(rawseconds/60);
|
||||||
|
long hour = Math.round(rawminutes/60);
|
||||||
|
long minute = rawminutes - (hour * 60);
|
||||||
|
long second = rawseconds - (rawminutes * 60);
|
||||||
|
if(hour < 0) {
|
||||||
|
hour = 0;
|
||||||
|
}
|
||||||
|
if(minute < 0) {
|
||||||
|
minute = 0;
|
||||||
|
}
|
||||||
|
if(second <= 1) {
|
||||||
|
second = 2;
|
||||||
|
}
|
||||||
|
return String.format("%02d:%02d:%02d", hour, minute, second - 1);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,6 +99,27 @@ DM-Before-Kick = true
|
||||||
#Use full link
|
#Use full link
|
||||||
Kick-DM-Invite =
|
Kick-DM-Invite =
|
||||||
|
|
||||||
|
#Enable Music Bot functionality.
|
||||||
|
#This command is for the bot admin only. If disabled, no guild
|
||||||
|
#Will be allowed to enable and use the Music bot commands.
|
||||||
|
Enable-Music-Bot = true
|
||||||
|
|
||||||
|
#Individual guild owners can enable/disable this to allow/disallow
|
||||||
|
#Music bot features in their server. Defaults to the setting
|
||||||
|
#Set in the main config.properties. This will do nothing if
|
||||||
|
#Enable-Music-Bot is already set to false.
|
||||||
|
Allow-Music-Bot = true
|
||||||
|
|
||||||
|
#This logs music player events to the terminal.
|
||||||
|
#The music player logs may be annoyance. Disable them here.
|
||||||
|
#Errors will still be logged.
|
||||||
|
Log-Music-Player = true
|
||||||
|
|
||||||
|
#To restrict music to certain channels, add them here.
|
||||||
|
#i.e:
|
||||||
|
#Music-Channels = Room 1, Room 2
|
||||||
|
Music-Channels =
|
||||||
|
|
||||||
#List your custom commands here. This line will always generate blank.
|
#List your custom commands here. This line will always generate blank.
|
||||||
#Example - Custom-Command-Names = hello,botcheck,apple
|
#Example - Custom-Command-Names = hello,botcheck,apple
|
||||||
Custom-Command-Names =
|
Custom-Command-Names =
|
||||||
|
|
Loading…
Reference in New Issue