Skip to content

Commit

Permalink
Merge pull request #1 from Kecerim24/master
Browse files Browse the repository at this point in the history
Master
  • Loading branch information
Kecerim24 authored Feb 28, 2024
2 parents 1c3101b + 33f5f9e commit 0f95d01
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 9 deletions.
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
<artifactId>JDA</artifactId>
<version>4.4.1_353</version>
</dependency>
<dependency>
<groupId>se.michaelthelin.spotify</groupId>
<artifactId>spotify-web-api-java</artifactId>
<version>7.0.0</version>
</dependency>
<dependency>
<groupId>com.jagrosh</groupId>
<artifactId>jda-utilities</artifactId>
Expand Down
41 changes: 40 additions & 1 deletion src/main/java/com/jagrosh/jmusicbot/JMusicBot.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,47 @@ private static void startBot()
.setHelpWord(config.getHelp())
.setLinkedCacheSize(200)
.setGuildSettingsManager(settings)
.addCommands(commands);
.addCommands(aboutCommand,
new PingCommand(),
new SettingsCmd(bot),

//new LyricsCmd(bot),
new NowplayingCmd(bot),
new PlayCmd(bot),
new PlaylistsCmd(bot),
new QueueCmd(bot),
new RemoveCmd(bot),
new SearchCmd(bot),
new SCSearchCmd(bot),
new ShuffleCmd(bot),
new SkipCmd(bot),
new SpotifyCmd(bot),

new ForceRemoveCmd(bot),
new ForceskipCmd(bot),
new MoveTrackCmd(bot),
new PauseCmd(bot),
new PlaynextCmd(bot),
new RepeatCmd(bot),
new SkiptoCmd(bot),
new StopCmd(bot),
new VolumeCmd(bot),

new PrefixCmd(bot),
new SetdjCmd(bot),
new SkipratioCmd(bot),
new SettcCmd(bot),
new SetvcCmd(bot),

new AutoplaylistCmd(bot),
new DebugCmd(bot),
new PlaylistCmd(bot),
new SetavatarCmd(bot),
new SetgameCmd(bot),
new SetnameCmd(bot),
new SetstatusCmd(bot),
new ShutdownCmd(bot)
);

if(config.useEval())
cb.addCommand(new EvalCmd(bot));
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/com/jagrosh/jmusicbot/audio/AudioHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package com.jagrosh.jmusicbot.audio;

import com.jagrosh.jmusicbot.JMusicBot;
import com.jagrosh.jmusicbot.playlist.PlaylistLoader.Playlist;
import com.jagrosh.jmusicbot.settings.RepeatMode;
import com.sedmelluq.discord.lavaplayer.player.AudioPlayer;
Expand Down Expand Up @@ -183,7 +182,7 @@ public void onTrackEnd(AudioPlayer player, AudioTrack track, AudioTrackEndReason
{
QueuedTrack clone = new QueuedTrack(track.makeClone(), track.getUserData(RequestMetadata.class));
if(repeatMode == RepeatMode.ALL)
queue.add(clone);
queue.betterADD(clone);
else
queue.addAt(0, clone);
}
Expand Down Expand Up @@ -261,7 +260,7 @@ public Message getNowPlaying(JDA jda)
eb.setTitle(track.getInfo().title);
}

if(track instanceof YoutubeAudioTrack && manager.getBot().getConfig().useNPImages())
if(track instanceof YoutubeAudioTrack)
{
eb.setImage("https://img.youtube.com/vi/"+track.getIdentifier()+"/mqdefault.jpg");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public NowplayingHandler(Bot bot)
this.lastNP = new HashMap<>();
}

public void init() {
public void init()
{
bot.getThreadpool().scheduleWithFixedDelay(() -> updateAll(), 0, 5, TimeUnit.SECONDS);
}
public void setLastNPMessage(Message m)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import com.jagrosh.jdautilities.command.CommandEvent;
import com.jagrosh.jdautilities.menu.Paginator;
import com.jagrosh.jmusicbot.Bot;
import com.jagrosh.jmusicbot.JMusicBot;
import com.jagrosh.jmusicbot.audio.AudioHandler;
import com.jagrosh.jmusicbot.audio.QueuedTrack;
import com.jagrosh.jmusicbot.commands.MusicCommand;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void doCommand(CommandEvent event) {
args = args.replace("https://open.spotify.com/track/", "").replaceAll("\\?(.*)", "");
String song = su.getTrack(args).getName();
CommandEvent finalEvent = new CommandEvent(event.getEvent(), song, event.getClient());
event.reply(loadingEmoji + " Loading... `["+song+"]`", m -> bot.getPlayerManager().loadItemOrdered(event.getGuild(), song, new SpotifyCmd.ResultHandler(m, finalEvent,false)));
event.reply(loadingEmoji + " Loading... `["+song+"]`", m -> bot.getPlayerManager().loadItemOrdered(event.getGuild(), song, new ResultHandler(m, finalEvent,false)));
}
else if (args.contains("playlist")){
args = args.replace("https://open.spotify.com/playlist/", "").replaceAll("\\?(.*)", "");
Expand Down Expand Up @@ -190,7 +190,7 @@ public void noMatches()
if(ytsearch)
m.editMessage(FormatUtil.filter(event.getClient().getWarning()+" No results found for `"+event.getArgs()+"`.")).queue();
else
bot.getPlayerManager().loadItemOrdered(event.getGuild(), "ytsearch:"+event.getArgs(), new SpotifyCmd.ResultHandler(m,event,true));
bot.getPlayerManager().loadItemOrdered(event.getGuild(), "ytsearch:"+event.getArgs(), new ResultHandler(m,event,true));
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/jagrosh/jmusicbot/queue/FairQueue.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public int betterADD(T item){
return lastIndex;

}

public void addAt(int index, T item)
{
if(index >= list.size())
Expand Down

0 comments on commit 0f95d01

Please sign in to comment.