Skip to content

Commit

Permalink
DiscordMusic v2.4.0
Browse files Browse the repository at this point in the history
Minor refactor
Added inheritable permission support
Added custom emote support
Updated dependencies
  • Loading branch information
LXGaming committed Feb 2, 2020
1 parent ba648ca commit 244c53a
Show file tree
Hide file tree
Showing 44 changed files with 336 additions and 194 deletions.
6 changes: 4 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ targetCompatibility = 1.8

group = "io.github.lxgaming"
archivesBaseName = "DiscordMusic"
version = "2.3.0"
version = "2.4.0"

configurations {
provided {
Expand All @@ -26,10 +26,12 @@ repositories {

dependencies {
compile("com.google.code.gson:gson:2.8.6")
compile("com.google.guava:guava:28.2-jre")
compile("com.jagrosh:jda-utilities-menu:3.0.+")
compile("com.sedmelluq:lavaplayer:1.3.+")
compile("net.dv8tion:JDA:4.0.+")
compile("net.dv8tion:JDA:4.1.+")
compile("org.apache.commons:commons-lang3:3.9")
compile("org.apache.commons:commons-text:1.8")
annotationProcessor("org.apache.logging.log4j:log4j-core:2.13.0")
compile("org.apache.logging.log4j:log4j-core:2.13.0")
compile("org.apache.logging.log4j:log4j-slf4j-impl:2.13.0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package io.github.lxgaming.discordmusic.command;

import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
import io.github.lxgaming.discordmusic.data.Color;
import io.github.lxgaming.discordmusic.entity.Color;
import io.github.lxgaming.discordmusic.manager.AudioManager;
import io.github.lxgaming.discordmusic.manager.MessageManager;
import net.dv8tion.jda.api.EmbedBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@

package io.github.lxgaming.discordmusic.command;

import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import io.github.lxgaming.discordmusic.manager.CommandManager;
import io.github.lxgaming.discordmusic.util.StringUtils;
import io.github.lxgaming.discordmusic.util.Toolbox;
import net.dv8tion.jda.api.entities.Message;

import java.util.List;
Expand All @@ -27,8 +28,8 @@

public abstract class Command {

private final Set<String> aliases = Toolbox.newLinkedHashSet();
private final Set<Command> children = Toolbox.newLinkedHashSet();
private final Set<String> aliases = Sets.newLinkedHashSet();
private final Set<Command> children = Sets.newLinkedHashSet();
private Command parentCommand;
private String description;
private String permission;
Expand All @@ -49,7 +50,7 @@ public final Optional<String> getPrimaryAlias() {
}

public final List<String> getPath() {
List<String> paths = Toolbox.newArrayList();
List<String> paths = Lists.newArrayList();
if (parentCommand != null) {
paths.addAll(parentCommand.getPath());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import io.github.lxgaming.discordmusic.DiscordMusic;
import io.github.lxgaming.discordmusic.configuration.Config;
import io.github.lxgaming.discordmusic.configuration.category.GeneralCategory;
import io.github.lxgaming.discordmusic.data.Color;
import io.github.lxgaming.discordmusic.entity.Color;
import io.github.lxgaming.discordmusic.exception.CommandException;
import io.github.lxgaming.discordmusic.manager.MessageManager;
import io.github.lxgaming.discordmusic.util.StringUtils;
Expand Down Expand Up @@ -54,7 +54,7 @@ public void execute(Message message, List<String> arguments) throws Exception {
if (StringUtils.isNotBlank(argument)) {
state = BooleanUtils.toBooleanObject(argument);
if (state == null) {
throw new CommandException(String.format("Failed to parse %s as a boolean", Toolbox.sanitize(argument)));
throw new CommandException(String.format("Failed to parse %s as a boolean", Toolbox.escapeMarkdown(argument)));
}
} else {
state = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@

package io.github.lxgaming.discordmusic.command;

import com.google.common.collect.Lists;
import io.github.lxgaming.discordmusic.DiscordMusic;
import io.github.lxgaming.discordmusic.configuration.Config;
import io.github.lxgaming.discordmusic.configuration.category.GeneralCategory;
import io.github.lxgaming.discordmusic.data.Color;
import io.github.lxgaming.discordmusic.entity.Color;
import io.github.lxgaming.discordmusic.manager.CommandManager;
import io.github.lxgaming.discordmusic.manager.MessageManager;
import io.github.lxgaming.discordmusic.manager.PermissionManager;
import io.github.lxgaming.discordmusic.util.StringUtils;
import io.github.lxgaming.discordmusic.util.Toolbox;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.Message;

Expand Down Expand Up @@ -69,7 +69,7 @@ public void execute(Message message, List<String> arguments) throws Exception {
return;
}

List<String> childArguments = Toolbox.newArrayList(arguments.toArray(new String[0]));
List<String> childArguments = Lists.newArrayList(arguments.toArray(new String[0]));
Command command = CommandManager.getCommand(childArguments);
if (command == null) {
embedBuilder.setColor(MessageManager.getColor(Color.WARNING));
Expand All @@ -96,7 +96,7 @@ public void execute(Message message, List<String> arguments) throws Exception {
embedBuilder.getDescriptionBuilder().append("\n");
}

List<String> children = Toolbox.newArrayList();
List<String> children = Lists.newArrayList();
for (Command childCommand : command.getChildren()) {
children.add(childCommand.getPrimaryAlias().orElse("Unknown"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import com.jagrosh.jdautilities.commons.JDAUtilitiesInfo;
import com.sedmelluq.discord.lavaplayer.tools.PlayerLibrary;
import io.github.lxgaming.discordmusic.DiscordMusic;
import io.github.lxgaming.discordmusic.data.Color;
import io.github.lxgaming.discordmusic.entity.Color;
import io.github.lxgaming.discordmusic.manager.MessageManager;
import io.github.lxgaming.discordmusic.util.Toolbox;
import net.dv8tion.jda.api.EmbedBuilder;
Expand All @@ -35,6 +35,7 @@ public class InfoCommand extends Command {
@Override
public boolean prepare() {
addAlias("info");
addAlias("information");
addAlias("version");
description("Displays bot information.");
permission("info.base");
Expand All @@ -46,10 +47,11 @@ public void execute(Message message, List<String> arguments) throws Exception {
EmbedBuilder embedBuilder = new EmbedBuilder();
embedBuilder.setAuthor(DiscordMusic.NAME + " v" + DiscordMusic.VERSION, DiscordMusic.SOURCE, message.getJDA().getSelfUser().getEffectiveAvatarUrl());
embedBuilder.setColor(MessageManager.getColor(Color.DEFAULT));
embedBuilder.addField("Uptime", Toolbox.getTimeString(Duration.between(DiscordMusic.getInstance().getStartTime(), Instant.now()).toMillis()), false);
embedBuilder.addField("Uptime", Toolbox.getDuration(Duration.between(DiscordMusic.getInstance().getStartTime(), Instant.now()).toMillis()), false);
embedBuilder.addField("Authors", DiscordMusic.AUTHORS, false);
embedBuilder.addField("Source", DiscordMusic.SOURCE, false);
embedBuilder.addField("Website", DiscordMusic.WEBSITE, false);
embedBuilder.addField("Java Version", System.getProperty("java.version"), false);
embedBuilder.addField("Dependencies", ""
+ "\n- " + "JDA v" + JDAInfo.VERSION
+ "\n- " + "JDA-Utilities v" + JDAUtilitiesInfo.VERSION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

package io.github.lxgaming.discordmusic.command;

import io.github.lxgaming.discordmusic.data.Color;
import com.google.common.collect.Sets;
import io.github.lxgaming.discordmusic.entity.Color;
import io.github.lxgaming.discordmusic.manager.MessageManager;
import io.github.lxgaming.discordmusic.util.StringUtils;
import io.github.lxgaming.discordmusic.util.Toolbox;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.VoiceChannel;
Expand All @@ -43,7 +43,7 @@ public boolean prepare() {
public void execute(Message message, List<String> arguments) throws Exception {
EmbedBuilder embedBuilder = new EmbedBuilder();

Set<VoiceChannel> voiceChannels = Toolbox.newLinkedHashSet();
Set<VoiceChannel> voiceChannels = Sets.newLinkedHashSet();
if (arguments.isEmpty()) {
if (!message.getMember().getVoiceState().inVoiceChannel()) {
embedBuilder.setColor(MessageManager.getColor(Color.WARNING));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import io.github.lxgaming.discordmusic.DiscordMusic;
import io.github.lxgaming.discordmusic.configuration.Config;
import io.github.lxgaming.discordmusic.configuration.category.GeneralCategory;
import io.github.lxgaming.discordmusic.data.AudioTrackData;
import io.github.lxgaming.discordmusic.data.Color;
import io.github.lxgaming.discordmusic.entity.AudioTrackData;
import io.github.lxgaming.discordmusic.entity.Color;
import io.github.lxgaming.discordmusic.handler.AudioPlayerLoadResultHandler;
import io.github.lxgaming.discordmusic.manager.AudioManager;
import io.github.lxgaming.discordmusic.manager.MessageManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package io.github.lxgaming.discordmusic.command;

import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
import io.github.lxgaming.discordmusic.data.Color;
import io.github.lxgaming.discordmusic.entity.Color;
import io.github.lxgaming.discordmusic.manager.AudioManager;
import io.github.lxgaming.discordmusic.manager.MessageManager;
import io.github.lxgaming.discordmusic.util.Toolbox;
Expand Down Expand Up @@ -53,9 +53,9 @@ public void execute(Message message, List<String> arguments) throws Exception {
embedBuilder.setColor(MessageManager.getColor(Color.SUCCESS));
embedBuilder.setTitle(audioTrack.getInfo().title, audioTrack.getInfo().uri);
if (audioTrack.getInfo().isStream) {
embedBuilder.setFooter(Toolbox.getTimeString(audioTrack.getPosition()), null);
embedBuilder.setFooter(Toolbox.getDuration(audioTrack.getPosition()), null);
} else {
embedBuilder.setFooter(Toolbox.getTimeString(audioTrack.getPosition()) + " / " + Toolbox.getTimeString(audioTrack.getDuration()), null);
embedBuilder.setFooter(Toolbox.getDuration(audioTrack.getPosition()) + " / " + Toolbox.getDuration(audioTrack.getDuration()), null);
}

MessageManager.sendTemporaryMessage(message.getChannel(), embedBuilder.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package io.github.lxgaming.discordmusic.command;

import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
import io.github.lxgaming.discordmusic.data.Color;
import io.github.lxgaming.discordmusic.entity.Color;
import io.github.lxgaming.discordmusic.manager.AudioManager;
import io.github.lxgaming.discordmusic.manager.MessageManager;
import net.dv8tion.jda.api.EmbedBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

package io.github.lxgaming.discordmusic.command;

import io.github.lxgaming.discordmusic.data.AudioTrackData;
import io.github.lxgaming.discordmusic.data.Color;
import io.github.lxgaming.discordmusic.entity.AudioTrackData;
import io.github.lxgaming.discordmusic.entity.Color;
import io.github.lxgaming.discordmusic.handler.AudioPlayerLoadResultHandler;
import io.github.lxgaming.discordmusic.manager.AudioManager;
import io.github.lxgaming.discordmusic.manager.MessageManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@

package io.github.lxgaming.discordmusic.command;

import com.google.common.collect.Lists;
import com.sedmelluq.discord.lavaplayer.track.AudioPlaylist;
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
import com.sedmelluq.discord.lavaplayer.track.BasicAudioPlaylist;
import io.github.lxgaming.discordmusic.data.Color;
import io.github.lxgaming.discordmusic.entity.Color;
import io.github.lxgaming.discordmusic.manager.AudioManager;
import io.github.lxgaming.discordmusic.manager.MessageManager;
import io.github.lxgaming.discordmusic.util.Toolbox;
Expand Down Expand Up @@ -59,7 +60,7 @@ public void execute(Message message, List<String> arguments) throws Exception {
return;
}

List<AudioTrack> audioTracks = Toolbox.newArrayList();
List<AudioTrack> audioTracks = Lists.newArrayList();
for (String string : arguments) {
if (embedBuilder.getDescriptionBuilder().length() != 0) {
embedBuilder.getDescriptionBuilder().append("\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package io.github.lxgaming.discordmusic.command;

import io.github.lxgaming.discordmusic.DiscordMusic;
import io.github.lxgaming.discordmusic.data.Color;
import io.github.lxgaming.discordmusic.entity.Color;
import io.github.lxgaming.discordmusic.manager.MessageManager;
import io.github.lxgaming.discordmusic.util.Toolbox;
import net.dv8tion.jda.api.EmbedBuilder;
Expand All @@ -42,7 +42,7 @@ public void execute(Message message, List<String> arguments) throws Exception {
EmbedBuilder embedBuilder = new EmbedBuilder();
embedBuilder.setColor(MessageManager.getColor(Color.WARNING));
embedBuilder.setTitle("Shutting down...");
embedBuilder.setFooter("Uptime: " + Toolbox.getTimeString(Duration.between(DiscordMusic.getInstance().getStartTime(), Instant.now()).toMillis()), null);
embedBuilder.setFooter("Uptime: " + Toolbox.getDuration(Duration.between(DiscordMusic.getInstance().getStartTime(), Instant.now()).toMillis()), null);
MessageManager.sendMessage(message.getChannel(), embedBuilder.build());
Runtime.getRuntime().exit(0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package io.github.lxgaming.discordmusic.command;

import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
import io.github.lxgaming.discordmusic.data.Color;
import io.github.lxgaming.discordmusic.entity.Color;
import io.github.lxgaming.discordmusic.manager.AudioManager;
import io.github.lxgaming.discordmusic.manager.MessageManager;
import net.dv8tion.jda.api.EmbedBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import io.github.lxgaming.discordmusic.DiscordMusic;
import io.github.lxgaming.discordmusic.configuration.Config;
import io.github.lxgaming.discordmusic.configuration.category.GeneralCategory;
import io.github.lxgaming.discordmusic.data.Color;
import io.github.lxgaming.discordmusic.entity.Color;
import io.github.lxgaming.discordmusic.manager.MessageManager;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.Message;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package io.github.lxgaming.discordmusic.command;

import com.sedmelluq.discord.lavaplayer.player.AudioPlayer;
import io.github.lxgaming.discordmusic.data.Color;
import io.github.lxgaming.discordmusic.entity.Color;
import io.github.lxgaming.discordmusic.manager.AudioManager;
import io.github.lxgaming.discordmusic.manager.MessageManager;
import net.dv8tion.jda.api.EmbedBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import io.github.lxgaming.discordmusic.DiscordMusic;
import io.github.lxgaming.discordmusic.configuration.Config;
import io.github.lxgaming.discordmusic.configuration.category.GeneralCategory;
import io.github.lxgaming.discordmusic.data.Color;
import io.github.lxgaming.discordmusic.entity.Color;
import io.github.lxgaming.discordmusic.manager.AudioManager;
import io.github.lxgaming.discordmusic.manager.MessageManager;
import io.github.lxgaming.discordmusic.util.Toolbox;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import io.github.lxgaming.discordmusic.command.Command;
import io.github.lxgaming.discordmusic.configuration.category.RoleCategory;
import io.github.lxgaming.discordmusic.configuration.category.UserCategory;
import io.github.lxgaming.discordmusic.data.Color;
import io.github.lxgaming.discordmusic.entity.Color;
import io.github.lxgaming.discordmusic.manager.MessageManager;
import io.github.lxgaming.discordmusic.manager.PermissionManager;
import net.dv8tion.jda.api.EmbedBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import io.github.lxgaming.discordmusic.command.Command;
import io.github.lxgaming.discordmusic.configuration.category.RoleCategory;
import io.github.lxgaming.discordmusic.configuration.category.UserCategory;
import io.github.lxgaming.discordmusic.data.Color;
import io.github.lxgaming.discordmusic.entity.Color;
import io.github.lxgaming.discordmusic.manager.MessageManager;
import io.github.lxgaming.discordmusic.manager.PermissionManager;
import net.dv8tion.jda.api.EmbedBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import io.github.lxgaming.discordmusic.command.Command;
import io.github.lxgaming.discordmusic.configuration.category.RoleCategory;
import io.github.lxgaming.discordmusic.configuration.category.UserCategory;
import io.github.lxgaming.discordmusic.data.Color;
import io.github.lxgaming.discordmusic.entity.Color;
import io.github.lxgaming.discordmusic.manager.MessageManager;
import io.github.lxgaming.discordmusic.manager.PermissionManager;
import net.dv8tion.jda.api.EmbedBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@

package io.github.lxgaming.discordmusic.configuration;

import com.google.common.collect.Sets;
import com.google.gson.annotations.SerializedName;
import io.github.lxgaming.discordmusic.configuration.category.AccountCategory;
import io.github.lxgaming.discordmusic.configuration.category.GeneralCategory;
import io.github.lxgaming.discordmusic.configuration.category.GuildCategory;
import io.github.lxgaming.discordmusic.configuration.category.MessageCategory;
import io.github.lxgaming.discordmusic.configuration.category.ServiceCategory;
import io.github.lxgaming.discordmusic.util.Toolbox;

import java.util.Set;

Expand All @@ -35,7 +35,7 @@ public class Config {
private GeneralCategory generalCategory = new GeneralCategory();

@SerializedName("guilds")
private Set<GuildCategory> guildCategories = Toolbox.newHashSet();
private Set<GuildCategory> guildCategories = Sets.newCopyOnWriteArraySet();

@SerializedName("message")
private MessageCategory messageCategory = new MessageCategory();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,33 @@

package io.github.lxgaming.discordmusic.configuration.category;

import com.google.gson.annotations.SerializedName;
import io.github.lxgaming.discordmusic.DiscordMusic;
import net.dv8tion.jda.api.OnlineStatus;
import net.dv8tion.jda.api.audio.SpeakingMode;
import net.dv8tion.jda.api.entities.Activity;

public class AccountCategory {

@SerializedName("id")
private long id = 0L;

@SerializedName("name")
private String name = "Unknown";

@SerializedName("token")
private String token = "";

@SerializedName("activityTitle")
private String activityTitle = DiscordMusic.NAME;

@SerializedName("activityType")
private Activity.ActivityType activityType = Activity.ActivityType.DEFAULT;

@SerializedName("onlineStatus")
private OnlineStatus onlineStatus = OnlineStatus.ONLINE;

@SerializedName("speakingMode")
private SpeakingMode speakingMode = SpeakingMode.VOICE;

public long getId() {
Expand Down
Loading

0 comments on commit 244c53a

Please sign in to comment.