Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c6ccbd5b6c | |||
| 52aad0a7a1 | |||
| 8d2648a895 | |||
| 6a77ea0c06 | |||
| 991d50a945 | |||
| 25acb23488 |
@@ -9,6 +9,7 @@
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="optional" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
@@ -28,5 +29,12 @@
|
||||
<attribute name="test" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="test" value="true"/>
|
||||
<attribute name="optional" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
|
||||
@@ -7,7 +7,9 @@ org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
|
||||
140
config.properties
Normal file
140
config.properties
Normal file
@@ -0,0 +1,140 @@
|
||||
#This doesn't do anything, but is set by the program to help users identify the guild associated with the file
|
||||
Guild-Identifier = Main Config
|
||||
|
||||
#Change this to redefine the main command signifier character/String
|
||||
Command-Signifier = -
|
||||
|
||||
#Set to false to disable chat logging
|
||||
ChatLog = true
|
||||
|
||||
#Automatically places spammers in spam mode
|
||||
AllowSpamPunish = true
|
||||
|
||||
Channels-To-Not-Chatlog = ignore_me,ignore_me2,ignore_me3
|
||||
|
||||
#Bot token provided by Discord
|
||||
Bot-Token =
|
||||
|
||||
#Normal channels will have messages with these words deleted by the bot
|
||||
NaughtyList = piff,word123,another1
|
||||
|
||||
#Set to true if you want to limit the channels bot commands can be done in
|
||||
#Admins will be able to bypass this
|
||||
Restrict-Cmd-Channels = false
|
||||
|
||||
#Channels to restrict bot commands to
|
||||
CmdChannels = bot,bot2,bot3
|
||||
|
||||
#Allow users to toggle these roles
|
||||
ToggleRoles = role1,role2,role3
|
||||
|
||||
#Restrict these toggle roles to boosters. Will be removed on boost cancel
|
||||
Boost-Exclusive-Roles = role2,role3
|
||||
|
||||
#Treat these roles like booster.
|
||||
Treat-Like-Booster = Nitro Booster,silver,gold
|
||||
|
||||
#Bot can automatically assign role upon user join
|
||||
UseCustomDefaultRole = true
|
||||
|
||||
#This role will give Biscuit mod commands to users with the role
|
||||
ModRole = biscuit-key
|
||||
|
||||
#This role will give complete admin bot access to users with the role
|
||||
AdminRole = biscuit-admin
|
||||
|
||||
#In these channels, the bot will toggle roles for the ToggleRoles for anyone
|
||||
#who reacts to a message with [Toggle <Role name>]
|
||||
Toggle-Role-React-Channels = toggleroles1,toggleroles2,toggleroles3
|
||||
|
||||
#Does nothing if UseCustomDefaultRole is off
|
||||
DefaultRoleName = Standard
|
||||
|
||||
#Custom Emote to react with when action is complete
|
||||
Done-Emote = ActionComplete
|
||||
|
||||
#Set true to enable captcha
|
||||
#Use with UseCustomDefaultRole enabled
|
||||
#Will require user to have that role for captcha check
|
||||
#Role will be replaced with reward role on clear
|
||||
Captcha = false
|
||||
|
||||
#All channels listed here will allow for users in these channels
|
||||
#to initiate captcha with the bot.
|
||||
Captcha-Channels = captcha,verification
|
||||
|
||||
#Reward this role when captcha cleared
|
||||
Captcha-Reward-Role = cleared
|
||||
|
||||
#Kick if Captcha is not completed in a timely manner
|
||||
No-Captcha-Kick = false
|
||||
|
||||
#Kick user after this number of minutes has passed without captcha clear
|
||||
#Due to the way the countdown works, the kick may not happen until at most one minute after
|
||||
No-Captcha-Kick-Time = 10
|
||||
|
||||
#Messages with these unicode emotes will be removed
|
||||
Block-Unicode-Emotes = baby,snake,squid
|
||||
|
||||
#Messages with these custom emotes will be removed
|
||||
Block-Custom-Emotes = badfish,fix,bigleaf
|
||||
|
||||
#Disable these commands for ALL users
|
||||
DisabledCommands = cmd1,cmd2,cmd3
|
||||
|
||||
#Disabled these commands for normal users
|
||||
DisabledUserCommands = cmd4,cmd5,cmd6
|
||||
|
||||
#Checks which invite users join with. Requires bot to have Manage Server permission.
|
||||
Check-Join-Invite = false
|
||||
|
||||
#Enables the captcha text-channel logging.
|
||||
#Logs join, complete captcha, invite joined with, and time-out kick
|
||||
LogCaptcha = false
|
||||
|
||||
#Put the name of the text channel you want to log captcha information to.
|
||||
Captcha-Log-Channel = verify-log
|
||||
|
||||
#DM the user before kicking for captcha.
|
||||
DM-Before-Kick = true
|
||||
|
||||
#Send an invite to the server when dm-ing kicked users
|
||||
#Does nothing when blank
|
||||
#Use full link
|
||||
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 =
|
||||
|
||||
#Users with this role have complete control over the music player.
|
||||
#Automatically granted to Mods and Admins.
|
||||
Music-Controller-Role = music-key
|
||||
|
||||
#List your custom commands here. This line will always generate blank.
|
||||
#Example - Custom-Command-Names = hello,botcheck,apple
|
||||
Custom-Command-Names =
|
||||
|
||||
#Placeholder(s):
|
||||
#<user> - Mentions the sender
|
||||
#Setting up custom commands works like this:
|
||||
#
|
||||
#cc-hello-message = Hello, <user>!
|
||||
#cc-hello-description = Greets the sender.
|
||||
@@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.fpghoti</groupId>
|
||||
<artifactId>Biscuit</artifactId>
|
||||
<version>1.11</version>
|
||||
<version>1.13</version>
|
||||
<build>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
<resources>
|
||||
@@ -13,20 +13,10 @@
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<encoding>UTF-8</encoding>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.4</version>
|
||||
<configuration>
|
||||
<encoding>UTF-8</encoding>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>com.fpghoti.biscuit.Main</mainClass>
|
||||
@@ -44,7 +34,6 @@
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<encoding>UTF-8</encoding>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
<filters>
|
||||
<filter>
|
||||
@@ -96,13 +85,15 @@
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.16.4-R0.1-SNAPSHOT</version>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.21.4-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
</properties>
|
||||
|
||||
124
pom.xml
124
pom.xml
@@ -5,7 +5,15 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.fpghoti</groupId>
|
||||
<artifactId>Biscuit</artifactId>
|
||||
<version>1.12</version>
|
||||
<version>2.0 Beta</version>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
<resources>
|
||||
@@ -15,32 +23,10 @@
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<encoding>UTF-8</encoding>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.4</version>
|
||||
<configuration>
|
||||
<encoding>UTF-8</encoding>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>com.fpghoti.biscuit.Main</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.4</version>
|
||||
<version>3.6.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
@@ -48,38 +34,23 @@
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<encoding>UTF-8</encoding>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>org.tuxdude.logback.extensions:logback-colorizer</artifact>
|
||||
<includes>
|
||||
<include>**</include>
|
||||
</includes>
|
||||
</filter>
|
||||
<filter>
|
||||
<artifact>commons-logging:commons-logging</artifact>
|
||||
<includes>
|
||||
<include>**</include>
|
||||
</includes>
|
||||
</filter>
|
||||
</filters>
|
||||
<transformers>
|
||||
<transformer
|
||||
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||
<mainClass>com.fpghoti.biscuit.Main</mainClass>
|
||||
</transformer>
|
||||
</transformers>
|
||||
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>dv8tion</id>
|
||||
<name>m2-dv8tion</name>
|
||||
<url>https://m2.dv8tion.net/releases</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
@@ -93,25 +64,21 @@
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jcenter</id>
|
||||
<name>jcenter-bintray</name>
|
||||
<url>https://jcenter.bintray.com</url>
|
||||
</repository>
|
||||
<id>arbjergDev-releases</id>
|
||||
<name>Lavalink Repository</name>
|
||||
<url>https://maven.lavalink.dev/releases</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.fusesource.jansi</groupId>
|
||||
<artifactId>jansi</artifactId>
|
||||
<version>1.18</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.tuxdude.logback.extensions</groupId>
|
||||
<artifactId>logback-colorizer</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<version>2.4.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.GhotiMayo</groupId>
|
||||
@@ -121,43 +88,38 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-configuration2</artifactId>
|
||||
<version>2.7</version>
|
||||
<version>2.11.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.16.4-R0.1-SNAPSHOT</version>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.21.4-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okio</groupId>
|
||||
<artifactId>okio</artifactId>
|
||||
<version>2.4.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-core</artifactId>
|
||||
<version>1.2.3</version>
|
||||
<version>3.10.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>1.2.3</version>
|
||||
<version>1.5.17</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.jcabi</groupId>
|
||||
<artifactId>jcabi-aspects</artifactId>
|
||||
<version>0.22.6</version>
|
||||
<version>0.26.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>joda-time</groupId>
|
||||
<artifactId>joda-time</artifactId>
|
||||
<version>2.3</version>
|
||||
<version>2.13.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.dv8tion</groupId>
|
||||
<artifactId>JDA</artifactId>
|
||||
<version>5.0.0-alpha.11</version>
|
||||
<version>5.6.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.cage</groupId>
|
||||
@@ -175,14 +137,24 @@
|
||||
<version>1.4.7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sedmelluq</groupId>
|
||||
<groupId>dev.arbjerg</groupId>
|
||||
<artifactId>lavaplayer</artifactId>
|
||||
<version>1.3.77</version>
|
||||
<version>2.2.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>dev.lavalink.youtube</groupId>
|
||||
<artifactId>v2</artifactId>
|
||||
<version>1.13.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.pf4j</groupId>
|
||||
<artifactId>pf4j</artifactId>
|
||||
<version>3.4.1</version>
|
||||
<version>3.13.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>xom</groupId>
|
||||
<artifactId>xom</artifactId>
|
||||
<version>1.3.9</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -8,13 +8,13 @@ import java.util.Scanner;
|
||||
|
||||
import org.fusesource.jansi.AnsiConsole;
|
||||
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.captcha.BCage;
|
||||
import com.fpghoti.biscuit.commands.CommandManager;
|
||||
import com.fpghoti.biscuit.commands.console.GuildSayCommand;
|
||||
import com.fpghoti.biscuit.commands.console.SayCommand;
|
||||
import com.fpghoti.biscuit.commands.console.ShutdownConsoleCommand;
|
||||
import com.fpghoti.biscuit.commands.discord.AddCommand;
|
||||
import com.fpghoti.biscuit.commands.discord.AddYTFeedCommand;
|
||||
import com.fpghoti.biscuit.commands.discord.ChanIDCommand;
|
||||
import com.fpghoti.biscuit.commands.discord.DivideCommand;
|
||||
import com.fpghoti.biscuit.commands.discord.GetConfigCommand;
|
||||
@@ -43,7 +43,6 @@ import com.fpghoti.biscuit.commands.discord.music.MoveToCommand;
|
||||
import com.fpghoti.biscuit.commands.discord.music.NowPlayingCommand;
|
||||
import com.fpghoti.biscuit.commands.discord.music.PauseCommand;
|
||||
import com.fpghoti.biscuit.commands.discord.music.PlayCommand;
|
||||
import com.fpghoti.biscuit.commands.discord.music.PlayFirstCommand;
|
||||
import com.fpghoti.biscuit.commands.discord.music.QueueCommand;
|
||||
import com.fpghoti.biscuit.commands.discord.music.RemoveCommand;
|
||||
import com.fpghoti.biscuit.commands.discord.music.ShuffleCommand;
|
||||
@@ -52,6 +51,7 @@ import com.fpghoti.biscuit.commands.discord.music.SkipCommand;
|
||||
import com.fpghoti.biscuit.commands.discord.music.TogglePauseCommand;
|
||||
import com.fpghoti.biscuit.commands.discord.music.UnpauseCommand;
|
||||
import com.fpghoti.biscuit.commands.discord.music.VolumeCommand;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.listener.CommandListener;
|
||||
import com.fpghoti.biscuit.listener.DMListener;
|
||||
import com.fpghoti.biscuit.listener.GuildListener;
|
||||
@@ -65,15 +65,15 @@ import com.fpghoti.biscuit.listener.NicknameListener;
|
||||
import com.fpghoti.biscuit.listener.ReactionListener;
|
||||
import com.fpghoti.biscuit.listener.RoleListener;
|
||||
import com.fpghoti.biscuit.logging.BColor;
|
||||
import com.fpghoti.biscuit.logging.BiscuitLog;
|
||||
import com.fpghoti.biscuit.logging.BiscuitLogger;
|
||||
import com.fpghoti.biscuit.plugin.PluginController;
|
||||
import com.github.cage.Cage;
|
||||
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.SizeAndTimeBasedRollingPolicy;
|
||||
import dev.lavalink.youtube.YoutubeAudioSourceManager;
|
||||
import net.dv8tion.jda.api.JDA;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.requests.GatewayIntent;
|
||||
@@ -90,28 +90,34 @@ public class Main {
|
||||
public RollingFileAppender<String> we;
|
||||
public SizeAndTimeBasedRollingPolicy<String> wes;
|
||||
|
||||
private static final BiscuitLog log = new BiscuitLog();
|
||||
private static final BiscuitLogger log = new BiscuitLogger();
|
||||
|
||||
private static ArrayList<Biscuit> biscuits;
|
||||
private static Biscuit mainBiscuit;
|
||||
private static ArrayList<BiscuitGuild> biscuits;
|
||||
private static BiscuitGuild mainBiscuit;
|
||||
public static Scanner sc;
|
||||
public static boolean ready = false;
|
||||
public static boolean isPlugin = false;
|
||||
public static boolean shutdownStarted = false;
|
||||
private static Cage cage;
|
||||
private static File pluginsDir;
|
||||
public static File audioDir;
|
||||
//public static File ytFeedDir;
|
||||
private static PluginController pluginController;
|
||||
|
||||
private static AudioPlayerManager playerManager;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void main(String[] args){
|
||||
if(!isPlugin) {
|
||||
pluginsDir = new File("plugins");
|
||||
audioDir = new File("audio");
|
||||
}else {
|
||||
pluginsDir = new File(PluginCore.plugin.getDataFolder(), "plugins");
|
||||
audioDir = new File(PluginCore.plugin.getDataFolder(), "audio");
|
||||
}
|
||||
pluginsDir.mkdir();
|
||||
|
||||
audioDir.mkdir();
|
||||
|
||||
final Properties properties = new Properties();
|
||||
try {
|
||||
properties.load(Main.class.getClassLoader().getResourceAsStream("info.properties"));
|
||||
@@ -125,11 +131,16 @@ public class Main {
|
||||
log.info("Running version: " + BColor.MAGENTA_BOLD + version);
|
||||
|
||||
playerManager = new DefaultAudioPlayerManager();
|
||||
AudioSourceManagers.registerRemoteSources(playerManager);
|
||||
|
||||
mainBiscuit = new Biscuit(null, null, log);
|
||||
startJDA();
|
||||
AudioSourceManagers.registerLocalSource(playerManager);
|
||||
YoutubeAudioSourceManager ytSourceManager = new dev.lavalink.youtube.YoutubeAudioSourceManager();
|
||||
playerManager.registerSourceManager(ytSourceManager);
|
||||
AudioSourceManagers.registerRemoteSources(playerManager,
|
||||
com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioSourceManager.class);
|
||||
|
||||
|
||||
mainBiscuit = new BiscuitGuild(null, null, log);
|
||||
startJDA();
|
||||
|
||||
cage = new BCage();
|
||||
|
||||
jda.addEventListener(new GuildListener());
|
||||
@@ -143,9 +154,9 @@ public class Main {
|
||||
jda.addEventListener(new RoleListener());
|
||||
jda.addEventListener(new NicknameListener());
|
||||
jda.addEventListener(new NameListener());
|
||||
biscuits = new ArrayList<Biscuit>();
|
||||
biscuits = new ArrayList<BiscuitGuild>();
|
||||
for(Guild g : jda.getGuilds()) {
|
||||
Biscuit.loadGuild(g);
|
||||
BiscuitGuild.loadGuild(g);
|
||||
}
|
||||
startCommandListener();
|
||||
|
||||
@@ -164,6 +175,7 @@ public class Main {
|
||||
CommandManager.addCommand(new ToggleRoleCommand());
|
||||
CommandManager.addCommand(new SquareRootCommand());
|
||||
CommandManager.addCommand(new AddCommand());
|
||||
CommandManager.addCommand(new AddYTFeedCommand());
|
||||
CommandManager.addCommand(new SubtractCommand());
|
||||
CommandManager.addCommand(new MultiplyCommand());
|
||||
CommandManager.addCommand(new DivideCommand());
|
||||
@@ -173,11 +185,10 @@ public class Main {
|
||||
CommandManager.addCommand(new SaveConfigCommand());
|
||||
CommandManager.addCommand(new GuildIDCommand());
|
||||
CommandManager.addCommand(new WikiCommand());
|
||||
|
||||
|
||||
//Music Client
|
||||
|
||||
|
||||
CommandManager.addCommand(new PlayCommand());
|
||||
CommandManager.addCommand(new PlayFirstCommand());
|
||||
CommandManager.addCommand(new ForceSkipCommand());
|
||||
CommandManager.addCommand(new PauseCommand());
|
||||
CommandManager.addCommand(new UnpauseCommand());
|
||||
@@ -202,11 +213,11 @@ public class Main {
|
||||
CommandManager.addCommand(new ShutdownConsoleCommand());
|
||||
|
||||
//Plugins
|
||||
|
||||
|
||||
pluginController = new PluginController();
|
||||
pluginController.loadPlugins();
|
||||
pluginController.startPlugins();
|
||||
|
||||
pluginController.loadPlugins();
|
||||
pluginController.startPlugins();
|
||||
|
||||
link = "https://discord.com/oauth2/authorize?&client_id=" + jda.getSelfUser().getId() + "&permissions=8&scope=bot";
|
||||
log.info("Connection successful!");
|
||||
log.info("Startup successful!");
|
||||
@@ -224,8 +235,7 @@ public class Main {
|
||||
shardm = DefaultShardManagerBuilder.createDefault(token)
|
||||
.setChunkingFilter(ChunkingFilter.ALL)
|
||||
.setMemberCachePolicy(MemberCachePolicy.ALL)
|
||||
.enableIntents(GatewayIntent.getIntents(GatewayIntent.DEFAULT))
|
||||
.enableIntents(GatewayIntent.GUILD_MEMBERS)
|
||||
.enableIntents(GatewayIntent.getIntents(GatewayIntent.ALL_INTENTS))
|
||||
.build();
|
||||
jda = shardm.getShardById(0);
|
||||
try {
|
||||
@@ -241,7 +251,7 @@ public class Main {
|
||||
}
|
||||
}
|
||||
|
||||
public static Biscuit getMainBiscuit() {
|
||||
public static BiscuitGuild getMainBiscuit() {
|
||||
return mainBiscuit;
|
||||
}
|
||||
|
||||
@@ -257,25 +267,27 @@ public class Main {
|
||||
}
|
||||
}
|
||||
|
||||
public static ArrayList<Biscuit> getBiscuits() {
|
||||
public static ArrayList<BiscuitGuild> getBiscuits() {
|
||||
return biscuits;
|
||||
}
|
||||
|
||||
public static AudioPlayerManager getPlayerManager() {
|
||||
return playerManager;
|
||||
}
|
||||
|
||||
|
||||
public static File getPluginDirectory() {
|
||||
return pluginsDir;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void shutdown() {
|
||||
if(!shutdownStarted) {
|
||||
shutdownStarted = true;
|
||||
mainBiscuit.log("Shutting down...");
|
||||
pluginController.shutdownPlugins();
|
||||
ArrayList<Biscuit> list = new ArrayList<Biscuit>(biscuits);
|
||||
for(Biscuit b : list) {
|
||||
ArrayList<BiscuitGuild> list = new ArrayList<BiscuitGuild>(biscuits);
|
||||
for(BiscuitGuild b : list) {
|
||||
b.remove();
|
||||
}
|
||||
mainBiscuit.wipeCaptchaDir();
|
||||
@@ -292,24 +304,24 @@ public class Main {
|
||||
public static JDA getJDA() {
|
||||
return jda;
|
||||
}
|
||||
|
||||
|
||||
public static Cage getCage() {
|
||||
return cage;
|
||||
}
|
||||
|
||||
public static BiscuitLog getLogger() {
|
||||
public static BiscuitLogger getLogger() {
|
||||
return log;
|
||||
}
|
||||
|
||||
|
||||
public static PluginController getPluginController() {
|
||||
return pluginController;
|
||||
}
|
||||
|
||||
public static void registerBiscuit(Biscuit b) {
|
||||
public static void registerBiscuit(BiscuitGuild b) {
|
||||
biscuits.add(b);
|
||||
}
|
||||
|
||||
public static void unregisterBiscuit(Biscuit b) {
|
||||
public static void unregisterBiscuit(BiscuitGuild b) {
|
||||
biscuits.remove(b);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import com.fpghoti.biscuit.audio.request.RequestType;
|
||||
import com.fpghoti.biscuit.audio.request.youtube.YTImmediateRequest;
|
||||
import com.fpghoti.biscuit.audio.request.youtube.YTRequest;
|
||||
import com.fpghoti.biscuit.audio.result.YTResultHandler;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
import com.sedmelluq.discord.lavaplayer.player.AudioPlayer;
|
||||
import com.sedmelluq.discord.lavaplayer.player.event.AudioEventAdapter;
|
||||
@@ -18,16 +18,16 @@ import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
|
||||
import com.sedmelluq.discord.lavaplayer.track.AudioTrackEndReason;
|
||||
|
||||
import net.dv8tion.jda.api.entities.MessageEmbed;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
|
||||
public class AudioScheduler extends AudioEventAdapter {
|
||||
|
||||
private Biscuit biscuit;
|
||||
private BiscuitGuild biscuit;
|
||||
private AudioQueue queue;
|
||||
private ArrayList<String> skips;
|
||||
private boolean loop;
|
||||
|
||||
public AudioScheduler(Biscuit biscuit) {
|
||||
public AudioScheduler(BiscuitGuild biscuit) {
|
||||
this.biscuit = biscuit;
|
||||
this.queue = new AudioQueue();
|
||||
this.skips = new ArrayList<String>();
|
||||
@@ -119,6 +119,9 @@ public class AudioScheduler extends AudioEventAdapter {
|
||||
|
||||
public void queue(RequestType type, AudioTrack track, String uid, TextChannel channel, Integer place) {
|
||||
if(queue.isEmpty() && biscuit.getAudioPlayer().getPlayingTrack() == null) {
|
||||
if(place == null) {
|
||||
place = 0;
|
||||
}
|
||||
QueuedTrack qt = new QueuedTrack(biscuit, track, uid, channel, type);
|
||||
queue.sendQueueMessage(qt);
|
||||
queue.addPreviousTrack(qt);
|
||||
@@ -191,7 +194,7 @@ public class AudioScheduler extends AudioEventAdapter {
|
||||
queue.clear();
|
||||
}
|
||||
|
||||
public Biscuit getBiscuit() {
|
||||
public BiscuitGuild getBiscuitGuild() {
|
||||
return biscuit;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
package com.fpghoti.biscuit.audio;
|
||||
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
|
||||
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 PlayCommandUtil {
|
||||
|
||||
public static boolean connectToChannel(MessageReceivedEvent event) {
|
||||
if(!event.isFromGuild()) {
|
||||
return false;
|
||||
}
|
||||
Guild guild = event.getGuild();
|
||||
Biscuit biscuit = Biscuit.getBiscuit(guild);
|
||||
TextChannel textChannel = event.getTextChannel();
|
||||
|
||||
String vcname = "";
|
||||
if(!event.getMember().getVoiceState().inAudioChannel()) {
|
||||
MessageText.send(textChannel, "You must be in a voice channel to do this!");
|
||||
return false;
|
||||
}
|
||||
vcname = event.getMember().getVoiceState().getChannel().getName();
|
||||
String[] musicChannels = biscuit.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) {
|
||||
MessageText.send(textChannel, "You are not in a channel that is authorized to use the music player.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(biscuit.getAudioPlayer().getPlayingTrack() != null && guild.getAudioManager().isConnected() && !guild.getAudioManager().getConnectedChannel().getMembers().contains(event.getMember())) {
|
||||
MessageText.send(textChannel, "Music is already playing in a voice channel. Connect to "
|
||||
+ "that channel, then queue your song.");
|
||||
return false;
|
||||
}
|
||||
|
||||
VoiceChannel voiceChannel = guild.getVoiceChannelsByName(vcname, true).get(0);
|
||||
AudioManager manager = guild.getAudioManager();
|
||||
|
||||
manager.setSendingHandler(new AudioHandler(biscuit.getAudioPlayer()));
|
||||
manager.openAudioConnection(voiceChannel);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static String getSearchPhrase(String[] args) {
|
||||
return getSearchPhrase(args, 0);
|
||||
}
|
||||
|
||||
public static String getSearchPhrase(String[] args, int startArg) {
|
||||
if(startArg >= args.length) {
|
||||
return "";
|
||||
}
|
||||
String searchPhrase = args[startArg];
|
||||
if(args.length > startArg + 1) {
|
||||
for(int i = startArg + 1; i < args.length; i++) {
|
||||
searchPhrase = searchPhrase + " " + args[i];
|
||||
}
|
||||
}
|
||||
return searchPhrase;
|
||||
}
|
||||
|
||||
public static String getID(MessageReceivedEvent event) {
|
||||
return getID(event.getMessage().getContentRaw().split(" ")[1]);
|
||||
}
|
||||
|
||||
public static String getID(String url) {
|
||||
String[] s = url.split("=");
|
||||
if(s.length > 1) {
|
||||
return s[1].split("&")[0];
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import com.fpghoti.biscuit.rest.MessageText;
|
||||
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
|
||||
|
||||
import net.dv8tion.jda.api.entities.MessageEmbed;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
|
||||
public class AudioQueue {
|
||||
|
||||
@@ -53,7 +53,7 @@ public class AudioQueue {
|
||||
QueuedTrack next = tracks.iterator().next();
|
||||
tracks.remove(next);
|
||||
addPreviousTrack(next);
|
||||
next.getBiscuit().getAudioPlayer().playTrack(next.getTrack());
|
||||
next.getBiscuitGuild().getAudioPlayer().playTrack(next.getTrack());
|
||||
}
|
||||
|
||||
public QueuedTrack getTrack(int index){
|
||||
|
||||
@@ -3,25 +3,25 @@ package com.fpghoti.biscuit.audio.queue;
|
||||
import java.awt.Color;
|
||||
|
||||
import com.fpghoti.biscuit.audio.request.RequestType;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.util.Util;
|
||||
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
|
||||
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.MessageEmbed;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
|
||||
public class QueuedTrack {
|
||||
|
||||
private Biscuit biscuit;
|
||||
private BiscuitGuild biscuit;
|
||||
private AudioTrack track;
|
||||
private String userId;
|
||||
private TextChannel channel;
|
||||
private RequestType type;
|
||||
private boolean triedAlternative;
|
||||
|
||||
public QueuedTrack(Biscuit biscuit, AudioTrack track, String userId, TextChannel channel, RequestType type) {
|
||||
public QueuedTrack(BiscuitGuild biscuit, AudioTrack track, String userId, TextChannel channel, RequestType type) {
|
||||
this.biscuit = biscuit;
|
||||
this.track = track;
|
||||
this.userId = userId;
|
||||
@@ -30,7 +30,7 @@ public class QueuedTrack {
|
||||
this.triedAlternative = false;
|
||||
}
|
||||
|
||||
public Biscuit getBiscuit() {
|
||||
public BiscuitGuild getBiscuitGuild() {
|
||||
return biscuit;
|
||||
}
|
||||
|
||||
@@ -56,31 +56,35 @@ public class QueuedTrack {
|
||||
|
||||
public MessageEmbed getEmbedMessage(String prefix, boolean showRemaining) {
|
||||
EmbedBuilder embed = new EmbedBuilder();
|
||||
|
||||
String title = track.getInfo().title;
|
||||
if(prefix != null && !prefix.equals("")) {
|
||||
title = prefix + " " + title;
|
||||
}
|
||||
|
||||
embed.setTitle(title, track.getInfo().uri);
|
||||
|
||||
String uri = track.getInfo().uri;
|
||||
if(type.toString().toLowerCase().contains("file")) {
|
||||
if(title.contains("Unknown title") && Util.getLast(title, " ").equals("title")) {
|
||||
title = title.replace("Unknown title", Util.getLast(uri,"\\\\"));
|
||||
}
|
||||
embed.setTitle(title);
|
||||
}else {
|
||||
embed.setTitle(title, uri);
|
||||
}
|
||||
|
||||
embed.setColor(Color.CYAN);
|
||||
|
||||
long duration = track.getDuration();
|
||||
|
||||
//Duration seems to change after track begins playing
|
||||
//This is to make the embeds more consistant with each other
|
||||
//This is to make the embeds more consistent with each other
|
||||
if(showRemaining) {
|
||||
duration+=1000;
|
||||
}
|
||||
|
||||
String desc = "Type: " + type.toString() + "\nAuthor: " + track.getInfo().author + "\nLength: " + Util.getTime(duration);
|
||||
|
||||
if(showRemaining) {
|
||||
desc = desc + "\nTime Remaining: " + Util.getTime(track.getDuration() - track.getPosition());
|
||||
}
|
||||
|
||||
embed.setDescription(desc);
|
||||
|
||||
String name = biscuit.getGuild().getSelfMember().getEffectiveName();
|
||||
String avatar = biscuit.getGuild().getSelfMember().getUser().getEffectiveAvatarUrl();
|
||||
|
||||
@@ -89,13 +93,11 @@ public class QueuedTrack {
|
||||
name = m.getEffectiveName();
|
||||
avatar = m.getUser().getEffectiveAvatarUrl();
|
||||
}
|
||||
|
||||
embed.setAuthor(name, null, avatar);
|
||||
|
||||
if(type.toString().toLowerCase().contains("youtube")) {
|
||||
embed.setThumbnail("https://img.youtube.com/vi/" + track.getIdentifier() + "/mqdefault.jpg");
|
||||
}
|
||||
|
||||
return embed.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
package com.fpghoti.biscuit.audio.request;
|
||||
|
||||
import com.fpghoti.biscuit.audio.request.file.FilePriorityRequest;
|
||||
import com.fpghoti.biscuit.audio.request.file.FileRequest;
|
||||
import com.fpghoti.biscuit.audio.request.soundcloud.SCPriorityRequest;
|
||||
import com.fpghoti.biscuit.audio.request.soundcloud.SCRequest;
|
||||
import com.fpghoti.biscuit.audio.request.youtube.YTImmediateRequest;
|
||||
import com.fpghoti.biscuit.audio.request.youtube.YTPriorityRequest;
|
||||
import com.fpghoti.biscuit.audio.request.youtube.YTRequest;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
|
||||
public abstract class PlayRequest {
|
||||
|
||||
@@ -42,37 +44,41 @@ public abstract class PlayRequest {
|
||||
case YOUTUBE_PRIORITY:
|
||||
return new YTPriorityRequest(message, searchPhrase, insertSlot);
|
||||
case YOUTUBE_IMMEDIATE:
|
||||
return new YTImmediateRequest(message.getTextChannel(), message.getAuthor().getId(), searchPhrase);
|
||||
return new YTImmediateRequest(message.getChannel().asTextChannel(), message.getAuthor().getId(), searchPhrase);
|
||||
case SOUNDCLOUD:
|
||||
return new SCRequest(message, searchPhrase);
|
||||
case SOUNDCLOUD_PRIORITY:
|
||||
return new SCPriorityRequest(message, searchPhrase, insertSlot);
|
||||
case FILE:
|
||||
return new FileRequest(message, searchPhrase);
|
||||
case FILE_PRIORITY:
|
||||
return new FilePriorityRequest(message, searchPhrase, insertSlot);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private TextChannel channel;
|
||||
private Biscuit biscuit;
|
||||
private BiscuitGuild biscuit;
|
||||
private String authorId;
|
||||
private String identifier;
|
||||
|
||||
public PlayRequest(Message message, String identifier) {
|
||||
this(message.getTextChannel(), message.getAuthor().getId(), identifier);
|
||||
this(message.getChannel().asTextChannel(), message.getAuthor().getId(), identifier);
|
||||
}
|
||||
|
||||
public PlayRequest(TextChannel channel, String authorId, String identifier) {
|
||||
this.channel = channel;
|
||||
this.authorId = authorId;
|
||||
this.identifier = identifier;
|
||||
this.biscuit = Biscuit.getBiscuit(channel.getGuild());
|
||||
this.biscuit = BiscuitGuild.getBiscuitGuild(channel.getGuild());
|
||||
}
|
||||
|
||||
public TextChannel getRequestChannel() {
|
||||
return channel;
|
||||
}
|
||||
|
||||
public Biscuit getBiscuit() {
|
||||
public BiscuitGuild getBiscuitGuild() {
|
||||
return biscuit;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,18 @@ public enum RequestType {
|
||||
public String toString() {
|
||||
return "Soundcloud - Priority";
|
||||
}
|
||||
},
|
||||
FILE{
|
||||
@Override
|
||||
public String toString() {
|
||||
return "File";
|
||||
}
|
||||
},
|
||||
FILE_PRIORITY{
|
||||
@Override
|
||||
public String toString() {
|
||||
return "File - Priority";
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.fpghoti.biscuit.audio.request.file;
|
||||
|
||||
import com.fpghoti.biscuit.audio.request.RequestType;
|
||||
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
|
||||
public class FilePriorityRequest extends FileRequest{
|
||||
|
||||
int insertSlot;
|
||||
|
||||
public FilePriorityRequest(Message message, String identifier, int insertSlot) {
|
||||
this(message.getChannel().asTextChannel(), message.getAuthor().getId(), identifier, insertSlot);
|
||||
}
|
||||
|
||||
public FilePriorityRequest(TextChannel channel, String authorId, String identifier, int insertSlot) {
|
||||
super(channel, authorId, identifier);
|
||||
this.insertSlot = insertSlot;
|
||||
}
|
||||
|
||||
public int getSlot() {
|
||||
return insertSlot;
|
||||
}
|
||||
|
||||
public void setSlot(int slotNumber) {
|
||||
insertSlot = slotNumber;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RequestType getType() {
|
||||
return RequestType.FILE_PRIORITY;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.fpghoti.biscuit.audio.request.file;
|
||||
|
||||
import com.fpghoti.biscuit.audio.request.PlayRequest;
|
||||
import com.fpghoti.biscuit.audio.request.RequestType;
|
||||
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
|
||||
public class FileRequest extends PlayRequest{
|
||||
|
||||
public FileRequest(Message message, String identifier) {
|
||||
this(message.getChannel().asTextChannel(), message.getAuthor().getId(), identifier);
|
||||
}
|
||||
|
||||
public FileRequest(TextChannel channel, String authorId, String identifier) {
|
||||
super(channel, authorId, identifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RequestType getType() {
|
||||
return RequestType.FILE;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,14 +3,14 @@ package com.fpghoti.biscuit.audio.request.soundcloud;
|
||||
import com.fpghoti.biscuit.audio.request.RequestType;
|
||||
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
|
||||
public class SCPriorityRequest extends SCRequest{
|
||||
|
||||
int insertSlot;
|
||||
|
||||
public SCPriorityRequest(Message message, String identifier, int insertSlot) {
|
||||
this(message.getTextChannel(), message.getAuthor().getId(), identifier, insertSlot);
|
||||
this(message.getChannel().asTextChannel(), message.getAuthor().getId(), identifier, insertSlot);
|
||||
}
|
||||
|
||||
public SCPriorityRequest(TextChannel channel, String authorId, String identifier, int insertSlot) {
|
||||
|
||||
@@ -4,14 +4,14 @@ import com.fpghoti.biscuit.audio.request.PlayRequest;
|
||||
import com.fpghoti.biscuit.audio.request.RequestType;
|
||||
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
|
||||
public class SCRequest extends PlayRequest{
|
||||
|
||||
private boolean searchMode;
|
||||
|
||||
public SCRequest(Message message, String identifier) {
|
||||
this(message.getTextChannel(), message.getAuthor().getId(), identifier);
|
||||
this(message.getChannel().asTextChannel(), message.getAuthor().getId(), identifier);
|
||||
}
|
||||
|
||||
public SCRequest(TextChannel channel, String authorId, String identifier) {
|
||||
|
||||
@@ -3,7 +3,8 @@ package com.fpghoti.biscuit.audio.request.youtube;
|
||||
import com.fpghoti.biscuit.audio.request.RequestType;
|
||||
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
//import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
|
||||
public class YTImmediateRequest extends YTRequest{
|
||||
|
||||
|
||||
@@ -3,14 +3,14 @@ package com.fpghoti.biscuit.audio.request.youtube;
|
||||
import com.fpghoti.biscuit.audio.request.RequestType;
|
||||
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
|
||||
public class YTPriorityRequest extends YTRequest{
|
||||
|
||||
int insertSlot;
|
||||
|
||||
public YTPriorityRequest(Message message, String identifier, int insertSlot) {
|
||||
this(message.getTextChannel(), message.getAuthor().getId(), identifier, insertSlot);
|
||||
this(message.getChannel().asTextChannel(), message.getAuthor().getId(), identifier, insertSlot);
|
||||
}
|
||||
|
||||
public YTPriorityRequest(TextChannel channel, String authorId, String identifier, int insertSlot) {
|
||||
|
||||
@@ -4,14 +4,15 @@ import com.fpghoti.biscuit.audio.request.PlayRequest;
|
||||
import com.fpghoti.biscuit.audio.request.RequestType;
|
||||
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
//import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
|
||||
public class YTRequest extends PlayRequest{
|
||||
|
||||
private boolean searchMode;
|
||||
|
||||
public YTRequest(Message message, String identifier) {
|
||||
this(message.getTextChannel(), message.getAuthor().getId(), identifier);
|
||||
this(message.getChannel().asTextChannel(), message.getAuthor().getId(), identifier);
|
||||
}
|
||||
|
||||
public YTRequest(TextChannel channel, String authorId, String identifier) {
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.fpghoti.biscuit.audio.result;
|
||||
|
||||
import com.fpghoti.biscuit.audio.AudioScheduler;
|
||||
import com.fpghoti.biscuit.audio.request.PlayRequest;
|
||||
import com.fpghoti.biscuit.audio.request.file.FilePriorityRequest;
|
||||
import com.fpghoti.biscuit.audio.request.file.FileRequest;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
import com.sedmelluq.discord.lavaplayer.tools.FriendlyException;
|
||||
import com.sedmelluq.discord.lavaplayer.track.AudioPlaylist;
|
||||
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
|
||||
|
||||
public class FileResultHandler extends ResultHandler {
|
||||
|
||||
private BiscuitGuild biscuit;
|
||||
private FileRequest request;
|
||||
|
||||
public FileResultHandler(FileRequest request) {
|
||||
this.request = request;
|
||||
this.biscuit = request.getBiscuitGuild();
|
||||
}
|
||||
|
||||
public PlayRequest getRequest() {
|
||||
return request;
|
||||
}
|
||||
|
||||
public void handleTrack(AudioTrack track) {
|
||||
AudioScheduler sched = biscuit.getAudioScheduler();
|
||||
|
||||
switch(request.getType()) {
|
||||
|
||||
case FILE:
|
||||
sched.queue(request.getType(), track, request.getAuthorId(), request.getRequestChannel());
|
||||
break;
|
||||
|
||||
case FILE_PRIORITY:
|
||||
FilePriorityRequest prq = (FilePriorityRequest) request;
|
||||
sched.queue(request.getType(), track, request.getAuthorId(), request.getRequestChannel(), prq.getSlot());
|
||||
break;
|
||||
|
||||
default:
|
||||
biscuit.error("File result handler received an incompatible request.");
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trackLoaded(AudioTrack track) {
|
||||
handleTrack(track);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playlistLoaded(AudioPlaylist playlist) {
|
||||
AudioTrack track = playlist.getTracks().get(0);
|
||||
handleTrack(track);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void noMatches() {
|
||||
MessageText.send(request.getRequestChannel(), "File not found.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadFailed(FriendlyException exception) {
|
||||
exception.printStackTrace();
|
||||
MessageText.send(request.getRequestChannel(), "An error was encountered while attempting to load audio.");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.fpghoti.biscuit.audio.result;
|
||||
|
||||
import com.fpghoti.biscuit.audio.request.PlayRequest;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
import com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler;
|
||||
import com.sedmelluq.discord.lavaplayer.tools.FriendlyException;
|
||||
@@ -10,7 +10,7 @@ import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
|
||||
|
||||
public abstract class ResultHandler implements AudioLoadResultHandler {
|
||||
|
||||
private Biscuit biscuit;
|
||||
private BiscuitGuild biscuit;
|
||||
private PlayRequest request;
|
||||
|
||||
public PlayRequest getRequest() {
|
||||
@@ -36,7 +36,7 @@ public abstract class ResultHandler implements AudioLoadResultHandler {
|
||||
MessageText.send(request.getRequestChannel(), "An error was encountered while attempting to load audio.");
|
||||
}
|
||||
|
||||
public Biscuit getBiscuit() {
|
||||
public BiscuitGuild getBiscuitGuild() {
|
||||
return biscuit;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.fpghoti.biscuit.audio.AudioScheduler;
|
||||
import com.fpghoti.biscuit.audio.request.PlayRequest;
|
||||
import com.fpghoti.biscuit.audio.request.soundcloud.SCPriorityRequest;
|
||||
import com.fpghoti.biscuit.audio.request.soundcloud.SCRequest;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
import com.sedmelluq.discord.lavaplayer.tools.FriendlyException;
|
||||
import com.sedmelluq.discord.lavaplayer.track.AudioPlaylist;
|
||||
@@ -13,12 +13,12 @@ import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
|
||||
|
||||
public class SCResultHandler extends ResultHandler {
|
||||
|
||||
private Biscuit biscuit;
|
||||
private BiscuitGuild biscuit;
|
||||
private SCRequest request;
|
||||
|
||||
public SCResultHandler(SCRequest request) {
|
||||
this.request = request;
|
||||
this.biscuit = request.getBiscuit();
|
||||
this.biscuit = request.getBiscuitGuild();
|
||||
}
|
||||
|
||||
public PlayRequest getRequest() {
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.fpghoti.biscuit.audio.AudioScheduler;
|
||||
import com.fpghoti.biscuit.audio.request.PlayRequest;
|
||||
import com.fpghoti.biscuit.audio.request.youtube.YTPriorityRequest;
|
||||
import com.fpghoti.biscuit.audio.request.youtube.YTRequest;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
import com.sedmelluq.discord.lavaplayer.tools.FriendlyException;
|
||||
import com.sedmelluq.discord.lavaplayer.track.AudioPlaylist;
|
||||
@@ -13,12 +13,12 @@ import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
|
||||
|
||||
public class YTResultHandler extends ResultHandler {
|
||||
|
||||
private Biscuit biscuit;
|
||||
private BiscuitGuild biscuit;
|
||||
private YTRequest request;
|
||||
|
||||
public YTResultHandler(YTRequest request) {
|
||||
this.request = request;
|
||||
this.biscuit = request.getBiscuit();
|
||||
this.biscuit = request.getBiscuitGuild();
|
||||
}
|
||||
|
||||
public PlayRequest getRequest() {
|
||||
|
||||
47
src/main/java/com/fpghoti/biscuit/audio/util/AudioUtil.java
Normal file
47
src/main/java/com/fpghoti/biscuit/audio/util/AudioUtil.java
Normal file
@@ -0,0 +1,47 @@
|
||||
package com.fpghoti.biscuit.audio.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.util.Util;
|
||||
|
||||
public class AudioUtil {
|
||||
|
||||
public static ArrayList<File> getAudioFiles(){
|
||||
return getAudioFiles(Main.audioDir);
|
||||
}
|
||||
|
||||
public static ArrayList<File> getAudioFiles(File a){
|
||||
ArrayList<File> audios = new ArrayList<File>();
|
||||
File[] files = a.listFiles();
|
||||
for(int i = 0; i < files.length; i++) {
|
||||
File f = files[i];
|
||||
if(!f.isDirectory()) {
|
||||
String name = f.getName();
|
||||
String filetype = Util.getLast(name, "\\.");
|
||||
String[] types = {"mp3", "wav", "flac", "mp4", "m4a", "ogg", "webm"};
|
||||
for(String s : types) {
|
||||
if(s.equalsIgnoreCase(filetype)) {
|
||||
audios.add(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return audios;
|
||||
}
|
||||
|
||||
public static File getAudioFile(String name) {
|
||||
return getAudioFile(getAudioFiles(), name);
|
||||
}
|
||||
|
||||
public static File getAudioFile(ArrayList<File> playlist, String name) {
|
||||
for(File f : playlist) {
|
||||
if(f.getName().equalsIgnoreCase(name)) {
|
||||
return f;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import java.io.OutputStream;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.PluginCore;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.logging.BColor;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
import com.fpghoti.biscuit.user.CaptchaUser;
|
||||
@@ -17,10 +17,11 @@ import com.github.cage.Cage;
|
||||
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.MessageChannel;
|
||||
import net.dv8tion.jda.api.entities.PrivateChannel;
|
||||
import net.dv8tion.jda.api.entities.Role;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.PrivateChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
|
||||
import net.dv8tion.jda.api.utils.FileUpload;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
|
||||
public class Captcha {
|
||||
@@ -102,10 +103,11 @@ public class Captcha {
|
||||
genToken();
|
||||
generateImage();
|
||||
File captcha = getImageFile();
|
||||
FileUpload capUpload = FileUpload.fromData(captcha);
|
||||
|
||||
respond("Respond with the exact text in this image.");
|
||||
channel.sendFile(captcha).submit();
|
||||
|
||||
//channel.sendFile(captcha).submit();
|
||||
channel.sendFiles(capUpload);
|
||||
}else {
|
||||
boolean disable = false;
|
||||
if(captchaUser.inTestMode()) {
|
||||
@@ -168,7 +170,7 @@ public class Captcha {
|
||||
//mark the PreUser as "done"
|
||||
p.setDone();
|
||||
|
||||
Biscuit biscuit = p.getBiscuit();
|
||||
BiscuitGuild biscuit = p.getBiscuitGuild();
|
||||
|
||||
if(biscuit == null) {
|
||||
Main.getMainBiscuit().error("CAPTCHA ERROR: Null Biscuit");
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package com.fpghoti.biscuit.captcha;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.user.CaptchaUser;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
|
||||
import net.dv8tion.jda.api.JDA;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.MessageChannel;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
|
||||
|
||||
public class HandleCaptcha {
|
||||
|
||||
@@ -35,7 +35,7 @@ public class HandleCaptcha {
|
||||
}
|
||||
|
||||
public static Boolean isCaptchaChannel(TextChannel c) {
|
||||
Biscuit biscuit = Biscuit.getBiscuit(c.getGuild());
|
||||
BiscuitGuild biscuit = BiscuitGuild.getBiscuitGuild(c.getGuild());
|
||||
Boolean a = true;
|
||||
for(String s: biscuit.getProperties().getCaptchaChannels()) {
|
||||
if(c.getName().equalsIgnoreCase(s)) {
|
||||
|
||||
@@ -4,11 +4,11 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
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.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
import com.fpghoti.biscuit.util.Util;
|
||||
@@ -20,7 +20,7 @@ public class CommandManager {
|
||||
private static List<BaseCommand> commands = new ArrayList<BaseCommand>();
|
||||
|
||||
public static void parse(String message, MessageReceivedEvent event){
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
BiscuitGuild b = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
ArrayList<String> split = new ArrayList<String>();
|
||||
String fixed = message.replaceFirst(b.getProperties().getCommandSignifier(), "");
|
||||
String[] splitMsg = fixed.split(" ");
|
||||
@@ -40,10 +40,10 @@ public class CommandManager {
|
||||
}
|
||||
|
||||
public static boolean dispatch(MessageReceivedEvent event, String label, String[] args) {
|
||||
Biscuit b = Main.getMainBiscuit();
|
||||
BiscuitGuild b = Main.getMainBiscuit();
|
||||
boolean isMain = true;
|
||||
if(event != null) {
|
||||
b = Biscuit.getBiscuit(event.getGuild());
|
||||
b = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
isMain = false;
|
||||
if(Util.contains(b.getProperties().disabledCommands(), label)) {
|
||||
return false;
|
||||
@@ -120,7 +120,7 @@ public class CommandManager {
|
||||
|
||||
public static void commandReply(MessageReceivedEvent event, String msg) {
|
||||
if(event != null) {
|
||||
MessageText.send(event.getTextChannel(), msg);
|
||||
MessageText.send(event.getChannel().asTextChannel(), msg);
|
||||
}else {
|
||||
Main.getLogger().info(msg);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.fpghoti.biscuit.commands.base;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.BaseCommand;
|
||||
import com.fpghoti.biscuit.commands.CommandType;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
@@ -15,9 +15,9 @@ public class CustomCommand extends BaseCommand {
|
||||
}
|
||||
|
||||
private String name;
|
||||
private Biscuit biscuit;
|
||||
private BiscuitGuild biscuit;
|
||||
|
||||
public CustomCommand(String name, Biscuit biscuit) {
|
||||
public CustomCommand(String name, BiscuitGuild biscuit) {
|
||||
this.name = name;
|
||||
this.biscuit = biscuit;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package com.fpghoti.biscuit.commands.console;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.base.ConsoleCommand;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
//import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
|
||||
public class GuildSayCommand extends ConsoleCommand{
|
||||
|
||||
@@ -23,7 +24,7 @@ public class GuildSayCommand extends ConsoleCommand{
|
||||
public void execute(String[] args) {
|
||||
if(args.length > 0) {
|
||||
String guildcode = args[0];
|
||||
Biscuit b = Biscuit.getBiscuit(guildcode);
|
||||
BiscuitGuild b = BiscuitGuild.getBiscuitGuild(guildcode);
|
||||
if(b == null) {
|
||||
Main.getMainBiscuit().log("INVALID GUILD! TRY: guildsay <guild-code> <channel-name> <message>");
|
||||
return;
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package com.fpghoti.biscuit.commands.console;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.base.ConsoleCommand;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
//import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
|
||||
public class SayCommand extends ConsoleCommand{
|
||||
|
||||
@@ -23,7 +24,7 @@ public class SayCommand extends ConsoleCommand{
|
||||
}
|
||||
|
||||
public void execute(String[] args) {
|
||||
Biscuit b = Main.getMainBiscuit();
|
||||
BiscuitGuild b = Main.getMainBiscuit();
|
||||
if(args.length > 0) {
|
||||
String target = args[0];
|
||||
String message = "";
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package com.fpghoti.biscuit.commands.discord;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
import com.fpghoti.biscuit.util.Util;
|
||||
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
public class AddCommand extends ClientCommand{
|
||||
@@ -21,7 +22,7 @@ public class AddCommand extends ClientCommand{
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
BiscuitGuild b = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -add");
|
||||
if(args[0] != null && Util.isDeciDigit(args[0]) && args[1] != null && Util.isDeciDigit(args[1])) {
|
||||
double num = Double.parseDouble(args[0]);
|
||||
@@ -31,7 +32,7 @@ public class AddCommand extends ClientCommand{
|
||||
if(end.equals(".0")) {
|
||||
sum = sum.replace(".0","");
|
||||
}
|
||||
MessageText.send(event.getTextChannel(), args[0] + " + " + args[1] + " is **" + sum + "**.");
|
||||
MessageText.send(event.getChannel().asTextChannel(), args[0] + " + " + args[1] + " is **" + sum + "**.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.fpghoti.biscuit.commands.discord;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
import com.fpghoti.biscuit.util.Util;
|
||||
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
//import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
public class AddYTFeedCommand extends ClientCommand{
|
||||
|
||||
public AddYTFeedCommand() {
|
||||
name = "Add YouTube Feed";
|
||||
description = "Sets bot to post YouTube uploads for a specified YouTube channel RSS feed inside the text channel the command was run in";
|
||||
usage = Main.getMainBiscuit().getProperties().getCommandSignifier() + "addytfeed <alias> <channel-rss-url> <message>";
|
||||
minArgs = 1;
|
||||
maxArgs = 1000000;
|
||||
identifiers.add("addytfeed");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
System.out.println("0");
|
||||
BiscuitGuild b = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -addytfeed " + args[0]);
|
||||
System.out.println("A");
|
||||
if((PermUtil.isAdmin(event.getMember()))) {
|
||||
System.out.println("B");
|
||||
Guild g = event.getGuild();
|
||||
TextChannel c = event.getChannel().asTextChannel();
|
||||
String alias = args[0];
|
||||
String channelURL = args[1];
|
||||
String message = Util.getArgsMessage(2, args);
|
||||
System.out.println("C");
|
||||
boolean success = b.addYoutubeFeed(alias, c, channelURL, message);
|
||||
System.out.println("D");
|
||||
if(success) {
|
||||
MessageText.send(event.getChannel().asTextChannel(), "YouTube Feed has been created.");
|
||||
}else {
|
||||
MessageText.send(event.getChannel().asTextChannel(), "There was an error creating the YouTube feed.");
|
||||
}
|
||||
}else {
|
||||
MessageText.send(event.getChannel().asTextChannel(), "You do not have permission to create a YouTube feed.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.fpghoti.biscuit.commands.discord;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
@@ -20,10 +20,10 @@ public class ChanIDCommand extends ClientCommand{
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
BiscuitGuild b = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -chanid");
|
||||
String id = event.getChannel().getId();
|
||||
MessageText.send(event.getTextChannel(), id);
|
||||
MessageText.send(event.getChannel().asTextChannel(), id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.fpghoti.biscuit.commands.discord;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
import com.fpghoti.biscuit.util.Util;
|
||||
|
||||
@@ -22,7 +22,7 @@ public class DivideCommand extends ClientCommand{
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
BiscuitGuild b = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -divide");
|
||||
if(args[0] != null && Util.isDeciDigit(args[0]) && args[1] != null && Util.isDeciDigit(args[1])) {
|
||||
double num = Double.parseDouble(args[0]);
|
||||
@@ -32,7 +32,7 @@ public class DivideCommand extends ClientCommand{
|
||||
if(end.equals(".0")) {
|
||||
divide = divide.replace(".0","");
|
||||
}
|
||||
MessageText.send(event.getTextChannel(), args[0] + " / " + args[1] + " is **" + divide + "**.");
|
||||
MessageText.send(event.getChannel().asTextChannel(), args[0] + " / " + args[1] + " is **" + divide + "**.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
package com.fpghoti.biscuit.commands.discord;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.logging.BColor;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import net.dv8tion.jda.api.utils.FileUpload;
|
||||
|
||||
public class GetConfigCommand extends ClientCommand{
|
||||
|
||||
@@ -22,13 +25,17 @@ public class GetConfigCommand extends ClientCommand{
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
BiscuitGuild b = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -getconfig");
|
||||
if(PermUtil.isAdmin(event.getMember())) {
|
||||
event.getChannel().sendFile(b.getConfig().getFile(), "config-" + b.getProperties().getGuildCode() + ".properties").queue();
|
||||
File config = b.getConfig().getFile();
|
||||
FileUpload confUpload = FileUpload.fromData(config);
|
||||
confUpload.setName("config-" + b.getProperties().getGuildCode() + ".properties");
|
||||
//event.getChannel().sendFile(config, "config-" + b.getProperties().getGuildCode() + ".properties").queue();
|
||||
event.getChannel().asTextChannel().sendFiles(confUpload).queue();
|
||||
}else {
|
||||
b.log(BColor.MAGENTA_BOLD + event.getAuthor().getName() + " lacks permission to view the config!");
|
||||
MessageText.sendTimed(event.getTextChannel(), event.getAuthor().getAsMention() + " You do not have "
|
||||
MessageText.sendTimed(event.getChannel().asTextChannel(), event.getAuthor().getAsMention() + " You do not have "
|
||||
+ "permission to view the config.", 5);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.fpghoti.biscuit.commands.discord;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
|
||||
@@ -22,10 +22,10 @@ public class GuildIDCommand extends ClientCommand{
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
BiscuitGuild b = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -guildid");
|
||||
if(PermUtil.isMod(event.getMember())) {
|
||||
MessageText.send(event.getTextChannel(), event.getGuild().getId());
|
||||
MessageText.send(event.getChannel().asTextChannel(), event.getGuild().getId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,12 +4,12 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.BaseCommand;
|
||||
import com.fpghoti.biscuit.commands.CommandManager;
|
||||
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.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
import com.fpghoti.biscuit.util.Util;
|
||||
|
||||
@@ -29,14 +29,14 @@ public class HelpCommand extends ClientCommand {
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
|
||||
Biscuit biscuit = Biscuit.getBiscuit(event.getGuild());
|
||||
BiscuitGuild biscuit = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
|
||||
int pg = 1;
|
||||
if (args.length > 0) {
|
||||
if(Util.isDigit(args[0])) {
|
||||
pg = Integer.parseInt(args[0]);
|
||||
}else {
|
||||
MessageText.send(event.getTextChannel(), "Usage: ``" + usage + "``");
|
||||
MessageText.send(event.getChannel().asTextChannel(), "Usage: ``" + usage + "``");
|
||||
}
|
||||
}
|
||||
List<BaseCommand> commands = new ArrayList<BaseCommand>();
|
||||
@@ -66,8 +66,8 @@ public class HelpCommand extends ClientCommand {
|
||||
pg = pageCount;
|
||||
}
|
||||
|
||||
MessageText.send(event.getTextChannel(), "**Use " + Main.getMainBiscuit().getProperties().getCommandSignifier() + "help [Page #] to navigate the different pages.**");
|
||||
MessageText.send(event.getTextChannel(), "[" + Integer.toString(pg) + "/" + Integer.toString(pageCount) + "] **Bot Commands:**");
|
||||
MessageText.send(event.getChannel().asTextChannel(), "**Use " + Main.getMainBiscuit().getProperties().getCommandSignifier() + "help [Page #] to navigate the different pages.**");
|
||||
MessageText.send(event.getChannel().asTextChannel(), "[" + Integer.toString(pg) + "/" + Integer.toString(pageCount) + "] **Bot Commands:**");
|
||||
String msg = "";
|
||||
for (int i = 0; i < 8; i++) {
|
||||
int index = (pg - 1) * 8 + i;
|
||||
@@ -82,7 +82,7 @@ public class HelpCommand extends ClientCommand {
|
||||
msg = msg + line;
|
||||
}
|
||||
}
|
||||
MessageText.send(event.getTextChannel(), msg);
|
||||
MessageText.send(event.getChannel().asTextChannel(), msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
package com.fpghoti.biscuit.commands.discord;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
import com.fpghoti.biscuit.util.Util;
|
||||
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
//import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
public class MakeInviteCommand extends ClientCommand{
|
||||
@@ -29,7 +30,7 @@ public class MakeInviteCommand extends ClientCommand{
|
||||
doubAge = Double.parseDouble(args[1]) * 3600;
|
||||
}
|
||||
int maxAge = (int)Math.round(doubAge);
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
BiscuitGuild b = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -makeinvite " + args[0]);
|
||||
if((PermUtil.isAdmin(event.getMember()))) {
|
||||
Guild g = event.getGuild();
|
||||
@@ -40,7 +41,7 @@ public class MakeInviteCommand extends ClientCommand{
|
||||
}
|
||||
}
|
||||
if(doubAge > 86400) {
|
||||
MessageText.send(event.getTextChannel(), "That length is longer than what Discord allows. Please try again. (Max 24 hours)");
|
||||
MessageText.send(event.getChannel().asTextChannel(), "That length is longer than what Discord allows. Please try again. (Max 24 hours)");
|
||||
return;
|
||||
}
|
||||
final double db = doubAge;
|
||||
@@ -50,7 +51,7 @@ public class MakeInviteCommand extends ClientCommand{
|
||||
if(db > 0) {
|
||||
exp = args[1] + " hour(s)";
|
||||
}
|
||||
MessageText.send(event.getTextChannel(), "Created invite **" + i.getCode() + "** Expiration: **" + exp + "**.");
|
||||
MessageText.send(event.getChannel().asTextChannel(), "Created invite **" + i.getCode() + "** Expiration: **" + exp + "**.");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.fpghoti.biscuit.commands.discord;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
import com.fpghoti.biscuit.util.Util;
|
||||
|
||||
@@ -22,7 +22,7 @@ public class MultiplyCommand extends ClientCommand{
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
BiscuitGuild b = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -multiply");
|
||||
if(args[0] != null && Util.isDeciDigit(args[0]) && args[1] != null && Util.isDeciDigit(args[1])) {
|
||||
double num = Double.parseDouble(args[0]);
|
||||
@@ -32,7 +32,7 @@ public class MultiplyCommand extends ClientCommand{
|
||||
if(end.equals(".0")) {
|
||||
prod = prod.replace(".0","");
|
||||
}
|
||||
MessageText.send(event.getTextChannel(), args[0] + " x " + args[1] + " is **" + prod + "**.");
|
||||
MessageText.send(event.getChannel().asTextChannel(), args[0] + " x " + args[1] + " is **" + prod + "**.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.fpghoti.biscuit.commands.discord;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
|
||||
@@ -23,14 +23,14 @@ public class NotSpammerCommand extends ClientCommand{
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
BiscuitGuild b = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -notspammer " + args[0]);
|
||||
for(Member m : event.getMessage().getMentionedMembers()){
|
||||
for(Member m : event.getMessage().getMentions().getMembers()){
|
||||
User u = m.getUser();
|
||||
String s = u.getAsMention();
|
||||
if(event.getChannel().getName().equals("public-spam-test") || (PermUtil.isMod(event.getMember()))) {
|
||||
b.getMessageStore().removeSpammer(u);
|
||||
MessageText.send(event.getTextChannel(), s + " is no longer flagged as spam.");
|
||||
MessageText.send(event.getChannel().asTextChannel(), s + " is no longer flagged as spam.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.fpghoti.biscuit.commands.discord;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
@@ -20,9 +20,9 @@ public class PingCommand extends ClientCommand{
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
BiscuitGuild b = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -ping");
|
||||
MessageText.send(event.getTextChannel(), "Pong!");
|
||||
MessageText.send(event.getChannel().asTextChannel(), "Pong!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.fpghoti.biscuit.commands.discord;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
import com.fpghoti.biscuit.util.Util;
|
||||
|
||||
@@ -22,7 +22,7 @@ public class PowerCommand extends ClientCommand{
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
BiscuitGuild b = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -power");
|
||||
if(args[0] != null && Util.isDeciDigit(args[0]) && args[1] != null && Util.isDeciDigit(args[1])) {
|
||||
double num = Double.parseDouble(args[0]);
|
||||
@@ -32,7 +32,7 @@ public class PowerCommand extends ClientCommand{
|
||||
if(end.equals(".0")) {
|
||||
pow = pow.replace(".0","");
|
||||
}
|
||||
MessageText.send(event.getTextChannel(), args[0] + "^" + args[1] + " is **" + pow + "**.");
|
||||
MessageText.send(event.getChannel().asTextChannel(), args[0] + "^" + args[1] + " is **" + pow + "**.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.fpghoti.biscuit.commands.discord;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
@@ -20,10 +20,10 @@ public class RecentSpammersCommand extends ClientCommand{
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
BiscuitGuild b = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -recentspammers");
|
||||
String msg = b.getMessageStore().getSpammerList();
|
||||
MessageText.send(event.getTextChannel(), msg);
|
||||
MessageText.send(event.getChannel().asTextChannel(), msg);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ package com.fpghoti.biscuit.commands.discord;
|
||||
import java.util.List;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.logging.BColor;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
@@ -25,28 +25,28 @@ public class SaveConfigCommand extends ClientCommand{
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
BiscuitGuild b = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -saveconfig");
|
||||
List<Attachment> attch = event.getMessage().getAttachments();
|
||||
if(PermUtil.isAdmin(event.getMember())) {
|
||||
if(!attch.isEmpty()) {
|
||||
if(attch.size() == 1) {
|
||||
for(Attachment a : attch) {
|
||||
b.getConfig().replaceConfig(a, event.getTextChannel());
|
||||
b.getConfig().replaceConfig(a, event.getChannel().asTextChannel());
|
||||
b.remove();
|
||||
b = Biscuit.loadGuild(event.getGuild());
|
||||
b = BiscuitGuild.loadGuild(event.getGuild());
|
||||
}
|
||||
}else {
|
||||
MessageText.sendTimed(event.getTextChannel(), event.getAuthor().getAsMention() + " Too many attachments added! "
|
||||
MessageText.sendTimed(event.getChannel().asTextChannel(), event.getAuthor().getAsMention() + " Too many attachments added! "
|
||||
+ "Please only include the config file you want to save.", 5);
|
||||
}
|
||||
}else {
|
||||
MessageText.sendTimed(event.getTextChannel(), event.getAuthor().getAsMention() + " You need to send "
|
||||
MessageText.sendTimed(event.getChannel().asTextChannel(), event.getAuthor().getAsMention() + " You need to send "
|
||||
+ "a file in order to save the config.", 5);
|
||||
}
|
||||
}else {
|
||||
b.log(BColor.MAGENTA_BOLD + event.getAuthor().getName() + " lacks permission to save the config!");
|
||||
MessageText.sendTimed(event.getTextChannel(), event.getAuthor().getAsMention() + " You do not have "
|
||||
MessageText.sendTimed(event.getChannel().asTextChannel(), event.getAuthor().getAsMention() + " You do not have "
|
||||
+ "permission to save the config.", 5);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.fpghoti.biscuit.commands.discord;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
|
||||
@@ -23,19 +23,19 @@ public class SoftMuteCommand extends ClientCommand{
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
BiscuitGuild b = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -softmute " + args[0]);
|
||||
for(Member m : event.getMessage().getMentionedMembers()){
|
||||
for(Member m : event.getMessage().getMentions().getMembers()){
|
||||
User u = m.getUser();
|
||||
String s = u.getAsMention();
|
||||
if(b.getMessageStore().isSoftmuted(u)) {
|
||||
MessageText.sendTimed(event.getTextChannel(), s + " is already softmuted.", 3);
|
||||
MessageText.sendTimed(event.getChannel().asTextChannel(), s + " is already softmuted.", 3);
|
||||
return;
|
||||
}
|
||||
if(event.getChannel().getName().equals("public-softmute-test") || (PermUtil.isMod(event.getMember()))) {
|
||||
b.getMessageStore().addSoftmuted(u);
|
||||
u.openPrivateChannel().queue();
|
||||
MessageText.send(event.getTextChannel(), s + " is now soft-muted. They will now be only able to send one message every two minutes.");
|
||||
MessageText.send(event.getChannel().asTextChannel(), s + " is now soft-muted. They will now be only able to send one message every two minutes.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.fpghoti.biscuit.commands.discord;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
import com.fpghoti.biscuit.util.Util;
|
||||
|
||||
@@ -22,7 +22,7 @@ public class SquareRootCommand extends ClientCommand{
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
BiscuitGuild b = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -squareroot");
|
||||
if(args[0] != null && Util.isDeciDigit(args[0])) {
|
||||
double num = Double.parseDouble(args[0]);
|
||||
@@ -31,7 +31,7 @@ public class SquareRootCommand extends ClientCommand{
|
||||
if(end.equals(".0")) {
|
||||
root = root.replace(".0","");
|
||||
}
|
||||
MessageText.send(event.getTextChannel(), "The sqaure root of " + args[0] + " is **" + root + "**.");
|
||||
MessageText.send(event.getChannel().asTextChannel(), "The sqaure root of " + args[0] + " is **" + root + "**.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.fpghoti.biscuit.commands.discord;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
import com.fpghoti.biscuit.util.Util;
|
||||
|
||||
@@ -22,7 +22,7 @@ public class SubtractCommand extends ClientCommand{
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
BiscuitGuild b = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -subtract");
|
||||
if(args[0] != null && Util.isDeciDigit(args[0]) && args[1] != null && Util.isDeciDigit(args[1])) {
|
||||
double num = Double.parseDouble(args[0]);
|
||||
@@ -32,7 +32,7 @@ public class SubtractCommand extends ClientCommand{
|
||||
if(end.equals(".0")) {
|
||||
sub = sub.replace(".0","");
|
||||
}
|
||||
MessageText.send(event.getTextChannel(), args[0] + " - " + args[1] + " is **" + sub + "**.");
|
||||
MessageText.send(event.getChannel().asTextChannel(), args[0] + " - " + args[1] + " is **" + sub + "**.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
package com.fpghoti.biscuit.commands.discord;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
|
||||
import net.dv8tion.jda.api.entities.Emote;
|
||||
import net.dv8tion.jda.api.entities.Role;
|
||||
import net.dv8tion.jda.api.entities.emoji.Emoji;
|
||||
import net.dv8tion.jda.api.entities.emoji.EmojiUnion;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
public class ToggleRoleCommand extends ClientCommand{
|
||||
@@ -24,7 +25,7 @@ public class ToggleRoleCommand extends ClientCommand{
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
BiscuitGuild b = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
if(!event.getAuthor().isBot()) {
|
||||
b.log(event.getAuthor().getName() + " issued a command: -togglerole " + args[0]);
|
||||
boolean foundEmote = false;
|
||||
@@ -38,7 +39,7 @@ public class ToggleRoleCommand extends ClientCommand{
|
||||
}
|
||||
|
||||
if(rolename.equals("")) {
|
||||
MessageText.send(event.getTextChannel(), "Sorry! This role either cannot be toggled or does not exist!");
|
||||
MessageText.send(event.getChannel().asTextChannel(), "Sorry! This role either cannot be toggled or does not exist!");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -53,8 +54,8 @@ public class ToggleRoleCommand extends ClientCommand{
|
||||
return;
|
||||
}
|
||||
|
||||
Emote done = null;
|
||||
for(Emote e : event.getGuild().getEmotes()) {
|
||||
Emoji done = null;
|
||||
for(Emoji e : event.getMessage().getMentions().getCustomEmojis()) {
|
||||
if(e.getName().contains(b.getProperties().getDoneEmote())) {
|
||||
done = e;
|
||||
}
|
||||
@@ -80,7 +81,8 @@ public class ToggleRoleCommand extends ClientCommand{
|
||||
if(foundEmote) {
|
||||
event.getMessage().addReaction(done).queue();
|
||||
}else {
|
||||
event.getMessage().addReaction("✔").queue();
|
||||
//event.getMessage().addReaction("✔").queue();
|
||||
event.getMessage().addReaction(Emoji.fromFormatted("U+2714")).queue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.fpghoti.biscuit.commands.discord;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
|
||||
@@ -23,12 +23,12 @@ public class UIDCommand extends ClientCommand{
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
BiscuitGuild b = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -uid " + args[0]);
|
||||
for(Member m : event.getMessage().getMentionedMembers()){
|
||||
for(Member m : event.getMessage().getMentions().getMembers()){
|
||||
User u = m.getUser();
|
||||
if(PermUtil.isMod(event.getMember())) {
|
||||
MessageText.send(event.getTextChannel(), u.getId());
|
||||
MessageText.send(event.getChannel().asTextChannel(), u.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.fpghoti.biscuit.commands.discord;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
|
||||
@@ -23,14 +23,14 @@ public class UnSoftMuteCommand extends ClientCommand{
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
BiscuitGuild b = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -unsoftmute " + args[0]);
|
||||
for(Member m : event.getMessage().getMentionedMembers()){
|
||||
for(Member m : event.getMessage().getMentions().getMembers()){
|
||||
User u = m.getUser();
|
||||
String s = u.getAsMention();
|
||||
if(event.getChannel().getName().equals("public-softmute-test") || (PermUtil.isMod(event.getMember()))) {
|
||||
b.getMessageStore().removeSoftmuted(u);
|
||||
MessageText.send(event.getTextChannel(), s + " is no longer soft-muted.");
|
||||
MessageText.send(event.getChannel().asTextChannel(), s + " is no longer soft-muted.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.fpghoti.biscuit.commands.discord;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.base.ClientCommand;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
|
||||
@@ -21,10 +21,10 @@ public class WikiCommand extends ClientCommand{
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
BiscuitGuild b = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -wiki");
|
||||
if(PermUtil.isMod(event.getMember())) {
|
||||
MessageText.send(event.getTextChannel(), "https://git.fpghoti.com/thmsdy/Biscuit/wiki");
|
||||
MessageText.send(event.getChannel().asTextChannel(), "https://git.fpghoti.com/thmsdy/Biscuit/wiki");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.fpghoti.biscuit.commands.discord.music;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
|
||||
@@ -21,10 +21,10 @@ public class ClearCommand extends MusicClientCommand{
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
BiscuitGuild b = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -clear");
|
||||
if(PermUtil.hasMusicControl(event.getMember())) {
|
||||
MessageText.send(event.getTextChannel(), "Cleared all upcoming songs from the queue.");
|
||||
MessageText.send(event.getChannel().asTextChannel(), "Cleared all upcoming songs from the queue.");
|
||||
b.getAudioScheduler().getQueue().clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.fpghoti.biscuit.commands.discord.music;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
|
||||
@@ -23,11 +23,11 @@ public class ClearUserSongsCommand extends MusicClientCommand{
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
BiscuitGuild b = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -clearusersongs " + args[0]);
|
||||
if(PermUtil.hasMusicControl(event.getMember())) {
|
||||
for(Member m : event.getMessage().getMentionedMembers()) {
|
||||
MessageText.send(event.getTextChannel(), "Clearing all upcoming tracks added by **" + m.getEffectiveName() + "**.");
|
||||
for(Member m : event.getMessage().getMentions().getMembers()) {
|
||||
MessageText.send(event.getChannel().asTextChannel(), "Clearing all upcoming tracks added by **" + m.getEffectiveName() + "**.");
|
||||
b.getAudioScheduler().getQueue().removeUserTracks(m.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.fpghoti.biscuit.commands.discord.music;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
|
||||
@@ -21,11 +21,11 @@ public class ForceSkipCommand extends MusicClientCommand{
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
BiscuitGuild b = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -forceskip");
|
||||
if(PermUtil.hasMusicControl(event.getMember())) {
|
||||
MessageText.send(event.getTextChannel(), "Force skipping current song.");
|
||||
b.getAudioScheduler().skip(event.getTextChannel());
|
||||
MessageText.send(event.getChannel().asTextChannel(), "Force skipping current song.");
|
||||
b.getAudioScheduler().skip(event.getChannel().asTextChannel());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.fpghoti.biscuit.commands.discord.music;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
import com.fpghoti.biscuit.util.Util;
|
||||
@@ -23,14 +23,14 @@ public class ForceSkipToCommand extends MusicClientCommand{
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
BiscuitGuild b = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -forceskipto " + args[0]);
|
||||
if(PermUtil.hasMusicControl(event.getMember())) {
|
||||
if(Util.isDigit(args[0])) {
|
||||
int place = Integer.parseInt(args[0]);
|
||||
MessageText.send(event.getTextChannel(), "Force skipping to queue position **" + place + "**.");
|
||||
MessageText.send(event.getChannel().asTextChannel(), "Force skipping to queue position **" + place + "**.");
|
||||
b.getAudioScheduler().getQueue().removeTracksBefore(place);
|
||||
b.getAudioScheduler().skip(event.getTextChannel());
|
||||
b.getAudioScheduler().skip(event.getChannel().asTextChannel());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.fpghoti.biscuit.commands.discord.music;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
|
||||
@@ -21,14 +21,14 @@ public class LoopMusicCommand extends MusicClientCommand{
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
BiscuitGuild b = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -loopmusic");
|
||||
if(PermUtil.hasMusicControl(event.getMember())) {
|
||||
if(!b.getAudioScheduler().isLooping()) {
|
||||
MessageText.send(event.getTextChannel(), "Setting all music to loop.");
|
||||
MessageText.send(event.getChannel().asTextChannel(), "Setting all music to loop.");
|
||||
b.getAudioScheduler().setLooping(true);
|
||||
}else {
|
||||
MessageText.send(event.getTextChannel(), "Disabling music looping.");
|
||||
MessageText.send(event.getChannel().asTextChannel(), "Disabling music looping.");
|
||||
b.getAudioScheduler().setLooping(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.fpghoti.biscuit.commands.discord.music;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
import com.fpghoti.biscuit.util.Util;
|
||||
@@ -22,13 +22,13 @@ public class MoveToCommand extends MusicClientCommand{
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
BiscuitGuild b = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -moveto " + args[0] + " " + args[1]);
|
||||
if(PermUtil.hasMusicControl(event.getMember())) {
|
||||
if(Util.isDigit(args[0]) && Util.isDigit(args[1])) {
|
||||
int oldPlace = Integer.parseInt(args[0]);
|
||||
int newPlace = Integer.parseInt(args[1]);
|
||||
MessageText.send(event.getTextChannel(), "The specified track was moved." );
|
||||
MessageText.send(event.getChannel().asTextChannel(), "The specified track was moved." );
|
||||
b.getAudioScheduler().getQueue().moveToPlace(oldPlace, newPlace);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.fpghoti.biscuit.commands.discord.music;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
|
||||
import net.dv8tion.jda.api.entities.MessageEmbed;
|
||||
@@ -21,13 +21,13 @@ public class NowPlayingCommand extends MusicClientCommand{
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
BiscuitGuild b = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -nowplaying");
|
||||
if(b.getAudioScheduler().getQueue().getLastTrack() != null ) {
|
||||
MessageEmbed next = b.getAudioScheduler().getQueue().getLastTrack().getEmbedMessage("Now Playing:", true);
|
||||
MessageText.send(event.getTextChannel(), next);
|
||||
MessageText.send(event.getChannel().asTextChannel(), next);
|
||||
}else {
|
||||
MessageText.send(event.getTextChannel(), "No song is currently playing.");
|
||||
MessageText.send(event.getChannel().asTextChannel(), "No song is currently playing.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.fpghoti.biscuit.commands.discord.music;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
|
||||
@@ -21,14 +21,14 @@ public class PauseCommand extends MusicClientCommand{
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
BiscuitGuild b = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -pause");
|
||||
if(PermUtil.hasMusicControl(event.getMember())) {
|
||||
if(!b.getAudioPlayer().isPaused()) {
|
||||
b.getAudioPlayer().setPaused(true);
|
||||
MessageText.send(event.getTextChannel(), "Paused the current track.");
|
||||
MessageText.send(event.getChannel().asTextChannel(), "Paused the current track.");
|
||||
}else {
|
||||
MessageText.send(event.getTextChannel(), "The music player is already paused.");
|
||||
MessageText.send(event.getChannel().asTextChannel(), "The music player is already paused.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,29 @@
|
||||
package com.fpghoti.biscuit.commands.discord.music;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.audio.PlayCommandUtil;
|
||||
import com.fpghoti.biscuit.audio.AudioHandler;
|
||||
import com.fpghoti.biscuit.audio.request.PlayRequest;
|
||||
import com.fpghoti.biscuit.audio.request.RequestType;
|
||||
import com.fpghoti.biscuit.audio.request.file.FileRequest;
|
||||
import com.fpghoti.biscuit.audio.request.soundcloud.SCRequest;
|
||||
import com.fpghoti.biscuit.audio.request.youtube.YTRequest;
|
||||
import com.fpghoti.biscuit.audio.result.FileResultHandler;
|
||||
import com.fpghoti.biscuit.audio.result.ResultHandler;
|
||||
import com.fpghoti.biscuit.audio.result.SCResultHandler;
|
||||
import com.fpghoti.biscuit.audio.result.YTResultHandler;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.audio.util.AudioUtil;
|
||||
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import net.dv8tion.jda.api.managers.AudioManager;
|
||||
|
||||
public class PlayCommand extends MusicClientCommand{
|
||||
|
||||
@@ -29,37 +39,148 @@ public class PlayCommand extends MusicClientCommand{
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Guild guild = event.getGuild();
|
||||
Biscuit b = Biscuit.getBiscuit(guild);
|
||||
|
||||
BiscuitGuild b = BiscuitGuild.getBiscuitGuild(guild);
|
||||
|
||||
int searchArg = 0;
|
||||
|
||||
boolean playFirst = false;
|
||||
boolean scSearch = false;
|
||||
|
||||
if(args[0].equalsIgnoreCase("-sc")) {
|
||||
scSearch = true;
|
||||
searchArg = 1;
|
||||
boolean isFile = false;
|
||||
|
||||
if(args[0].equalsIgnoreCase("-first")) {
|
||||
searchArg += 1;
|
||||
if(!PermUtil.hasMusicControl(event.getMember())) {
|
||||
MessageText.send(event.getChannel().asTextChannel(), "You do not have permission to do this!");
|
||||
return;
|
||||
}
|
||||
playFirst = true;
|
||||
}
|
||||
|
||||
String searchPhrase = PlayCommandUtil.getSearchPhrase(args, searchArg);
|
||||
if(args[searchArg].equalsIgnoreCase("-sc")) {
|
||||
scSearch = true;
|
||||
searchArg += 1;
|
||||
}else if (args[searchArg].equalsIgnoreCase("-file") || args[searchArg].equalsIgnoreCase("-fileid") || args[searchArg].equalsIgnoreCase("-fid")) {
|
||||
isFile = true;
|
||||
searchArg += 1;
|
||||
}
|
||||
|
||||
String searchPhrase = getSearchPhrase(args, searchArg);
|
||||
|
||||
b.log(event.getAuthor().getName() + " issued a command: -play " + searchPhrase);
|
||||
|
||||
boolean connected = PlayCommandUtil.connectToChannel(event);
|
||||
boolean connected = connectToChannel(event);
|
||||
if(!connected) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
PlayRequest request;
|
||||
ResultHandler handler;
|
||||
|
||||
|
||||
if(scSearch) {
|
||||
request = PlayRequest.createPlayRequest(RequestType.SOUNDCLOUD, event.getMessage(), searchPhrase);
|
||||
if(playFirst) {
|
||||
request = PlayRequest.createPlayRequest(RequestType.SOUNDCLOUD_PRIORITY, event.getMessage(), searchPhrase, 1);
|
||||
} else {
|
||||
request = PlayRequest.createPlayRequest(RequestType.SOUNDCLOUD, event.getMessage(), searchPhrase);
|
||||
}
|
||||
handler = new SCResultHandler((SCRequest)request);
|
||||
}else if(isFile) {
|
||||
File file = AudioUtil.getAudioFile(searchPhrase);
|
||||
if(file == null) {
|
||||
MessageText.send(event.getChannel().asTextChannel(), "Unable to locate file.");
|
||||
if(b.getAudioScheduler().getQueue().isEmpty()) {
|
||||
b.getGuild().getAudioManager().closeAudioConnection();
|
||||
}
|
||||
return;
|
||||
}
|
||||
String filename = file.getPath();
|
||||
if(playFirst) {
|
||||
request = PlayRequest.createPlayRequest(RequestType.FILE_PRIORITY, event.getMessage(), filename, 1);
|
||||
}else {
|
||||
request = PlayRequest.createPlayRequest(RequestType.FILE, event.getMessage(), filename);
|
||||
}
|
||||
|
||||
handler = new FileResultHandler((FileRequest)request);
|
||||
|
||||
Main.getPlayerManager().loadItemOrdered(guild, filename, handler);
|
||||
return;
|
||||
}else {
|
||||
request = PlayRequest.createPlayRequest(event.getMessage(), searchPhrase);
|
||||
if(playFirst) {
|
||||
request = PlayRequest.createPlayRequest(event.getMessage(), searchPhrase, 1);
|
||||
}else {
|
||||
request = PlayRequest.createPlayRequest(event.getMessage(), searchPhrase);
|
||||
}
|
||||
handler = new YTResultHandler((YTRequest)request);
|
||||
}
|
||||
|
||||
Main.getPlayerManager().loadItemOrdered(guild, getID(event), handler);
|
||||
}
|
||||
|
||||
public static boolean connectToChannel(MessageReceivedEvent event) {
|
||||
if(!event.isFromGuild()) {
|
||||
return false;
|
||||
}
|
||||
Guild guild = event.getGuild();
|
||||
BiscuitGuild biscuit = BiscuitGuild.getBiscuitGuild(guild);
|
||||
TextChannel textChannel = event.getChannel().asTextChannel();
|
||||
|
||||
Main.getPlayerManager().loadItemOrdered(guild, PlayCommandUtil.getID(event), handler);
|
||||
String vcname = "";
|
||||
if(!event.getMember().getVoiceState().inAudioChannel()) {
|
||||
MessageText.send(textChannel, "You must be in a voice channel to do this!");
|
||||
return false;
|
||||
}
|
||||
vcname = event.getMember().getVoiceState().getChannel().getName();
|
||||
String[] musicChannels = biscuit.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) {
|
||||
MessageText.send(textChannel, "You are not in a channel that is authorized to use the music player.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(biscuit.getAudioPlayer().getPlayingTrack() != null && guild.getAudioManager().isConnected() && !guild.getAudioManager().getConnectedChannel().getMembers().contains(event.getMember())) {
|
||||
MessageText.send(textChannel, "Music is already playing in a voice channel. Connect to "
|
||||
+ "that channel, then queue your song.");
|
||||
return false;
|
||||
}
|
||||
|
||||
VoiceChannel voiceChannel = guild.getVoiceChannelsByName(vcname, true).get(0);
|
||||
AudioManager manager = guild.getAudioManager();
|
||||
|
||||
manager.setSendingHandler(new AudioHandler(biscuit.getAudioPlayer()));
|
||||
manager.openAudioConnection(voiceChannel);
|
||||
return true;
|
||||
}
|
||||
|
||||
private String getSearchPhrase(String[] args, int startArg) {
|
||||
if(startArg >= args.length) {
|
||||
return "";
|
||||
}
|
||||
String searchPhrase = args[startArg];
|
||||
if(args.length > startArg + 1) {
|
||||
for(int i = startArg + 1; i < args.length; i++) {
|
||||
searchPhrase = searchPhrase + " " + args[i];
|
||||
}
|
||||
}
|
||||
return searchPhrase;
|
||||
}
|
||||
|
||||
private String getID(MessageReceivedEvent event) {
|
||||
return getID(event.getMessage().getContentRaw().split(" ")[1]);
|
||||
}
|
||||
|
||||
private String getID(String url) {
|
||||
String[] s = url.split("=");
|
||||
if(s.length > 1) {
|
||||
return s[1].split("&")[0];
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
package com.fpghoti.biscuit.commands.discord.music;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.audio.PlayCommandUtil;
|
||||
import com.fpghoti.biscuit.audio.request.PlayRequest;
|
||||
import com.fpghoti.biscuit.audio.request.RequestType;
|
||||
import com.fpghoti.biscuit.audio.request.soundcloud.SCRequest;
|
||||
import com.fpghoti.biscuit.audio.request.youtube.YTRequest;
|
||||
import com.fpghoti.biscuit.audio.result.ResultHandler;
|
||||
import com.fpghoti.biscuit.audio.result.SCResultHandler;
|
||||
import com.fpghoti.biscuit.audio.result.YTResultHandler;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
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 <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();
|
||||
|
||||
int searchArg = 0;
|
||||
boolean scSearch = false;
|
||||
|
||||
if(args[0].equalsIgnoreCase("-sc")) {
|
||||
scSearch = true;
|
||||
searchArg = 1;
|
||||
}
|
||||
|
||||
String searchPhrase = PlayCommandUtil.getSearchPhrase(args, searchArg);
|
||||
|
||||
b.log(event.getAuthor().getName() + " issued a command: -playfirst " + searchPhrase);
|
||||
|
||||
if(!PermUtil.hasMusicControl(event.getMember())) {
|
||||
MessageText.send(tchannel, "You do not have permission to do this!");
|
||||
return;
|
||||
}
|
||||
|
||||
boolean connected = PlayCommandUtil.connectToChannel(event);
|
||||
if(!connected) {
|
||||
return;
|
||||
}
|
||||
|
||||
PlayRequest request;
|
||||
ResultHandler handler;
|
||||
|
||||
if(scSearch) {
|
||||
request = PlayRequest.createPlayRequest(RequestType.SOUNDCLOUD_PRIORITY, event.getMessage(), searchPhrase, 1);
|
||||
handler = new SCResultHandler((SCRequest)request);
|
||||
}else {
|
||||
request = PlayRequest.createPlayRequest(event.getMessage(), searchPhrase, 1);
|
||||
handler = new YTResultHandler((YTRequest)request);
|
||||
}
|
||||
|
||||
Main.getPlayerManager().loadItemOrdered(guild, PlayCommandUtil.getID(event), handler);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,8 +3,8 @@ package com.fpghoti.biscuit.commands.discord.music;
|
||||
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.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
import com.fpghoti.biscuit.util.Util;
|
||||
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
|
||||
@@ -26,14 +26,14 @@ public class QueueCommand extends MusicClientCommand{
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
|
||||
Biscuit biscuit = Biscuit.getBiscuit(event.getGuild());
|
||||
BiscuitGuild biscuit = BiscuitGuild.getBiscuitGuild(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 {
|
||||
MessageText.send(event.getTextChannel(), "Usage: ``" + usage + "``");
|
||||
MessageText.send(event.getChannel().asTextChannel(), "Usage: ``" + usage + "``");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,15 +46,15 @@ public class QueueCommand extends MusicClientCommand{
|
||||
|
||||
if(queue.size() == 0) {
|
||||
if(biscuit.getAudioPlayer().getPlayingTrack() == null) {
|
||||
MessageText.send(event.getTextChannel(), "There is currently no song playing.");
|
||||
MessageText.send(event.getChannel().asTextChannel(), "There is currently no song playing.");
|
||||
}else {
|
||||
MessageText.send(event.getTextChannel(), "Nothing is queued to play after the current track.");
|
||||
MessageText.send(event.getChannel().asTextChannel(), "Nothing is queued to play after the current track.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
MessageText.send(event.getTextChannel(), "**Use " + Main.getMainBiscuit().getProperties().getCommandSignifier() + "queue [Page #] to navigate the different pages.**");
|
||||
MessageText.send(event.getTextChannel(), "[" + Integer.toString(pg) + "/" + Integer.toString(pageCount) + "] ** Upcoming Music Tracks:**");
|
||||
MessageText.send(event.getChannel().asTextChannel(), "**Use " + Main.getMainBiscuit().getProperties().getCommandSignifier() + "queue [Page #] to navigate the different pages.**");
|
||||
MessageText.send(event.getChannel().asTextChannel(), "[" + Integer.toString(pg) + "/" + Integer.toString(pageCount) + "] ** Upcoming Music Tracks:**");
|
||||
String msg = "";
|
||||
for (int i = 0; i < 8; i++) {
|
||||
int index = (pg - 1) * 8 + i;
|
||||
@@ -76,7 +76,7 @@ public class QueueCommand extends MusicClientCommand{
|
||||
msg = msg + line;
|
||||
}
|
||||
}
|
||||
MessageText.send(event.getTextChannel(), msg);
|
||||
MessageText.send(event.getChannel().asTextChannel(), msg);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.fpghoti.biscuit.commands.discord.music;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
import com.fpghoti.biscuit.util.Util;
|
||||
@@ -22,12 +22,12 @@ public class RemoveCommand extends MusicClientCommand{
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
BiscuitGuild b = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -remove " + args[0]);
|
||||
if(PermUtil.hasMusicControl(event.getMember())) {
|
||||
if(Util.isDigit(args[0])) {
|
||||
int place = Integer.parseInt(args[0]);
|
||||
MessageText.send(event.getTextChannel(), "Removing track at position **" + place + "**.");
|
||||
MessageText.send(event.getChannel().asTextChannel(), "Removing track at position **" + place + "**.");
|
||||
b.getAudioScheduler().getQueue().removeTrack(place);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.fpghoti.biscuit.commands.discord.music;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
@@ -20,13 +20,13 @@ public class ShuffleCommand extends MusicClientCommand{
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
BiscuitGuild b = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -shuffle");
|
||||
if(b.getAudioScheduler().getQueue().getLastTrack() != null ) {
|
||||
b.getAudioScheduler().getQueue().shuffleUserTracks(event.getAuthor().getId());
|
||||
MessageText.send(event.getTextChannel(), "All songs that you have added to the queue have been shuffled.");
|
||||
MessageText.send(event.getChannel().asTextChannel(), "All songs that you have added to the queue have been shuffled.");
|
||||
}else {
|
||||
MessageText.send(event.getTextChannel(), "No song is currently playing.");
|
||||
MessageText.send(event.getChannel().asTextChannel(), "No song is currently playing.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.fpghoti.biscuit.commands.discord.music;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
|
||||
@@ -21,12 +21,12 @@ public class SkipAllCommand extends MusicClientCommand{
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
BiscuitGuild b = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -skipall");
|
||||
if(PermUtil.hasMusicControl(event.getMember())) {
|
||||
MessageText.send(event.getTextChannel(), "Force skipping all songs.");
|
||||
MessageText.send(event.getChannel().asTextChannel(), "Force skipping all songs.");
|
||||
b.getAudioScheduler().getQueue().clear();
|
||||
b.getAudioScheduler().skip(event.getTextChannel());
|
||||
b.getAudioScheduler().skip(event.getChannel().asTextChannel());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,14 +4,14 @@ import java.util.ArrayList;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.audio.AudioScheduler;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
|
||||
import net.dv8tion.jda.api.entities.AudioChannel;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.AudioChannel;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
public class SkipCommand extends MusicClientCommand{
|
||||
@@ -29,14 +29,14 @@ public class SkipCommand extends MusicClientCommand{
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
|
||||
Guild guild = event.getGuild();
|
||||
Biscuit biscuit = Biscuit.getBiscuit(guild);
|
||||
BiscuitGuild biscuit = BiscuitGuild.getBiscuitGuild(guild);
|
||||
biscuit.log(event.getAuthor().getName() + " issued a command: -skip");
|
||||
|
||||
TextChannel cmdChannel = event.getTextChannel();
|
||||
TextChannel cmdChannel = event.getChannel().asTextChannel();
|
||||
|
||||
//Bot is not connected to voice channel. Do nothing.
|
||||
if(!guild.getAudioManager().isConnected()) {
|
||||
MessageText.send(event.getTextChannel(), "The music player is not connected to a voice channel!");
|
||||
MessageText.send(event.getChannel().asTextChannel(), "The music player is not connected to a voice channel!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.fpghoti.biscuit.commands.discord.music;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
|
||||
@@ -22,15 +22,15 @@ public class TogglePauseCommand extends MusicClientCommand{
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
BiscuitGuild b = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -togglepause");
|
||||
if(PermUtil.hasMusicControl(event.getMember())) {
|
||||
if(b.getAudioPlayer().isPaused()) {
|
||||
b.getAudioPlayer().setPaused(false);
|
||||
MessageText.send(event.getTextChannel(), "Unpaused the current track.");
|
||||
MessageText.send(event.getChannel().asTextChannel(), "Unpaused the current track.");
|
||||
}else {
|
||||
b.getAudioPlayer().setPaused(true);
|
||||
MessageText.send(event.getTextChannel(), "Paused the current track.");
|
||||
MessageText.send(event.getChannel().asTextChannel(), "Paused the current track.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.fpghoti.biscuit.commands.discord.music;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
|
||||
@@ -22,14 +22,14 @@ public class UnpauseCommand extends MusicClientCommand{
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
BiscuitGuild b = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
b.log(event.getAuthor().getName() + " issued a command: -unpause");
|
||||
if(PermUtil.hasMusicControl(event.getMember())) {
|
||||
if(b.getAudioPlayer().isPaused()) {
|
||||
b.getAudioPlayer().setPaused(false);
|
||||
MessageText.send(event.getTextChannel(), "Unpaused the current track.");
|
||||
MessageText.send(event.getChannel().asTextChannel(), "Unpaused the current track.");
|
||||
}else {
|
||||
MessageText.send(event.getTextChannel(), "The music player is not paused.");
|
||||
MessageText.send(event.getChannel().asTextChannel(), "The music player is not paused.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.fpghoti.biscuit.commands.discord.music;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.base.MusicClientCommand;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
import com.fpghoti.biscuit.util.Util;
|
||||
@@ -23,11 +23,11 @@ public class VolumeCommand extends MusicClientCommand{
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, MessageReceivedEvent event) {
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
BiscuitGuild b = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
|
||||
if(args.length < 1) {
|
||||
b.log(event.getAuthor().getName() + " issued a command: -volume");
|
||||
MessageText.send(event.getTextChannel(), "The current volume is: **" + b.getAudioPlayer().getVolume() + "**.");
|
||||
MessageText.send(event.getChannel().asTextChannel(), "The current volume is: **" + b.getAudioPlayer().getVolume() + "**.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class VolumeCommand extends MusicClientCommand{
|
||||
vol = 150;
|
||||
}
|
||||
b.getAudioPlayer().setVolume(vol);
|
||||
MessageText.send(event.getTextChannel(), "The volume was set to **" + b.getAudioPlayer().getVolume() + "**.");
|
||||
MessageText.send(event.getChannel().asTextChannel(), "The volume was set to **" + b.getAudioPlayer().getVolume() + "**.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,19 +14,19 @@ import org.apache.commons.configuration2.PropertiesConfiguration;
|
||||
import org.apache.commons.configuration2.PropertiesConfigurationLayout;
|
||||
import org.apache.commons.configuration2.ex.ConfigurationException;
|
||||
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
import com.jcabi.aspects.Async;
|
||||
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.Message.Attachment;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
|
||||
public class BiscuitConfig {
|
||||
|
||||
private Biscuit biscuit;
|
||||
private BiscuitGuild biscuit;
|
||||
|
||||
public BiscuitConfig(Biscuit b) {
|
||||
public BiscuitConfig(BiscuitGuild b) {
|
||||
this.biscuit = b;
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ public class BiscuitConfig {
|
||||
return;
|
||||
}
|
||||
File config = new File(biscuit.getConfigDir(), name);
|
||||
a.downloadToFile(config).thenAccept(file -> {
|
||||
a.getProxy().downloadToFile(config).thenAccept(file -> {
|
||||
updateConfig(file, true, code);
|
||||
MessageText.send(c, "**The config was successfully updated.**");
|
||||
}).exceptionally(t -> {
|
||||
@@ -82,6 +82,7 @@ public class BiscuitConfig {
|
||||
MessageText.send(c, "**An Exception occurred while trying to read the file.**");
|
||||
return null;
|
||||
});
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -135,6 +136,7 @@ public class BiscuitConfig {
|
||||
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("Powershell-Display-Mode", "false", prop, added, silent);
|
||||
}
|
||||
|
||||
added = addProperty("Guild-Identifier", name, prop, added, silent);
|
||||
@@ -150,7 +152,7 @@ public class BiscuitConfig {
|
||||
|
||||
//Add properties to appear in both types of configs here
|
||||
added = addProperty("ChatLog", "true", prop, added, silent);
|
||||
added = addProperty("AllowSpamPunish", "true", prop, added, silent);
|
||||
added = addProperty("AllowSpamPunish", "false", prop, added, silent);
|
||||
added = addProperty("Channels-To-Not-Chatlog", "ignore_me,ignore_me2,ignore_me3", prop, added, silent);
|
||||
added = addProperty("NaughtyList", "piff,word123,another1", prop, added, silent);
|
||||
added = addProperty("Restrict-Cmd-Channels", "false", prop, added, silent);
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package com.fpghoti.biscuit.config;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.util.Util;
|
||||
|
||||
public class BiscuitProperties {
|
||||
|
||||
Biscuit biscuit;
|
||||
BiscuitGuild biscuit;
|
||||
|
||||
public BiscuitProperties(Biscuit b) {
|
||||
public BiscuitProperties(BiscuitGuild b) {
|
||||
this.biscuit = b;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,11 @@ public class BiscuitProperties {
|
||||
return Main.getMainBiscuit().getConfig().getFromConfig(key).equalsIgnoreCase("true");
|
||||
}
|
||||
|
||||
public boolean isPowerShell(){
|
||||
String key = "Powershell-Display-Mode";
|
||||
return Main.getMainBiscuit().getConfig().getFromConfig(key).equalsIgnoreCase("true");
|
||||
}
|
||||
|
||||
public boolean allowMusicBot(){
|
||||
if(!musicBotEnabled()) {
|
||||
return false;
|
||||
|
||||
@@ -1,11 +1,18 @@
|
||||
package com.fpghoti.biscuit.biscuit;
|
||||
package com.fpghoti.biscuit.guild;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.Timer;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.PluginCore;
|
||||
@@ -13,8 +20,10 @@ import com.fpghoti.biscuit.audio.AudioScheduler;
|
||||
import com.fpghoti.biscuit.config.BiscuitConfig;
|
||||
import com.fpghoti.biscuit.config.BiscuitProperties;
|
||||
import com.fpghoti.biscuit.logging.BColor;
|
||||
import com.fpghoti.biscuit.logging.BiscuitLog;
|
||||
import com.fpghoti.biscuit.logging.BiscuitLogger;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
import com.fpghoti.biscuit.rss.YTFeed;
|
||||
import com.fpghoti.biscuit.rss.YTFeedConfig;
|
||||
import com.fpghoti.biscuit.timer.BiscuitTimer;
|
||||
import com.fpghoti.biscuit.timer.task.ChatCountTimer;
|
||||
import com.fpghoti.biscuit.timer.task.DecrementTimer;
|
||||
@@ -29,13 +38,14 @@ import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.Invite;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Role;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
|
||||
public class Biscuit {
|
||||
|
||||
public static Biscuit getBiscuit(Guild g) {
|
||||
for(Biscuit b : Main.getBiscuits()) {
|
||||
public class BiscuitGuild {
|
||||
|
||||
public static BiscuitGuild getBiscuitGuild(Guild g) {
|
||||
for(BiscuitGuild b : Main.getBiscuits()) {
|
||||
if(b.getGuild().getId().equals(g.getId())) {
|
||||
return b;
|
||||
}
|
||||
@@ -43,8 +53,8 @@ public class Biscuit {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Biscuit getBiscuit(String guildcode) {
|
||||
for(Biscuit b : Main.getBiscuits()) {
|
||||
public static BiscuitGuild getBiscuitGuild(String guildcode) {
|
||||
for(BiscuitGuild b : Main.getBiscuits()) {
|
||||
if(b.getProperties().getGuildCode().equalsIgnoreCase(guildcode)) {
|
||||
return b;
|
||||
}
|
||||
@@ -56,7 +66,7 @@ public class Biscuit {
|
||||
ArrayList<PreUser> pres = new ArrayList<PreUser>();
|
||||
for(Guild g : Main.getJDA().getGuilds()) {
|
||||
if(g.isMember(u)){
|
||||
Biscuit b = getBiscuit(g);
|
||||
BiscuitGuild b = getBiscuitGuild(g);
|
||||
if(b.preUserExists(u)) {
|
||||
pres.add(b.getPreUser(u));
|
||||
}
|
||||
@@ -65,8 +75,8 @@ public class Biscuit {
|
||||
return pres;
|
||||
}
|
||||
|
||||
public static Biscuit loadGuild(Guild g) {
|
||||
Biscuit biscuit = new Biscuit(Main.getJDA(), g, Main.getLogger());
|
||||
public static BiscuitGuild loadGuild(Guild g) {
|
||||
BiscuitGuild biscuit = new BiscuitGuild(Main.getJDA(), g, Main.getLogger());
|
||||
biscuit.addTimer(new ChatCountTimer(biscuit));
|
||||
biscuit.addTimer(new SoftMuteTimer(biscuit));
|
||||
biscuit.addTimer(new DecrementTimer(biscuit));
|
||||
@@ -77,33 +87,36 @@ public class Biscuit {
|
||||
|
||||
private boolean isMain;
|
||||
private JDA jda;
|
||||
private BiscuitLog logger;
|
||||
private BiscuitLogger logger;
|
||||
private Timer timer;
|
||||
private List<BiscuitTimer> timers;
|
||||
private File captchaDir;
|
||||
private File ytFeedDir;
|
||||
//private Cage cage;
|
||||
private Guild guild;
|
||||
private HashMap<String, Integer> inviteUses;
|
||||
private HashMap<String, YTFeedConfig> ytfeeds;
|
||||
private BiscuitConfig config;
|
||||
private BiscuitProperties properties;
|
||||
private BiscuitMessageStore messageStore;
|
||||
private GuildMessageStore messageStore;
|
||||
private AudioPlayer player;
|
||||
private AudioScheduler scheduler;
|
||||
|
||||
private CopyOnWriteArrayList<PreUser> users = new CopyOnWriteArrayList<PreUser>();
|
||||
private HashMap<Member, Role> rolequeue;
|
||||
|
||||
public Biscuit(JDA jda, Guild guild, BiscuitLog log) {
|
||||
public BiscuitGuild(JDA jda, Guild guild, BiscuitLogger log) {
|
||||
this.jda = jda;
|
||||
this.guild = guild;
|
||||
this.logger = log;
|
||||
this.isMain = guild == null;
|
||||
this.messageStore = new BiscuitMessageStore(this);
|
||||
this.messageStore = new GuildMessageStore(this);
|
||||
this.config = new BiscuitConfig(this);
|
||||
config.generateConfig();
|
||||
this.properties = new BiscuitProperties(this);
|
||||
this.rolequeue = new HashMap<Member, Role>();
|
||||
this.player = Main.getPlayerManager().createPlayer();
|
||||
this.ytfeeds = new HashMap<String, YTFeedConfig>();
|
||||
|
||||
scheduler = new AudioScheduler(this);
|
||||
player.addListener(scheduler);
|
||||
@@ -113,9 +126,19 @@ public class Biscuit {
|
||||
if(!Main.isPlugin) {
|
||||
captchaDir = new File("captcha");
|
||||
captchaDir.mkdir();
|
||||
if(guild != null) {
|
||||
File f = new File("ytchannels");
|
||||
f.mkdir();
|
||||
ytFeedDir = new File(f, guild.getId());
|
||||
ytFeedDir.mkdir();
|
||||
}
|
||||
}else {
|
||||
captchaDir = new File(PluginCore.plugin.getDataFolder(), "captcha");
|
||||
captchaDir.mkdir();
|
||||
if(guild != null) {
|
||||
ytFeedDir = new File(PluginCore.plugin.getDataFolder(), "ytchannels\\" + guild.getId());
|
||||
ytFeedDir.mkdirs();
|
||||
}
|
||||
}
|
||||
if(isMain) {
|
||||
wipeCaptchaDir();
|
||||
@@ -129,6 +152,20 @@ public class Biscuit {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if(guild != null) {
|
||||
loadYoutubeFeeds();
|
||||
Runnable post = () -> {
|
||||
try {
|
||||
log("Updating Youtube feeds...");
|
||||
postYoutubeFeeds();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
};
|
||||
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
|
||||
scheduler.scheduleAtFixedRate(post, 0, 10, TimeUnit.MINUTES);
|
||||
}
|
||||
}
|
||||
|
||||
public BiscuitConfig getConfig() {
|
||||
@@ -139,7 +176,7 @@ public class Biscuit {
|
||||
return properties;
|
||||
}
|
||||
|
||||
public BiscuitMessageStore getMessageStore() {
|
||||
public GuildMessageStore getMessageStore() {
|
||||
return messageStore;
|
||||
}
|
||||
|
||||
@@ -159,6 +196,90 @@ public class Biscuit {
|
||||
return scheduler;
|
||||
}
|
||||
|
||||
public YTFeedConfig loadYouTubeFeedConfig(String alias) {
|
||||
alias = alias.toLowerCase();
|
||||
String channelID = "null";
|
||||
String youTubeChannelURL = "null";
|
||||
String message = "null";
|
||||
String lastVideo = "null";
|
||||
|
||||
Properties prop = new Properties();
|
||||
InputStream input = null;
|
||||
|
||||
File config = new File(ytFeedDir, alias);
|
||||
|
||||
if(!config.exists()) {
|
||||
logger.error("Could not locate YouTube feed config.");
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
input = new FileInputStream(config);
|
||||
prop.load(input);
|
||||
channelID = prop.getProperty("TextChannelID");
|
||||
youTubeChannelURL = prop.getProperty("YouTubeChannelURL");
|
||||
message = prop.getProperty("Message");
|
||||
lastVideo = prop.getProperty("LastVideo");
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
} finally {
|
||||
if (input != null) {
|
||||
try {
|
||||
input.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TextChannel textChannel = jda.getTextChannelById(channelID);
|
||||
if(textChannel == null) {
|
||||
logger.error("Error retrieving Text Channel from YouTube feed file.");
|
||||
return null;
|
||||
}
|
||||
YTFeed feed = new YTFeed(alias, textChannel, youTubeChannelURL, message);
|
||||
feed.setLastVideo(lastVideo);
|
||||
return new YTFeedConfig(this, feed);
|
||||
}
|
||||
|
||||
public void loadYoutubeFeeds() {
|
||||
ytfeeds.clear();
|
||||
File[] files = ytFeedDir.listFiles();
|
||||
for(File f : files) {
|
||||
String alias = f.getName().toLowerCase();
|
||||
ytfeeds.put(alias, loadYouTubeFeedConfig(alias));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean addYoutubeFeed(String alias, TextChannel channel, String channelURL, String message) {
|
||||
alias = alias.toLowerCase();
|
||||
if(guild == null || ytfeeds.containsKey(alias)) {
|
||||
return false;
|
||||
}
|
||||
YTFeed feed = new YTFeed(alias, channel, channelURL, message);
|
||||
|
||||
String lastURL =feed.getEntries().getLast().getURL();
|
||||
feed.setLastVideo(lastURL);
|
||||
//Generate a file for the feed
|
||||
new YTFeedConfig(this, feed);
|
||||
//Loads all feeds from files into hash map
|
||||
loadYoutubeFeeds();
|
||||
return true;
|
||||
}
|
||||
|
||||
public void postYoutubeFeeds() throws IOException {
|
||||
for(String s : ytfeeds.keySet()) {
|
||||
YTFeedConfig config = ytfeeds.get(s);
|
||||
YTFeed feed = config.getFeed();
|
||||
feed.post();
|
||||
config.setLastPosted(feed.getLastVideo());
|
||||
}
|
||||
}
|
||||
|
||||
public File getYTFeedDir() {
|
||||
return ytFeedDir;
|
||||
}
|
||||
|
||||
public void log(String message) {
|
||||
if(properties == null) {
|
||||
logger.info(message);
|
||||
@@ -1,13 +1,13 @@
|
||||
package com.fpghoti.biscuit.biscuit;
|
||||
package com.fpghoti.biscuit.guild;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
|
||||
public class BiscuitMessageStore {
|
||||
public class GuildMessageStore {
|
||||
|
||||
Biscuit biscuit;
|
||||
BiscuitGuild biscuit;
|
||||
private HashMap<User, Integer> messageCounts = new HashMap<>();
|
||||
private HashMap<User, Integer> messagesTenSeconds = new HashMap<>();
|
||||
private HashMap<User, Integer> messagesTwoMin = new HashMap<>();
|
||||
@@ -16,7 +16,7 @@ public class BiscuitMessageStore {
|
||||
private ArrayList<User> spamWarned = new ArrayList<User>();
|
||||
private ArrayList<User> softmuted = new ArrayList<User>();
|
||||
|
||||
public BiscuitMessageStore(Biscuit b) {
|
||||
public GuildMessageStore(BiscuitGuild b) {
|
||||
this.biscuit = b;
|
||||
}
|
||||
|
||||
@@ -2,21 +2,21 @@ package com.fpghoti.biscuit.listener;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.commands.CommandManager;
|
||||
import com.fpghoti.biscuit.logging.BiscuitLog;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.logging.BiscuitLogger;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||
|
||||
public class CommandListener extends ListenerAdapter implements Runnable {
|
||||
|
||||
private Scanner sc;
|
||||
private BiscuitLog log;
|
||||
private BiscuitLogger log;
|
||||
|
||||
public CommandListener(Scanner sc, BiscuitLog log) {
|
||||
public CommandListener(Scanner sc, BiscuitLogger log) {
|
||||
this.sc = sc;
|
||||
this.log = log;
|
||||
}
|
||||
@@ -26,8 +26,8 @@ public class CommandListener extends ListenerAdapter implements Runnable {
|
||||
if(!event.isFromGuild()) {
|
||||
return;
|
||||
}
|
||||
Biscuit b = Biscuit.getBiscuit(event.getGuild());
|
||||
if(PermUtil.isAdmin(event.getMember()) || !b.getProperties().restrictCmdChannels() || (b.getProperties().restrictCmdChannels() && isBotChannel(event.getTextChannel()))) {
|
||||
BiscuitGuild b = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
if(PermUtil.isAdmin(event.getMember()) || !b.getProperties().restrictCmdChannels() || (b.getProperties().restrictCmdChannels() && isBotChannel(event.getChannel().asTextChannel()))) {
|
||||
if(!event.getAuthor().isBot() && event.getMessage().getContentDisplay().startsWith(b.getProperties().getCommandSignifier()) && event.getMessage().getAuthor().getId() != event.getJDA().getSelfUser().getId()){
|
||||
CommandManager.parse(event.getMessage().getContentRaw().toLowerCase(), event);
|
||||
}
|
||||
@@ -35,7 +35,7 @@ public class CommandListener extends ListenerAdapter implements Runnable {
|
||||
}
|
||||
|
||||
private boolean isBotChannel(TextChannel c) {
|
||||
Biscuit b = Biscuit.getBiscuit(c.getGuild());
|
||||
BiscuitGuild b = BiscuitGuild.getBiscuitGuild(c.getGuild());
|
||||
for(String s : b.getProperties().getCmdChannels()) {
|
||||
if(s.equals(c.getName())) {
|
||||
return true;
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.captcha.HandleCaptcha;
|
||||
import com.fpghoti.biscuit.logging.BColor;
|
||||
|
||||
import net.dv8tion.jda.api.entities.ChannelType;
|
||||
import net.dv8tion.jda.api.entities.channel.ChannelType;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.fpghoti.biscuit.listener;
|
||||
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.logging.BColor;
|
||||
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
@@ -35,7 +35,7 @@ public class GuildListener extends ListenerAdapter {
|
||||
|
||||
private void loadGuild(GenericGuildEvent event) {
|
||||
Guild g = event.getGuild();
|
||||
Biscuit biscuit = Biscuit.loadGuild(g);
|
||||
BiscuitGuild biscuit = BiscuitGuild.loadGuild(g);
|
||||
biscuit.log(BColor.CYAN_BOLD + "---- Joined new Guild! ----");
|
||||
biscuit.log(BColor.CYAN_BOLD + "Name: " + BColor.WHITE + g.getName());
|
||||
biscuit.log(BColor.CYAN_BOLD + "Id: " + BColor.WHITE + g.getId());
|
||||
@@ -44,7 +44,7 @@ public class GuildListener extends ListenerAdapter {
|
||||
|
||||
private void unloadGuild(GenericGuildEvent event) {
|
||||
Guild g = event.getGuild();
|
||||
Biscuit biscuit = Biscuit.getBiscuit(g);
|
||||
BiscuitGuild biscuit = BiscuitGuild.getBiscuitGuild(g);
|
||||
biscuit.remove();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.fpghoti.biscuit.listener;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.logging.BColor;
|
||||
import com.fpghoti.biscuit.user.CaptchaUser;
|
||||
import com.fpghoti.biscuit.user.PreUser;
|
||||
@@ -19,7 +19,7 @@ public class JoinListener extends ListenerAdapter {
|
||||
|
||||
@Override
|
||||
public void onGuildMemberJoin(GuildMemberJoinEvent event) {
|
||||
Biscuit biscuit = Biscuit.getBiscuit(event.getGuild());
|
||||
BiscuitGuild biscuit = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
User user = event.getMember().getUser();
|
||||
biscuit.log(BColor.YELLOW_BOLD + "USER JOINED: " + user.getName() + " " + user.getAsMention());
|
||||
biscuit.eventLog("**User Joined:** ``" + user.getName() + "`` " + user.getAsMention());
|
||||
@@ -54,7 +54,7 @@ public class JoinListener extends ListenerAdapter {
|
||||
}
|
||||
|
||||
@Async
|
||||
private void logUserInvite(final User user, final Biscuit b){
|
||||
private void logUserInvite(final User user, final BiscuitGuild b){
|
||||
Guild g = b.getGuild();
|
||||
g.retrieveInvites().queue(invs -> {
|
||||
String usedInv = "Other";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.fpghoti.biscuit.listener;
|
||||
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.logging.BColor;
|
||||
import com.fpghoti.biscuit.user.PreUser;
|
||||
|
||||
@@ -12,7 +12,7 @@ public class LeaveListener extends ListenerAdapter {
|
||||
|
||||
@Override
|
||||
public void onGuildMemberRemove(GuildMemberRemoveEvent event) {
|
||||
Biscuit biscuit = Biscuit.getBiscuit(event.getGuild());
|
||||
BiscuitGuild biscuit = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
User user = event.getMember().getUser();
|
||||
PreUser u = biscuit.getPreUser(user);
|
||||
int time = 1;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.fpghoti.biscuit.listener;
|
||||
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.logging.BColor;
|
||||
import com.fpghoti.biscuit.util.Util;
|
||||
|
||||
@@ -11,8 +11,8 @@ public class MessageDeleteListener extends ListenerAdapter {
|
||||
|
||||
@Override
|
||||
public void onMessageDelete(MessageDeleteEvent event) {
|
||||
Biscuit biscuit = Biscuit.getBiscuit(event.getGuild());
|
||||
if(Util.isLoggable(event.getTextChannel())) {
|
||||
BiscuitGuild biscuit = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
if(Util.isLoggable(event.getChannel().asTextChannel())) {
|
||||
biscuit.log("[" + BColor.MAGENTA + "#" + event.getChannel().getName() + BColor.RESET + "] " + BColor.MAGENTA_BOLD + "Message " + event.getMessageId() + " was deleted.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.fpghoti.biscuit.listener;
|
||||
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.logging.BColor;
|
||||
import com.fpghoti.biscuit.util.Util;
|
||||
|
||||
@@ -11,8 +11,8 @@ public class MessageEditListener extends ListenerAdapter {
|
||||
|
||||
@Override
|
||||
public void onMessageUpdate(MessageUpdateEvent event) {
|
||||
Biscuit biscuit = Biscuit.getBiscuit(event.getGuild());
|
||||
if(Util.isLoggable(event.getTextChannel()) && (!event.getAuthor().getName().equalsIgnoreCase("jbot") && !event.getAuthor().isBot())) {
|
||||
BiscuitGuild biscuit = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
if(Util.isLoggable(event.getChannel().asTextChannel()) && (!event.getAuthor().getName().equalsIgnoreCase("jbot") && !event.getAuthor().isBot())) {
|
||||
biscuit.log("[" + BColor.CYAN_BOLD + "MSG EDIT" + BColor.RESET + "] " + BColor.CYAN + "ID: " + BColor.RESET +
|
||||
event.getMessageId() + BColor.CYAN + " User: " + BColor.RESET + event.getAuthor().getAsMention());
|
||||
biscuit.log("[" + BColor.CYAN_BOLD + "#" + event.getChannel().getName() + BColor.RESET + "] " + BColor.CYAN + event.getAuthor().getName() + ": " + BColor.WHITE_BOLD + event.getMessage().getContentDisplay());
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.fpghoti.biscuit.listener;
|
||||
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.biscuit.BiscuitMessageStore;
|
||||
import com.fpghoti.biscuit.captcha.HandleCaptcha;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.guild.GuildMessageStore;
|
||||
import com.fpghoti.biscuit.logging.BColor;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
import com.fpghoti.biscuit.util.ChatFilter;
|
||||
@@ -24,7 +24,7 @@ public class MessageReceiveListener extends ListenerAdapter{
|
||||
if(!event.isFromGuild()) {
|
||||
return;
|
||||
}
|
||||
Biscuit biscuit = Biscuit.getBiscuit(event.getGuild());
|
||||
BiscuitGuild biscuit = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
if(event.getAuthor().isBot()) {
|
||||
logBot(event, biscuit);
|
||||
return;
|
||||
@@ -42,14 +42,14 @@ public class MessageReceiveListener extends ListenerAdapter{
|
||||
}
|
||||
|
||||
//Channel is a captcha channel
|
||||
if(HandleCaptcha.isCaptchaChannel(event.getTextChannel())) {
|
||||
if(HandleCaptcha.isCaptchaChannel(event.getChannel().asTextChannel())) {
|
||||
HandleCaptcha.handleCaptcha(event.getAuthor(), event.getChannel(), event.getMessage().getContentDisplay());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void logBot(MessageReceivedEvent event, Biscuit biscuit) {
|
||||
if(Util.isLoggable(event.getTextChannel())) {
|
||||
private void logBot(MessageReceivedEvent event, BiscuitGuild biscuit) {
|
||||
if(Util.isLoggable(event.getChannel().asTextChannel())) {
|
||||
if(biscuit.getProperties().logChat()) {
|
||||
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());
|
||||
@@ -57,8 +57,8 @@ public class MessageReceiveListener extends ListenerAdapter{
|
||||
}
|
||||
}
|
||||
|
||||
private void logUser(MessageReceivedEvent event, Biscuit biscuit) {
|
||||
if(Util.isLoggable(event.getTextChannel())) {
|
||||
private void logUser(MessageReceivedEvent event, BiscuitGuild biscuit) {
|
||||
if(Util.isLoggable(event.getChannel().asTextChannel())) {
|
||||
if(biscuit.getProperties().logChat()) {
|
||||
biscuit.log("[" + BColor.CYAN_BOLD + "MSG" + BColor.RESET + "] " + BColor.GREEN + "ID: " + BColor.RESET +
|
||||
event.getMessageId() + BColor.GREEN + " Sender: " + BColor.RESET + event.getAuthor().getAsMention());
|
||||
@@ -83,16 +83,16 @@ public class MessageReceiveListener extends ListenerAdapter{
|
||||
private boolean isNaughty(MessageReceivedEvent event) {
|
||||
// TODO make staff filter configurable
|
||||
if(!event.getChannel().getName().toLowerCase().contains("staff") && ChatFilter.filter(event, false)){
|
||||
MessageText.sendTimed(event.getTextChannel(), event.getAuthor().getAsMention() + " This message contains words not appropriate for this channel.", 3);
|
||||
MessageText.sendTimed(event.getChannel().asTextChannel(), event.getAuthor().getAsMention() + " This message contains words not appropriate for this channel.", 3);
|
||||
event.getMessage().delete().submit();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean handleSpammer(MessageReceivedEvent event, Biscuit biscuit) {
|
||||
private boolean handleSpammer(MessageReceivedEvent event, BiscuitGuild biscuit) {
|
||||
//TODO make numbers configurable
|
||||
BiscuitMessageStore store = biscuit.getMessageStore();
|
||||
GuildMessageStore store = biscuit.getMessageStore();
|
||||
String mention = event.getAuthor().getAsMention();
|
||||
if(store.isSpammer(event.getAuthor())){
|
||||
//User is a spammer but has not sent a message during
|
||||
@@ -112,9 +112,9 @@ public class MessageReceiveListener extends ListenerAdapter{
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean handleSoftmuted(MessageReceivedEvent event, Biscuit biscuit) {
|
||||
private boolean handleSoftmuted(MessageReceivedEvent event, BiscuitGuild biscuit) {
|
||||
//TODO make numbers configurable
|
||||
BiscuitMessageStore store = biscuit.getMessageStore();
|
||||
GuildMessageStore store = biscuit.getMessageStore();
|
||||
String mention = event.getAuthor().getAsMention();
|
||||
if(store.isSoftmuted(event.getAuthor())){
|
||||
//User is softmuted but has not sent a message during
|
||||
@@ -134,8 +134,8 @@ public class MessageReceiveListener extends ListenerAdapter{
|
||||
return false;
|
||||
}
|
||||
|
||||
private void checkNewSpammer(MessageReceivedEvent event, Biscuit biscuit) {
|
||||
BiscuitMessageStore store = biscuit.getMessageStore();
|
||||
private void checkNewSpammer(MessageReceivedEvent event, BiscuitGuild biscuit) {
|
||||
GuildMessageStore store = biscuit.getMessageStore();
|
||||
String mention = event.getAuthor().getAsMention();
|
||||
|
||||
if(!store.hasMessageCount(event.getAuthor())) {
|
||||
@@ -151,14 +151,14 @@ public class MessageReceiveListener extends ListenerAdapter{
|
||||
store.addSpammer(event.getAuthor());
|
||||
store.removeSpamWarned(event.getAuthor());
|
||||
event.getMessage().delete().submit();
|
||||
MessageText.sendTimed(event.getTextChannel(), "*Flagging " + mention + " as spam!*", 3);
|
||||
MessageText.sendTimed(event.getChannel().asTextChannel(), "*Flagging " + mention + " as spam!*", 3);
|
||||
biscuit.log(BColor.MAGENTA_BOLD + "User " + event.getAuthor().getName() + " has been flagged as spam!");
|
||||
event.getMessage().delete().reason("Spam removal activated for " + mention).submit();
|
||||
//User is spamming and has not been warned. Apply warning.
|
||||
}else if(!store.isSpammer(event.getAuthor()) && !store.isSpamWarned(event.getAuthor())){
|
||||
store.removeMessageCount(event.getAuthor());
|
||||
store.addSpamWarned(event.getAuthor());
|
||||
MessageText.sendTimed(event.getTextChannel(), "**STOP spamming, " + mention + "! You have been warned!**", 3);
|
||||
MessageText.sendTimed(event.getChannel().asTextChannel(), "**STOP spamming, " + mention + "! You have been warned!**", 3);
|
||||
biscuit.log(BColor.MAGENTA_BOLD + "User " + event.getAuthor().getName() + " has been warned for spam!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.fpghoti.biscuit.listener;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.logging.BColor;
|
||||
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
@@ -17,7 +17,7 @@ public class NameListener extends ListenerAdapter {
|
||||
Main.getMainBiscuit().log(BColor.CYAN_BOLD + "User " + user.getName() + " " + user.getAsMention() + " changed username from " +
|
||||
event.getOldName() + " to " + event.getNewName() + ".");
|
||||
for(Guild guild : user.getMutualGuilds()) {
|
||||
Biscuit biscuit = Biscuit.getBiscuit(guild);
|
||||
BiscuitGuild biscuit = BiscuitGuild.getBiscuitGuild(guild);
|
||||
biscuit.eventLog("**Username changed:** ``" + user.getName() + "`` " + user.getAsMention() + " - From ``" +
|
||||
event.getOldName() + "`` to ``" + event.getNewName() + "``");
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.fpghoti.biscuit.listener;
|
||||
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.logging.BColor;
|
||||
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
@@ -11,7 +11,7 @@ public class NicknameListener extends ListenerAdapter {
|
||||
|
||||
@Override
|
||||
public void onGuildMemberUpdateNickname(GuildMemberUpdateNicknameEvent event) {
|
||||
Biscuit biscuit = Biscuit.getBiscuit(event.getGuild());
|
||||
BiscuitGuild biscuit = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
User user = event.getMember().getUser();
|
||||
String oldNick = "None";
|
||||
String newNick = "None";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.fpghoti.biscuit.listener;
|
||||
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.logging.BColor;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
import com.fpghoti.biscuit.util.Util;
|
||||
@@ -17,29 +17,29 @@ public class ReactionListener extends ListenerAdapter{
|
||||
|
||||
@Override
|
||||
public void onMessageReactionAdd(MessageReactionAddEvent event){
|
||||
Biscuit biscuit = Biscuit.getBiscuit(event.getGuild());
|
||||
BiscuitGuild biscuit = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
if(event.getGuild() == null) {
|
||||
return;
|
||||
}
|
||||
if(Util.contains(biscuit.getProperties().getToggleChannels(),event.getTextChannel().getName())) {
|
||||
if(Util.contains(biscuit.getProperties().getToggleChannels(),event.getChannel().asTextChannel().getName())) {
|
||||
handleMessageRole(event, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessageReactionRemove(MessageReactionRemoveEvent event){
|
||||
Biscuit biscuit = Biscuit.getBiscuit(event.getGuild());
|
||||
BiscuitGuild biscuit = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
if(event.getGuild() == null) {
|
||||
return;
|
||||
}
|
||||
if(Util.contains(biscuit.getProperties().getToggleChannels(),event.getTextChannel().getName())) {
|
||||
if(Util.contains(biscuit.getProperties().getToggleChannels(),event.getChannel().asTextChannel().getName())) {
|
||||
handleMessageRole(event, true);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleMessageRole(GenericMessageReactionEvent event, boolean remove) {
|
||||
Biscuit biscuit = Biscuit.getBiscuit(event.getGuild());
|
||||
event.getTextChannel().retrieveMessageById(event.getMessageId()).queue((message) -> {
|
||||
BiscuitGuild biscuit = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
event.getChannel().asTextChannel().retrieveMessageById(event.getMessageId()).queue((message) -> {
|
||||
String msg = message.getContentDisplay();
|
||||
for(String rolename : biscuit.getProperties().getToggleRoles()) {
|
||||
for(Role r : event.getGuild().getRoles()) {
|
||||
@@ -57,7 +57,7 @@ public class ReactionListener extends ListenerAdapter{
|
||||
}
|
||||
|
||||
private void toggleRole(Role role, GenericMessageReactionEvent event, boolean remove) {
|
||||
Biscuit biscuit = Biscuit.getBiscuit(event.getGuild());
|
||||
BiscuitGuild biscuit = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
Guild guild = event.getGuild();
|
||||
if(role == null) {
|
||||
return;
|
||||
@@ -65,7 +65,7 @@ public class ReactionListener extends ListenerAdapter{
|
||||
Member m = event.getMember();
|
||||
if(remove) {
|
||||
if(PermUtil.hasRole(m, role)) {
|
||||
biscuit.log(BColor.MAGENTA_BOLD + "REACTION TOGGLE (#" + event.getTextChannel().getName() + ") - " + BColor.RESET + "Removing role " + role.getName() + " from " + m.getUser().getName() + "(" + m.getId() + ")");
|
||||
biscuit.log(BColor.MAGENTA_BOLD + "REACTION TOGGLE (#" + event.getChannel().asTextChannel().getName() + ") - " + BColor.RESET + "Removing role " + role.getName() + " from " + m.getUser().getName() + "(" + m.getId() + ")");
|
||||
guild.removeRoleFromMember(m, role).queue();
|
||||
}
|
||||
}else {
|
||||
@@ -80,7 +80,7 @@ public class ReactionListener extends ListenerAdapter{
|
||||
canAdd = true;
|
||||
}
|
||||
if(canAdd) {
|
||||
biscuit.log(BColor.MAGENTA_BOLD + "REACTION TOGGLE (#" + event.getTextChannel().getName() + ") - " + BColor.RESET + " Adding role " + role.getName() + " to " + m.getUser().getName() + "(" + m.getId() + ")");
|
||||
biscuit.log(BColor.MAGENTA_BOLD + "REACTION TOGGLE (#" + event.getChannel().asTextChannel().getName() + ") - " + BColor.RESET + " Adding role " + role.getName() + " to " + m.getUser().getName() + "(" + m.getId() + ")");
|
||||
guild.addRoleToMember(m, role).queue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
package com.fpghoti.biscuit.logging;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
|
||||
public class BiscuitLog {
|
||||
|
||||
private final Logger console = LoggerFactory.getLogger("Biscuit");
|
||||
private final Logger file = LoggerFactory.getLogger("B-File");
|
||||
|
||||
public void debug(String msg) {
|
||||
console.debug("[" + BColor.MAGENTA_BOLD + "DEBUG" + BColor.RESET + "] " + BColor.MAGENTA + msg + BColor.RESET);
|
||||
if(!Main.isPlugin) {
|
||||
file.debug(BColor.clear(msg));
|
||||
}
|
||||
}
|
||||
|
||||
public void error(String msg) {
|
||||
console.error("[" + BColor.RED_BOLD + "ERROR" + BColor.RESET + "] " + BColor.RED + msg + BColor.RESET);
|
||||
if(!Main.isPlugin) {
|
||||
file.error(BColor.clear(msg));
|
||||
}
|
||||
}
|
||||
|
||||
public void info(String msg) {
|
||||
console.info(msg + BColor.RESET);
|
||||
if(!Main.isPlugin) {
|
||||
file.info(BColor.clear(msg));
|
||||
}
|
||||
}
|
||||
|
||||
public void trace(String msg) {
|
||||
console.trace("[" + BColor.CYAN_BOLD + "TRACE" + BColor.RESET + "] " + BColor.CYAN + msg + BColor.RESET);
|
||||
if(!Main.isPlugin) {
|
||||
file.trace(BColor.clear(msg));
|
||||
}
|
||||
}
|
||||
|
||||
public void warn(String msg) {
|
||||
console.warn("[" + BColor.YELLOW_BOLD + "WARN" + BColor.RESET + "] " + BColor.YELLOW + msg + BColor.RESET);
|
||||
if(!Main.isPlugin) {
|
||||
file.warn(BColor.clear(msg));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
58
src/main/java/com/fpghoti/biscuit/logging/BiscuitLogger.java
Normal file
58
src/main/java/com/fpghoti/biscuit/logging/BiscuitLogger.java
Normal file
@@ -0,0 +1,58 @@
|
||||
package com.fpghoti.biscuit.logging;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
|
||||
public class BiscuitLogger {
|
||||
|
||||
private final Logger console = LoggerFactory.getLogger("Biscuit");
|
||||
private final Logger file = LoggerFactory.getLogger("B-File");
|
||||
|
||||
public void debug(String msg) {
|
||||
console.debug(powerShellCompat("[" + BColor.MAGENTA_BOLD + "DEBUG" + BColor.RESET + "] " + BColor.MAGENTA + msg + BColor.RESET));
|
||||
if(!Main.isPlugin) {
|
||||
file.debug(BColor.clear(msg));
|
||||
}
|
||||
}
|
||||
|
||||
public void error(String msg) {
|
||||
console.error(powerShellCompat("[" + BColor.RED_BOLD + "ERROR" + BColor.RESET + "] " + BColor.RED + msg + BColor.RESET));
|
||||
if(!Main.isPlugin) {
|
||||
file.error(BColor.clear(msg));
|
||||
}
|
||||
}
|
||||
|
||||
public void info(String msg) {
|
||||
console.info(powerShellCompat(msg + BColor.RESET));
|
||||
if(!Main.isPlugin) {
|
||||
file.info(BColor.clear(msg));
|
||||
}
|
||||
}
|
||||
|
||||
public void trace(String msg) {
|
||||
console.trace(powerShellCompat("[" + BColor.CYAN_BOLD + "TRACE" + BColor.RESET + "] " + BColor.CYAN + msg + BColor.RESET));
|
||||
if(!Main.isPlugin) {
|
||||
file.trace(BColor.clear(msg));
|
||||
}
|
||||
}
|
||||
|
||||
public void warn(String msg) {
|
||||
console.warn(powerShellCompat("[" + BColor.YELLOW_BOLD + "WARN" + BColor.RESET + "] " + BColor.YELLOW + msg + BColor.RESET));
|
||||
if(!Main.isPlugin) {
|
||||
file.warn(BColor.clear(msg));
|
||||
}
|
||||
}
|
||||
|
||||
private String powerShellCompat(String s) {
|
||||
if(Main.getMainBiscuit() == null || Main.getMainBiscuit().getProperties() == null) {
|
||||
return s;
|
||||
}
|
||||
if(Main.getMainBiscuit().getProperties().isPowerShell()) {
|
||||
s = s.replace(BColor.MAGENTA + "", BColor.RED_BOLD + "");
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,8 +6,8 @@ import org.pf4j.Plugin;
|
||||
import org.pf4j.PluginWrapper;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.logging.BiscuitLog;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.logging.BiscuitLogger;
|
||||
import com.github.cage.Cage;
|
||||
import com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager;
|
||||
|
||||
@@ -47,7 +47,7 @@ public abstract class BiscuitPlugin extends Plugin {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ArrayList<Biscuit> getBiscuits() {
|
||||
public ArrayList<BiscuitGuild> getBiscuits() {
|
||||
return Main.getBiscuits();
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public abstract class BiscuitPlugin extends Plugin {
|
||||
return Main.getPlayerManager();
|
||||
}
|
||||
|
||||
public BiscuitLog getLogger() {
|
||||
public BiscuitLogger getLogger() {
|
||||
return Main.getLogger();
|
||||
}
|
||||
|
||||
|
||||
@@ -3,11 +3,11 @@ package com.fpghoti.biscuit.rest;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
|
||||
import net.dv8tion.jda.api.entities.MessageEmbed;
|
||||
import net.dv8tion.jda.api.entities.PrivateChannel;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.PrivateChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;;
|
||||
|
||||
public class MessageText {
|
||||
|
||||
@@ -17,7 +17,7 @@ public class MessageText {
|
||||
Main.getMainBiscuit().error("Message could not be sent to null channel: " + message);
|
||||
return;
|
||||
}
|
||||
final Biscuit b = Biscuit.getBiscuit(c.getGuild());
|
||||
final BiscuitGuild b = BiscuitGuild.getBiscuitGuild(c.getGuild());
|
||||
c.sendMessage(message).submit().whenComplete((msg, error) -> {
|
||||
if(error != null) {
|
||||
b.warn("Message did not send: " + message);
|
||||
@@ -44,7 +44,7 @@ public class MessageText {
|
||||
Main.getMainBiscuit().error("Message embed could not be sent to null channel: " + message);
|
||||
return;
|
||||
}
|
||||
final Biscuit b = Biscuit.getBiscuit(c.getGuild());
|
||||
final BiscuitGuild b = BiscuitGuild.getBiscuitGuild(c.getGuild());
|
||||
c.sendMessageEmbeds(message).submit().whenComplete((msg, error) -> {
|
||||
if(error != null) {
|
||||
b.warn("Message embed did not send: " + message);
|
||||
@@ -58,7 +58,7 @@ public class MessageText {
|
||||
Main.getMainBiscuit().error("Timed message could not be sent to null channel - Time: " + seconds + " Text: " + message);
|
||||
return;
|
||||
}
|
||||
final Biscuit b = Biscuit.getBiscuit(c.getGuild());
|
||||
final BiscuitGuild b = BiscuitGuild.getBiscuitGuild(c.getGuild());
|
||||
c.sendMessage(message).submit()
|
||||
.whenComplete((msg, error) -> {
|
||||
if(error != null) {
|
||||
@@ -79,7 +79,7 @@ public class MessageText {
|
||||
Main.getMainBiscuit().error("Timed message embed could not be sent to null channel - Time: " + seconds + " Text: " + message);
|
||||
return;
|
||||
}
|
||||
final Biscuit b = Biscuit.getBiscuit(c.getGuild());
|
||||
final BiscuitGuild b = BiscuitGuild.getBiscuitGuild(c.getGuild());
|
||||
c.sendMessageEmbeds(message).submit()
|
||||
.whenComplete((msg, error) -> {
|
||||
if(error != null) {
|
||||
|
||||
67
src/main/java/com/fpghoti/biscuit/rss/YTEntry.java
Normal file
67
src/main/java/com/fpghoti/biscuit/rss/YTEntry.java
Normal file
@@ -0,0 +1,67 @@
|
||||
package com.fpghoti.biscuit.rss;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import com.fpghoti.biscuit.util.Util;
|
||||
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.MessageEmbed;
|
||||
|
||||
public class YTEntry {
|
||||
|
||||
private String id;
|
||||
private String title;
|
||||
private String author;
|
||||
private String description;
|
||||
private String thumbnail;
|
||||
|
||||
public YTEntry(String id, String title, String author, String description, String thumbnail) {
|
||||
this.id = id;
|
||||
this.title = title;
|
||||
this.author = author;
|
||||
this.description = description;
|
||||
this.thumbnail = thumbnail;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public String getThumbnail() {
|
||||
return thumbnail;
|
||||
}
|
||||
|
||||
public String getURL() {
|
||||
return "https://www.youtube.com/watch?v=" + id;
|
||||
}
|
||||
|
||||
public MessageEmbed getEmbedMessage() {
|
||||
EmbedBuilder embed = new EmbedBuilder();
|
||||
embed.setTitle(title, getURL());
|
||||
embed.setColor(Color.RED);
|
||||
|
||||
String descPreview = description.substring(0, Math.min(description.length(), 200));
|
||||
if(descPreview.length() < description.length()) {
|
||||
descPreview += "...";
|
||||
}
|
||||
|
||||
embed.setDescription(descPreview);
|
||||
embed.setAuthor(author, null, null);
|
||||
embed.setThumbnail(thumbnail);
|
||||
return embed.build();
|
||||
}
|
||||
|
||||
}
|
||||
143
src/main/java/com/fpghoti/biscuit/rss/YTFeed.java
Normal file
143
src/main/java/com/fpghoti/biscuit/rss/YTFeed.java
Normal file
@@ -0,0 +1,143 @@
|
||||
package com.fpghoti.biscuit.rss;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.rest.MessageText;
|
||||
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
import nu.xom.Builder;
|
||||
import nu.xom.Document;
|
||||
import nu.xom.Element;
|
||||
import nu.xom.Elements;
|
||||
import nu.xom.ParsingException;
|
||||
|
||||
public class YTFeed {
|
||||
|
||||
private BiscuitGuild guild;
|
||||
private String alias;
|
||||
private TextChannel channel;
|
||||
private String channelURL;
|
||||
private String message;
|
||||
private String lastVideo;
|
||||
|
||||
public YTFeed(String alias, TextChannel channel, String channelURL, String message) {
|
||||
this.guild = BiscuitGuild.getBiscuitGuild(channel.getGuild());
|
||||
this.alias = alias;
|
||||
this.channel = channel;
|
||||
this.channelURL = channelURL;
|
||||
this.message = message;
|
||||
lastVideo = "";
|
||||
}
|
||||
|
||||
public String getAlias() {
|
||||
return alias;
|
||||
}
|
||||
|
||||
public TextChannel getTextChannel() {
|
||||
return channel;
|
||||
}
|
||||
|
||||
public String getChannelURL() {
|
||||
return channelURL;
|
||||
}
|
||||
|
||||
public String getMesage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public String getLastVideo() {
|
||||
return lastVideo;
|
||||
}
|
||||
|
||||
public void setLastVideo(String link) {
|
||||
lastVideo = link;
|
||||
}
|
||||
|
||||
public void post(){
|
||||
List<YTEntry> ytentries = getEntries();
|
||||
int index = 0;
|
||||
int lastVidIndex = -1;
|
||||
for(YTEntry entry : ytentries) {
|
||||
String link = entry.getURL();
|
||||
if(link.equals(lastVideo)) {
|
||||
lastVidIndex = index;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
index = 0;
|
||||
for(YTEntry entry : ytentries) {
|
||||
if(index > lastVidIndex) {
|
||||
String link = entry.getURL();
|
||||
lastVideo = link;
|
||||
MessageText.send(channel, message);
|
||||
MessageText.send(channel, entry.getEmbedMessage());
|
||||
}
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
public List<YTEntry> getEntries() {
|
||||
List<YTEntry> ytentries = new ArrayList<YTEntry>();
|
||||
|
||||
Builder builder = new Builder();
|
||||
Document doc = null;
|
||||
try {
|
||||
doc = builder.build(channelURL);
|
||||
} catch (ParsingException | IOException e) {
|
||||
guild.error("Unable to parse feed: " + channelURL);
|
||||
MessageText.send(channel, "Unable to parse feed: " + channelURL);
|
||||
}
|
||||
|
||||
Element rss = doc.getRootElement();
|
||||
Elements entries = rss.getChildElements();
|
||||
for(Element entry : entries){
|
||||
if(entry.getLocalName().equals("entry")) {
|
||||
|
||||
String id = "";
|
||||
String title = "";
|
||||
String author = "";
|
||||
String description = "";
|
||||
String thumbnail = "";
|
||||
|
||||
Elements values = entry.getChildElements();
|
||||
for(Element value : values){
|
||||
if(value.getLocalName().equals("videoId")) {
|
||||
id = value.getValue();
|
||||
}
|
||||
if(value.getLocalName().equals("title")) {
|
||||
title = value.getValue();
|
||||
}
|
||||
if(value.getLocalName().equals("author")) {
|
||||
Elements subvalues = value.getChildElements();
|
||||
for(Element subvalue : subvalues) {
|
||||
if(subvalue.getLocalName().equals("name")) {
|
||||
author = subvalue.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
if(value.getLocalName().equals("group")) {
|
||||
Elements subvalues = value.getChildElements();
|
||||
for(Element subvalue : subvalues) {
|
||||
if(subvalue.getLocalName().equals("description")) {
|
||||
description = subvalue.getValue();
|
||||
}
|
||||
if(subvalue.getLocalName().equals("thumbnail")) {
|
||||
thumbnail = subvalue.getAttributeValue("url");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ytentries.add(new YTEntry(id, title, author, description, thumbnail));
|
||||
}
|
||||
}
|
||||
|
||||
return ytentries.reversed();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
149
src/main/java/com/fpghoti/biscuit/rss/YTFeedConfig.java
Normal file
149
src/main/java/com/fpghoti/biscuit/rss/YTFeedConfig.java
Normal file
@@ -0,0 +1,149 @@
|
||||
package com.fpghoti.biscuit.rss;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.commons.configuration2.PropertiesConfiguration;
|
||||
import org.apache.commons.configuration2.PropertiesConfigurationLayout;
|
||||
import org.apache.commons.configuration2.ex.ConfigurationException;
|
||||
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
|
||||
public class YTFeedConfig {
|
||||
|
||||
private BiscuitGuild biscuit;
|
||||
private YTFeed feed;
|
||||
private File config;
|
||||
|
||||
public YTFeedConfig(BiscuitGuild b, YTFeed feed) {
|
||||
this.biscuit = b;
|
||||
this.feed = feed;
|
||||
generateConfig();
|
||||
}
|
||||
|
||||
public BiscuitGuild getGuild() {
|
||||
return biscuit;
|
||||
}
|
||||
|
||||
public YTFeed getFeed() {
|
||||
return feed;
|
||||
}
|
||||
|
||||
public void generateConfig() {
|
||||
|
||||
String name = feed.getAlias();
|
||||
|
||||
File config = new File(biscuit.getYTFeedDir(), name);
|
||||
|
||||
if (!config.exists()) {
|
||||
try {
|
||||
config.createNewFile();
|
||||
updateConfig(config);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}else {
|
||||
updateConfig(config);
|
||||
}
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
|
||||
public void setLastPosted(String link) {
|
||||
PropertiesConfiguration prop = new PropertiesConfiguration();
|
||||
PropertiesConfigurationLayout layout = new PropertiesConfigurationLayout();
|
||||
prop.setLayout(layout);
|
||||
try {
|
||||
layout.load(prop, new FileReader(config));
|
||||
FileWriter fw = new FileWriter(config);
|
||||
prop.setProperty("LastVideo", link);
|
||||
feed.setLastVideo(link);
|
||||
layout.save(prop, fw);
|
||||
} catch (ConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
biscuit.error("There was an issue updating a YouTube feed file.");
|
||||
return;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
biscuit.error("There was an issue updating a YouTube feed file.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateConfig(File config) {
|
||||
PropertiesConfiguration prop = new PropertiesConfiguration();
|
||||
PropertiesConfigurationLayout layout = new PropertiesConfigurationLayout();
|
||||
prop.setLayout(layout);
|
||||
try {
|
||||
layout.load(prop, new FileReader(config));
|
||||
FileWriter fw = new FileWriter(config);
|
||||
addNewOptions(prop);
|
||||
layout.save(prop, fw);
|
||||
} catch (ConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
biscuit.error("There was an issue preparing a YouTube feed config for updates.");
|
||||
return;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
biscuit.error("There was an issue preparing a YouTube feed config for updates.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void addNewOptions(PropertiesConfiguration prop) {
|
||||
if(feed == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
addProperty("Alias", feed.getAlias(), prop);
|
||||
addProperty("TextChannelID", feed.getTextChannel().getId(), prop);
|
||||
addProperty("YouTubeChannelURL", feed.getChannelURL(), prop);
|
||||
addProperty("Message", feed.getMesage(), prop);
|
||||
addProperty("LastVideo", "", prop);
|
||||
}
|
||||
|
||||
private void addProperty(String key, String value, PropertiesConfiguration prop) {
|
||||
if(prop.getProperty(key) == null) {
|
||||
prop.addProperty(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
public String getFromConfig(String property){
|
||||
|
||||
String setting = "";
|
||||
|
||||
Properties prop = new Properties();
|
||||
InputStream input = null;
|
||||
|
||||
File config = new File(biscuit.getYTFeedDir(), feed.getAlias());
|
||||
|
||||
if(!config.exists()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
try {
|
||||
input = new FileInputStream(config);
|
||||
prop.load(input);
|
||||
setting = prop.getProperty(property);
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
} finally {
|
||||
if (input != null) {
|
||||
try {
|
||||
input.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return setting;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,14 +2,14 @@ package com.fpghoti.biscuit.timer;
|
||||
|
||||
import java.util.TimerTask;
|
||||
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
|
||||
public abstract class BiscuitTimer extends TimerTask{
|
||||
|
||||
protected Long delay;
|
||||
protected Long period;
|
||||
|
||||
protected Biscuit biscuit;
|
||||
protected BiscuitGuild biscuit;
|
||||
|
||||
public long getDelay() {
|
||||
if(delay != null) {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.fpghoti.biscuit.timer.task;
|
||||
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.timer.BiscuitTimer;
|
||||
|
||||
public class ChatCountTimer extends BiscuitTimer {
|
||||
|
||||
public ChatCountTimer(Biscuit b){
|
||||
public ChatCountTimer(BiscuitGuild b){
|
||||
biscuit = b;
|
||||
delay = (long) 0;
|
||||
period = (long) 10*1000;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package com.fpghoti.biscuit.timer.task;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.timer.BiscuitTimer;
|
||||
import com.fpghoti.biscuit.user.PreUser;
|
||||
|
||||
public class DecrementTimer extends BiscuitTimer{
|
||||
|
||||
public DecrementTimer(Biscuit b){
|
||||
public DecrementTimer(BiscuitGuild b){
|
||||
biscuit = b;
|
||||
delay = (long) 0;
|
||||
period = (long) 60*1000;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.fpghoti.biscuit.timer.task;
|
||||
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.timer.BiscuitTimer;
|
||||
|
||||
public class SoftMuteTimer extends BiscuitTimer{
|
||||
|
||||
public SoftMuteTimer(Biscuit b){
|
||||
public SoftMuteTimer(BiscuitGuild b){
|
||||
biscuit = b;
|
||||
delay = (long) 0;
|
||||
period = (long) 120*1000;
|
||||
|
||||
@@ -4,13 +4,13 @@ import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.captcha.Captcha;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
|
||||
import net.dv8tion.jda.api.JDA;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.MessageChannel;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
|
||||
|
||||
public class CaptchaUser implements Iterable<PreUser>{
|
||||
|
||||
@@ -118,14 +118,14 @@ public class CaptchaUser implements Iterable<PreUser>{
|
||||
return false;
|
||||
}
|
||||
for(PreUser u : preUsers) {
|
||||
if(u.getBiscuit().getGuild().getId().equals(g.getId())) {
|
||||
if(u.getBiscuitGuild().getGuild().getId().equals(g.getId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean contains(Biscuit b) {
|
||||
public boolean contains(BiscuitGuild b) {
|
||||
return contains(b.getGuild());
|
||||
}
|
||||
|
||||
@@ -167,10 +167,10 @@ public class CaptchaUser implements Iterable<PreUser>{
|
||||
}
|
||||
|
||||
public void add(PreUser u) {
|
||||
if(u.getBiscuit() == null || u.getBiscuit().getGuild() == null) {
|
||||
if(u.getBiscuitGuild() == null || u.getBiscuitGuild().getGuild() == null) {
|
||||
return;
|
||||
}
|
||||
if(contains(u.getBiscuit())) {
|
||||
if(contains(u.getBiscuitGuild())) {
|
||||
return;
|
||||
}
|
||||
preUsers.add(u);
|
||||
@@ -190,14 +190,14 @@ public class CaptchaUser implements Iterable<PreUser>{
|
||||
return null;
|
||||
}
|
||||
for(PreUser u : preUsers) {
|
||||
if(u.getBiscuit().getGuild().getId().equals(g.getId())) {
|
||||
if(u.getBiscuitGuild().getGuild().getId().equals(g.getId())) {
|
||||
return u;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public PreUser get(Biscuit b) {
|
||||
public PreUser get(BiscuitGuild b) {
|
||||
return get(b.getGuild());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.fpghoti.biscuit.user;
|
||||
|
||||
import com.fpghoti.biscuit.Main;
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.util.PermUtil;
|
||||
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
@@ -9,7 +9,7 @@ import net.dv8tion.jda.api.entities.User;
|
||||
|
||||
public class PreUser {
|
||||
|
||||
public static PreUser getPreUser(CaptchaUser capUser, Biscuit biscuit) {
|
||||
public static PreUser getPreUser(CaptchaUser capUser, BiscuitGuild biscuit) {
|
||||
if(capUser == null) {
|
||||
Main.getMainBiscuit().error("Cannot get PreUser (Invalid Captcha User).");
|
||||
return null;
|
||||
@@ -31,9 +31,9 @@ public class PreUser {
|
||||
private int timeLeft;
|
||||
private boolean done;
|
||||
private boolean test;
|
||||
private Biscuit biscuit;
|
||||
private BiscuitGuild biscuit;
|
||||
|
||||
private PreUser(CaptchaUser capUser, Biscuit biscuit, boolean test) {
|
||||
private PreUser(CaptchaUser capUser, BiscuitGuild biscuit, boolean test) {
|
||||
this.test = test;
|
||||
this.capUser = capUser;
|
||||
this.user = capUser.getUser();
|
||||
@@ -45,7 +45,7 @@ public class PreUser {
|
||||
}
|
||||
}
|
||||
|
||||
public Biscuit getBiscuit() {
|
||||
public BiscuitGuild getBiscuitGuild() {
|
||||
return biscuit;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.fpghoti.biscuit.util;
|
||||
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.fpghoti.biscuit.logging.BColor;
|
||||
import com.vdurmont.emoji.EmojiParser;
|
||||
|
||||
import net.dv8tion.jda.api.entities.Emote;
|
||||
import net.dv8tion.jda.api.entities.emoji.Emoji;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
public class ChatFilter {
|
||||
@@ -19,7 +19,7 @@ public class ChatFilter {
|
||||
if(!event.isFromGuild()) {
|
||||
return false;
|
||||
}
|
||||
Biscuit biscuit = Biscuit.getBiscuit(event.getGuild());
|
||||
BiscuitGuild biscuit = BiscuitGuild.getBiscuitGuild(event.getGuild());
|
||||
String msg = event.getMessage().getContentDisplay();
|
||||
|
||||
//Message removal priority occurs in this order
|
||||
@@ -36,7 +36,7 @@ public class ChatFilter {
|
||||
}
|
||||
|
||||
//Custom emote check
|
||||
for(Emote e : event.getMessage().getEmotes()) {
|
||||
for(Emoji e : event.getMessage().getMentions().getCustomEmojis()) {
|
||||
String name = e.getName();
|
||||
|
||||
for(String s : biscuit.getProperties().blockedCustomEmotes()) {
|
||||
@@ -73,7 +73,7 @@ public class ChatFilter {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean filter(Biscuit biscuit, String sentence){
|
||||
public static boolean filter(BiscuitGuild biscuit, String sentence){
|
||||
for(String s : sentence.split(" ")){
|
||||
if(filterWord(biscuit, s)){
|
||||
return true;
|
||||
@@ -82,7 +82,7 @@ public class ChatFilter {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean filterWord(Biscuit biscuit, String word) {
|
||||
public static boolean filterWord(BiscuitGuild biscuit, String word) {
|
||||
String[] match = findMatchPair(biscuit, word);
|
||||
if(match != null) {
|
||||
return true;
|
||||
@@ -90,7 +90,7 @@ public class ChatFilter {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static String findMatch(Biscuit biscuit, String word) {
|
||||
public static String findMatch(BiscuitGuild biscuit, String word) {
|
||||
String[] match = findMatchPair(biscuit, word);
|
||||
if(match == null || match[0] == null) {
|
||||
return null;
|
||||
@@ -98,7 +98,7 @@ public class ChatFilter {
|
||||
return match[0];
|
||||
}
|
||||
|
||||
public static String[] findMatchPair(Biscuit biscuit, String word) {
|
||||
public static String[] findMatchPair(BiscuitGuild biscuit, String word) {
|
||||
String cleaned = "";
|
||||
word = word.toLowerCase();
|
||||
if(word.length() >= 2 && word.charAt(word.length() -1) == '!'){
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.fpghoti.biscuit.util;
|
||||
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
import com.jcabi.aspects.Async;
|
||||
|
||||
import net.dv8tion.jda.api.Permission;
|
||||
@@ -10,7 +10,7 @@ import net.dv8tion.jda.api.entities.Role;
|
||||
public class PermUtil {
|
||||
|
||||
public static boolean isAdmin(Member member){
|
||||
Biscuit biscuit = Biscuit.getBiscuit(member.getGuild());
|
||||
BiscuitGuild biscuit = BiscuitGuild.getBiscuitGuild(member.getGuild());
|
||||
if(member.hasPermission(Permission.ADMINISTRATOR)){
|
||||
return true;
|
||||
}else{
|
||||
@@ -24,7 +24,7 @@ public class PermUtil {
|
||||
}
|
||||
|
||||
public static boolean isMod(Member member){
|
||||
Biscuit biscuit = Biscuit.getBiscuit(member.getGuild());
|
||||
BiscuitGuild biscuit = BiscuitGuild.getBiscuitGuild(member.getGuild());
|
||||
if(isAdmin(member)){
|
||||
return true;
|
||||
}else{
|
||||
@@ -39,7 +39,7 @@ public class PermUtil {
|
||||
}
|
||||
|
||||
public static boolean hasMusicControl(Member member){
|
||||
Biscuit biscuit = Biscuit.getBiscuit(member.getGuild());
|
||||
BiscuitGuild biscuit = BiscuitGuild.getBiscuitGuild(member.getGuild());
|
||||
if(isAdmin(member) || isMod(member)){
|
||||
return true;
|
||||
}else{
|
||||
@@ -74,7 +74,7 @@ public class PermUtil {
|
||||
}
|
||||
|
||||
public static boolean isBooster(Member member) {
|
||||
Biscuit biscuit = Biscuit.getBiscuit(member.getGuild());
|
||||
BiscuitGuild biscuit = BiscuitGuild.getBiscuitGuild(member.getGuild());
|
||||
if(isAdmin(member)) {
|
||||
return true;
|
||||
}
|
||||
@@ -87,12 +87,12 @@ public class PermUtil {
|
||||
}
|
||||
|
||||
public static boolean isBoosterExclusive(Role r) {
|
||||
Biscuit biscuit = Biscuit.getBiscuit(r.getGuild());
|
||||
BiscuitGuild biscuit = BiscuitGuild.getBiscuitGuild(r.getGuild());
|
||||
return Util.containsIgnoreCase(biscuit.getProperties().getBoostExclusiveRoles(),r.getName());
|
||||
}
|
||||
|
||||
public static boolean hasDefaultRole(Member m) {
|
||||
Biscuit biscuit = Biscuit.getBiscuit(m.getGuild());
|
||||
BiscuitGuild biscuit = BiscuitGuild.getBiscuitGuild(m.getGuild());
|
||||
for(Role r : biscuit.getGuild().getRoles()) {
|
||||
if(r.getName().equalsIgnoreCase(biscuit.getProperties().getDefaultRole())){
|
||||
return hasRole(m,r);
|
||||
@@ -102,7 +102,7 @@ public class PermUtil {
|
||||
}
|
||||
|
||||
public static boolean hasRewardRole(Member m) {
|
||||
Biscuit biscuit = Biscuit.getBiscuit(m.getGuild());
|
||||
BiscuitGuild biscuit = BiscuitGuild.getBiscuitGuild(m.getGuild());
|
||||
for(Role r : biscuit.getGuild().getRoles()) {
|
||||
if(r.getName().equalsIgnoreCase(biscuit.getProperties().getCaptchaReward())){
|
||||
return hasRole(m,r);
|
||||
@@ -114,7 +114,7 @@ public class PermUtil {
|
||||
@Async
|
||||
public static void clearUndeservedRoles(Member m) {
|
||||
boolean booster = isBooster(m);
|
||||
Biscuit b = Biscuit.getBiscuit(m.getGuild());
|
||||
BiscuitGuild b = BiscuitGuild.getBiscuitGuild(m.getGuild());
|
||||
for(Role r : m.getRoles()) {
|
||||
if(!booster && isBoosterExclusive(r)) {
|
||||
m.getGuild().removeRoleFromMember(m,r).queue();
|
||||
|
||||
@@ -2,9 +2,9 @@ package com.fpghoti.biscuit.util;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.fpghoti.biscuit.biscuit.Biscuit;
|
||||
import com.fpghoti.biscuit.guild.BiscuitGuild;
|
||||
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
|
||||
public class Util {
|
||||
public static int randInt(int min, int max) {
|
||||
@@ -16,7 +16,7 @@ public class Util {
|
||||
}
|
||||
|
||||
public static Boolean isLoggable(TextChannel c) {
|
||||
Biscuit biscuit = Biscuit.getBiscuit(c.getGuild());
|
||||
BiscuitGuild biscuit = BiscuitGuild.getBiscuitGuild(c.getGuild());
|
||||
Boolean a = true;
|
||||
for(String s: biscuit.getProperties().getDontLogChannels()) {
|
||||
if(c.getName().equalsIgnoreCase(s)) {
|
||||
@@ -77,5 +77,22 @@ public class Util {
|
||||
}
|
||||
return String.format("%02d:%02d:%02d", hour, minute, second - 1);
|
||||
}
|
||||
|
||||
public static String getLast(String toSplit, String splitBy) {
|
||||
String[] s = toSplit.split(splitBy);
|
||||
String last = s[s.length - 1];
|
||||
return last;
|
||||
}
|
||||
|
||||
public static String getArgsMessage(int startAt, String[] args) {
|
||||
String message = "";
|
||||
for(int i = startAt; i < args.length; i++) {
|
||||
message = message + args[i] + " ";
|
||||
}
|
||||
if (message.length() > 0) {
|
||||
message = message.substring(0, message.length() - 1);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user