Skip to content

Commit

Permalink
Merge pull request #64 from nano-devs/development
Browse files Browse the repository at this point in the history
SaveQueue Development
  • Loading branch information
madeyoga authored Nov 15, 2020
2 parents 264b8a9 + 9ad73da commit 050422a
Show file tree
Hide file tree
Showing 56 changed files with 1,108 additions and 668 deletions.
63 changes: 35 additions & 28 deletions src/main/java/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
import com.jagrosh.jdautilities.command.CommandClient;
import com.jagrosh.jdautilities.command.CommandClientBuilder;
import com.jagrosh.jdautilities.commons.waiter.EventWaiter;
import command.*;
import command.UserPlaylistCommand.CreatePlaylistCommand;
import command.general.CustomPrefixCommand;
import command.general.HelpCommand;
import command.general.InviteCommand;
import command.general.VoteCommand;
import command.history.UserHistoryCommand;
import command.music.*;
import command.owner.ChangePresenceCommand;
import command.owner.NotifyMaintenanceCommand;
import command.owner.PremiumUserCommand;
import command.owner.ShutdownCommand;
import listener.GuildEventListener;
import listener.MemberVoiceListener;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.JDABuilder;
Expand Down Expand Up @@ -38,7 +41,7 @@ public static void main(String[] args) {
int coreThreadPoolSize = availableProcessors - 1 > 0 ? availableProcessors - 1 : 1;
String botToken = System.getenv("SAN_TOKEN");
String ytToken = System.getenv("DEVELOPER_KEY");
String dblToken = System.getenv("DBL_TOKEN");
String dblToken = System.getenv("DBL_TOKEN_2");
String prefix = "m$";

// Initialize Dependencies
Expand All @@ -60,9 +63,12 @@ public static void main(String[] args) {
commandClientBuilder.setActivity(Activity.listening("m$help"));
commandClientBuilder.useHelpBuilder(false);
commandClientBuilder.setGuildSettingsManager(nano);
commandClientBuilder.setScheduleExecutor(exec);

// Add Command & Inject Dependencies.
// Free Commands
commandClientBuilder.addCommand(new NotifyMaintenanceCommand());
commandClientBuilder.addCommand(new ShutdownCommand());
commandClientBuilder.addCommand(new VoteCommand(nano));
commandClientBuilder.addCommand(new InviteCommand());
commandClientBuilder.addCommand(new CustomPrefixCommand());
Expand All @@ -83,28 +89,29 @@ public static void main(String[] args) {
commandClientBuilder.addCommand(new ShuffleCommand(nano));
commandClientBuilder.addCommand(new RecommendationCommand(nano, youtubeClient));
commandClientBuilder.addCommand(new LyricCommand(nano));
commandClientBuilder.addCommand(new SaveQueueToPlaylistCommand());
commandClientBuilder.addCommand(new PremiumUserCommand());
commandClientBuilder.addCommand(new UserHistoryCommand());
commandClientBuilder.addCommand(new CreatePlaylistCommand());
commandClientBuilder.addCommand(new command.UserPlaylistCommand.RenamePlaylistCommand());
commandClientBuilder.addCommand(new command.UserPlaylistCommand.DeletePlaylistCommand());
commandClientBuilder.addCommand(new command.UserPlaylistCommand.ShowPlaylistCommand());
commandClientBuilder.addCommand(new command.UserPlaylistCommand.AddTrackToPlaylistCommand(youtubeClient));
commandClientBuilder.addCommand(new command.UserPlaylistCommand.DeleteTrackFromPlaylistCommand());
commandClientBuilder.addCommand(new command.UserPlaylistCommand.ShowPlaylistTrackCommand());
commandClientBuilder.addCommand(new command.UserPlaylistCommand.PlayPlaylistCommand(nano));
commandClientBuilder.addCommand(new command.playlist.user.CreatePlaylistCommand());
commandClientBuilder.addCommand(new command.playlist.user.RenamePlaylistCommand());
commandClientBuilder.addCommand(new command.playlist.user.DeletePlaylistCommand());
commandClientBuilder.addCommand(new command.playlist.user.ShowPlaylistCommand());
commandClientBuilder.addCommand(new command.playlist.user.AddTrackToPlaylistCommand(youtubeClient));
commandClientBuilder.addCommand(new command.playlist.user.DeleteTrackFromPlaylistCommand());
commandClientBuilder.addCommand(new command.playlist.user.ShowPlaylistTrackCommand());
commandClientBuilder.addCommand(new command.playlist.user.PlayPlaylistCommand(nano));

// Premium Guild Commands
// commandClientBuilder.addCommand(new PremiumGuildCommand());
// commandClientBuilder.addCommand(new GuildHistoryCommand(nano));
// commandClientBuilder.addCommand(new command.GuildPlaylistCommand.CreatePlaylistCommand());
// commandClientBuilder.addCommand(new command.GuildPlaylistCommand.RenamePlaylistCommand());
// commandClientBuilder.addCommand(new command.GuildPlaylistCommand.DeletePlaylistCommand());
// commandClientBuilder.addCommand(new command.GuildPlaylistCommand.ShowPlaylistCommand());
// commandClientBuilder.addCommand(new command.GuildPlaylistCommand.AddTrackToPlaylistCommand());
// commandClientBuilder.addCommand(new command.GuildPlaylistCommand.DeleteTrackFromPlaylistCommand());
// commandClientBuilder.addCommand(new command.GuildPlaylistCommand.ShowPlaylistTrackCommand());
// commandClientBuilder.addCommand(new command.GuildPlaylistCommand.PlayPlaylistCommand(nano));
// commandClientBuilder.addCommand(new command.playlist.guild.CreatePlaylistCommand());
// commandClientBuilder.addCommand(new command.playlist.guild.RenamePlaylistCommand());
// commandClientBuilder.addCommand(new command.playlist.guild.DeletePlaylistCommand());
// commandClientBuilder.addCommand(new command.playlist.guild.ShowPlaylistCommand());
// commandClientBuilder.addCommand(new command.playlist.guild.AddTrackToPlaylistCommand());
// commandClientBuilder.addCommand(new command.playlist.guild.DeleteTrackFromPlaylistCommand());
// commandClientBuilder.addCommand(new command.playlist.guild.ShowPlaylistTrackCommand());
// commandClientBuilder.addCommand(new command.playlist.guild.PlayPlaylistCommand(nano));

// Owner's commands
commandClientBuilder.addCommand(new ChangePresenceCommand());
Expand All @@ -124,7 +131,7 @@ public static void main(String[] args) {
builder.addEventListeners(commandClient);
builder.addEventListeners(nano.getWaiter());
builder.addEventListeners(new MemberVoiceListener(nano, exec));
// builder.addEventListeners(new GuildEventListener(dblApi, commandClient));
builder.addEventListeners(new GuildEventListener(dblApi, commandClient));

try {
JDA jda = builder.build();
Expand All @@ -133,14 +140,14 @@ public static void main(String[] args) {
e.printStackTrace();
}

Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
System.out.println("Shutting down scheduled thread pool executor!");
exec.shutdown();
super.run();
}
});
// Runtime.getRuntime().addShutdownHook(new Thread() {
// @Override
// public void run() {
//// System.out.println("Shutting down scheduled thread pool executor!");
//// exec.shutdown();
// super.run();
// }
// });
}

private static void configureMemoryUsage(JDABuilder builder) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/command/general/HelpCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private CustomEmbedBuilder getHelpEmbedBuilder(CommandClient commandClient, JDA
String categoryValue = "`" + command.getName() + "`, ";

// Use the temporary memory for Main Embed
if (currentCategoryName.equals("Owner"))
if (currentCategoryName.equals("**Owner**"))
continue;

if (!dictionary.containsKey(currentCategoryName)) {
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/command/general/InviteCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public InviteCommand() {

@Override
protected void execute(CommandEvent event) {
String inviteLink = "https://discord.com/api/oauth2/authorize?client_id=473023109666963467&permissions=36793408&scope=bot";
String inviteLink = "[invite link](https://discord.com/api/oauth2/authorize?client_id=473023109666963467&permissions=36793408&scope=bot)";
CustomEmbedBuilder embedBuilder = new CustomEmbedBuilder();
embedBuilder.setAuthor("Invite " + event.getSelfUser().getName(),
event.getAuthor().getEffectiveAvatarUrl(),
Expand All @@ -27,7 +27,6 @@ protected void execute(CommandEvent event) {
embedBuilder.setFooter("Have a nice dayy~");
embedBuilder.addField("Here is the invite link!", inviteLink, true);
embedBuilder.setThumbnail(event.getSelfUser().getAvatarUrl());
embedBuilder.setColor(event.getMember().getColor());
event.reply(embedBuilder.build());
}
}
4 changes: 3 additions & 1 deletion src/main/java/command/general/VoteCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import client.NanoClient;
import com.jagrosh.jdautilities.command.Command;
import com.jagrosh.jdautilities.command.CommandEvent;
import com.jagrosh.jdautilities.command.impl.CommandClientImpl;
import database.Entity.ClassicUser;
import database.UserModel;
import service.music.CustomEmbedBuilder;
Expand All @@ -13,7 +14,7 @@
import java.util.concurrent.CompletableFuture;

public class VoteCommand extends Command {

CommandClientImpl impl;
NanoClient nanoClient;

public VoteCommand(NanoClient nanoClient) {
Expand All @@ -40,6 +41,7 @@ protected void execute(CommandEvent event) {
}

if (classicUser == null) {
classicUser = new ClassicUser(event.getAuthor().getIdLong(), 1, 3);
CompletableFuture.runAsync(() -> {
try {
userModel.create(event.getAuthor().getIdLong(), 3, 1);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package command;
package command.music;

import client.NanoClient;
import com.jagrosh.jdautilities.command.Command;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package command;
package command.music;

import client.NanoClient;
import com.jagrosh.jdautilities.command.Command;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package command;
package command.music;

import client.NanoClient;
import com.jagrosh.jdautilities.command.Command;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package command;
package command.music;

import YouTubeSearchApi.utility.Utils;
import client.NanoClient;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package command;
package command.music;

import client.NanoClient;
import com.jagrosh.jdautilities.command.Command;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package command;
package command.music;

import client.NanoClient;
import com.jagrosh.jdautilities.command.Command;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package command;
package command.music;

import client.NanoClient;
import com.jagrosh.jdautilities.command.Command;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package command;
package command.music;

import client.NanoClient;
import com.jagrosh.jdautilities.command.Command;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package command;
package command.music;

import YouTubeSearchApi.YoutubeClient;
import YouTubeSearchApi.entity.YoutubePlaylist;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package command;
package command.music;

import client.NanoClient;
import com.jagrosh.jdautilities.command.Command;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package command;
package command.music;

import client.NanoClient;
import com.jagrosh.jdautilities.command.Command;
Expand Down
Loading

0 comments on commit 050422a

Please sign in to comment.