Changed channelId to long
This commit is contained in:
parent
49e53fb01c
commit
44a335bf12
|
|
@ -53,7 +53,7 @@ public class Bot {
|
|||
}
|
||||
}
|
||||
|
||||
public void sendMessageToDiscord(String channelid, String message) {
|
||||
public void sendMessageToDiscord(long channelid, String message) {
|
||||
//sendMessageToDiscord(client.getTextChannelById(channel), message, blocking);
|
||||
TextChannel channel = jda.getTextChannelById(channelid);
|
||||
if (jda == null) return;
|
||||
|
|
@ -74,7 +74,7 @@ public class Bot {
|
|||
}
|
||||
}
|
||||
|
||||
public void sendEmbedToDiscord(String channelid, EmbedBuilder embedBuilder, long secondsTillDelete) {
|
||||
public void sendEmbedToDiscord(long channelid, EmbedBuilder embedBuilder, long secondsTillDelete) {
|
||||
//sendMessageToDiscord(client.getTextChannelById(channel), message, blocking);
|
||||
TextChannel channel = jda.getTextChannelById(channelid);
|
||||
if (jda == null) return;
|
||||
|
|
|
|||
|
|
@ -7,14 +7,14 @@ import net.dv8tion.jda.api.EmbedBuilder;
|
|||
import java.awt.*;
|
||||
|
||||
public class DiscordSendMessage {
|
||||
public static void sendMessage(String channelId, String message)
|
||||
public static void sendMessage(long channelId, String message)
|
||||
{
|
||||
Bot bot = DiscordLink.getPlugin().getBot();
|
||||
|
||||
bot.sendMessageToDiscord(channelId, message);
|
||||
}
|
||||
|
||||
public static void sendEmbed(String channelId, String title, String description)
|
||||
public static void sendEmbed(long channelId, String title, String description)
|
||||
{
|
||||
Bot bot = DiscordLink.getPlugin().getBot();
|
||||
EmbedBuilder embedBuilder = new EmbedBuilder();
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
|||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
|
||||
public class DiscordMessageListener extends ListenerAdapter {
|
||||
|
||||
|
|
@ -27,7 +28,7 @@ public class DiscordMessageListener extends ListenerAdapter {
|
|||
if (event.isWebhookMessage()) {
|
||||
return;
|
||||
}
|
||||
if (event.getMessage().getChannel().getId().equals(BotConfig.COMMAND_CHANNEL)) {
|
||||
if (event.getMessage().getChannel().getIdLong() == BotConfig.LINK_CHANNEL) {
|
||||
String content = event.getMessage().getContentRaw();
|
||||
if (content.startsWith(BotConfig.prefixMap.get(event.getGuild().getIdLong())) && content.length() > 1) {
|
||||
String[] split = content.split(" ");
|
||||
|
|
@ -44,6 +45,18 @@ public class DiscordMessageListener extends ListenerAdapter {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (event.getMessage().getChannel().getIdLong() == BotConfig.LINK_CHANNEL) {
|
||||
String content = event.getMessage().getContentRaw();
|
||||
String[] split = content.split(" ");
|
||||
String cmd = split[0].substring(1).toLowerCase();
|
||||
String[] args = Arrays.copyOfRange(split, 1, split.length);
|
||||
if (cmd.equalsIgnoreCase("link")) {
|
||||
Optional<DiscordCommand> link = DiscordCommand.getCommands().stream().filter(discordCommand -> discordCommand.getCommand().equals("link")).findFirst();
|
||||
if (!link.isEmpty()) {
|
||||
link.get().handleCommand(event.getMessage(), event.getAuthor().getName(), cmd, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,13 +167,15 @@ public class BotConfig {
|
|||
**/
|
||||
|
||||
public static String BOT_TOKEN = "unconfigured";
|
||||
public static String COMMAND_CHANNEL = "unconfigured";
|
||||
public static long COMMAND_CHANNEL = -1;
|
||||
public static long LINK_CHANNEL = -1;
|
||||
public static long GUILD_ID = -1;
|
||||
public static long LINKED_ROLE_ID = -1;
|
||||
|
||||
private static void settings() {
|
||||
BOT_TOKEN = getString("settings.token", BOT_TOKEN);
|
||||
COMMAND_CHANNEL = getString("settings.command_channel", COMMAND_CHANNEL);
|
||||
COMMAND_CHANNEL = getLong("settings.command-channel", COMMAND_CHANNEL);
|
||||
LINK_CHANNEL = getLong("settings.link-channel", LINK_CHANNEL);
|
||||
GUILD_ID = getLong("settings.guild-id", GUILD_ID);
|
||||
LINKED_ROLE_ID = getLong("settings.linked-role-id", LINKED_ROLE_ID);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user