0

Updated dependencies.

This is a massive commit incorporating 5 years' worth of upstream dependencies updates all at once, particularly with JDA. Several classpaths and APIs changed, requiring some rework. The bot is mostly functional as a result, but issues remain with reaction callbacks and playing audio from YouTube.
This commit is contained in:
2024-06-02 17:51:12 -04:00
parent 87510448d4
commit 93b41e99c8
53 changed files with 658 additions and 1032 deletions

View File

@@ -1,27 +1,38 @@
buildscript { buildscript {
repositories { repositories {
jcenter() gradlePluginPortal()
} }
dependencies { 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: 'com.github.johnrengelman.shadow'
apply plugin: 'java'
repositories { 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 { 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 'net.dv8tion:JDA:5.0.0-beta.24'
implementation 'com.sedmelluq:lavaplayer:1.3.17' implementation 'dev.arbjerg:lavaplayer:2.1.1'
implementation 'redis.clients:jedis:3.0.1' implementation 'redis.clients:jedis:5.1.3'
implementation 'com.vdurmont:emoji-java:4.0.0'
} }
jar { jar {

View File

@@ -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 distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-bin.zip zipStoreBase=GRADLE_USER_HOME

View File

@@ -1,35 +1,32 @@
package dev.logal.logalbot; 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"); import dev.logal.logalbot.commands.administration.Settings;
// you may not use this file except in compliance with the License. import dev.logal.logalbot.commands.administration.Whitelist;
// 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.audio.*; import dev.logal.logalbot.commands.audio.*;
import dev.logal.logalbot.commands.fun.*; import dev.logal.logalbot.commands.fun.Dice;
import dev.logal.logalbot.commands.general.*; 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.events.*;
import dev.logal.logalbot.utils.AudioUtil; import dev.logal.logalbot.utils.AudioUtil;
import dev.logal.logalbot.utils.CommandManager; import dev.logal.logalbot.utils.CommandManager;
import dev.logal.logalbot.utils.DataManager; import dev.logal.logalbot.utils.DataManager;
import net.dv8tion.jda.core.AccountType; import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.core.JDA; import net.dv8tion.jda.api.JDABuilder;
import net.dv8tion.jda.core.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 { public final class Main implements Runnable {
private static final Logger logger = LoggerFactory.getLogger(Main.class); 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..."); logger.info("Attempting to log into Discord...");
try { 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.setAutoReconnect(true);
builder.setAudioEnabled(true);
builder.setToken(token); builder.setToken(token);
builder.addEventListener(new GuildReady()); builder.addEventListeners(new GuildReady());
jda = builder.build().awaitReady(); jda = builder.build().awaitReady();
} catch (final LoginException exception) {
logger.error("The token specified is not valid.");
System.exit(1);
} catch (final Throwable exception) { } catch (final Throwable exception) {
logger.error("An error occurred while attempting to set up JDA!", exception); logger.error("An error occurred while attempting to set up JDA!", exception);
System.exit(1); System.exit(1);
@@ -85,9 +80,8 @@ public final class Main implements Runnable {
logger.info("Initializing..."); logger.info("Initializing...");
AudioUtil.initializePlayerManager(); AudioUtil.initializePlayerManager();
jda.addEventListener(new GuildVoiceLeave()); jda.addEventListener(new GuildVoiceUpdate());
jda.addEventListener(new GuildVoiceMove()); jda.addEventListener(new MessageReactionAdd());
jda.addEventListener(new GuildMessageReactionAdd());
// General Commands // General Commands
CommandManager.registerCommand("about", new About(), false); CommandManager.registerCommand("about", new About(), false);
@@ -145,7 +139,7 @@ public final class Main implements Runnable {
CommandManager.registerCommandAlias("conf", "settings"); CommandManager.registerCommandAlias("conf", "settings");
logger.info("Everything seems to be ready! Enabling command listener..."); logger.info("Everything seems to be ready! Enabling command listener...");
jda.addEventListener(new GuildMessageReceived()); jda.addEventListener(new MessageReceived());
logger.info("Initialization complete!"); logger.info("Initialization complete!");
} }
} }

View File

@@ -1,26 +1,20 @@
package dev.logal.logalbot; 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"); import net.dv8tion.jda.internal.utils.Checks;
// 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.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import net.dv8tion.jda.core.utils.Checks;
public final class MainThread { public final class MainThread {
private static final ScheduledExecutorService mainThread = Executors private static final ScheduledExecutorService mainThread = Executors
.newSingleThreadScheduledExecutor(new MainThreadFactory()); .newSingleThreadScheduledExecutor(new MainThreadFactory());

View File

@@ -1,23 +1,17 @@
package dev.logal.logalbot; 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"); import net.dv8tion.jda.internal.utils.Checks;
// 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.ThreadFactory; import java.util.concurrent.ThreadFactory;
import net.dv8tion.jda.core.utils.Checks;
public final class MainThreadFactory implements ThreadFactory { public final class MainThreadFactory implements ThreadFactory {
@Override @Override
public final Thread newThread(final Runnable runnable) { public final Thread newThread(final Runnable runnable) {

View File

@@ -1,24 +1,19 @@
package dev.logal.logalbot.audio; package dev.logal.logalbot.audio;
// 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. * 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
// You may obtain a copy of the License at *
* 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.
// 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.AudioPlayer;
import com.sedmelluq.discord.lavaplayer.track.playback.AudioFrame; 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 java.nio.ByteBuffer;
import net.dv8tion.jda.core.utils.Checks;
public final class AudioPlayerSendHandler implements AudioSendHandler { public final class AudioPlayerSendHandler implements AudioSendHandler {
private final AudioPlayer audioPlayer; private final AudioPlayer audioPlayer;
@@ -37,8 +32,8 @@ public final class AudioPlayerSendHandler implements AudioSendHandler {
} }
@Override @Override
public final byte[] provide20MsAudio() { public final ByteBuffer provide20MsAudio() {
return lastFrame.getData(); return ByteBuffer.wrap(lastFrame.getData());
} }
@Override @Override

View File

@@ -1,23 +1,16 @@
package dev.logal.logalbot.audio; package dev.logal.logalbot.audio;
// 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. * 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
// You may obtain a copy of the License at *
* 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.
// 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.AudioTrack;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.core.entities.Member; import net.dv8tion.jda.internal.utils.Checks;
import net.dv8tion.jda.core.utils.Checks;
public final class RequestedTrack { public final class RequestedTrack {
private final AudioTrack track; private final AudioTrack track;

View File

@@ -1,41 +1,33 @@
package dev.logal.logalbot.audio; package dev.logal.logalbot.audio;
// 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. * 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
// You may obtain a copy of the License at *
* 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.
// 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;
import com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler; import com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler;
import com.sedmelluq.discord.lavaplayer.tools.FriendlyException; import com.sedmelluq.discord.lavaplayer.tools.FriendlyException;
import com.sedmelluq.discord.lavaplayer.track.AudioPlaylist; import com.sedmelluq.discord.lavaplayer.track.AudioPlaylist;
import com.sedmelluq.discord.lavaplayer.track.AudioTrack; import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
import com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo; import com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import dev.logal.logalbot.MainThread; import dev.logal.logalbot.MainThread;
import dev.logal.logalbot.commands.CommandResponse; import dev.logal.logalbot.commands.CommandResponse;
import dev.logal.logalbot.tasks.TrackAdditionTask; import dev.logal.logalbot.tasks.TrackAdditionTask;
import dev.logal.logalbot.utils.AudioUtil; import dev.logal.logalbot.utils.AudioUtil;
import dev.logal.logalbot.utils.PermissionManager; import dev.logal.logalbot.utils.PermissionManager;
import dev.logal.logalbot.utils.TrackUtil; import dev.logal.logalbot.utils.TrackUtil;
import net.dv8tion.jda.core.entities.Guild; import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.core.entities.Member; import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.core.entities.TextChannel; import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import net.dv8tion.jda.core.utils.Checks; 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 { public final class TrackLoadHandler implements AudioLoadResultHandler {
private final Logger logger = LoggerFactory.getLogger(TrackLoadHandler.class); private final Logger logger = LoggerFactory.getLogger(TrackLoadHandler.class);

View File

@@ -1,46 +1,34 @@
package dev.logal.logalbot.audio; package dev.logal.logalbot.audio;
// 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. * 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
// You may obtain a copy of the License at *
* 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.
// 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;
import com.sedmelluq.discord.lavaplayer.player.AudioPlayer; import com.sedmelluq.discord.lavaplayer.player.AudioPlayer;
import com.sedmelluq.discord.lavaplayer.player.event.AudioEventAdapter; import com.sedmelluq.discord.lavaplayer.player.event.AudioEventAdapter;
import com.sedmelluq.discord.lavaplayer.track.AudioTrack; import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
import com.sedmelluq.discord.lavaplayer.track.AudioTrackEndReason; import com.sedmelluq.discord.lavaplayer.track.AudioTrackEndReason;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import dev.logal.logalbot.MainThread; import dev.logal.logalbot.MainThread;
import dev.logal.logalbot.tasks.CloseAudioConnectionTask; import dev.logal.logalbot.tasks.CloseAudioConnectionTask;
import dev.logal.logalbot.tasks.OpenAudioConnectionTask; import dev.logal.logalbot.tasks.OpenAudioConnectionTask;
import dev.logal.logalbot.tasks.PlayNextTrackTask; import dev.logal.logalbot.tasks.PlayNextTrackTask;
import dev.logal.logalbot.utils.AudioUtil; import dev.logal.logalbot.utils.*;
import dev.logal.logalbot.utils.DataManager; import net.dv8tion.jda.api.entities.Guild;
import dev.logal.logalbot.utils.PermissionManager; import net.dv8tion.jda.api.entities.Member;
import dev.logal.logalbot.utils.SkipTracker; import net.dv8tion.jda.api.entities.User;
import dev.logal.logalbot.utils.VoiceChannelUtil; import net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel;
import net.dv8tion.jda.core.entities.Guild; import net.dv8tion.jda.internal.utils.Checks;
import net.dv8tion.jda.core.entities.Member; import org.slf4j.Logger;
import net.dv8tion.jda.core.entities.User; import org.slf4j.LoggerFactory;
import net.dv8tion.jda.core.entities.VoiceChannel;
import net.dv8tion.jda.core.utils.Checks; import java.util.Collections;
import java.util.LinkedList;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
public final class TrackScheduler extends AudioEventAdapter { public final class TrackScheduler extends AudioEventAdapter {
private static final Logger logger = LoggerFactory.getLogger(TrackScheduler.class); private static final Logger logger = LoggerFactory.getLogger(TrackScheduler.class);

View File

@@ -1,21 +1,16 @@
package dev.logal.logalbot.commands; 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 import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
// 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;
public interface Command { public interface Command {
CommandResponse execute(final String[] arguments, final Member executor, final TextChannel channel); CommandResponse execute(final String[] arguments, final Member executor, final TextChannel channel);

View File

@@ -1,37 +1,27 @@
package dev.logal.logalbot.commands; 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. * 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
// You may obtain a copy of the License at *
* 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.
// 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;
import dev.logal.logalbot.MainThread; import dev.logal.logalbot.MainThread;
import dev.logal.logalbot.tasks.MessageDeleteTask; import dev.logal.logalbot.tasks.MessageDeleteTask;
import dev.logal.logalbot.tasks.ReactionCallbackExpireTask; import dev.logal.logalbot.tasks.ReactionCallbackExpireTask;
import dev.logal.logalbot.utils.ReactionCallbackManager; import dev.logal.logalbot.utils.ReactionCallbackManager;
import net.dv8tion.jda.core.MessageBuilder; import net.dv8tion.jda.api.entities.*;
import net.dv8tion.jda.core.entities.Member; import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import net.dv8tion.jda.core.entities.Message; import net.dv8tion.jda.api.entities.emoji.Emoji;
import net.dv8tion.jda.core.entities.MessageEmbed; import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder;
import net.dv8tion.jda.core.entities.TextChannel; import net.dv8tion.jda.internal.utils.Checks;
import net.dv8tion.jda.core.entities.User;
import net.dv8tion.jda.core.utils.Checks; import java.util.LinkedHashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
public final class CommandResponse { public final class CommandResponse {
private final Emoji emoji; private final Emoji emoji;
@@ -47,7 +37,7 @@ public final class CommandResponse {
Checks.notEmpty(emoji, "Emoji"); Checks.notEmpty(emoji, "Emoji");
Checks.notEmpty(response, "Response"); Checks.notEmpty(response, "Response");
this.emoji = EmojiManager.getForAlias(emoji); this.emoji = Emoji.fromUnicode(emoji);
Checks.notNull(this.emoji, "Valid Emoji"); Checks.notNull(this.emoji, "Valid Emoji");
this.response = response; this.response = response;
} }
@@ -72,7 +62,7 @@ public final class CommandResponse {
Checks.notEmpty(emoji, "Emoji"); Checks.notEmpty(emoji, "Emoji");
Checks.notNull(callback, "Callback"); Checks.notNull(callback, "Callback");
this.callbacks.put(EmojiManager.getForAlias(emoji), callback); this.callbacks.put(Emoji.fromUnicode(emoji), callback);
return this; return this;
} }
@@ -95,11 +85,11 @@ public final class CommandResponse {
public final void sendResponse(final TextChannel channel) { public final void sendResponse(final TextChannel channel) {
Checks.notNull(channel, "Channel"); Checks.notNull(channel, "Channel");
final MessageBuilder builder = new MessageBuilder(); final MessageCreateBuilder builder = new MessageCreateBuilder();
builder.setContent(this.emoji.getUnicode() + " " + this.response); builder.setContent(":" + this.emoji.getFormatted() + ": " + this.response);
if (this.responseEmbed != null) { if (this.responseEmbed != null) {
builder.setEmbed(this.responseEmbed); builder.addEmbeds(this.responseEmbed);
} }
channel.sendMessage(builder.build()).queue(this::handleResponseCreation); channel.sendMessage(builder.build()).queue(this::handleResponseCreation);

View File

@@ -1,21 +1,15 @@
package dev.logal.logalbot.commands; 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"); import net.dv8tion.jda.api.entities.Member;
// you may not use this file except in compliance with the License. import net.dv8tion.jda.api.entities.Message;
// 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;
public interface ReactionCallback { public interface ReactionCallback {
void run(final Member reactor, final Message message); void run(final Member reactor, final Message message);

View File

@@ -1,30 +1,24 @@
package dev.logal.logalbot.commands.administration; package dev.logal.logalbot.commands.administration;
// 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. * 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
// You may obtain a copy of the License at *
* 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.
// 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;
import dev.logal.logalbot.commands.Command; import dev.logal.logalbot.commands.Command;
import dev.logal.logalbot.commands.CommandResponse; import dev.logal.logalbot.commands.CommandResponse;
import dev.logal.logalbot.utils.AudioUtil; import dev.logal.logalbot.utils.AudioUtil;
import dev.logal.logalbot.utils.DataManager; import dev.logal.logalbot.utils.DataManager;
import dev.logal.logalbot.utils.StringUtil; import dev.logal.logalbot.utils.StringUtil;
import net.dv8tion.jda.core.EmbedBuilder; import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.core.entities.Guild; import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.core.entities.Member; import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.core.entities.TextChannel; import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import java.util.concurrent.TimeUnit;
public final class Settings implements Command { public final class Settings implements Command {
@Override @Override

View File

@@ -1,28 +1,22 @@
package dev.logal.logalbot.commands.administration; package dev.logal.logalbot.commands.administration;
// 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. * 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
// You may obtain a copy of the License at *
* 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.
// 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;
import dev.logal.logalbot.commands.Command; import dev.logal.logalbot.commands.Command;
import dev.logal.logalbot.commands.CommandResponse; import dev.logal.logalbot.commands.CommandResponse;
import dev.logal.logalbot.utils.PermissionManager; import dev.logal.logalbot.utils.PermissionManager;
import net.dv8tion.jda.core.Permission; import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.core.entities.Guild; import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.core.entities.Member; import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.core.entities.TextChannel; import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import java.util.concurrent.TimeUnit;
public final class Whitelist implements Command { public final class Whitelist implements Command {
@Override @Override

View File

@@ -1,20 +1,12 @@
package dev.logal.logalbot.commands.audio; package dev.logal.logalbot.commands.audio;
// 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. * 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
// You may obtain a copy of the License at *
* 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.
// 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;
import dev.logal.logalbot.audio.RequestedTrack; import dev.logal.logalbot.audio.RequestedTrack;
import dev.logal.logalbot.commands.Command; 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.AudioUtil;
import dev.logal.logalbot.utils.TrackUtil; import dev.logal.logalbot.utils.TrackUtil;
import dev.logal.logalbot.utils.VoiceChannelUtil; import dev.logal.logalbot.utils.VoiceChannelUtil;
import net.dv8tion.jda.core.entities.Guild; import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.core.entities.Member; import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.core.entities.TextChannel; import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import java.util.concurrent.TimeUnit;
public final class ForceSkip implements Command { public final class ForceSkip implements Command {
@Override @Override

View File

@@ -1,29 +1,23 @@
package dev.logal.logalbot.commands.audio; package dev.logal.logalbot.commands.audio;
// 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. * 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
// You may obtain a copy of the License at *
* 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.
// 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;
import dev.logal.logalbot.audio.TrackScheduler; import dev.logal.logalbot.audio.TrackScheduler;
import dev.logal.logalbot.commands.Command; import dev.logal.logalbot.commands.Command;
import dev.logal.logalbot.commands.CommandResponse; import dev.logal.logalbot.commands.CommandResponse;
import dev.logal.logalbot.utils.AudioUtil; import dev.logal.logalbot.utils.AudioUtil;
import dev.logal.logalbot.utils.VoiceChannelUtil; import dev.logal.logalbot.utils.VoiceChannelUtil;
import net.dv8tion.jda.core.entities.Guild; import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.core.entities.Member; import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.core.entities.TextChannel; import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import java.util.concurrent.TimeUnit;
public final class Lock implements Command { public final class Lock implements Command {
@Override @Override

View File

@@ -1,26 +1,20 @@
package dev.logal.logalbot.commands.audio; package dev.logal.logalbot.commands.audio;
// 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. * 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
// You may obtain a copy of the License at *
* 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.
// 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.Command;
import dev.logal.logalbot.commands.CommandResponse; import dev.logal.logalbot.commands.CommandResponse;
import dev.logal.logalbot.utils.AudioUtil; import dev.logal.logalbot.utils.AudioUtil;
import dev.logal.logalbot.utils.TrackUtil; import dev.logal.logalbot.utils.TrackUtil;
import net.dv8tion.jda.core.entities.Guild; import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.core.entities.Member; import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.core.entities.TextChannel; import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
public final class NowPlaying implements Command { public final class NowPlaying implements Command {
@Override @Override

View File

@@ -1,28 +1,22 @@
package dev.logal.logalbot.commands.audio; package dev.logal.logalbot.commands.audio;
// 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. * 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
// You may obtain a copy of the License at *
* 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.
// 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;
import dev.logal.logalbot.commands.Command; import dev.logal.logalbot.commands.Command;
import dev.logal.logalbot.commands.CommandResponse; import dev.logal.logalbot.commands.CommandResponse;
import dev.logal.logalbot.utils.AudioUtil; import dev.logal.logalbot.utils.AudioUtil;
import dev.logal.logalbot.utils.VoiceChannelUtil; import dev.logal.logalbot.utils.VoiceChannelUtil;
import net.dv8tion.jda.core.entities.Guild; import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.core.entities.Member; import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.core.entities.TextChannel; import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import java.util.concurrent.TimeUnit;
public final class Pause implements Command { public final class Pause implements Command {
@Override @Override

View File

@@ -1,22 +1,12 @@
package dev.logal.logalbot.commands.audio; package dev.logal.logalbot.commands.audio;
// 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. * 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
// You may obtain a copy of the License at *
* 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.
// 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;
import dev.logal.logalbot.audio.TrackScheduler; import dev.logal.logalbot.audio.TrackScheduler;
import dev.logal.logalbot.commands.Command; 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.DataManager;
import dev.logal.logalbot.utils.PermissionManager; import dev.logal.logalbot.utils.PermissionManager;
import dev.logal.logalbot.utils.VoiceChannelUtil; import dev.logal.logalbot.utils.VoiceChannelUtil;
import net.dv8tion.jda.core.Permission; import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.core.entities.Guild; import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.core.entities.Member; import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.core.entities.TextChannel; import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import net.dv8tion.jda.core.entities.VoiceChannel; 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 { public final class Play implements Command {
@Override @Override

View File

@@ -1,21 +1,12 @@
package dev.logal.logalbot.commands.audio; package dev.logal.logalbot.commands.audio;
// 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. * 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
// You may obtain a copy of the License at *
* 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.
// 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;
import dev.logal.logalbot.MainThread; import dev.logal.logalbot.MainThread;
import dev.logal.logalbot.audio.RequestedTrack; 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.AudioUtil;
import dev.logal.logalbot.utils.ReactionCallbackManager; import dev.logal.logalbot.utils.ReactionCallbackManager;
import dev.logal.logalbot.utils.TrackUtil; import dev.logal.logalbot.utils.TrackUtil;
import net.dv8tion.jda.core.entities.Guild; import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.core.entities.Member; import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.core.entities.TextChannel; import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import java.util.List;
import java.util.concurrent.TimeUnit;
public final class Queue implements Command { public final class Queue implements Command {
@Override @Override

View File

@@ -1,20 +1,12 @@
package dev.logal.logalbot.commands.audio; package dev.logal.logalbot.commands.audio;
// 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. * 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
// You may obtain a copy of the License at *
* 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.
// 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;
import dev.logal.logalbot.MainThread; import dev.logal.logalbot.MainThread;
import dev.logal.logalbot.audio.RequestedTrack; 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.Command;
import dev.logal.logalbot.commands.CommandResponse; import dev.logal.logalbot.commands.CommandResponse;
import dev.logal.logalbot.tasks.CommandExecutionTask; import dev.logal.logalbot.tasks.CommandExecutionTask;
import dev.logal.logalbot.utils.AudioUtil; import dev.logal.logalbot.utils.*;
import dev.logal.logalbot.utils.ReactionCallbackManager; import net.dv8tion.jda.api.Permission;
import dev.logal.logalbot.utils.StringUtil; import net.dv8tion.jda.api.entities.Guild;
import dev.logal.logalbot.utils.TrackUtil; import net.dv8tion.jda.api.entities.Member;
import dev.logal.logalbot.utils.VoiceChannelUtil; import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import net.dv8tion.jda.core.Permission;
import net.dv8tion.jda.core.entities.Guild; import java.util.concurrent.TimeUnit;
import net.dv8tion.jda.core.entities.Member;
import net.dv8tion.jda.core.entities.TextChannel;
public final class Remove implements Command { public final class Remove implements Command {
@Override @Override

View File

@@ -1,28 +1,22 @@
package dev.logal.logalbot.commands.audio; package dev.logal.logalbot.commands.audio;
// 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. * 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
// You may obtain a copy of the License at *
* 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.
// 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;
import dev.logal.logalbot.commands.Command; import dev.logal.logalbot.commands.Command;
import dev.logal.logalbot.commands.CommandResponse; import dev.logal.logalbot.commands.CommandResponse;
import dev.logal.logalbot.utils.AudioUtil; import dev.logal.logalbot.utils.AudioUtil;
import dev.logal.logalbot.utils.VoiceChannelUtil; import dev.logal.logalbot.utils.VoiceChannelUtil;
import net.dv8tion.jda.core.entities.Guild; import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.core.entities.Member; import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.core.entities.TextChannel; import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import java.util.concurrent.TimeUnit;
public final class Reset implements Command { public final class Reset implements Command {
@Override @Override

View File

@@ -1,29 +1,23 @@
package dev.logal.logalbot.commands.audio; package dev.logal.logalbot.commands.audio;
// 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. * 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
// You may obtain a copy of the License at *
* 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.
// 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;
import dev.logal.logalbot.audio.TrackScheduler; import dev.logal.logalbot.audio.TrackScheduler;
import dev.logal.logalbot.commands.Command; import dev.logal.logalbot.commands.Command;
import dev.logal.logalbot.commands.CommandResponse; import dev.logal.logalbot.commands.CommandResponse;
import dev.logal.logalbot.utils.AudioUtil; import dev.logal.logalbot.utils.AudioUtil;
import dev.logal.logalbot.utils.VoiceChannelUtil; import dev.logal.logalbot.utils.VoiceChannelUtil;
import net.dv8tion.jda.core.entities.Guild; import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.core.entities.Member; import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.core.entities.TextChannel; import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import java.util.concurrent.TimeUnit;
public final class Shuffle implements Command { public final class Shuffle implements Command {
@Override @Override

View File

@@ -1,20 +1,12 @@
package dev.logal.logalbot.commands.audio; package dev.logal.logalbot.commands.audio;
// 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. * 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
// You may obtain a copy of the License at *
* 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.
// 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;
import dev.logal.logalbot.audio.RequestedTrack; import dev.logal.logalbot.audio.RequestedTrack;
import dev.logal.logalbot.commands.Command; 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.SkipTracker;
import dev.logal.logalbot.utils.TrackUtil; import dev.logal.logalbot.utils.TrackUtil;
import dev.logal.logalbot.utils.VoiceChannelUtil; import dev.logal.logalbot.utils.VoiceChannelUtil;
import net.dv8tion.jda.core.entities.Guild; import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.core.entities.Member; import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.core.entities.TextChannel; import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import java.util.concurrent.TimeUnit;
public final class Skip implements Command { public final class Skip implements Command {
@Override @Override

View File

@@ -1,28 +1,22 @@
package dev.logal.logalbot.commands.audio; package dev.logal.logalbot.commands.audio;
// 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. * 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
// You may obtain a copy of the License at *
* 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.
// 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;
import dev.logal.logalbot.commands.Command; import dev.logal.logalbot.commands.Command;
import dev.logal.logalbot.commands.CommandResponse; import dev.logal.logalbot.commands.CommandResponse;
import dev.logal.logalbot.utils.AudioUtil; import dev.logal.logalbot.utils.AudioUtil;
import dev.logal.logalbot.utils.VoiceChannelUtil; import dev.logal.logalbot.utils.VoiceChannelUtil;
import net.dv8tion.jda.core.entities.Guild; import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.core.entities.Member; import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.core.entities.TextChannel; import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import java.util.concurrent.TimeUnit;
public final class Volume implements Command { public final class Volume implements Command {
@Override @Override

View File

@@ -1,26 +1,20 @@
package dev.logal.logalbot.commands.fun; 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. * 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
// You may obtain a copy of the License at *
* 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.
// 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;
import dev.logal.logalbot.commands.Command; import dev.logal.logalbot.commands.Command;
import dev.logal.logalbot.commands.CommandResponse; import dev.logal.logalbot.commands.CommandResponse;
import net.dv8tion.jda.core.entities.Member; import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.core.entities.TextChannel; import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import java.security.SecureRandom;
import java.util.concurrent.TimeUnit;
public final class Dice implements Command { public final class Dice implements Command {
private final SecureRandom rng = new SecureRandom(); private final SecureRandom rng = new SecureRandom();

View File

@@ -1,31 +1,24 @@
package dev.logal.logalbot.commands.fun; 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"); import com.vdurmont.emoji.EmojiManager;
// you may not use this file except in compliance with the License. import dev.logal.logalbot.commands.Command;
// You may obtain a copy of the License at import dev.logal.logalbot.commands.CommandResponse;
import dev.logal.logalbot.utils.StringUtil;
// https://www.apache.org/licenses/LICENSE-2.0 import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
// 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.ArrayList; import java.util.ArrayList;
import java.util.Random; import java.util.Random;
import java.util.concurrent.TimeUnit; 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 { public final class EightBall implements Command {
private final ArrayList<String> responses = new ArrayList<>(20); private final ArrayList<String> responses = new ArrayList<>(20);
private final Random rng = new Random(); private final Random rng = new Random();

View File

@@ -1,23 +1,17 @@
package dev.logal.logalbot.commands.general; package dev.logal.logalbot.commands.general;
// 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. * 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
// You may obtain a copy of the License at *
* 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.
// 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.Command;
import dev.logal.logalbot.commands.CommandResponse; import dev.logal.logalbot.commands.CommandResponse;
import net.dv8tion.jda.core.entities.Member; import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.core.entities.TextChannel; import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
public final class About implements Command { public final class About implements Command {
@Override @Override

View File

@@ -1,24 +1,18 @@
package dev.logal.logalbot.commands.general; package dev.logal.logalbot.commands.general;
// 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. * 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
// You may obtain a copy of the License at *
* 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.
// 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.Command;
import dev.logal.logalbot.commands.CommandResponse; import dev.logal.logalbot.commands.CommandResponse;
import net.dv8tion.jda.core.EmbedBuilder; import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.core.entities.Member; import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.core.entities.TextChannel; import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
public final class Help implements Command { public final class Help implements Command {
@Override @Override

View File

@@ -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()));
}
}
}

View File

@@ -1,23 +1,17 @@
package dev.logal.logalbot.events; package dev.logal.logalbot.events;
// 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. * 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
// You may obtain a copy of the License at *
* 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.
// 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 dev.logal.logalbot.utils.AudioUtil;
import net.dv8tion.jda.core.events.guild.GuildReadyEvent; import net.dv8tion.jda.api.events.guild.GuildReadyEvent;
import net.dv8tion.jda.core.hooks.ListenerAdapter; import net.dv8tion.jda.api.hooks.ListenerAdapter;
import net.dv8tion.jda.core.utils.Checks; import net.dv8tion.jda.internal.utils.Checks;
public final class GuildReady extends ListenerAdapter { public final class GuildReady extends ListenerAdapter {
@Override @Override

View File

@@ -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<Member> 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));
}
}
}
}

View File

@@ -1,39 +1,32 @@
package dev.logal.logalbot.events; package dev.logal.logalbot.events;
// 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. * 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
// You may obtain a copy of the License at *
* 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.
// 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.MainThread;
import dev.logal.logalbot.tasks.ResetAudioPlayerTask; import dev.logal.logalbot.tasks.ResetAudioPlayerTask;
import dev.logal.logalbot.utils.AudioUtil; import dev.logal.logalbot.utils.AudioUtil;
import net.dv8tion.jda.core.entities.Guild; import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.core.entities.Member; import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.core.entities.VoiceChannel; import net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel;
import net.dv8tion.jda.core.events.guild.voice.GuildVoiceLeaveEvent; import net.dv8tion.jda.api.events.guild.voice.GuildVoiceUpdateEvent;
import net.dv8tion.jda.core.hooks.ListenerAdapter; import net.dv8tion.jda.api.hooks.ListenerAdapter;
import net.dv8tion.jda.core.utils.Checks; import net.dv8tion.jda.internal.utils.Checks;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public final class GuildVoiceLeave extends ListenerAdapter { import java.util.List;
private static final Logger logger = LoggerFactory.getLogger(GuildVoiceLeave.class);
public final class GuildVoiceUpdate extends ListenerAdapter {
private static final Logger logger = LoggerFactory.getLogger(GuildVoiceUpdate.class);
@Override @Override
public final void onGuildVoiceLeave(final GuildVoiceLeaveEvent event) { public final void onGuildVoiceUpdate(final GuildVoiceUpdateEvent event) {
Checks.notNull(event, "Event"); Checks.notNull(event, "Event");
final Guild guild = event.getGuild(); final Guild guild = event.getGuild();
@@ -51,7 +44,7 @@ public final class GuildVoiceLeave extends ListenerAdapter {
return; return;
} }
final VoiceChannel leftChannel = event.getChannelLeft(); final VoiceChannel leftChannel = event.getChannelLeft().asVoiceChannel(); // TODO: This will break.
if (leftChannel.equals(AudioUtil.getVoiceChannelConnectedTo(guild))) { if (leftChannel.equals(AudioUtil.getVoiceChannelConnectedTo(guild))) {
final List<Member> members = leftChannel.getMembers(); final List<Member> members = leftChannel.getMembers();
if (members.size() == 1 && members.get(0).getUser().equals(event.getJDA().getSelfUser())) { if (members.size() == 1 && members.get(0).getUser().equals(event.getJDA().getSelfUser())) {

View File

@@ -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.
}
}
}

View File

@@ -1,52 +1,43 @@
package dev.logal.logalbot.events; package dev.logal.logalbot.events;
// 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. * 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
// You may obtain a copy of the License at *
* 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.
// 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;
import dev.logal.logalbot.MainThread; import dev.logal.logalbot.MainThread;
import dev.logal.logalbot.tasks.CommandExecutionTask; import dev.logal.logalbot.tasks.CommandExecutionTask;
import dev.logal.logalbot.utils.DataManager; import dev.logal.logalbot.utils.DataManager;
import net.dv8tion.jda.core.Permission; import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.core.entities.Guild; import net.dv8tion.jda.api.entities.*;
import net.dv8tion.jda.core.entities.Member; import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import net.dv8tion.jda.core.entities.Message; import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.core.entities.SelfUser; import net.dv8tion.jda.api.hooks.ListenerAdapter;
import net.dv8tion.jda.core.entities.TextChannel; import net.dv8tion.jda.internal.utils.Checks;
import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
import net.dv8tion.jda.core.hooks.ListenerAdapter;
import net.dv8tion.jda.core.utils.Checks;
public final class GuildMessageReceived extends ListenerAdapter { import java.util.Arrays;
import java.util.List;
public final class MessageReceived extends ListenerAdapter {
@Override @Override
public final void onGuildMessageReceived(final GuildMessageReceivedEvent event) { public final void onMessageReceived(final MessageReceivedEvent event) {
Checks.notNull(event, "Event"); Checks.notNull(event, "Event");
final Guild guild = event.getGuild(); final Guild guild = event.getGuild();
final Member self = guild.getSelfMember(); 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(); 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)) { || !self.hasPermission(channel, Permission.MESSAGE_EMBED_LINKS)) {
return; return;
} }
final String content = message.getContentRaw(); final String content = message.getContentRaw();
final SelfUser selfUser = event.getJDA().getSelfUser(); final SelfUser selfUser = event.getJDA().getSelfUser();
final List<Member> mentionedMembers = message.getMentionedMembers(); final List<Member> mentionedMembers = message.getMentions().getMembers();
final Member author = event.getMember(); final Member author = event.getMember();
if (mentionedMembers.size() >= 1 && mentionedMembers.get(0).getUser().getIdLong() == selfUser.getIdLong() if (mentionedMembers.size() >= 1 && mentionedMembers.get(0).getUser().getIdLong() == selfUser.getIdLong()
&& (content.startsWith(self.getAsMention()) || content.startsWith(selfUser.getAsMention()))) { && (content.startsWith(self.getAsMention()) || content.startsWith(selfUser.getAsMention()))) {

View File

@@ -1,22 +1,16 @@
package dev.logal.logalbot.tasks; package dev.logal.logalbot.tasks;
// 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. * 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
// You may obtain a copy of the License at *
* 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.
// 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 dev.logal.logalbot.utils.AudioUtil;
import net.dv8tion.jda.core.entities.Guild; import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.core.utils.Checks; import net.dv8tion.jda.internal.utils.Checks;
public final class CloseAudioConnectionTask implements Runnable { public final class CloseAudioConnectionTask implements Runnable {
private final Guild guild; private final Guild guild;

View File

@@ -1,23 +1,17 @@
package dev.logal.logalbot.tasks; package dev.logal.logalbot.tasks;
// 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. * 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
// You may obtain a copy of the License at *
* 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.
// 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 dev.logal.logalbot.utils.CommandManager;
import net.dv8tion.jda.core.entities.Member; import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.core.entities.TextChannel; import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import net.dv8tion.jda.core.utils.Checks; import net.dv8tion.jda.internal.utils.Checks;
public final class CommandExecutionTask implements Runnable { public final class CommandExecutionTask implements Runnable {
private final String[] command; private final String[] command;

View File

@@ -1,22 +1,16 @@
package dev.logal.logalbot.tasks; package dev.logal.logalbot.tasks;
// 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. * 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
// You may obtain a copy of the License at *
* 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.
// 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 dev.logal.logalbot.utils.ReactionCallbackManager;
import net.dv8tion.jda.core.entities.Message; import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.core.utils.Checks; import net.dv8tion.jda.internal.utils.Checks;
public final class MessageDeleteTask implements Runnable { public final class MessageDeleteTask implements Runnable {
private final Message messageToDelete; private final Message messageToDelete;

View File

@@ -1,22 +1,16 @@
package dev.logal.logalbot.tasks; package dev.logal.logalbot.tasks;
// 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. * 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
// You may obtain a copy of the License at *
* 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.
// 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 dev.logal.logalbot.utils.AudioUtil;
import net.dv8tion.jda.core.entities.VoiceChannel; import net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel;
import net.dv8tion.jda.core.utils.Checks; import net.dv8tion.jda.internal.utils.Checks;
public final class OpenAudioConnectionTask implements Runnable { public final class OpenAudioConnectionTask implements Runnable {
private final VoiceChannel channel; private final VoiceChannel channel;

View File

@@ -1,22 +1,16 @@
package dev.logal.logalbot.tasks; package dev.logal.logalbot.tasks;
// 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. * 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
// You may obtain a copy of the License at *
* 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.
// 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 dev.logal.logalbot.utils.AudioUtil;
import net.dv8tion.jda.core.entities.Guild; import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.core.utils.Checks; import net.dv8tion.jda.internal.utils.Checks;
public final class PlayNextTrackTask implements Runnable { public final class PlayNextTrackTask implements Runnable {
private final Guild guild; private final Guild guild;

View File

@@ -1,23 +1,17 @@
package dev.logal.logalbot.tasks; package dev.logal.logalbot.tasks;
// 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. * 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
// You may obtain a copy of the License at *
* 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.
// 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 dev.logal.logalbot.utils.ReactionCallbackManager;
import net.dv8tion.jda.core.entities.Member; import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.core.entities.TextChannel; import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import net.dv8tion.jda.core.utils.Checks; import net.dv8tion.jda.internal.utils.Checks;
public final class ReactionCallbackExecutionTask implements Runnable { public final class ReactionCallbackExecutionTask implements Runnable {
private final long messageID; private final long messageID;

View File

@@ -1,22 +1,16 @@
package dev.logal.logalbot.tasks; package dev.logal.logalbot.tasks;
// 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. * 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
// You may obtain a copy of the License at *
* 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.
// 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 dev.logal.logalbot.utils.ReactionCallbackManager;
import net.dv8tion.jda.core.entities.Message; import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.core.utils.Checks; import net.dv8tion.jda.internal.utils.Checks;
public final class ReactionCallbackExpireTask implements Runnable { public final class ReactionCallbackExpireTask implements Runnable {
private final Message messageToExpire; private final Message messageToExpire;

View File

@@ -1,22 +1,16 @@
package dev.logal.logalbot.tasks; package dev.logal.logalbot.tasks;
// 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. * 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
// You may obtain a copy of the License at *
* 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.
// 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 dev.logal.logalbot.utils.AudioUtil;
import net.dv8tion.jda.core.entities.Guild; import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.core.utils.Checks; import net.dv8tion.jda.internal.utils.Checks;
public final class ResetAudioPlayerTask implements Runnable { public final class ResetAudioPlayerTask implements Runnable {
private final Guild guild; private final Guild guild;

View File

@@ -1,27 +1,21 @@
package dev.logal.logalbot.tasks; package dev.logal.logalbot.tasks;
// 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. * 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
// You may obtain a copy of the License at *
* 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.
// 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;
import dev.logal.logalbot.audio.RequestedTrack; import dev.logal.logalbot.audio.RequestedTrack;
import dev.logal.logalbot.audio.TrackScheduler; import dev.logal.logalbot.audio.TrackScheduler;
import dev.logal.logalbot.utils.AudioUtil; import dev.logal.logalbot.utils.AudioUtil;
import net.dv8tion.jda.core.entities.Guild; import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.core.utils.Checks; import net.dv8tion.jda.internal.utils.Checks;
import java.util.LinkedList;
import java.util.List;
public final class TrackAdditionTask implements Runnable { public final class TrackAdditionTask implements Runnable {
private final Guild guild; private final Guild guild;

View File

@@ -1,39 +1,31 @@
package dev.logal.logalbot.utils; 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. * 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
// You may obtain a copy of the License at *
* 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.
// 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.sedmelluq.discord.lavaplayer.player.AudioPlayer; import com.sedmelluq.discord.lavaplayer.player.AudioPlayer;
import com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager; import com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager;
import com.sedmelluq.discord.lavaplayer.player.DefaultAudioPlayerManager; import com.sedmelluq.discord.lavaplayer.player.DefaultAudioPlayerManager;
import com.sedmelluq.discord.lavaplayer.source.AudioSourceManagers; 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.AudioPlayerSendHandler;
import dev.logal.logalbot.audio.RequestedTrack; import dev.logal.logalbot.audio.RequestedTrack;
import dev.logal.logalbot.audio.TrackLoadHandler; import dev.logal.logalbot.audio.TrackLoadHandler;
import dev.logal.logalbot.audio.TrackScheduler; import dev.logal.logalbot.audio.TrackScheduler;
import net.dv8tion.jda.core.entities.Guild; import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.core.entities.Member; import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.core.entities.TextChannel; import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import net.dv8tion.jda.core.entities.VoiceChannel; import net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel;
import net.dv8tion.jda.core.managers.AudioManager; import net.dv8tion.jda.api.managers.AudioManager;
import net.dv8tion.jda.core.utils.Checks; import net.dv8tion.jda.internal.utils.Checks;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.HashMap;
public final class AudioUtil { public final class AudioUtil {
private static final Logger logger = LoggerFactory.getLogger(AudioUtil.class); 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) { public static final VoiceChannel getVoiceChannelConnectedTo(final Guild guild) {
Checks.notNull(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) { public static final boolean isAudioConnectionOpen(final Guild guild) {

View File

@@ -1,33 +1,25 @@
package dev.logal.logalbot.utils; 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. * 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
// You may obtain a copy of the License at *
* 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.
// 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;
import dev.logal.logalbot.commands.Command; import dev.logal.logalbot.commands.Command;
import dev.logal.logalbot.commands.CommandResponse; import dev.logal.logalbot.commands.CommandResponse;
import net.dv8tion.jda.core.entities.Guild; import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.core.entities.Member; import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.core.entities.TextChannel; import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import net.dv8tion.jda.core.utils.Checks; 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 { public final class CommandManager {
private static final Logger logger = LoggerFactory.getLogger(CommandManager.class); private static final Logger logger = LoggerFactory.getLogger(CommandManager.class);

View File

@@ -1,26 +1,19 @@
package dev.logal.logalbot.utils; 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. * 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
// You may obtain a copy of the License at *
* 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.
// 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.Logger;
import org.slf4j.LoggerFactory; 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; import redis.clients.jedis.Jedis;
public final class DataManager { public final class DataManager {
@@ -37,7 +30,7 @@ public final class DataManager {
public static final void verifyConnection() { public static final void verifyConnection() {
if (!jedis.isConnected()) { if (!jedis.isConnected()) {
jedis = new Jedis(host); jedis = new Jedis(host, 6379);
if (password != null) { if (password != null) {
jedis.auth(password); jedis.auth(password);

View File

@@ -1,26 +1,19 @@
package dev.logal.logalbot.utils; 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. * 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
// You may obtain a copy of the License at *
* 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.
// 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.Logger;
import org.slf4j.LoggerFactory; 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 { public final class PermissionManager {
private static final Logger logger = LoggerFactory.getLogger(PermissionManager.class); private static final Logger logger = LoggerFactory.getLogger(PermissionManager.class);

View File

@@ -1,30 +1,22 @@
package dev.logal.logalbot.utils; 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. * 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
// You may obtain a copy of the License at *
* 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.
// 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;
import dev.logal.logalbot.commands.ReactionCallback; import dev.logal.logalbot.commands.ReactionCallback;
import net.dv8tion.jda.core.entities.Member; import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.core.entities.Message; import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.core.entities.TextChannel; import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import net.dv8tion.jda.core.entities.User; import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.core.utils.Checks; import net.dv8tion.jda.api.entities.emoji.Emoji;
import net.dv8tion.jda.internal.utils.Checks;
import java.util.HashMap;
public final class ReactionCallbackManager { public final class ReactionCallbackManager {
private static final HashMap<Long, HashMap<Emoji, ReactionCallback>> callbackDictionary = new HashMap<>(); private static final HashMap<Long, HashMap<Emoji, ReactionCallback>> callbackDictionary = new HashMap<>();
@@ -45,7 +37,7 @@ public final class ReactionCallbackManager {
} }
callbackDictionary.get(message.getIdLong()).put(emoji, callback); 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) { public static final void setCallbackTarget(final Message message, final User user) {
@@ -62,7 +54,7 @@ public final class ReactionCallbackManager {
message.delete().queue(); message.delete().queue();
} else { } else {
if (callbackDictionary.containsKey(message.getIdLong())) { 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();
} }
} }
@@ -77,7 +69,8 @@ public final class ReactionCallbackManager {
Checks.notNull(reactor, "Reactor"); Checks.notNull(reactor, "Reactor");
Checks.notEmpty(emoji, "Emoji"); Checks.notEmpty(emoji, "Emoji");
channel.getMessageById(messageID).queue((message) -> { // TODO: This is broke.
/*channel.getMessageById(messageID).queue((message) -> {
if (callbackDictionary.containsKey(messageID)) { if (callbackDictionary.containsKey(messageID)) {
if (targetDictionary.containsKey(messageID) if (targetDictionary.containsKey(messageID)
&& !targetDictionary.get(messageID).equals(reactor.getUser().getIdLong())) { && !targetDictionary.get(messageID).equals(reactor.getUser().getIdLong())) {
@@ -89,6 +82,6 @@ public final class ReactionCallbackManager {
callbackDictionary.get(messageID).get(parsedEmoji).run(reactor, message); callbackDictionary.get(messageID).get(parsedEmoji).run(reactor, message);
} }
} }
}); });*/
} }
} }

View File

@@ -1,26 +1,21 @@
package dev.logal.logalbot.utils; 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 import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Member;
// Unless required by applicable law or agreed to in writing, software import net.dv8tion.jda.internal.utils.Checks;
// 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.ArrayList; import java.util.ArrayList;
import java.util.HashMap; 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 { public final class SkipTracker {
private static final HashMap<Long, ArrayList<Long>> skipVotesDictionary = new HashMap<>(); private static final HashMap<Long, ArrayList<Long>> skipVotesDictionary = new HashMap<>();

View File

@@ -1,23 +1,16 @@
package dev.logal.logalbot.utils; 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. * 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
// You may obtain a copy of the License at *
* 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.
// 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.Emoji;
import com.vdurmont.emoji.EmojiManager; import com.vdurmont.emoji.EmojiManager;
import net.dv8tion.jda.internal.utils.Checks;
import net.dv8tion.jda.core.utils.Checks;
public final class StringUtil { public final class StringUtil {
private StringUtil() { private StringUtil() {

View File

@@ -1,30 +1,23 @@
package dev.logal.logalbot.utils; 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. * 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
// You may obtain a copy of the License at *
* 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.
// 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 com.sedmelluq.discord.lavaplayer.track.AudioTrack; import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
import com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo; import com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo;
import dev.logal.logalbot.audio.RequestedTrack; import dev.logal.logalbot.audio.RequestedTrack;
import net.dv8tion.jda.core.EmbedBuilder; import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.core.entities.Guild; import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.core.entities.MessageEmbed; import net.dv8tion.jda.api.entities.MessageEmbed;
import net.dv8tion.jda.core.entities.User; import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.core.utils.Checks; import net.dv8tion.jda.internal.utils.Checks;
import java.util.List;
public final class TrackUtil { public final class TrackUtil {
private TrackUtil() { private TrackUtil() {

View File

@@ -1,22 +1,16 @@
package dev.logal.logalbot.utils; 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"); import net.dv8tion.jda.api.entities.Member;
// you may not use this file except in compliance with the License. import net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel;
// You may obtain a copy of the License at import net.dv8tion.jda.internal.utils.Checks;
// 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;
public final class VoiceChannelUtil { public final class VoiceChannelUtil {
private VoiceChannelUtil() { private VoiceChannelUtil() {