|
|
@ -27,8 +27,10 @@ import moe.nekojimi.musicsearcher.providers.Searcher; |
|
|
|
import net.dv8tion.jda.api.JDA; |
|
|
|
import net.dv8tion.jda.api.JDA; |
|
|
|
import net.dv8tion.jda.api.JDABuilder; |
|
|
|
import net.dv8tion.jda.api.JDABuilder; |
|
|
|
import net.dv8tion.jda.api.entities.*; |
|
|
|
import net.dv8tion.jda.api.entities.*; |
|
|
|
import net.dv8tion.jda.api.events.guild.voice.GuildVoiceLeaveEvent; |
|
|
|
import net.dv8tion.jda.api.entities.channel.middleman.AudioChannel; |
|
|
|
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; |
|
|
|
import net.dv8tion.jda.api.entities.channel.unions.AudioChannelUnion; |
|
|
|
|
|
|
|
import net.dv8tion.jda.api.events.guild.voice.GuildVoiceUpdateEvent; |
|
|
|
|
|
|
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent; |
|
|
|
import net.dv8tion.jda.api.hooks.ListenerAdapter; |
|
|
|
import net.dv8tion.jda.api.hooks.ListenerAdapter; |
|
|
|
import net.dv8tion.jda.api.managers.AudioManager; |
|
|
|
import net.dv8tion.jda.api.managers.AudioManager; |
|
|
|
import net.dv8tion.jda.api.requests.GatewayIntent; |
|
|
|
import net.dv8tion.jda.api.requests.GatewayIntent; |
|
|
@ -61,7 +63,7 @@ public final class Chords extends ListenerAdapter |
|
|
|
private final Command helpCommand; |
|
|
|
private final Command helpCommand; |
|
|
|
private PlayCommand playCommand; |
|
|
|
private PlayCommand playCommand; |
|
|
|
|
|
|
|
|
|
|
|
private VoiceChannel currentVoiceChannel = null; |
|
|
|
private AudioChannel currentVoiceChannel = null; |
|
|
|
|
|
|
|
|
|
|
|
private int trackNumber = 1; |
|
|
|
private int trackNumber = 1; |
|
|
|
|
|
|
|
|
|
|
@ -85,7 +87,8 @@ public final class Chords extends ListenerAdapter |
|
|
|
GatewayIntent.GUILD_MESSAGES, |
|
|
|
GatewayIntent.GUILD_MESSAGES, |
|
|
|
// We need voice states to connect to the voice channel
|
|
|
|
// We need voice states to connect to the voice channel
|
|
|
|
GatewayIntent.GUILD_VOICE_STATES, |
|
|
|
GatewayIntent.GUILD_VOICE_STATES, |
|
|
|
GatewayIntent.GUILD_MEMBERS |
|
|
|
GatewayIntent.GUILD_MEMBERS, |
|
|
|
|
|
|
|
GatewayIntent.MESSAGE_CONTENT |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
settings = new Settings(new File(options.getSettingsPath())); |
|
|
|
settings = new Settings(new File(options.getSettingsPath())); |
|
|
@ -178,12 +181,13 @@ public final class Chords extends ListenerAdapter |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onGuildVoiceLeave(GuildVoiceLeaveEvent event) |
|
|
|
public void onGuildVoiceUpdate(GuildVoiceUpdateEvent event) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
super.onGuildVoiceUpdate(event); |
|
|
|
if (this.currentVoiceChannel == null) |
|
|
|
if (this.currentVoiceChannel == null) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
final VoiceChannel channelLeft = event.getChannelLeft(); |
|
|
|
final AudioChannelUnion channelLeft = event.getChannelLeft(); |
|
|
|
|
|
|
|
|
|
|
|
if (channelLeft.getMembers().isEmpty()) |
|
|
|
if (channelLeft.getMembers().isEmpty()) |
|
|
|
if (channelLeft == currentVoiceChannel) |
|
|
|
if (channelLeft == currentVoiceChannel) |
|
|
@ -191,8 +195,9 @@ public final class Chords extends ListenerAdapter |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onGuildMessageReceived(GuildMessageReceivedEvent event) |
|
|
|
public void onMessageReceived(MessageReceivedEvent event) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
super.onMessageReceived(event); //To change body of generated methods, choose Tools | Templates.
|
|
|
|
Message message = event.getMessage(); |
|
|
|
Message message = event.getMessage(); |
|
|
|
User author = message.getAuthor(); |
|
|
|
User author = message.getAuthor(); |
|
|
|
String content = message.getContentRaw(); |
|
|
|
String content = message.getContentRaw(); |
|
|
@ -309,7 +314,7 @@ public final class Chords extends ListenerAdapter |
|
|
|
* @param channel |
|
|
|
* @param channel |
|
|
|
* The channel to connect to |
|
|
|
* The channel to connect to |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void connectTo(VoiceChannel channel) |
|
|
|
public void connectTo(AudioChannel channel) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Guild guild = channel.getGuild(); |
|
|
|
Guild guild = channel.getGuild(); |
|
|
|
// Get an audio manager for this guild, this will be created upon first use for each guild
|
|
|
|
// Get an audio manager for this guild, this will be created upon first use for each guild
|
|
|
@ -398,7 +403,7 @@ public final class Chords extends ListenerAdapter |
|
|
|
return jda; |
|
|
|
return jda; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public VoiceChannel getCurrentVoiceChannel() |
|
|
|
public AudioChannel getCurrentVoiceChannel() |
|
|
|
{ |
|
|
|
{ |
|
|
|
return currentVoiceChannel; |
|
|
|
return currentVoiceChannel; |
|
|
|
} |
|
|
|
} |
|
|
|