Eliminated guild identifiers from BotConstants as they are now stored in the actual Guild enum.
This commit is contained in:
parent
8ceb57aee1
commit
d19afbb5be
@ -12,14 +12,8 @@ public class BotConstants {
|
|||||||
public static final String OWNER_ID = "504069946528104471"; // Joel
|
public static final String OWNER_ID = "504069946528104471"; // Joel
|
||||||
public static final String[] BOT_ADMINS = new String[] {
|
public static final String[] BOT_ADMINS = new String[] {
|
||||||
"758733013579595836", // Nicholas
|
"758733013579595836", // Nicholas
|
||||||
"504147739131641857" // Braydon
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Guilds
|
|
||||||
public static final String MAIN_GUILD_ID = "764609803459756093";
|
|
||||||
public static final String TEAM_GUILD_ID = "796582717956423760";
|
|
||||||
public static final String TEST_GUILD_ID = "811044415211700234";
|
|
||||||
|
|
||||||
// Default Lines
|
// Default Lines
|
||||||
public static final String COPYRIGHT = "© McGamerZone - " + Calendar.getInstance().get(Calendar.YEAR);
|
public static final String COPYRIGHT = "© McGamerZone - " + Calendar.getInstance().get(Calendar.YEAR);
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ public abstract class BaseCommand extends Command {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void execute(CommandEvent event) {
|
protected void execute(CommandEvent event) {
|
||||||
if (!guilds.contains(GuildUtils.getGuildFromId(event.getGuild().getId())))
|
if (!guilds.contains(GuildUtils.matchGuild(event.getGuild().getId())))
|
||||||
return;
|
return;
|
||||||
List<String> args = new ArrayList<>();
|
List<String> args = new ArrayList<>();
|
||||||
if (event.getArgs() != null && event.getArgs().length() > 0) {
|
if (event.getArgs() != null && event.getArgs().length() > 0) {
|
||||||
|
@ -6,7 +6,6 @@ import net.dv8tion.jda.api.entities.*;
|
|||||||
import net.dv8tion.jda.api.events.guild.member.GuildMemberJoinEvent;
|
import net.dv8tion.jda.api.events.guild.member.GuildMemberJoinEvent;
|
||||||
import net.dv8tion.jda.api.events.message.guild.react.GuildMessageReactionAddEvent;
|
import net.dv8tion.jda.api.events.message.guild.react.GuildMessageReactionAddEvent;
|
||||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||||
import zone.themcgamer.discordbot.BotConstants;
|
|
||||||
import zone.themcgamer.discordbot.MGZBot;
|
import zone.themcgamer.discordbot.MGZBot;
|
||||||
import zone.themcgamer.discordbot.utilities.EmbedUtils;
|
import zone.themcgamer.discordbot.utilities.EmbedUtils;
|
||||||
import zone.themcgamer.discordbot.utilities.GuildUtils;
|
import zone.themcgamer.discordbot.utilities.GuildUtils;
|
||||||
@ -36,10 +35,8 @@ public class MainGuildListener extends ListenerAdapter {
|
|||||||
Guild guild = event.getGuild();
|
Guild guild = event.getGuild();
|
||||||
if (user.isBot())
|
if (user.isBot())
|
||||||
return;
|
return;
|
||||||
|
if (!guild.getId().equals(zone.themcgamer.discordbot.guild.Guild.MAIN.getGuildId()))
|
||||||
if (!guild.getId().equals(BotConstants.MAIN_GUILD_ID))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Role memberRole = guild.getRoleById(793672609395900446L);
|
Role memberRole = guild.getRoleById(793672609395900446L);
|
||||||
GuildUtils.toggleRole(guild, member, memberRole);
|
GuildUtils.toggleRole(guild, member, memberRole);
|
||||||
Role newsRole = guild.getRoleById(812440883898875914L);
|
Role newsRole = guild.getRoleById(812440883898875914L);
|
||||||
@ -52,12 +49,14 @@ public class MainGuildListener extends ListenerAdapter {
|
|||||||
user.openPrivateChannel().queue(privateChannel -> {
|
user.openPrivateChannel().queue(privateChannel -> {
|
||||||
EmbedBuilder embedBuilder = EmbedUtils.defaultEmbed();
|
EmbedBuilder embedBuilder = EmbedUtils.defaultEmbed();
|
||||||
embedBuilder.setThumbnail(mgzBot.getJda().getSelfUser().getAvatarUrl());
|
embedBuilder.setThumbnail(mgzBot.getJda().getSelfUser().getAvatarUrl());
|
||||||
embedBuilder.setDescription("Welcome to **McGamerZone**! You have have the default roles applied your account.\nYou can toggle them in #roles channel!");
|
embedBuilder.setDescription("Welcome to **McGamerZone**! The default roles have been applied to your account, " +
|
||||||
|
"and you can toggle them at any time in the <#813139125195898880> channel!");
|
||||||
privateChannel.sendMessage(embedBuilder.build()).queue();
|
privateChannel.sendMessage(embedBuilder.build()).queue();
|
||||||
}, error -> {
|
}, error -> {
|
||||||
TextChannel textChannelById = guild.getTextChannelById(767396615299923998L);
|
TextChannel textChannelById = guild.getTextChannelById(767396615299923998L);
|
||||||
if (textChannelById != null)
|
if (textChannelById != null)
|
||||||
textChannelById.sendMessage(user.getAsMention() + ", I could not sent a message to you due you have private messages disabled!").queue();
|
textChannelById.sendMessage(user.getAsMention() + ", I could not send you a message due to you having " +
|
||||||
|
"private messages disabled!").queue();
|
||||||
});
|
});
|
||||||
|
|
||||||
TextChannel textChannelById = guild.getTextChannelById(812453030405996564L);
|
TextChannel textChannelById = guild.getTextChannelById(812453030405996564L);
|
||||||
@ -65,13 +64,13 @@ public class MainGuildListener extends ListenerAdapter {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
EmbedBuilder embedBuilder = EmbedUtils.defaultEmbed();
|
EmbedBuilder embedBuilder = EmbedUtils.defaultEmbed();
|
||||||
embedBuilder.setTitle("Welcome to McGamerZone, " + user.getAsTag());
|
embedBuilder.setTitle("Welcome to McGamerZone, " + user.getAsTag() + "!");
|
||||||
embedBuilder.setThumbnail(user.getAvatarUrl());
|
embedBuilder.setThumbnail(user.getAvatarUrl());
|
||||||
embedBuilder.setDescription("This is the official Discord server for McGamerZone Minecraft server." +
|
embedBuilder.setDescription("This is the official Discord server for the McGamerZone Minecraft server network." +
|
||||||
" We are a fun Server that is focused on creativity, community-building, and keeping to the" +
|
" We are a fun server that is focused on creativity, community-building, and keeping to the" +
|
||||||
" core of the game itself. Our goal here; is to maintain a friendly, fun, " +
|
" core of the game itself. Our goal is to maintain a friendly, fun, " +
|
||||||
"and equal community for anyone and everyone that joins in and " +
|
"and equal community for anyone and everyone that joins in, and to " +
|
||||||
"give the og players of MGZ the nostalgia feeling back!");
|
"give the OG players of MGZ that nostalgia feeling back!");
|
||||||
embedBuilder.setTimestamp(event.getMember().getTimeJoined());
|
embedBuilder.setTimestamp(event.getMember().getTimeJoined());
|
||||||
embedBuilder.setFooter("Joined at » ");
|
embedBuilder.setFooter("Joined at » ");
|
||||||
textChannelById.sendMessage(user.getAsMention()).queue(message -> message.delete().queue());
|
textChannelById.sendMessage(user.getAsMention()).queue(message -> message.delete().queue());
|
||||||
@ -86,9 +85,8 @@ public class MainGuildListener extends ListenerAdapter {
|
|||||||
Member member = event.getMember();
|
Member member = event.getMember();
|
||||||
if (event.getUser().isBot())
|
if (event.getUser().isBot())
|
||||||
return;
|
return;
|
||||||
if (!guild.getId().equals(BotConstants.MAIN_GUILD_ID))
|
if (!guild.getId().equals(zone.themcgamer.discordbot.guild.Guild.MAIN.getGuildId()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (event.getChannel().getId().equals("813139125195898880") && event.getMessageId().equals("813143359249842186")) {
|
if (event.getChannel().getId().equals("813139125195898880") && event.getMessageId().equals("813143359249842186")) {
|
||||||
MessageReaction.ReactionEmote reactionEmote = event.getReactionEmote();
|
MessageReaction.ReactionEmote reactionEmote = event.getReactionEmote();
|
||||||
for (Map.Entry<String, Long> entry : reactionRoles.entrySet()) {
|
for (Map.Entry<String, Long> entry : reactionRoles.entrySet()) {
|
||||||
|
@ -1,8 +1,16 @@
|
|||||||
package zone.themcgamer.discordbot.guild;
|
package zone.themcgamer.discordbot.guild;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Nicholas
|
* @author Nicholas
|
||||||
*/
|
*/
|
||||||
|
@AllArgsConstructor @Getter
|
||||||
public enum Guild {
|
public enum Guild {
|
||||||
MAIN, TEAM, TEST
|
MAIN("764609803459756093"),
|
||||||
|
TEAM("796582717956423760"),
|
||||||
|
TEST("811044415211700234");
|
||||||
|
|
||||||
|
private final String guildId;
|
||||||
}
|
}
|
@ -4,26 +4,18 @@ import net.dv8tion.jda.api.EmbedBuilder;
|
|||||||
import net.dv8tion.jda.api.entities.Member;
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
import net.dv8tion.jda.api.entities.Role;
|
import net.dv8tion.jda.api.entities.Role;
|
||||||
import net.dv8tion.jda.api.entities.TextChannel;
|
import net.dv8tion.jda.api.entities.TextChannel;
|
||||||
import zone.themcgamer.discordbot.BotConstants;
|
|
||||||
import zone.themcgamer.discordbot.MGZBot;
|
import zone.themcgamer.discordbot.MGZBot;
|
||||||
import zone.themcgamer.discordbot.guild.Guild;
|
import zone.themcgamer.discordbot.guild.Guild;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Nicholas
|
* @author Nicholas
|
||||||
*/
|
*/
|
||||||
public class GuildUtils {
|
public class GuildUtils {
|
||||||
public static Guild getGuildFromId(String id) {
|
public static Guild matchGuild(String guildId) {
|
||||||
switch (id) {
|
return Arrays.stream(Guild.values()).filter(guild -> guild.getGuildId().equals(guildId)).findFirst().orElse(null);
|
||||||
case BotConstants.MAIN_GUILD_ID:
|
|
||||||
return Guild.MAIN;
|
|
||||||
case BotConstants.TEAM_GUILD_ID:
|
|
||||||
return Guild.TEAM;
|
|
||||||
case BotConstants.TEST_GUILD_ID:
|
|
||||||
return Guild.TEST;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void toggleRole(net.dv8tion.jda.api.entities.Guild guild, Member member, Role role) {
|
public static void toggleRole(net.dv8tion.jda.api.entities.Guild guild, Member member, Role role) {
|
||||||
@ -37,11 +29,13 @@ public class GuildUtils {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
member.getUser().openPrivateChannel().queue(privateChannel -> {
|
member.getUser().openPrivateChannel().queue(privateChannel -> {
|
||||||
privateChannel.sendMessage(EmbedUtils.successEmbed().setDescription("Succesfully toggled " + role.getName() + " " + (!member.getRoles().contains(role) ? "On" : "Off")).build()).queue();
|
privateChannel.sendMessage(EmbedUtils.successEmbed().setDescription("Successfully toggled " + role.getName() +
|
||||||
|
" " + (!member.getRoles().contains(role) ? "On" : "Off")).build()).queue();
|
||||||
}, error -> {
|
}, error -> {
|
||||||
EmbedBuilder embedBuilder = EmbedUtils.successEmbed();
|
EmbedBuilder embedBuilder = EmbedUtils.successEmbed();
|
||||||
embedBuilder.setTitle("Role Manager");
|
embedBuilder.setTitle("Role Manager");
|
||||||
embedBuilder.setDescription("Successfully toggled " + role.getName() + " " + (!member.getRoles().contains(role) ? "On" : "Off"));
|
embedBuilder.setDescription("Successfully toggled " + role.getName() + " " +
|
||||||
|
(!member.getRoles().contains(role) ? "On" : "Off"));
|
||||||
TextChannel textChannelById = guild.getTextChannelById(813139125195898880L);
|
TextChannel textChannelById = guild.getTextChannelById(813139125195898880L);
|
||||||
if (textChannelById == null)
|
if (textChannelById == null)
|
||||||
return;
|
return;
|
||||||
|
@ -30,7 +30,8 @@ public class MessageUtils {
|
|||||||
if (logChannel == null) {
|
if (logChannel == null) {
|
||||||
Objects.requireNonNull(MGZBot.getInstance().getJda().getUserById("504069946528104471"))
|
Objects.requireNonNull(MGZBot.getInstance().getJda().getUserById("504069946528104471"))
|
||||||
.openPrivateChannel().queue(privateChannel ->
|
.openPrivateChannel().queue(privateChannel ->
|
||||||
privateChannel.sendMessage("There was an error while sending a log message, the channel id is invalid or does not exist.").queue());
|
privateChannel.sendMessage("There was an error while sending a log message, the channel id is " +
|
||||||
|
"invalid or does not exist.").queue());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return logChannel;
|
return logChannel;
|
||||||
|
Reference in New Issue
Block a user