update to jda 5 alpha 20

This commit is contained in:
Tyler Murphy 2022-10-04 13:15:36 -04:00
parent 77144b15e7
commit 2f3280d4e7
34 changed files with 58 additions and 55 deletions

View file

@ -65,7 +65,7 @@
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-alpha.18</version>
<version>5.0.0-alpha.20</version>
</dependency>
<dependency>
<groupId>org.yaml</groupId>

View file

@ -3,6 +3,7 @@ package net.tylermurphy.ken.command;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.entities.*;
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
import net.dv8tion.jda.api.events.guild.member.GuildMemberJoinEvent;
import net.dv8tion.jda.api.events.guild.member.GuildMemberRemoveEvent;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
@ -322,7 +323,7 @@ public class Responder extends ListenerAdapter {
if(value != null) setValue = Boolean.parseBoolean(value);
if(!setValue){
try {
event.getGuild().kick(user, "Server is currently closed").queue();
event.getGuild().kick(user).reason("Server is currently closed").queue();
user.openPrivateChannel().queue(privateChannel -> {
EmbedBuilder builder = Ken.getInstance().getDefaultEmbed()
.appendDescription("Kicked from "+event.getGuild().getName() + " because the server is currently closed");

View file

@ -4,8 +4,7 @@ import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.PrivateChannel;
import net.dv8tion.jda.api.entities.Role;
import net.dv8tion.jda.api.entities.channel.concrete.PrivateChannel;
import net.dv8tion.jda.api.exceptions.ErrorResponseException;
import net.dv8tion.jda.api.interactions.commands.OptionType;
import net.tylermurphy.ken.Ken;
@ -22,6 +21,7 @@ import org.json.JSONObject;
import java.awt.*;
import java.util.Date;
import java.util.List;
import java.util.concurrent.TimeUnit;
public class Ban {
@ -48,7 +48,7 @@ public class Ban {
} catch (Exception ignored){}
try {
guild.ban(target,purge ? 1 : 0,reason).queue();
guild.ban(target,purge ? 1 : 0, TimeUnit.DAYS).reason(reason).queue();
} catch (Exception e){
return Response.error("Failed to ban user");
}

View file

@ -4,8 +4,7 @@ import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.PrivateChannel;
import net.dv8tion.jda.api.entities.Role;
import net.dv8tion.jda.api.entities.channel.concrete.PrivateChannel;
import net.dv8tion.jda.api.exceptions.ErrorResponseException;
import net.dv8tion.jda.api.interactions.commands.OptionType;
import net.tylermurphy.ken.Ken;
@ -46,7 +45,7 @@ public class Kick {
} catch (Exception ignored){}
try {
guild.kick(target).queue();
guild.kick(target).reason(reason).queue();
} catch (Exception e){
return Response.error("Failed to kick user");
}

View file

@ -4,9 +4,7 @@ import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.PrivateChannel;
import net.dv8tion.jda.api.entities.Role;
import net.dv8tion.jda.api.exceptions.ErrorResponseException;
import net.dv8tion.jda.api.entities.channel.concrete.PrivateChannel;
import net.dv8tion.jda.api.interactions.commands.OptionType;
import net.tylermurphy.ken.Ken;
import net.tylermurphy.ken.command.Response;
@ -20,7 +18,6 @@ import org.json.JSONArray;
import org.json.JSONObject;
import java.awt.*;
import java.sql.Time;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@ -57,7 +54,7 @@ public class Mute {
String date = format.format(time);
try {
guild.timeoutUntil(target, new Date(time).toInstant()).queue();
guild.timeoutUntil(target, new Date(time).toInstant()).reason(reason).queue();
} catch (Exception e){
return Response.error("Failed to mute user");
}

View file

@ -2,8 +2,8 @@ package net.tylermurphy.ken.command.moderation;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.GuildMessageChannel;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
import net.dv8tion.jda.api.interactions.commands.OptionType;
import net.tylermurphy.ken.command.annotation.Command;
import net.tylermurphy.ken.command.annotation.Option;

View file

@ -4,8 +4,7 @@ import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.PrivateChannel;
import net.dv8tion.jda.api.entities.Role;
import net.dv8tion.jda.api.entities.channel.concrete.PrivateChannel;
import net.dv8tion.jda.api.exceptions.ErrorResponseException;
import net.dv8tion.jda.api.interactions.commands.OptionType;
import net.tylermurphy.ken.Ken;
@ -23,6 +22,7 @@ import java.awt.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.concurrent.TimeUnit;
public class TempBan {
@ -57,7 +57,7 @@ public class TempBan {
} catch (Exception ignored){}
try {
guild.ban(target,purge ? 1 : 0,reason).queue();
guild.ban(target,purge ? 1 : 0, TimeUnit.DAYS).reason(reason).queue();
} catch (Exception e){
return Response.error("Failed to temp ban user");
}

View file

@ -3,6 +3,7 @@ package net.tylermurphy.ken.command.moderation;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.*;
import net.dv8tion.jda.api.entities.channel.concrete.PrivateChannel;
import net.dv8tion.jda.api.exceptions.ErrorResponseException;
import net.dv8tion.jda.api.interactions.commands.OptionType;
import net.tylermurphy.ken.Ken;
@ -59,7 +60,7 @@ public class UnBan {
}
try {
guild.unban(target).queue();
guild.unban(target).reason(reason).queue();
} catch (Exception e){
return Response.error("Failed to unban user");
}

View file

@ -3,6 +3,7 @@ package net.tylermurphy.ken.command.moderation;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.*;
import net.dv8tion.jda.api.entities.channel.concrete.PrivateChannel;
import net.dv8tion.jda.api.interactions.commands.OptionType;
import net.tylermurphy.ken.Ken;
import net.tylermurphy.ken.command.Response;
@ -37,7 +38,7 @@ public class UnMute {
}
try {
guild.removeTimeout(target).queue();
guild.removeTimeout(target).reason(reason).queue();
} catch (Exception e){
return Response.error("Failed to unmute user");
}

View file

@ -3,6 +3,7 @@ package net.tylermurphy.ken.command.music;
import com.sedmelluq.discord.lavaplayer.player.AudioPlayer;
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
import net.dv8tion.jda.api.entities.*;
import net.dv8tion.jda.api.entities.channel.middleman.AudioChannel;
import net.dv8tion.jda.api.managers.AudioManager;
import net.tylermurphy.ken.Ken;
import net.tylermurphy.ken.command.annotation.Command;

View file

@ -2,6 +2,7 @@ package net.tylermurphy.ken.command.music;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.*;
import net.dv8tion.jda.api.entities.channel.middleman.AudioChannel;
import net.dv8tion.jda.api.managers.AudioManager;
import net.tylermurphy.ken.Ken;
import net.tylermurphy.ken.command.annotation.Command;

View file

@ -1,8 +1,8 @@
package net.tylermurphy.ken.command.music;
import net.dv8tion.jda.api.entities.AudioChannel;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.channel.middleman.AudioChannel;
import net.dv8tion.jda.api.managers.AudioManager;
import net.tylermurphy.ken.command.annotation.Command;
import net.tylermurphy.ken.command.Response;

View file

@ -1,9 +1,9 @@
package net.tylermurphy.ken.command.music;
import com.sedmelluq.discord.lavaplayer.player.AudioPlayer;
import net.dv8tion.jda.api.entities.AudioChannel;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.channel.middleman.AudioChannel;
import net.dv8tion.jda.api.managers.AudioManager;
import net.tylermurphy.ken.Ken;
import net.tylermurphy.ken.command.annotation.Command;

View file

@ -1,9 +1,9 @@
package net.tylermurphy.ken.command.music;
import com.sedmelluq.discord.lavaplayer.player.AudioPlayer;
import net.dv8tion.jda.api.entities.AudioChannel;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.channel.middleman.AudioChannel;
import net.dv8tion.jda.api.managers.AudioManager;
import net.tylermurphy.ken.Ken;
import net.tylermurphy.ken.command.annotation.Command;

View file

@ -4,6 +4,7 @@ import com.sedmelluq.discord.lavaplayer.player.AudioPlayer;
import com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.*;
import net.dv8tion.jda.api.entities.channel.middleman.AudioChannel;
import net.dv8tion.jda.api.managers.AudioManager;
import net.tylermurphy.ken.Ken;
import net.tylermurphy.ken.command.annotation.Command;

View file

@ -1,7 +1,7 @@
package net.tylermurphy.ken.command.music;
import com.sedmelluq.discord.lavaplayer.player.AudioPlayer;
import net.dv8tion.jda.api.entities.AudioChannel;
import net.dv8tion.jda.api.entities.channel.middleman.AudioChannel;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.managers.AudioManager;

View file

@ -3,6 +3,8 @@ package net.tylermurphy.ken.command.music;
import com.google.api.services.youtube.model.SearchResult;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.*;
import net.dv8tion.jda.api.entities.channel.middleman.AudioChannel;
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
import net.dv8tion.jda.api.interactions.commands.OptionType;
import net.dv8tion.jda.api.managers.AudioManager;
import net.tylermurphy.ken.Ken;

View file

@ -1,7 +1,7 @@
package net.tylermurphy.ken.command.music;
import com.sedmelluq.discord.lavaplayer.player.AudioPlayer;
import net.dv8tion.jda.api.entities.AudioChannel;
import net.dv8tion.jda.api.entities.channel.middleman.AudioChannel;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.interactions.commands.OptionType;

View file

@ -1,7 +1,7 @@
package net.tylermurphy.ken.command.music;
import com.sedmelluq.discord.lavaplayer.player.AudioPlayer;
import net.dv8tion.jda.api.entities.AudioChannel;
import net.dv8tion.jda.api.entities.channel.middleman.AudioChannel;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.managers.AudioManager;

View file

@ -2,10 +2,10 @@ package net.tylermurphy.ken.command.music;
import com.sedmelluq.discord.lavaplayer.player.AudioPlayer;
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
import net.dv8tion.jda.api.entities.AudioChannel;
import net.dv8tion.jda.api.entities.channel.middleman.AudioChannel;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.GuildMessageChannel;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
import net.dv8tion.jda.api.managers.AudioManager;
import net.tylermurphy.ken.Ken;
import net.tylermurphy.ken.command.annotation.Command;

View file

@ -1,7 +1,7 @@
package net.tylermurphy.ken.command.music;
import com.sedmelluq.discord.lavaplayer.player.AudioPlayer;
import net.dv8tion.jda.api.entities.AudioChannel;
import net.dv8tion.jda.api.entities.channel.middleman.AudioChannel;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.managers.AudioManager;

View file

@ -1,7 +1,7 @@
package net.tylermurphy.ken.command.nsfw;
import net.dv8tion.jda.api.entities.GuildMessageChannel;
import net.dv8tion.jda.api.entities.TextChannel;
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
import net.dv8tion.jda.api.interactions.commands.OptionType;
import net.tylermurphy.ken.Ken;
import net.tylermurphy.ken.api.HTTPMethod;

View file

@ -1,7 +1,7 @@
package net.tylermurphy.ken.command.nsfw;
import net.dv8tion.jda.api.entities.GuildMessageChannel;
import net.dv8tion.jda.api.entities.TextChannel;
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
import net.dv8tion.jda.api.interactions.commands.OptionType;
import net.tylermurphy.ken.Ken;
import net.tylermurphy.ken.api.HTTPMethod;

View file

@ -1,7 +1,7 @@
package net.tylermurphy.ken.command.nsfw;
import net.dv8tion.jda.api.entities.GuildMessageChannel;
import net.dv8tion.jda.api.entities.TextChannel;
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
import net.dv8tion.jda.api.interactions.commands.OptionType;
import net.tylermurphy.ken.Ken;
import net.tylermurphy.ken.api.HTTPMethod;

View file

@ -1,7 +1,7 @@
package net.tylermurphy.ken.command.nsfw;
import net.dv8tion.jda.api.entities.GuildMessageChannel;
import net.dv8tion.jda.api.entities.TextChannel;
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import net.dv8tion.jda.api.interactions.commands.OptionType;
import net.tylermurphy.ken.Ken;
import net.tylermurphy.ken.api.HTTPMethod;

View file

@ -1,7 +1,7 @@
package net.tylermurphy.ken.command.nsfw;
import net.dv8tion.jda.api.entities.GuildMessageChannel;
import net.dv8tion.jda.api.entities.TextChannel;
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import net.dv8tion.jda.api.interactions.commands.OptionType;
import net.tylermurphy.ken.Ken;
import net.tylermurphy.ken.api.HTTPMethod;

View file

@ -1,7 +1,7 @@
package net.tylermurphy.ken.command.nsfw;
import net.dv8tion.jda.api.entities.GuildMessageChannel;
import net.dv8tion.jda.api.entities.TextChannel;
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import net.dv8tion.jda.api.interactions.commands.OptionType;
import net.tylermurphy.ken.Ken;
import net.tylermurphy.ken.api.HTTPMethod;

View file

@ -1,7 +1,7 @@
package net.tylermurphy.ken.command.nsfw;
import net.dv8tion.jda.api.entities.GuildMessageChannel;
import net.dv8tion.jda.api.entities.TextChannel;
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import net.dv8tion.jda.api.interactions.commands.OptionType;
import net.tylermurphy.ken.Ken;
import net.tylermurphy.ken.api.HTTPMethod;

View file

@ -1,9 +1,9 @@
package net.tylermurphy.ken.command.nsfw;
import net.dv8tion.jda.api.entities.GuildMessageChannel;
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.MessageEmbed;
import net.dv8tion.jda.api.entities.TextChannel;
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import net.dv8tion.jda.api.interactions.commands.OptionType;
import net.tylermurphy.ken.Ken;
import net.tylermurphy.ken.api.HTTPMethod;

View file

@ -5,8 +5,7 @@ import java.util.TimerTask;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.MessageChannel;
import net.dv8tion.jda.api.entities.TextChannel;
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import net.dv8tion.jda.api.managers.AudioManager;
import net.tylermurphy.ken.Ken;
@ -15,7 +14,6 @@ public class AutoLeaveManager extends ListenerAdapter {
Timer timer;
TimeoutTask task;
Guild guild;
public AutoLeaveManager() {
Ken.getInstance().addEventListener(this);
@ -47,9 +45,10 @@ class TimeoutTask extends TimerTask {
this.manager = guild.getAudioManager();
}
private AudioManager manager;
private final AudioManager manager;
private final MessageChannel channel;
private long lastTime = 0;
private MessageChannel channel;
public void run() {
if(lastTime == 0) {

View file

@ -4,16 +4,17 @@ import com.sedmelluq.discord.lavaplayer.player.AudioPlayer;
import com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.GuildMessageChannel;
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
public class GuildMusicManager {
public final AudioPlayer player;
public final TrackScheduler scheduler;
public GuildMessageChannel boundChannel;
public final AutoLeaveManager autoLeaveManager;
public final Guild guild;
public GuildMessageChannel boundChannel;
public GuildMusicManager(Guild guild, AudioPlayerManager manager) {
player = manager.createPlayer();
scheduler = new TrackScheduler(player, guild);

View file

@ -2,9 +2,9 @@ package net.tylermurphy.ken.music;
import java.util.List;
import net.dv8tion.jda.api.entities.AudioChannel;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.Role;
import net.dv8tion.jda.api.entities.channel.middleman.AudioChannel;
public class MusicPermissions {

View file

@ -11,7 +11,7 @@ import com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.GuildMessageChannel;
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
import net.dv8tion.jda.api.entities.User;
import net.tylermurphy.ken.Ken;

View file

@ -2,11 +2,10 @@ package net.tylermurphy.ken.util;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.PrivateChannel;
import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.entities.channel.concrete.PrivateChannel;
import net.dv8tion.jda.api.exceptions.ErrorResponseException;
import net.tylermurphy.ken.Ken;
import net.tylermurphy.ken.database.ModerationTable;
import org.json.JSONArray;
import org.json.JSONObject;