Skip to content

Commit 600698d

Browse files
committed
Multiple fixes, this bot now works again. Spotify feature no longer works, unless account owner for the API key has premium.
Plus some uncommitted changes in regards of slash commands
1 parent a8b81f6 commit 600698d

18 files changed

Lines changed: 145 additions & 34 deletions

pom.xml

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@
5858
<dependency>
5959
<groupId>net.dv8tion</groupId>
6060
<artifactId>JDA</artifactId>
61-
<version>5.3.2</version>
61+
<version>6.4.1</version>
6262
</dependency>
6363
<dependency>
64-
<groupId>pw.chew</groupId>
64+
<groupId>com.github.chew</groupId>
6565
<artifactId>jda-chewtils</artifactId>
66-
<version>2.1-SNAPSHOT</version>
66+
<version>2.2.1</version>
6767
<scope>compile</scope>
6868
<type>pom</type>
6969
</dependency>
@@ -79,12 +79,12 @@
7979
<dependency>
8080
<groupId>dev.arbjerg</groupId>
8181
<artifactId>lavaplayer</artifactId>
82-
<version>2.2.4</version>
82+
<version>2.2.6</version>
8383
</dependency>
8484
<dependency>
8585
<groupId>dev.lavalink.youtube</groupId>
8686
<artifactId>common</artifactId>
87-
<version>1.16.0</version>
87+
<version>1.18.1</version>
8888
</dependency>
8989

9090
<dependency>
@@ -144,6 +144,40 @@
144144
<artifactId>protocol-jvm</artifactId>
145145
<version>4.2.0</version>
146146
</dependency>
147+
148+
149+
150+
151+
<dependency>
152+
<groupId>club.minnced</groupId>
153+
<artifactId>jdave-api</artifactId>
154+
<version>0.1.8</version>
155+
</dependency>
156+
157+
<!-- Compiled natives for libdave for the specified platform -->
158+
<dependency>
159+
<groupId>club.minnced</groupId>
160+
<artifactId>jdave-native-linux-x86-64</artifactId>
161+
<version>0.1.8</version>
162+
</dependency>
163+
164+
<dependency>
165+
<groupId>club.minnced</groupId>
166+
<artifactId>jdave-native-linux-aarch64</artifactId>
167+
<version>0.1.8</version>
168+
</dependency>
169+
170+
<dependency>
171+
<groupId>club.minnced</groupId>
172+
<artifactId>jdave-native-win-x86-64</artifactId>
173+
<version>0.1.8</version>
174+
</dependency>
175+
176+
<dependency>
177+
<groupId>club.minnced</groupId>
178+
<artifactId>jdave-native-darwin</artifactId>
179+
<version>0.1.8</version>
180+
</dependency>
147181
</dependencies>
148182

149183
<build>
@@ -223,6 +257,6 @@
223257

224258
<properties>
225259
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
226-
<maven.compiler.release>17</maven.compiler.release>
260+
<maven.compiler.release>25</maven.compiler.release>
227261
</properties>
228262
</project>

src/main/java/com/jagrosh/jmusicbot/JMusicBot.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package com.jagrosh.jmusicbot;
1717

18+
import club.minnced.discord.jdave.interop.JDaveSessionFactory;
1819
import com.jagrosh.jdautilities.command.CommandClient;
1920
import com.jagrosh.jdautilities.command.CommandClientBuilder;
2021
import com.jagrosh.jdautilities.commons.waiter.EventWaiter;
@@ -31,6 +32,7 @@
3132
import java.awt.Color;
3233
import java.util.Arrays;
3334
import net.dv8tion.jda.api.*;
35+
import net.dv8tion.jda.api.audio.AudioModuleConfig;
3436
import net.dv8tion.jda.api.entities.Activity;
3537
import net.dv8tion.jda.api.requests.GatewayIntent;
3638
import net.dv8tion.jda.api.utils.cache.CacheFlag;
@@ -126,6 +128,8 @@ private static void startBot()
126128
.setStatus(config.getStatus()==OnlineStatus.INVISIBLE || config.getStatus()==OnlineStatus.OFFLINE
127129
? OnlineStatus.INVISIBLE : OnlineStatus.DO_NOT_DISTURB)
128130
.addEventListeners(client, waiter, new Listener(bot))
131+
.setAudioModuleConfig(new AudioModuleConfig()
132+
.withDaveSessionFactory(new JDaveSessionFactory()))
129133
.setBulkDeleteSplittingEnabled(true)
130134
.build();
131135
bot.setJDA(jda);
@@ -250,6 +254,7 @@ private static CommandClient createCommandClient(BotConfig config, SettingsManag
250254
new SeekCmd(bot),
251255
new ShuffleCmd(bot),
252256
new SkipCmd(bot),
257+
new StopCmd(bot),
253258

254259
new QueueTypeCmd(bot),
255260
new SetdjCmd(bot),

src/main/java/com/jagrosh/jmusicbot/audio/PlayerManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public void init() {
5757
YoutubeSourceOptions options = new YoutubeSourceOptions().setAllowSearch(true);
5858
if(bot.getConfig().getYtCipherHost() != null)
5959
options.setRemoteCipher(bot.getConfig().getYtCipherHost(), bot.getConfig().getYtCipherKey(), "JMusicBot (Fork)");
60-
YoutubeAudioSourceManager yt = new YoutubeAudioSourceManager(options, new Web(), new WebEmbedded(), new TvHtml5Embedded(), new Ios(), new Music());
60+
YoutubeAudioSourceManager yt = new YoutubeAudioSourceManager(options, new Web(), new AndroidMusic(), new WebEmbedded(), new TvHtml5Simply(), new Ios(), new Music(),new Tv() );
6161
yt.setPlaylistPageCount(bot.getConfig().getMaxYTPlaylistPages());
6262
if (bot.getConfig().isOAUTHEnabled())
6363
if (!refreshTokenFile.exists()) {

src/main/java/com/jagrosh/jmusicbot/commands/DJCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*
2727
* @author John Grosh (john.a.grosh@gmail.com)
2828
*/
29-
public abstract class DJCommand extends LegacyMusicCommand
29+
public abstract class DJCommand extends MusicCommand
3030
{
3131
public DJCommand(Bot bot)
3232
{
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Copyright 2018 John Grosh <john.a.grosh@gmail.com>.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.jagrosh.jmusicbot.commands;
17+
18+
import com.jagrosh.jdautilities.command.CommandEvent;
19+
import com.jagrosh.jdautilities.command.SlashCommandEvent;
20+
import com.jagrosh.jmusicbot.Bot;
21+
import com.jagrosh.jmusicbot.settings.Settings;
22+
import net.dv8tion.jda.api.Permission;
23+
import net.dv8tion.jda.api.entities.Role;
24+
25+
/**
26+
*
27+
* @author John Grosh (john.a.grosh@gmail.com)
28+
*/
29+
public abstract class LegacyDJCommand extends LegacyMusicCommand
30+
{
31+
public LegacyDJCommand(Bot bot)
32+
{
33+
super(bot);
34+
this.category = new Category("DJ", event -> checkDJPermission(event));
35+
}
36+
37+
public static boolean checkDJPermission(CommandEvent event)
38+
{
39+
if(event.getAuthor().getId().equals(event.getClient().getOwnerId()))
40+
return true;
41+
if(event.getGuild()==null)
42+
return true;
43+
if(event.getMember().hasPermission(Permission.MANAGE_SERVER))
44+
return true;
45+
Settings settings = event.getClient().getSettingsFor(event.getGuild());
46+
Role dj = settings.getRole(event.getGuild());
47+
return dj!=null && (event.getMember().getRoles().contains(dj) || dj.getIdLong()==event.getGuild().getIdLong());
48+
}
49+
public static boolean checkDJPermission(SlashCommandEvent event)
50+
{
51+
if(event.getUser().getId().equals(event.getClient().getOwnerId()))
52+
return true;
53+
if(event.getGuild()==null)
54+
return true;
55+
if(event.getMember().hasPermission(Permission.MANAGE_SERVER))
56+
return true;
57+
Settings settings = event.getClient().getSettingsFor(event.getGuild());
58+
Role dj = settings.getRole(event.getGuild());
59+
return dj!=null && (event.getMember().getRoles().contains(dj) || dj.getIdLong()==event.getGuild().getIdLong());
60+
}
61+
}

src/main/java/com/jagrosh/jmusicbot/commands/dj/ClearCmd.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
import com.jagrosh.jdautilities.command.CommandEvent;
1919
import com.jagrosh.jmusicbot.Bot;
2020
import com.jagrosh.jmusicbot.audio.AudioHandler;
21-
import com.jagrosh.jmusicbot.commands.DJCommand;
21+
import com.jagrosh.jmusicbot.commands.LegacyDJCommand;
2222

2323
/**
2424
*
2525
* @author John Grosh <john.a.grosh@gmail.com>
2626
*/
27-
public class ClearCmd extends DJCommand
27+
public class ClearCmd extends LegacyDJCommand
2828
{
2929
public ClearCmd(Bot bot)
3030
{

src/main/java/com/jagrosh/jmusicbot/commands/dj/ForceRemoveCmd.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import com.jagrosh.jdautilities.menu.OrderedMenu;
2121
import com.jagrosh.jmusicbot.Bot;
2222
import com.jagrosh.jmusicbot.audio.AudioHandler;
23-
import com.jagrosh.jmusicbot.commands.DJCommand;
23+
import com.jagrosh.jmusicbot.commands.LegacyDJCommand;
2424
import com.jagrosh.jmusicbot.utils.FormatUtil;
2525
import net.dv8tion.jda.api.Permission;
2626
import net.dv8tion.jda.api.entities.Member;
@@ -33,7 +33,7 @@
3333
*
3434
* @author Michaili K.
3535
*/
36-
public class ForceRemoveCmd extends DJCommand
36+
public class ForceRemoveCmd extends LegacyDJCommand
3737
{
3838
public ForceRemoveCmd(Bot bot)
3939
{

src/main/java/com/jagrosh/jmusicbot/commands/dj/ForceskipCmd.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919
import com.jagrosh.jmusicbot.Bot;
2020
import com.jagrosh.jmusicbot.audio.AudioHandler;
2121
import com.jagrosh.jmusicbot.audio.RequestMetadata;
22-
import com.jagrosh.jmusicbot.commands.DJCommand;
22+
import com.jagrosh.jmusicbot.commands.LegacyDJCommand;
2323
import com.jagrosh.jmusicbot.utils.FormatUtil;
2424

2525
/**
2626
*
2727
* @author John Grosh <john.a.grosh@gmail.com>
2828
*/
29-
public class ForceskipCmd extends DJCommand
29+
public class ForceskipCmd extends LegacyDJCommand
3030
{
3131
public ForceskipCmd(Bot bot)
3232
{

src/main/java/com/jagrosh/jmusicbot/commands/dj/MoveTrackCmd.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
import com.jagrosh.jmusicbot.Bot;
66
import com.jagrosh.jmusicbot.audio.AudioHandler;
77
import com.jagrosh.jmusicbot.audio.QueuedTrack;
8-
import com.jagrosh.jmusicbot.commands.DJCommand;
8+
import com.jagrosh.jmusicbot.commands.LegacyDJCommand;
99
import com.jagrosh.jmusicbot.queue.AbstractQueue;
1010

1111
/**
1212
* Command that provides users the ability to move a track in the playlist.
1313
*/
14-
public class MoveTrackCmd extends DJCommand
14+
public class MoveTrackCmd extends LegacyDJCommand
1515
{
1616

1717
public MoveTrackCmd(Bot bot)

src/main/java/com/jagrosh/jmusicbot/commands/dj/PauseCmd.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
import com.jagrosh.jdautilities.command.CommandEvent;
1919
import com.jagrosh.jmusicbot.Bot;
2020
import com.jagrosh.jmusicbot.audio.AudioHandler;
21-
import com.jagrosh.jmusicbot.commands.DJCommand;
21+
import com.jagrosh.jmusicbot.commands.LegacyDJCommand;
2222

2323
/**
2424
*
2525
* @author John Grosh <john.a.grosh@gmail.com>
2626
*/
27-
public class PauseCmd extends DJCommand
27+
public class PauseCmd extends LegacyDJCommand
2828
{
2929
public PauseCmd(Bot bot)
3030
{

0 commit comments

Comments
 (0)