diff --git a/build.gradle b/build.gradle index cf4f1fe..310bb12 100644 --- a/build.gradle +++ b/build.gradle @@ -1,27 +1,38 @@ buildscript { repositories { - jcenter() + gradlePluginPortal() } - dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4' + classpath 'com.github.johnrengelman:shadow:8.1.1' } } -apply plugin: 'java' apply plugin: 'com.github.johnrengelman.shadow' +apply plugin: 'java' repositories { - jcenter() + mavenCentral() + + maven { + name 'm2-dv8tion' + url 'https://m2.dv8tion.net/releases' + } + + maven { + url 'https://m2.dv8tion.net/releases' + } + + maven { + url 'https://jitpack.io' + } } dependencies { - implementation 'org.slf4j:slf4j-simple:1.7.26' + implementation 'org.slf4j:slf4j-simple:2.0.13' - implementation 'net.dv8tion:JDA:3.8.3_463' - implementation 'com.sedmelluq:lavaplayer:1.3.17' - implementation 'redis.clients:jedis:3.0.1' - implementation 'com.vdurmont:emoji-java:4.0.0' + implementation 'net.dv8tion:JDA:5.0.0-beta.24' + implementation 'dev.arbjerg:lavaplayer:2.1.1' + implementation 'redis.clients:jedis:5.1.3' } jar { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 92402a8..42c1b2d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ +#Wed May 29 18:53:59 EDT 2024 +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-bin.zip \ No newline at end of file +zipStoreBase=GRADLE_USER_HOME diff --git a/src/main/java/dev/logal/logalbot/Main.java b/src/main/java/dev/logal/logalbot/Main.java index 8b18b37..cc44cbb 100644 --- a/src/main/java/dev/logal/logalbot/Main.java +++ b/src/main/java/dev/logal/logalbot/Main.java @@ -1,35 +1,32 @@ package dev.logal.logalbot; -// Copyright 2019 Logan Fick +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import javax.security.auth.login.LoginException; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import dev.logal.logalbot.commands.administration.*; +import dev.logal.logalbot.commands.administration.Settings; +import dev.logal.logalbot.commands.administration.Whitelist; import dev.logal.logalbot.commands.audio.*; -import dev.logal.logalbot.commands.fun.*; -import dev.logal.logalbot.commands.general.*; +import dev.logal.logalbot.commands.fun.Dice; +import dev.logal.logalbot.commands.fun.EightBall; +import dev.logal.logalbot.commands.general.About; +import dev.logal.logalbot.commands.general.Help; import dev.logal.logalbot.events.*; import dev.logal.logalbot.utils.AudioUtil; import dev.logal.logalbot.utils.CommandManager; import dev.logal.logalbot.utils.DataManager; -import net.dv8tion.jda.core.AccountType; -import net.dv8tion.jda.core.JDA; -import net.dv8tion.jda.core.JDABuilder; +import net.dv8tion.jda.api.JDA; +import net.dv8tion.jda.api.JDABuilder; +import net.dv8tion.jda.api.requests.GatewayIntent; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.Collection; public final class Main implements Runnable { private static final Logger logger = LoggerFactory.getLogger(Main.class); @@ -67,15 +64,13 @@ public final class Main implements Runnable { logger.info("Attempting to log into Discord..."); try { - final JDABuilder builder = new JDABuilder(AccountType.BOT); + final JDABuilder builder = JDABuilder.createDefault(token); + builder.enableIntents(GatewayIntent.GUILD_VOICE_STATES); + builder.enableIntents(GatewayIntent.MESSAGE_CONTENT); builder.setAutoReconnect(true); - builder.setAudioEnabled(true); builder.setToken(token); - builder.addEventListener(new GuildReady()); + builder.addEventListeners(new GuildReady()); jda = builder.build().awaitReady(); - } catch (final LoginException exception) { - logger.error("The token specified is not valid."); - System.exit(1); } catch (final Throwable exception) { logger.error("An error occurred while attempting to set up JDA!", exception); System.exit(1); @@ -85,9 +80,8 @@ public final class Main implements Runnable { logger.info("Initializing..."); AudioUtil.initializePlayerManager(); - jda.addEventListener(new GuildVoiceLeave()); - jda.addEventListener(new GuildVoiceMove()); - jda.addEventListener(new GuildMessageReactionAdd()); + jda.addEventListener(new GuildVoiceUpdate()); + jda.addEventListener(new MessageReactionAdd()); // General Commands CommandManager.registerCommand("about", new About(), false); @@ -145,7 +139,7 @@ public final class Main implements Runnable { CommandManager.registerCommandAlias("conf", "settings"); logger.info("Everything seems to be ready! Enabling command listener..."); - jda.addEventListener(new GuildMessageReceived()); + jda.addEventListener(new MessageReceived()); logger.info("Initialization complete!"); } } \ No newline at end of file diff --git a/src/main/java/dev/logal/logalbot/MainThread.java b/src/main/java/dev/logal/logalbot/MainThread.java index 702afcf..f80e382 100644 --- a/src/main/java/dev/logal/logalbot/MainThread.java +++ b/src/main/java/dev/logal/logalbot/MainThread.java @@ -1,26 +1,20 @@ package dev.logal.logalbot; -// Copyright 2019 Logan Fick +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +import net.dv8tion.jda.internal.utils.Checks; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; -import net.dv8tion.jda.core.utils.Checks; - public final class MainThread { private static final ScheduledExecutorService mainThread = Executors .newSingleThreadScheduledExecutor(new MainThreadFactory()); diff --git a/src/main/java/dev/logal/logalbot/MainThreadFactory.java b/src/main/java/dev/logal/logalbot/MainThreadFactory.java index 8097655..f13c1a2 100644 --- a/src/main/java/dev/logal/logalbot/MainThreadFactory.java +++ b/src/main/java/dev/logal/logalbot/MainThreadFactory.java @@ -1,23 +1,17 @@ package dev.logal.logalbot; -// Copyright 2019 Logan Fick +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +import net.dv8tion.jda.internal.utils.Checks; import java.util.concurrent.ThreadFactory; -import net.dv8tion.jda.core.utils.Checks; - public final class MainThreadFactory implements ThreadFactory { @Override public final Thread newThread(final Runnable runnable) { diff --git a/src/main/java/dev/logal/logalbot/audio/AudioPlayerSendHandler.java b/src/main/java/dev/logal/logalbot/audio/AudioPlayerSendHandler.java index 178454e..2f9c4b9 100644 --- a/src/main/java/dev/logal/logalbot/audio/AudioPlayerSendHandler.java +++ b/src/main/java/dev/logal/logalbot/audio/AudioPlayerSendHandler.java @@ -1,24 +1,19 @@ package dev.logal.logalbot.audio; -// Copyright 2019 Logan Fick - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ import com.sedmelluq.discord.lavaplayer.player.AudioPlayer; import com.sedmelluq.discord.lavaplayer.track.playback.AudioFrame; +import net.dv8tion.jda.api.audio.AudioSendHandler; +import net.dv8tion.jda.internal.utils.Checks; -import net.dv8tion.jda.core.audio.AudioSendHandler; -import net.dv8tion.jda.core.utils.Checks; +import java.nio.ByteBuffer; public final class AudioPlayerSendHandler implements AudioSendHandler { private final AudioPlayer audioPlayer; @@ -37,8 +32,8 @@ public final class AudioPlayerSendHandler implements AudioSendHandler { } @Override - public final byte[] provide20MsAudio() { - return lastFrame.getData(); + public final ByteBuffer provide20MsAudio() { + return ByteBuffer.wrap(lastFrame.getData()); } @Override diff --git a/src/main/java/dev/logal/logalbot/audio/RequestedTrack.java b/src/main/java/dev/logal/logalbot/audio/RequestedTrack.java index 899efd6..0b65f75 100644 --- a/src/main/java/dev/logal/logalbot/audio/RequestedTrack.java +++ b/src/main/java/dev/logal/logalbot/audio/RequestedTrack.java @@ -1,23 +1,16 @@ package dev.logal.logalbot.audio; -// Copyright 2019 Logan Fick - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ import com.sedmelluq.discord.lavaplayer.track.AudioTrack; - -import net.dv8tion.jda.core.entities.Member; -import net.dv8tion.jda.core.utils.Checks; +import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.internal.utils.Checks; public final class RequestedTrack { private final AudioTrack track; diff --git a/src/main/java/dev/logal/logalbot/audio/TrackLoadHandler.java b/src/main/java/dev/logal/logalbot/audio/TrackLoadHandler.java index 518b18a..6909a48 100644 --- a/src/main/java/dev/logal/logalbot/audio/TrackLoadHandler.java +++ b/src/main/java/dev/logal/logalbot/audio/TrackLoadHandler.java @@ -1,41 +1,33 @@ package dev.logal.logalbot.audio; -// Copyright 2019 Logan Fick - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import java.util.LinkedList; -import java.util.concurrent.TimeUnit; +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ import com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler; import com.sedmelluq.discord.lavaplayer.tools.FriendlyException; import com.sedmelluq.discord.lavaplayer.track.AudioPlaylist; import com.sedmelluq.discord.lavaplayer.track.AudioTrack; import com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import dev.logal.logalbot.MainThread; import dev.logal.logalbot.commands.CommandResponse; import dev.logal.logalbot.tasks.TrackAdditionTask; import dev.logal.logalbot.utils.AudioUtil; import dev.logal.logalbot.utils.PermissionManager; import dev.logal.logalbot.utils.TrackUtil; -import net.dv8tion.jda.core.entities.Guild; -import net.dv8tion.jda.core.entities.Member; -import net.dv8tion.jda.core.entities.TextChannel; -import net.dv8tion.jda.core.utils.Checks; +import net.dv8tion.jda.api.entities.Guild; +import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; +import net.dv8tion.jda.internal.utils.Checks; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.LinkedList; +import java.util.concurrent.TimeUnit; public final class TrackLoadHandler implements AudioLoadResultHandler { private final Logger logger = LoggerFactory.getLogger(TrackLoadHandler.class); diff --git a/src/main/java/dev/logal/logalbot/audio/TrackScheduler.java b/src/main/java/dev/logal/logalbot/audio/TrackScheduler.java index 470a291..4a3b781 100644 --- a/src/main/java/dev/logal/logalbot/audio/TrackScheduler.java +++ b/src/main/java/dev/logal/logalbot/audio/TrackScheduler.java @@ -1,46 +1,34 @@ package dev.logal.logalbot.audio; -// Copyright 2019 Logan Fick - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import java.util.Collections; -import java.util.LinkedList; -import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.TimeUnit; +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ import com.sedmelluq.discord.lavaplayer.player.AudioPlayer; import com.sedmelluq.discord.lavaplayer.player.event.AudioEventAdapter; import com.sedmelluq.discord.lavaplayer.track.AudioTrack; import com.sedmelluq.discord.lavaplayer.track.AudioTrackEndReason; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import dev.logal.logalbot.MainThread; import dev.logal.logalbot.tasks.CloseAudioConnectionTask; import dev.logal.logalbot.tasks.OpenAudioConnectionTask; import dev.logal.logalbot.tasks.PlayNextTrackTask; -import dev.logal.logalbot.utils.AudioUtil; -import dev.logal.logalbot.utils.DataManager; -import dev.logal.logalbot.utils.PermissionManager; -import dev.logal.logalbot.utils.SkipTracker; -import dev.logal.logalbot.utils.VoiceChannelUtil; -import net.dv8tion.jda.core.entities.Guild; -import net.dv8tion.jda.core.entities.Member; -import net.dv8tion.jda.core.entities.User; -import net.dv8tion.jda.core.entities.VoiceChannel; -import net.dv8tion.jda.core.utils.Checks; +import dev.logal.logalbot.utils.*; +import net.dv8tion.jda.api.entities.Guild; +import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.entities.User; +import net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel; +import net.dv8tion.jda.internal.utils.Checks; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Collections; +import java.util.LinkedList; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; public final class TrackScheduler extends AudioEventAdapter { private static final Logger logger = LoggerFactory.getLogger(TrackScheduler.class); diff --git a/src/main/java/dev/logal/logalbot/commands/Command.java b/src/main/java/dev/logal/logalbot/commands/Command.java index 1688228..58c9647 100644 --- a/src/main/java/dev/logal/logalbot/commands/Command.java +++ b/src/main/java/dev/logal/logalbot/commands/Command.java @@ -1,21 +1,16 @@ package dev.logal.logalbot.commands; -// Copyright 2019 Logan Fick +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import net.dv8tion.jda.core.entities.Member; -import net.dv8tion.jda.core.entities.TextChannel; +import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; public interface Command { CommandResponse execute(final String[] arguments, final Member executor, final TextChannel channel); diff --git a/src/main/java/dev/logal/logalbot/commands/CommandResponse.java b/src/main/java/dev/logal/logalbot/commands/CommandResponse.java index e8a3f35..e92cb7b 100644 --- a/src/main/java/dev/logal/logalbot/commands/CommandResponse.java +++ b/src/main/java/dev/logal/logalbot/commands/CommandResponse.java @@ -1,37 +1,27 @@ package dev.logal.logalbot.commands; -// Copyright 2019 Logan Fick - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.concurrent.TimeUnit; - -import com.vdurmont.emoji.Emoji; -import com.vdurmont.emoji.EmojiManager; +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ import dev.logal.logalbot.MainThread; import dev.logal.logalbot.tasks.MessageDeleteTask; import dev.logal.logalbot.tasks.ReactionCallbackExpireTask; import dev.logal.logalbot.utils.ReactionCallbackManager; -import net.dv8tion.jda.core.MessageBuilder; -import net.dv8tion.jda.core.entities.Member; -import net.dv8tion.jda.core.entities.Message; -import net.dv8tion.jda.core.entities.MessageEmbed; -import net.dv8tion.jda.core.entities.TextChannel; -import net.dv8tion.jda.core.entities.User; -import net.dv8tion.jda.core.utils.Checks; +import net.dv8tion.jda.api.entities.*; +import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; +import net.dv8tion.jda.api.entities.emoji.Emoji; +import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder; +import net.dv8tion.jda.internal.utils.Checks; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.concurrent.TimeUnit; + public final class CommandResponse { private final Emoji emoji; @@ -47,7 +37,7 @@ public final class CommandResponse { Checks.notEmpty(emoji, "Emoji"); Checks.notEmpty(response, "Response"); - this.emoji = EmojiManager.getForAlias(emoji); + this.emoji = Emoji.fromUnicode(emoji); Checks.notNull(this.emoji, "Valid Emoji"); this.response = response; } @@ -72,7 +62,7 @@ public final class CommandResponse { Checks.notEmpty(emoji, "Emoji"); Checks.notNull(callback, "Callback"); - this.callbacks.put(EmojiManager.getForAlias(emoji), callback); + this.callbacks.put(Emoji.fromUnicode(emoji), callback); return this; } @@ -95,11 +85,11 @@ public final class CommandResponse { public final void sendResponse(final TextChannel channel) { Checks.notNull(channel, "Channel"); - final MessageBuilder builder = new MessageBuilder(); - builder.setContent(this.emoji.getUnicode() + " " + this.response); + final MessageCreateBuilder builder = new MessageCreateBuilder(); + builder.setContent(":" + this.emoji.getFormatted() + ": " + this.response); if (this.responseEmbed != null) { - builder.setEmbed(this.responseEmbed); + builder.addEmbeds(this.responseEmbed); } channel.sendMessage(builder.build()).queue(this::handleResponseCreation); diff --git a/src/main/java/dev/logal/logalbot/commands/ReactionCallback.java b/src/main/java/dev/logal/logalbot/commands/ReactionCallback.java index dc64799..b073770 100644 --- a/src/main/java/dev/logal/logalbot/commands/ReactionCallback.java +++ b/src/main/java/dev/logal/logalbot/commands/ReactionCallback.java @@ -1,21 +1,15 @@ package dev.logal.logalbot.commands; -// Copyright 2019 Logan Fick +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import net.dv8tion.jda.core.entities.Member; -import net.dv8tion.jda.core.entities.Message; +import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.entities.Message; public interface ReactionCallback { void run(final Member reactor, final Message message); diff --git a/src/main/java/dev/logal/logalbot/commands/administration/Settings.java b/src/main/java/dev/logal/logalbot/commands/administration/Settings.java index b1d0f25..e3ffcb4 100644 --- a/src/main/java/dev/logal/logalbot/commands/administration/Settings.java +++ b/src/main/java/dev/logal/logalbot/commands/administration/Settings.java @@ -1,30 +1,24 @@ package dev.logal.logalbot.commands.administration; -// Copyright 2019 Logan Fick - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import java.util.concurrent.TimeUnit; +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ import dev.logal.logalbot.commands.Command; import dev.logal.logalbot.commands.CommandResponse; import dev.logal.logalbot.utils.AudioUtil; import dev.logal.logalbot.utils.DataManager; import dev.logal.logalbot.utils.StringUtil; -import net.dv8tion.jda.core.EmbedBuilder; -import net.dv8tion.jda.core.entities.Guild; -import net.dv8tion.jda.core.entities.Member; -import net.dv8tion.jda.core.entities.TextChannel; +import net.dv8tion.jda.api.EmbedBuilder; +import net.dv8tion.jda.api.entities.Guild; +import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; + +import java.util.concurrent.TimeUnit; public final class Settings implements Command { @Override diff --git a/src/main/java/dev/logal/logalbot/commands/administration/Whitelist.java b/src/main/java/dev/logal/logalbot/commands/administration/Whitelist.java index be63bab..c8f151a 100644 --- a/src/main/java/dev/logal/logalbot/commands/administration/Whitelist.java +++ b/src/main/java/dev/logal/logalbot/commands/administration/Whitelist.java @@ -1,28 +1,22 @@ package dev.logal.logalbot.commands.administration; -// Copyright 2019 Logan Fick - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import java.util.concurrent.TimeUnit; +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ import dev.logal.logalbot.commands.Command; import dev.logal.logalbot.commands.CommandResponse; import dev.logal.logalbot.utils.PermissionManager; -import net.dv8tion.jda.core.Permission; -import net.dv8tion.jda.core.entities.Guild; -import net.dv8tion.jda.core.entities.Member; -import net.dv8tion.jda.core.entities.TextChannel; +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.channel.concrete.TextChannel; + +import java.util.concurrent.TimeUnit; public final class Whitelist implements Command { @Override diff --git a/src/main/java/dev/logal/logalbot/commands/audio/ForceSkip.java b/src/main/java/dev/logal/logalbot/commands/audio/ForceSkip.java index 24badd5..c05540a 100644 --- a/src/main/java/dev/logal/logalbot/commands/audio/ForceSkip.java +++ b/src/main/java/dev/logal/logalbot/commands/audio/ForceSkip.java @@ -1,20 +1,12 @@ package dev.logal.logalbot.commands.audio; -// Copyright 2019 Logan Fick - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import java.util.concurrent.TimeUnit; +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ import dev.logal.logalbot.audio.RequestedTrack; import dev.logal.logalbot.commands.Command; @@ -22,9 +14,11 @@ import dev.logal.logalbot.commands.CommandResponse; import dev.logal.logalbot.utils.AudioUtil; import dev.logal.logalbot.utils.TrackUtil; import dev.logal.logalbot.utils.VoiceChannelUtil; -import net.dv8tion.jda.core.entities.Guild; -import net.dv8tion.jda.core.entities.Member; -import net.dv8tion.jda.core.entities.TextChannel; +import net.dv8tion.jda.api.entities.Guild; +import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; + +import java.util.concurrent.TimeUnit; public final class ForceSkip implements Command { @Override diff --git a/src/main/java/dev/logal/logalbot/commands/audio/Lock.java b/src/main/java/dev/logal/logalbot/commands/audio/Lock.java index 3d81378..f6369a9 100644 --- a/src/main/java/dev/logal/logalbot/commands/audio/Lock.java +++ b/src/main/java/dev/logal/logalbot/commands/audio/Lock.java @@ -1,29 +1,23 @@ package dev.logal.logalbot.commands.audio; -// Copyright 2019 Logan Fick - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import java.util.concurrent.TimeUnit; +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ import dev.logal.logalbot.audio.TrackScheduler; import dev.logal.logalbot.commands.Command; import dev.logal.logalbot.commands.CommandResponse; import dev.logal.logalbot.utils.AudioUtil; import dev.logal.logalbot.utils.VoiceChannelUtil; -import net.dv8tion.jda.core.entities.Guild; -import net.dv8tion.jda.core.entities.Member; -import net.dv8tion.jda.core.entities.TextChannel; +import net.dv8tion.jda.api.entities.Guild; +import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; + +import java.util.concurrent.TimeUnit; public final class Lock implements Command { @Override diff --git a/src/main/java/dev/logal/logalbot/commands/audio/NowPlaying.java b/src/main/java/dev/logal/logalbot/commands/audio/NowPlaying.java index 78ab1de..73a3efc 100644 --- a/src/main/java/dev/logal/logalbot/commands/audio/NowPlaying.java +++ b/src/main/java/dev/logal/logalbot/commands/audio/NowPlaying.java @@ -1,26 +1,20 @@ package dev.logal.logalbot.commands.audio; -// Copyright 2019 Logan Fick - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ import dev.logal.logalbot.commands.Command; import dev.logal.logalbot.commands.CommandResponse; import dev.logal.logalbot.utils.AudioUtil; import dev.logal.logalbot.utils.TrackUtil; -import net.dv8tion.jda.core.entities.Guild; -import net.dv8tion.jda.core.entities.Member; -import net.dv8tion.jda.core.entities.TextChannel; +import net.dv8tion.jda.api.entities.Guild; +import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; public final class NowPlaying implements Command { @Override diff --git a/src/main/java/dev/logal/logalbot/commands/audio/Pause.java b/src/main/java/dev/logal/logalbot/commands/audio/Pause.java index 3b9c839..ced8ef6 100644 --- a/src/main/java/dev/logal/logalbot/commands/audio/Pause.java +++ b/src/main/java/dev/logal/logalbot/commands/audio/Pause.java @@ -1,28 +1,22 @@ package dev.logal.logalbot.commands.audio; -// Copyright 2019 Logan Fick - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import java.util.concurrent.TimeUnit; +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ import dev.logal.logalbot.commands.Command; import dev.logal.logalbot.commands.CommandResponse; import dev.logal.logalbot.utils.AudioUtil; import dev.logal.logalbot.utils.VoiceChannelUtil; -import net.dv8tion.jda.core.entities.Guild; -import net.dv8tion.jda.core.entities.Member; -import net.dv8tion.jda.core.entities.TextChannel; +import net.dv8tion.jda.api.entities.Guild; +import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; + +import java.util.concurrent.TimeUnit; public final class Pause implements Command { @Override diff --git a/src/main/java/dev/logal/logalbot/commands/audio/Play.java b/src/main/java/dev/logal/logalbot/commands/audio/Play.java index a41df11..7eb2c6f 100644 --- a/src/main/java/dev/logal/logalbot/commands/audio/Play.java +++ b/src/main/java/dev/logal/logalbot/commands/audio/Play.java @@ -1,22 +1,12 @@ package dev.logal.logalbot.commands.audio; -// Copyright 2019 Logan Fick - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import java.net.MalformedURLException; -import java.net.URL; -import java.util.concurrent.TimeUnit; +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ import dev.logal.logalbot.audio.TrackScheduler; import dev.logal.logalbot.commands.Command; @@ -25,11 +15,15 @@ import dev.logal.logalbot.utils.AudioUtil; import dev.logal.logalbot.utils.DataManager; import dev.logal.logalbot.utils.PermissionManager; import dev.logal.logalbot.utils.VoiceChannelUtil; -import net.dv8tion.jda.core.Permission; -import net.dv8tion.jda.core.entities.Guild; -import net.dv8tion.jda.core.entities.Member; -import net.dv8tion.jda.core.entities.TextChannel; -import net.dv8tion.jda.core.entities.VoiceChannel; +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.channel.concrete.TextChannel; +import net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.concurrent.TimeUnit; public final class Play implements Command { @Override diff --git a/src/main/java/dev/logal/logalbot/commands/audio/Queue.java b/src/main/java/dev/logal/logalbot/commands/audio/Queue.java index 10d5409..0ff2e5d 100644 --- a/src/main/java/dev/logal/logalbot/commands/audio/Queue.java +++ b/src/main/java/dev/logal/logalbot/commands/audio/Queue.java @@ -1,21 +1,12 @@ package dev.logal.logalbot.commands.audio; -// Copyright 2019 Logan Fick - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import java.util.List; -import java.util.concurrent.TimeUnit; +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ import dev.logal.logalbot.MainThread; import dev.logal.logalbot.audio.RequestedTrack; @@ -25,9 +16,12 @@ import dev.logal.logalbot.tasks.CommandExecutionTask; import dev.logal.logalbot.utils.AudioUtil; import dev.logal.logalbot.utils.ReactionCallbackManager; import dev.logal.logalbot.utils.TrackUtil; -import net.dv8tion.jda.core.entities.Guild; -import net.dv8tion.jda.core.entities.Member; -import net.dv8tion.jda.core.entities.TextChannel; +import net.dv8tion.jda.api.entities.Guild; +import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; + +import java.util.List; +import java.util.concurrent.TimeUnit; public final class Queue implements Command { @Override diff --git a/src/main/java/dev/logal/logalbot/commands/audio/Remove.java b/src/main/java/dev/logal/logalbot/commands/audio/Remove.java index 7787e86..bac6196 100644 --- a/src/main/java/dev/logal/logalbot/commands/audio/Remove.java +++ b/src/main/java/dev/logal/logalbot/commands/audio/Remove.java @@ -1,20 +1,12 @@ package dev.logal.logalbot.commands.audio; -// Copyright 2019 Logan Fick - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import java.util.concurrent.TimeUnit; +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ import dev.logal.logalbot.MainThread; import dev.logal.logalbot.audio.RequestedTrack; @@ -22,15 +14,13 @@ import dev.logal.logalbot.audio.TrackScheduler; import dev.logal.logalbot.commands.Command; import dev.logal.logalbot.commands.CommandResponse; import dev.logal.logalbot.tasks.CommandExecutionTask; -import dev.logal.logalbot.utils.AudioUtil; -import dev.logal.logalbot.utils.ReactionCallbackManager; -import dev.logal.logalbot.utils.StringUtil; -import dev.logal.logalbot.utils.TrackUtil; -import dev.logal.logalbot.utils.VoiceChannelUtil; -import net.dv8tion.jda.core.Permission; -import net.dv8tion.jda.core.entities.Guild; -import net.dv8tion.jda.core.entities.Member; -import net.dv8tion.jda.core.entities.TextChannel; +import dev.logal.logalbot.utils.*; +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.channel.concrete.TextChannel; + +import java.util.concurrent.TimeUnit; public final class Remove implements Command { @Override diff --git a/src/main/java/dev/logal/logalbot/commands/audio/Reset.java b/src/main/java/dev/logal/logalbot/commands/audio/Reset.java index 2f4833a..f9e4b60 100644 --- a/src/main/java/dev/logal/logalbot/commands/audio/Reset.java +++ b/src/main/java/dev/logal/logalbot/commands/audio/Reset.java @@ -1,28 +1,22 @@ package dev.logal.logalbot.commands.audio; -// Copyright 2019 Logan Fick - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import java.util.concurrent.TimeUnit; +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ import dev.logal.logalbot.commands.Command; import dev.logal.logalbot.commands.CommandResponse; import dev.logal.logalbot.utils.AudioUtil; import dev.logal.logalbot.utils.VoiceChannelUtil; -import net.dv8tion.jda.core.entities.Guild; -import net.dv8tion.jda.core.entities.Member; -import net.dv8tion.jda.core.entities.TextChannel; +import net.dv8tion.jda.api.entities.Guild; +import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; + +import java.util.concurrent.TimeUnit; public final class Reset implements Command { @Override diff --git a/src/main/java/dev/logal/logalbot/commands/audio/Shuffle.java b/src/main/java/dev/logal/logalbot/commands/audio/Shuffle.java index 048fa0c..c5fd69d 100644 --- a/src/main/java/dev/logal/logalbot/commands/audio/Shuffle.java +++ b/src/main/java/dev/logal/logalbot/commands/audio/Shuffle.java @@ -1,29 +1,23 @@ package dev.logal.logalbot.commands.audio; -// Copyright 2019 Logan Fick - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import java.util.concurrent.TimeUnit; +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ import dev.logal.logalbot.audio.TrackScheduler; import dev.logal.logalbot.commands.Command; import dev.logal.logalbot.commands.CommandResponse; import dev.logal.logalbot.utils.AudioUtil; import dev.logal.logalbot.utils.VoiceChannelUtil; -import net.dv8tion.jda.core.entities.Guild; -import net.dv8tion.jda.core.entities.Member; -import net.dv8tion.jda.core.entities.TextChannel; +import net.dv8tion.jda.api.entities.Guild; +import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; + +import java.util.concurrent.TimeUnit; public final class Shuffle implements Command { @Override diff --git a/src/main/java/dev/logal/logalbot/commands/audio/Skip.java b/src/main/java/dev/logal/logalbot/commands/audio/Skip.java index 3ff1ad1..0fd2dd7 100644 --- a/src/main/java/dev/logal/logalbot/commands/audio/Skip.java +++ b/src/main/java/dev/logal/logalbot/commands/audio/Skip.java @@ -1,20 +1,12 @@ package dev.logal.logalbot.commands.audio; -// Copyright 2019 Logan Fick - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import java.util.concurrent.TimeUnit; +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ import dev.logal.logalbot.audio.RequestedTrack; import dev.logal.logalbot.commands.Command; @@ -23,9 +15,11 @@ import dev.logal.logalbot.utils.AudioUtil; import dev.logal.logalbot.utils.SkipTracker; import dev.logal.logalbot.utils.TrackUtil; import dev.logal.logalbot.utils.VoiceChannelUtil; -import net.dv8tion.jda.core.entities.Guild; -import net.dv8tion.jda.core.entities.Member; -import net.dv8tion.jda.core.entities.TextChannel; +import net.dv8tion.jda.api.entities.Guild; +import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; + +import java.util.concurrent.TimeUnit; public final class Skip implements Command { @Override diff --git a/src/main/java/dev/logal/logalbot/commands/audio/Volume.java b/src/main/java/dev/logal/logalbot/commands/audio/Volume.java index 3c28f8d..16a6d0e 100644 --- a/src/main/java/dev/logal/logalbot/commands/audio/Volume.java +++ b/src/main/java/dev/logal/logalbot/commands/audio/Volume.java @@ -1,28 +1,22 @@ package dev.logal.logalbot.commands.audio; -// Copyright 2019 Logan Fick - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import java.util.concurrent.TimeUnit; +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ import dev.logal.logalbot.commands.Command; import dev.logal.logalbot.commands.CommandResponse; import dev.logal.logalbot.utils.AudioUtil; import dev.logal.logalbot.utils.VoiceChannelUtil; -import net.dv8tion.jda.core.entities.Guild; -import net.dv8tion.jda.core.entities.Member; -import net.dv8tion.jda.core.entities.TextChannel; +import net.dv8tion.jda.api.entities.Guild; +import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; + +import java.util.concurrent.TimeUnit; public final class Volume implements Command { @Override diff --git a/src/main/java/dev/logal/logalbot/commands/fun/Dice.java b/src/main/java/dev/logal/logalbot/commands/fun/Dice.java index fdafe9a..8de3666 100644 --- a/src/main/java/dev/logal/logalbot/commands/fun/Dice.java +++ b/src/main/java/dev/logal/logalbot/commands/fun/Dice.java @@ -1,26 +1,20 @@ package dev.logal.logalbot.commands.fun; -// Copyright 2019 Logan Fick - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import java.security.SecureRandom; -import java.util.concurrent.TimeUnit; +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ import dev.logal.logalbot.commands.Command; import dev.logal.logalbot.commands.CommandResponse; -import net.dv8tion.jda.core.entities.Member; -import net.dv8tion.jda.core.entities.TextChannel; +import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; + +import java.security.SecureRandom; +import java.util.concurrent.TimeUnit; public final class Dice implements Command { private final SecureRandom rng = new SecureRandom(); diff --git a/src/main/java/dev/logal/logalbot/commands/fun/EightBall.java b/src/main/java/dev/logal/logalbot/commands/fun/EightBall.java index 6ea5974..3eed055 100644 --- a/src/main/java/dev/logal/logalbot/commands/fun/EightBall.java +++ b/src/main/java/dev/logal/logalbot/commands/fun/EightBall.java @@ -1,31 +1,24 @@ package dev.logal.logalbot.commands.fun; -// Copyright 2019 Logan Fick +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +import com.vdurmont.emoji.EmojiManager; +import dev.logal.logalbot.commands.Command; +import dev.logal.logalbot.commands.CommandResponse; +import dev.logal.logalbot.utils.StringUtil; +import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; import java.util.ArrayList; import java.util.Random; import java.util.concurrent.TimeUnit; -import com.vdurmont.emoji.EmojiManager; - -import dev.logal.logalbot.commands.Command; -import dev.logal.logalbot.commands.CommandResponse; -import dev.logal.logalbot.utils.StringUtil; -import net.dv8tion.jda.core.entities.Member; -import net.dv8tion.jda.core.entities.TextChannel; - public final class EightBall implements Command { private final ArrayList responses = new ArrayList<>(20); private final Random rng = new Random(); diff --git a/src/main/java/dev/logal/logalbot/commands/general/About.java b/src/main/java/dev/logal/logalbot/commands/general/About.java index c4cc222..7081bea 100644 --- a/src/main/java/dev/logal/logalbot/commands/general/About.java +++ b/src/main/java/dev/logal/logalbot/commands/general/About.java @@ -1,23 +1,17 @@ package dev.logal.logalbot.commands.general; -// Copyright 2019 Logan Fick - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ import dev.logal.logalbot.commands.Command; import dev.logal.logalbot.commands.CommandResponse; -import net.dv8tion.jda.core.entities.Member; -import net.dv8tion.jda.core.entities.TextChannel; +import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; public final class About implements Command { @Override diff --git a/src/main/java/dev/logal/logalbot/commands/general/Help.java b/src/main/java/dev/logal/logalbot/commands/general/Help.java index 257da73..698c3aa 100644 --- a/src/main/java/dev/logal/logalbot/commands/general/Help.java +++ b/src/main/java/dev/logal/logalbot/commands/general/Help.java @@ -1,24 +1,18 @@ package dev.logal.logalbot.commands.general; -// Copyright 2019 Logan Fick - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ import dev.logal.logalbot.commands.Command; import dev.logal.logalbot.commands.CommandResponse; -import net.dv8tion.jda.core.EmbedBuilder; -import net.dv8tion.jda.core.entities.Member; -import net.dv8tion.jda.core.entities.TextChannel; +import net.dv8tion.jda.api.EmbedBuilder; +import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; public final class Help implements Command { @Override diff --git a/src/main/java/dev/logal/logalbot/events/GuildMessageReactionAdd.java b/src/main/java/dev/logal/logalbot/events/GuildMessageReactionAdd.java deleted file mode 100644 index 804a86e..0000000 --- a/src/main/java/dev/logal/logalbot/events/GuildMessageReactionAdd.java +++ /dev/null @@ -1,33 +0,0 @@ -package dev.logal.logalbot.events; - -// Copyright 2019 Logan Fick - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import dev.logal.logalbot.MainThread; -import dev.logal.logalbot.tasks.ReactionCallbackExecutionTask; -import net.dv8tion.jda.core.events.message.guild.react.GuildMessageReactionAddEvent; -import net.dv8tion.jda.core.hooks.ListenerAdapter; -import net.dv8tion.jda.core.utils.Checks; - -public final class GuildMessageReactionAdd extends ListenerAdapter { - @Override - public final void onGuildMessageReactionAdd(final GuildMessageReactionAddEvent event) { - Checks.notNull(event, "Event"); - - if (!event.getUser().equals(event.getJDA().getSelfUser())) { - MainThread.scheduleImmediately(new ReactionCallbackExecutionTask(event.getMessageIdLong(), - event.getChannel(), event.getMember(), event.getReactionEmote().getName())); - } - } -} \ No newline at end of file diff --git a/src/main/java/dev/logal/logalbot/events/GuildReady.java b/src/main/java/dev/logal/logalbot/events/GuildReady.java index bcec4a0..df56ff3 100644 --- a/src/main/java/dev/logal/logalbot/events/GuildReady.java +++ b/src/main/java/dev/logal/logalbot/events/GuildReady.java @@ -1,23 +1,17 @@ package dev.logal.logalbot.events; -// Copyright 2019 Logan Fick - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ import dev.logal.logalbot.utils.AudioUtil; -import net.dv8tion.jda.core.events.guild.GuildReadyEvent; -import net.dv8tion.jda.core.hooks.ListenerAdapter; -import net.dv8tion.jda.core.utils.Checks; +import net.dv8tion.jda.api.events.guild.GuildReadyEvent; +import net.dv8tion.jda.api.hooks.ListenerAdapter; +import net.dv8tion.jda.internal.utils.Checks; public final class GuildReady extends ListenerAdapter { @Override diff --git a/src/main/java/dev/logal/logalbot/events/GuildVoiceMove.java b/src/main/java/dev/logal/logalbot/events/GuildVoiceMove.java deleted file mode 100644 index 5462f99..0000000 --- a/src/main/java/dev/logal/logalbot/events/GuildVoiceMove.java +++ /dev/null @@ -1,64 +0,0 @@ -package dev.logal.logalbot.events; - -// Copyright 2019 Logan Fick - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import java.util.List; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import dev.logal.logalbot.MainThread; -import dev.logal.logalbot.tasks.ResetAudioPlayerTask; -import dev.logal.logalbot.utils.AudioUtil; -import net.dv8tion.jda.core.entities.Guild; -import net.dv8tion.jda.core.entities.Member; -import net.dv8tion.jda.core.entities.VoiceChannel; -import net.dv8tion.jda.core.events.guild.voice.GuildVoiceMoveEvent; -import net.dv8tion.jda.core.hooks.ListenerAdapter; -import net.dv8tion.jda.core.utils.Checks; - -public final class GuildVoiceMove extends ListenerAdapter { - private static final Logger logger = LoggerFactory.getLogger(GuildVoiceMove.class); - - @Override - public final void onGuildVoiceMove(final GuildVoiceMoveEvent event) { - Checks.notNull(event, "Event"); - - final Guild guild = event.getGuild(); - if (!AudioUtil.isAudioConnectionOpen(guild)) { - return; - } - - if (!AudioUtil.isTrackLoaded(guild)) { - return; - } - - final Member member = event.getMember(); - - if (member.getUser().equals(event.getJDA().getSelfUser())) { - return; - } - - final VoiceChannel leftChannel = event.getChannelLeft(); - if (leftChannel.equals(AudioUtil.getVoiceChannelConnectedTo(guild))) { - final List members = leftChannel.getMembers(); - if (members.size() == 1 && members.get(0).getUser().equals(event.getJDA().getSelfUser())) { - logger.info("All listeners left " + leftChannel.getName() + " (" + leftChannel.getId() + ") in " - + guild.getName() + " (" + guild.getId() + ")."); - MainThread.scheduleImmediately(new ResetAudioPlayerTask(guild)); - } - } - } -} \ No newline at end of file diff --git a/src/main/java/dev/logal/logalbot/events/GuildVoiceLeave.java b/src/main/java/dev/logal/logalbot/events/GuildVoiceUpdate.java similarity index 52% rename from src/main/java/dev/logal/logalbot/events/GuildVoiceLeave.java rename to src/main/java/dev/logal/logalbot/events/GuildVoiceUpdate.java index 7cecec6..5d1ce4c 100644 --- a/src/main/java/dev/logal/logalbot/events/GuildVoiceLeave.java +++ b/src/main/java/dev/logal/logalbot/events/GuildVoiceUpdate.java @@ -1,39 +1,32 @@ package dev.logal.logalbot.events; -// Copyright 2019 Logan Fick - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import java.util.List; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ import dev.logal.logalbot.MainThread; import dev.logal.logalbot.tasks.ResetAudioPlayerTask; import dev.logal.logalbot.utils.AudioUtil; -import net.dv8tion.jda.core.entities.Guild; -import net.dv8tion.jda.core.entities.Member; -import net.dv8tion.jda.core.entities.VoiceChannel; -import net.dv8tion.jda.core.events.guild.voice.GuildVoiceLeaveEvent; -import net.dv8tion.jda.core.hooks.ListenerAdapter; -import net.dv8tion.jda.core.utils.Checks; +import net.dv8tion.jda.api.entities.Guild; +import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel; +import net.dv8tion.jda.api.events.guild.voice.GuildVoiceUpdateEvent; +import net.dv8tion.jda.api.hooks.ListenerAdapter; +import net.dv8tion.jda.internal.utils.Checks; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -public final class GuildVoiceLeave extends ListenerAdapter { - private static final Logger logger = LoggerFactory.getLogger(GuildVoiceLeave.class); +import java.util.List; + +public final class GuildVoiceUpdate extends ListenerAdapter { + private static final Logger logger = LoggerFactory.getLogger(GuildVoiceUpdate.class); @Override - public final void onGuildVoiceLeave(final GuildVoiceLeaveEvent event) { + public final void onGuildVoiceUpdate(final GuildVoiceUpdateEvent event) { Checks.notNull(event, "Event"); final Guild guild = event.getGuild(); @@ -51,7 +44,7 @@ public final class GuildVoiceLeave extends ListenerAdapter { return; } - final VoiceChannel leftChannel = event.getChannelLeft(); + final VoiceChannel leftChannel = event.getChannelLeft().asVoiceChannel(); // TODO: This will break. if (leftChannel.equals(AudioUtil.getVoiceChannelConnectedTo(guild))) { final List members = leftChannel.getMembers(); if (members.size() == 1 && members.get(0).getUser().equals(event.getJDA().getSelfUser())) { diff --git a/src/main/java/dev/logal/logalbot/events/MessageReactionAdd.java b/src/main/java/dev/logal/logalbot/events/MessageReactionAdd.java new file mode 100644 index 0000000..9eed903 --- /dev/null +++ b/src/main/java/dev/logal/logalbot/events/MessageReactionAdd.java @@ -0,0 +1,27 @@ +package dev.logal.logalbot.events; + +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ + +import dev.logal.logalbot.MainThread; +import dev.logal.logalbot.tasks.ReactionCallbackExecutionTask; +import net.dv8tion.jda.api.events.message.react.MessageReactionAddEvent; +import net.dv8tion.jda.api.hooks.ListenerAdapter; +import net.dv8tion.jda.internal.utils.Checks; + +public final class MessageReactionAdd extends ListenerAdapter { + @Override + public final void onMessageReactionAdd(final MessageReactionAddEvent event) { + Checks.notNull(event, "Event"); + + if (!event.getUser().equals(event.getJDA().getSelfUser())) { + MainThread.scheduleImmediately(new ReactionCallbackExecutionTask(event.getMessageIdLong(), + event.getChannel().asTextChannel(), event.getMember(), event.getEmoji().getName())); // TODO: This will break. + } + } +} \ No newline at end of file diff --git a/src/main/java/dev/logal/logalbot/events/GuildMessageReceived.java b/src/main/java/dev/logal/logalbot/events/MessageReceived.java similarity index 63% rename from src/main/java/dev/logal/logalbot/events/GuildMessageReceived.java rename to src/main/java/dev/logal/logalbot/events/MessageReceived.java index 1ec429a..dd088f4 100644 --- a/src/main/java/dev/logal/logalbot/events/GuildMessageReceived.java +++ b/src/main/java/dev/logal/logalbot/events/MessageReceived.java @@ -1,52 +1,43 @@ package dev.logal.logalbot.events; -// Copyright 2019 Logan Fick - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import java.util.Arrays; -import java.util.List; +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ import dev.logal.logalbot.MainThread; import dev.logal.logalbot.tasks.CommandExecutionTask; import dev.logal.logalbot.utils.DataManager; -import net.dv8tion.jda.core.Permission; -import net.dv8tion.jda.core.entities.Guild; -import net.dv8tion.jda.core.entities.Member; -import net.dv8tion.jda.core.entities.Message; -import net.dv8tion.jda.core.entities.SelfUser; -import net.dv8tion.jda.core.entities.TextChannel; -import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent; -import net.dv8tion.jda.core.hooks.ListenerAdapter; -import net.dv8tion.jda.core.utils.Checks; +import net.dv8tion.jda.api.Permission; +import net.dv8tion.jda.api.entities.*; +import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; +import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.hooks.ListenerAdapter; +import net.dv8tion.jda.internal.utils.Checks; -public final class GuildMessageReceived extends ListenerAdapter { +import java.util.Arrays; +import java.util.List; + +public final class MessageReceived extends ListenerAdapter { @Override - public final void onGuildMessageReceived(final GuildMessageReceivedEvent event) { + public final void onMessageReceived(final MessageReceivedEvent event) { Checks.notNull(event, "Event"); final Guild guild = event.getGuild(); final Member self = guild.getSelfMember(); - final TextChannel channel = event.getChannel(); + final TextChannel channel = event.getChannel().asTextChannel(); // TODO: This will break. final Message message = event.getMessage(); - if (event.getAuthor().isBot() || message.isTTS() || !self.hasPermission(channel, Permission.MESSAGE_WRITE) + if (event.getAuthor().isBot() || message.isTTS() || !self.hasPermission(channel, Permission.MESSAGE_SEND) || !self.hasPermission(channel, Permission.MESSAGE_EMBED_LINKS)) { return; } final String content = message.getContentRaw(); final SelfUser selfUser = event.getJDA().getSelfUser(); - final List mentionedMembers = message.getMentionedMembers(); + final List mentionedMembers = message.getMentions().getMembers(); final Member author = event.getMember(); if (mentionedMembers.size() >= 1 && mentionedMembers.get(0).getUser().getIdLong() == selfUser.getIdLong() && (content.startsWith(self.getAsMention()) || content.startsWith(selfUser.getAsMention()))) { diff --git a/src/main/java/dev/logal/logalbot/tasks/CloseAudioConnectionTask.java b/src/main/java/dev/logal/logalbot/tasks/CloseAudioConnectionTask.java index e3ee3bb..0695019 100644 --- a/src/main/java/dev/logal/logalbot/tasks/CloseAudioConnectionTask.java +++ b/src/main/java/dev/logal/logalbot/tasks/CloseAudioConnectionTask.java @@ -1,22 +1,16 @@ package dev.logal.logalbot.tasks; -// Copyright 2019 Logan Fick - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ import dev.logal.logalbot.utils.AudioUtil; -import net.dv8tion.jda.core.entities.Guild; -import net.dv8tion.jda.core.utils.Checks; +import net.dv8tion.jda.api.entities.Guild; +import net.dv8tion.jda.internal.utils.Checks; public final class CloseAudioConnectionTask implements Runnable { private final Guild guild; diff --git a/src/main/java/dev/logal/logalbot/tasks/CommandExecutionTask.java b/src/main/java/dev/logal/logalbot/tasks/CommandExecutionTask.java index b16d9cf..165b140 100644 --- a/src/main/java/dev/logal/logalbot/tasks/CommandExecutionTask.java +++ b/src/main/java/dev/logal/logalbot/tasks/CommandExecutionTask.java @@ -1,23 +1,17 @@ package dev.logal.logalbot.tasks; -// Copyright 2019 Logan Fick - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ import dev.logal.logalbot.utils.CommandManager; -import net.dv8tion.jda.core.entities.Member; -import net.dv8tion.jda.core.entities.TextChannel; -import net.dv8tion.jda.core.utils.Checks; +import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; +import net.dv8tion.jda.internal.utils.Checks; public final class CommandExecutionTask implements Runnable { private final String[] command; diff --git a/src/main/java/dev/logal/logalbot/tasks/MessageDeleteTask.java b/src/main/java/dev/logal/logalbot/tasks/MessageDeleteTask.java index 23c78f3..b714796 100644 --- a/src/main/java/dev/logal/logalbot/tasks/MessageDeleteTask.java +++ b/src/main/java/dev/logal/logalbot/tasks/MessageDeleteTask.java @@ -1,22 +1,16 @@ package dev.logal.logalbot.tasks; -// Copyright 2019 Logan Fick - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ import dev.logal.logalbot.utils.ReactionCallbackManager; -import net.dv8tion.jda.core.entities.Message; -import net.dv8tion.jda.core.utils.Checks; +import net.dv8tion.jda.api.entities.Message; +import net.dv8tion.jda.internal.utils.Checks; public final class MessageDeleteTask implements Runnable { private final Message messageToDelete; diff --git a/src/main/java/dev/logal/logalbot/tasks/OpenAudioConnectionTask.java b/src/main/java/dev/logal/logalbot/tasks/OpenAudioConnectionTask.java index a41dc32..3b7207f 100644 --- a/src/main/java/dev/logal/logalbot/tasks/OpenAudioConnectionTask.java +++ b/src/main/java/dev/logal/logalbot/tasks/OpenAudioConnectionTask.java @@ -1,22 +1,16 @@ package dev.logal.logalbot.tasks; -// Copyright 2019 Logan Fick - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ import dev.logal.logalbot.utils.AudioUtil; -import net.dv8tion.jda.core.entities.VoiceChannel; -import net.dv8tion.jda.core.utils.Checks; +import net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel; +import net.dv8tion.jda.internal.utils.Checks; public final class OpenAudioConnectionTask implements Runnable { private final VoiceChannel channel; diff --git a/src/main/java/dev/logal/logalbot/tasks/PlayNextTrackTask.java b/src/main/java/dev/logal/logalbot/tasks/PlayNextTrackTask.java index f8dd47f..a691d8f 100644 --- a/src/main/java/dev/logal/logalbot/tasks/PlayNextTrackTask.java +++ b/src/main/java/dev/logal/logalbot/tasks/PlayNextTrackTask.java @@ -1,22 +1,16 @@ package dev.logal.logalbot.tasks; -// Copyright 2019 Logan Fick - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ import dev.logal.logalbot.utils.AudioUtil; -import net.dv8tion.jda.core.entities.Guild; -import net.dv8tion.jda.core.utils.Checks; +import net.dv8tion.jda.api.entities.Guild; +import net.dv8tion.jda.internal.utils.Checks; public final class PlayNextTrackTask implements Runnable { private final Guild guild; diff --git a/src/main/java/dev/logal/logalbot/tasks/ReactionCallbackExecutionTask.java b/src/main/java/dev/logal/logalbot/tasks/ReactionCallbackExecutionTask.java index bd06805..7ff3236 100644 --- a/src/main/java/dev/logal/logalbot/tasks/ReactionCallbackExecutionTask.java +++ b/src/main/java/dev/logal/logalbot/tasks/ReactionCallbackExecutionTask.java @@ -1,23 +1,17 @@ package dev.logal.logalbot.tasks; -// Copyright 2019 Logan Fick - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ import dev.logal.logalbot.utils.ReactionCallbackManager; -import net.dv8tion.jda.core.entities.Member; -import net.dv8tion.jda.core.entities.TextChannel; -import net.dv8tion.jda.core.utils.Checks; +import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; +import net.dv8tion.jda.internal.utils.Checks; public final class ReactionCallbackExecutionTask implements Runnable { private final long messageID; diff --git a/src/main/java/dev/logal/logalbot/tasks/ReactionCallbackExpireTask.java b/src/main/java/dev/logal/logalbot/tasks/ReactionCallbackExpireTask.java index 86372fb..6f35843 100644 --- a/src/main/java/dev/logal/logalbot/tasks/ReactionCallbackExpireTask.java +++ b/src/main/java/dev/logal/logalbot/tasks/ReactionCallbackExpireTask.java @@ -1,22 +1,16 @@ package dev.logal.logalbot.tasks; -// Copyright 2019 Logan Fick - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ import dev.logal.logalbot.utils.ReactionCallbackManager; -import net.dv8tion.jda.core.entities.Message; -import net.dv8tion.jda.core.utils.Checks; +import net.dv8tion.jda.api.entities.Message; +import net.dv8tion.jda.internal.utils.Checks; public final class ReactionCallbackExpireTask implements Runnable { private final Message messageToExpire; diff --git a/src/main/java/dev/logal/logalbot/tasks/ResetAudioPlayerTask.java b/src/main/java/dev/logal/logalbot/tasks/ResetAudioPlayerTask.java index 52db92f..8b93c67 100644 --- a/src/main/java/dev/logal/logalbot/tasks/ResetAudioPlayerTask.java +++ b/src/main/java/dev/logal/logalbot/tasks/ResetAudioPlayerTask.java @@ -1,22 +1,16 @@ package dev.logal.logalbot.tasks; -// Copyright 2019 Logan Fick - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ import dev.logal.logalbot.utils.AudioUtil; -import net.dv8tion.jda.core.entities.Guild; -import net.dv8tion.jda.core.utils.Checks; +import net.dv8tion.jda.api.entities.Guild; +import net.dv8tion.jda.internal.utils.Checks; public final class ResetAudioPlayerTask implements Runnable { private final Guild guild; diff --git a/src/main/java/dev/logal/logalbot/tasks/TrackAdditionTask.java b/src/main/java/dev/logal/logalbot/tasks/TrackAdditionTask.java index 8d88765..a3f0b23 100644 --- a/src/main/java/dev/logal/logalbot/tasks/TrackAdditionTask.java +++ b/src/main/java/dev/logal/logalbot/tasks/TrackAdditionTask.java @@ -1,27 +1,21 @@ package dev.logal.logalbot.tasks; -// Copyright 2019 Logan Fick - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import java.util.LinkedList; -import java.util.List; +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ import dev.logal.logalbot.audio.RequestedTrack; import dev.logal.logalbot.audio.TrackScheduler; import dev.logal.logalbot.utils.AudioUtil; -import net.dv8tion.jda.core.entities.Guild; -import net.dv8tion.jda.core.utils.Checks; +import net.dv8tion.jda.api.entities.Guild; +import net.dv8tion.jda.internal.utils.Checks; + +import java.util.LinkedList; +import java.util.List; public final class TrackAdditionTask implements Runnable { private final Guild guild; diff --git a/src/main/java/dev/logal/logalbot/utils/AudioUtil.java b/src/main/java/dev/logal/logalbot/utils/AudioUtil.java index 62c710c..30d97a3 100644 --- a/src/main/java/dev/logal/logalbot/utils/AudioUtil.java +++ b/src/main/java/dev/logal/logalbot/utils/AudioUtil.java @@ -1,39 +1,31 @@ package dev.logal.logalbot.utils; -// Copyright 2019 Logan Fick - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import java.util.HashMap; +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ import com.sedmelluq.discord.lavaplayer.player.AudioPlayer; import com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager; import com.sedmelluq.discord.lavaplayer.player.DefaultAudioPlayerManager; import com.sedmelluq.discord.lavaplayer.source.AudioSourceManagers; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import dev.logal.logalbot.audio.AudioPlayerSendHandler; import dev.logal.logalbot.audio.RequestedTrack; import dev.logal.logalbot.audio.TrackLoadHandler; import dev.logal.logalbot.audio.TrackScheduler; -import net.dv8tion.jda.core.entities.Guild; -import net.dv8tion.jda.core.entities.Member; -import net.dv8tion.jda.core.entities.TextChannel; -import net.dv8tion.jda.core.entities.VoiceChannel; -import net.dv8tion.jda.core.managers.AudioManager; -import net.dv8tion.jda.core.utils.Checks; +import net.dv8tion.jda.api.entities.Guild; +import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; +import net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel; +import net.dv8tion.jda.api.managers.AudioManager; +import net.dv8tion.jda.internal.utils.Checks; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.HashMap; public final class AudioUtil { private static final Logger logger = LoggerFactory.getLogger(AudioUtil.class); @@ -89,7 +81,7 @@ public final class AudioUtil { public static final VoiceChannel getVoiceChannelConnectedTo(final Guild guild) { Checks.notNull(guild, "Guild"); - return guild.getAudioManager().getConnectedChannel(); + return guild.getAudioManager().getConnectedChannel().asVoiceChannel(); // TODO: This will break. } public static final boolean isAudioConnectionOpen(final Guild guild) { diff --git a/src/main/java/dev/logal/logalbot/utils/CommandManager.java b/src/main/java/dev/logal/logalbot/utils/CommandManager.java index a1dbc52..d7c7617 100644 --- a/src/main/java/dev/logal/logalbot/utils/CommandManager.java +++ b/src/main/java/dev/logal/logalbot/utils/CommandManager.java @@ -1,33 +1,25 @@ package dev.logal.logalbot.utils; -// Copyright 2019 Logan Fick - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import java.util.Arrays; - -import java.util.HashMap; -import java.util.concurrent.TimeUnit; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ import dev.logal.logalbot.commands.Command; import dev.logal.logalbot.commands.CommandResponse; -import net.dv8tion.jda.core.entities.Guild; -import net.dv8tion.jda.core.entities.Member; -import net.dv8tion.jda.core.entities.TextChannel; -import net.dv8tion.jda.core.utils.Checks; +import net.dv8tion.jda.api.entities.Guild; +import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; +import net.dv8tion.jda.internal.utils.Checks; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.concurrent.TimeUnit; public final class CommandManager { private static final Logger logger = LoggerFactory.getLogger(CommandManager.class); diff --git a/src/main/java/dev/logal/logalbot/utils/DataManager.java b/src/main/java/dev/logal/logalbot/utils/DataManager.java index 09838ae..e8f3b63 100644 --- a/src/main/java/dev/logal/logalbot/utils/DataManager.java +++ b/src/main/java/dev/logal/logalbot/utils/DataManager.java @@ -1,26 +1,19 @@ package dev.logal.logalbot.utils; -// Copyright 2019 Logan Fick - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ +import net.dv8tion.jda.api.entities.Guild; +import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.entities.User; +import net.dv8tion.jda.internal.utils.Checks; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - -import net.dv8tion.jda.core.entities.Guild; -import net.dv8tion.jda.core.entities.Member; -import net.dv8tion.jda.core.entities.User; -import net.dv8tion.jda.core.utils.Checks; import redis.clients.jedis.Jedis; public final class DataManager { @@ -37,7 +30,7 @@ public final class DataManager { public static final void verifyConnection() { if (!jedis.isConnected()) { - jedis = new Jedis(host); + jedis = new Jedis(host, 6379); if (password != null) { jedis.auth(password); diff --git a/src/main/java/dev/logal/logalbot/utils/PermissionManager.java b/src/main/java/dev/logal/logalbot/utils/PermissionManager.java index 12026a3..5dcaee3 100644 --- a/src/main/java/dev/logal/logalbot/utils/PermissionManager.java +++ b/src/main/java/dev/logal/logalbot/utils/PermissionManager.java @@ -1,26 +1,19 @@ package dev.logal.logalbot.utils; -// Copyright 2019 Logan Fick - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ +import net.dv8tion.jda.api.Permission; +import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.internal.utils.Checks; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import net.dv8tion.jda.core.Permission; -import net.dv8tion.jda.core.entities.Member; -import net.dv8tion.jda.core.utils.Checks; - public final class PermissionManager { private static final Logger logger = LoggerFactory.getLogger(PermissionManager.class); diff --git a/src/main/java/dev/logal/logalbot/utils/ReactionCallbackManager.java b/src/main/java/dev/logal/logalbot/utils/ReactionCallbackManager.java index 28f8a39..6fd44e4 100644 --- a/src/main/java/dev/logal/logalbot/utils/ReactionCallbackManager.java +++ b/src/main/java/dev/logal/logalbot/utils/ReactionCallbackManager.java @@ -1,30 +1,22 @@ package dev.logal.logalbot.utils; -// Copyright 2019 Logan Fick - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import java.util.HashMap; - -import com.vdurmont.emoji.Emoji; -import com.vdurmont.emoji.EmojiManager; +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ import dev.logal.logalbot.commands.ReactionCallback; -import net.dv8tion.jda.core.entities.Member; -import net.dv8tion.jda.core.entities.Message; -import net.dv8tion.jda.core.entities.TextChannel; -import net.dv8tion.jda.core.entities.User; -import net.dv8tion.jda.core.utils.Checks; +import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.entities.Message; +import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; +import net.dv8tion.jda.api.entities.User; +import net.dv8tion.jda.api.entities.emoji.Emoji; +import net.dv8tion.jda.internal.utils.Checks; + +import java.util.HashMap; public final class ReactionCallbackManager { private static final HashMap> callbackDictionary = new HashMap<>(); @@ -35,7 +27,7 @@ public final class ReactionCallbackManager { } public static final void registerCallback(final Message message, final Emoji emoji, - final ReactionCallback callback) { + final ReactionCallback callback) { Checks.notNull(message, "Message"); Checks.notNull(emoji, "Emoji"); Checks.notNull(callback, "Callback"); @@ -45,7 +37,7 @@ public final class ReactionCallbackManager { } callbackDictionary.get(message.getIdLong()).put(emoji, callback); - message.addReaction(emoji.getUnicode()).queue(); + message.addReaction(emoji).queue(); } public static final void setCallbackTarget(final Message message, final User user) { @@ -62,7 +54,7 @@ public final class ReactionCallbackManager { message.delete().queue(); } else { if (callbackDictionary.containsKey(message.getIdLong())) { - message.addReaction(EmojiManager.getForAlias("no_entry").getUnicode()).queue(); + message.addReaction(net.dv8tion.jda.api.entities.emoji.Emoji.fromUnicode("no_entry")).queue(); } } @@ -71,13 +63,14 @@ public final class ReactionCallbackManager { } public static final void executeCallback(final long messageID, final TextChannel channel, final Member reactor, - final String emoji) { + final String emoji) { Checks.notNegative(messageID, "Message ID"); Checks.notNull(channel, "Channel"); Checks.notNull(reactor, "Reactor"); Checks.notEmpty(emoji, "Emoji"); - channel.getMessageById(messageID).queue((message) -> { + // TODO: This is broke. + /*channel.getMessageById(messageID).queue((message) -> { if (callbackDictionary.containsKey(messageID)) { if (targetDictionary.containsKey(messageID) && !targetDictionary.get(messageID).equals(reactor.getUser().getIdLong())) { @@ -89,6 +82,6 @@ public final class ReactionCallbackManager { callbackDictionary.get(messageID).get(parsedEmoji).run(reactor, message); } } - }); + });*/ } } \ No newline at end of file diff --git a/src/main/java/dev/logal/logalbot/utils/SkipTracker.java b/src/main/java/dev/logal/logalbot/utils/SkipTracker.java index df3ba1b..5fee950 100644 --- a/src/main/java/dev/logal/logalbot/utils/SkipTracker.java +++ b/src/main/java/dev/logal/logalbot/utils/SkipTracker.java @@ -1,26 +1,21 @@ package dev.logal.logalbot.utils; -// Copyright 2019 Logan Fick +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +import net.dv8tion.jda.api.entities.Guild; +import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.internal.utils.Checks; import java.util.ArrayList; import java.util.HashMap; -import net.dv8tion.jda.core.entities.Guild; -import net.dv8tion.jda.core.entities.Member; -import net.dv8tion.jda.core.utils.Checks; - public final class SkipTracker { private static final HashMap> skipVotesDictionary = new HashMap<>(); diff --git a/src/main/java/dev/logal/logalbot/utils/StringUtil.java b/src/main/java/dev/logal/logalbot/utils/StringUtil.java index d8b69b8..8317263 100644 --- a/src/main/java/dev/logal/logalbot/utils/StringUtil.java +++ b/src/main/java/dev/logal/logalbot/utils/StringUtil.java @@ -1,23 +1,16 @@ package dev.logal.logalbot.utils; -// Copyright 2019 Logan Fick - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ import com.vdurmont.emoji.Emoji; import com.vdurmont.emoji.EmojiManager; - -import net.dv8tion.jda.core.utils.Checks; +import net.dv8tion.jda.internal.utils.Checks; public final class StringUtil { private StringUtil() { diff --git a/src/main/java/dev/logal/logalbot/utils/TrackUtil.java b/src/main/java/dev/logal/logalbot/utils/TrackUtil.java index 521261a..2e1f3fd 100644 --- a/src/main/java/dev/logal/logalbot/utils/TrackUtil.java +++ b/src/main/java/dev/logal/logalbot/utils/TrackUtil.java @@ -1,30 +1,23 @@ package dev.logal.logalbot.utils; -// Copyright 2019 Logan Fick - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import java.util.List; +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ import com.sedmelluq.discord.lavaplayer.track.AudioTrack; import com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo; - import dev.logal.logalbot.audio.RequestedTrack; -import net.dv8tion.jda.core.EmbedBuilder; -import net.dv8tion.jda.core.entities.Guild; -import net.dv8tion.jda.core.entities.MessageEmbed; -import net.dv8tion.jda.core.entities.User; -import net.dv8tion.jda.core.utils.Checks; +import net.dv8tion.jda.api.EmbedBuilder; +import net.dv8tion.jda.api.entities.Guild; +import net.dv8tion.jda.api.entities.MessageEmbed; +import net.dv8tion.jda.api.entities.User; +import net.dv8tion.jda.internal.utils.Checks; + +import java.util.List; public final class TrackUtil { private TrackUtil() { diff --git a/src/main/java/dev/logal/logalbot/utils/VoiceChannelUtil.java b/src/main/java/dev/logal/logalbot/utils/VoiceChannelUtil.java index 45a9b03..407aa2e 100644 --- a/src/main/java/dev/logal/logalbot/utils/VoiceChannelUtil.java +++ b/src/main/java/dev/logal/logalbot/utils/VoiceChannelUtil.java @@ -1,22 +1,16 @@ package dev.logal.logalbot.utils; -// Copyright 2019 Logan Fick +/* + * Copyright 2022 Logan Fick + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// https://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import net.dv8tion.jda.core.entities.Member; -import net.dv8tion.jda.core.entities.VoiceChannel; -import net.dv8tion.jda.core.utils.Checks; +import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel; +import net.dv8tion.jda.internal.utils.Checks; public final class VoiceChannelUtil { private VoiceChannelUtil() {