Skip to content

Commit 7cd2027

Browse files
Removed Embed.java & old Permission Checks
1 parent e243f42 commit 7cd2027

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+251
-453
lines changed

src/main/java/com/javadiscord/javabot/commands/configuation/config/Config.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
import com.javadiscord.javabot.commands.Responses;
55
import com.javadiscord.javabot.commands.configuation.config.subcommands.*;
66
import com.javadiscord.javabot.other.Constants;
7-
import com.javadiscord.javabot.other.Embeds;
8-
import net.dv8tion.jda.api.Permission;
7+
import net.dv8tion.jda.api.EmbedBuilder;
8+
import net.dv8tion.jda.api.entities.MessageEmbed;
99
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
1010
import net.dv8tion.jda.api.requests.restaction.interactions.ReplyAction;
1111

12+
import java.util.Date;
13+
1214
// TODO: Replace with file-based config or at least something much less convoluted.
13-
@Deprecated(forRemoval = true)
15+
@Deprecated
1416
public class Config extends DelegatingCommandHandler {
1517
public Config() {
1618
addSubcommand("list", new GetList());
@@ -34,12 +36,19 @@ public Config() {
3436

3537
@Override
3638
public ReplyAction handle(SlashCommandEvent event) {
37-
if (event.getMember() != null && !event.getMember().hasPermission(Permission.ADMINISTRATOR)) {
38-
return event.replyEmbeds(Embeds.permissionError("ADMINISTRATOR", event)).setEphemeral(Constants.ERR_EPHEMERAL);
39-
}
4039

4140
try { return super.handle(event);
4241
} catch (Exception e) { return Responses.error(event, "```" + e.getMessage() + "```"); }
4342
}
43+
44+
public MessageEmbed configEmbed (String configName, String newValue) {
45+
var embed = new EmbedBuilder()
46+
.setColor(Constants.GRAY)
47+
.setAuthor("Config: " + configName)
48+
.setDescription("Successfully set ``" + configName + "`` to " + newValue)
49+
.setTimestamp(new Date().toInstant())
50+
.build();
51+
return embed;
52+
}
4453
}
4554

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package com.javadiscord.javabot.commands.configuation.config.subcommands;
22

33
import com.javadiscord.javabot.commands.SlashCommandHandler;
4-
import com.javadiscord.javabot.other.Database;
5-
import com.javadiscord.javabot.other.Embeds;
4+
import com.javadiscord.javabot.commands.configuation.config.Config;
65
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
76
import net.dv8tion.jda.api.requests.restaction.interactions.ReplyAction;
87

@@ -11,13 +10,9 @@ public class SetDMQOTWStatus implements SlashCommandHandler {
1110
public ReplyAction handle(SlashCommandEvent event) {
1211
boolean status = event.getOption("enabled").getAsBoolean();
1312
//new Database().queryConfig(event.getGuild().getId(), "other.qotw.dm-qotw", status);
14-
return event.replyEmbeds(Embeds.configEmbed(
15-
event,
16-
"QOTW-DM Status",
17-
"QOTW-DM Status successfully changed to",
18-
null,
19-
String.valueOf(status),
20-
true
13+
return event.replyEmbeds(new Config().configEmbed(
14+
"DM-QOTW Status",
15+
"`" + status + "`"
2116
));
2217
}
2318
}
Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package com.javadiscord.javabot.commands.configuation.config.subcommands;
22

33
import com.javadiscord.javabot.commands.SlashCommandHandler;
4-
import com.javadiscord.javabot.other.Database;
5-
import com.javadiscord.javabot.other.Embeds;
4+
import com.javadiscord.javabot.commands.configuation.config.Config;
65
import net.dv8tion.jda.api.entities.Role;
76
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
87
import net.dv8tion.jda.api.requests.restaction.interactions.ReplyAction;
@@ -12,15 +11,9 @@ public class SetJamAdminRole implements SlashCommandHandler {
1211
public ReplyAction handle(SlashCommandEvent event) {
1312
Role role = event.getOption("role").getAsRole();
1413
//new Database().queryConfig(event.getGuild().getId(), "roles.jam_admin_rid", role.getId());
15-
return event.replyEmbeds(Embeds.configEmbed(
16-
event,
14+
return event.replyEmbeds(new Config().configEmbed(
1715
"Jam Admin Role",
18-
"Jam Admin Role successfully changed to",
19-
null,
20-
role.getId(),
21-
true,
22-
false,
23-
true
16+
role.getAsMention()
2417
));
2518
}
2619
}
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package com.javadiscord.javabot.commands.configuation.config.subcommands;
22

33
import com.javadiscord.javabot.commands.SlashCommandHandler;
4-
import com.javadiscord.javabot.other.Database;
5-
import com.javadiscord.javabot.other.Embeds;
4+
import com.javadiscord.javabot.commands.configuation.config.Config;
65
import net.dv8tion.jda.api.entities.MessageChannel;
76
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
87
import net.dv8tion.jda.api.requests.restaction.interactions.ReplyAction;
@@ -12,6 +11,9 @@ public class SetJamAnnouncementChannel implements SlashCommandHandler {
1211
public ReplyAction handle(SlashCommandEvent event) {
1312
MessageChannel channel = event.getOption("channel").getAsMessageChannel();
1413
//new Database().queryConfig(event.getGuild().getId(), "channels.jam_announcement_cid", channel.getId());
15-
return event.replyEmbeds(Embeds.configEmbed(event, "Jam Announcement Channel", "Jam Announcement Channel successfully changed to", null, channel.getId(), true, true));
14+
return event.replyEmbeds(new Config().configEmbed(
15+
"Jam Announcement Channel",
16+
"<#" + channel.getId() + ">"
17+
));
1618
}
1719
}
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package com.javadiscord.javabot.commands.configuation.config.subcommands;
22

33
import com.javadiscord.javabot.commands.SlashCommandHandler;
4-
import com.javadiscord.javabot.other.Database;
5-
import com.javadiscord.javabot.other.Embeds;
4+
import com.javadiscord.javabot.commands.configuation.config.Config;
65
import net.dv8tion.jda.api.entities.Role;
76
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
87
import net.dv8tion.jda.api.requests.restaction.interactions.ReplyAction;
@@ -12,6 +11,9 @@ public class SetJamPingRole implements SlashCommandHandler {
1211
public ReplyAction handle(SlashCommandEvent event) {
1312
Role role = event.getOption("role").getAsRole();
1413
//new Database().queryConfig(event.getGuild().getId(), "roles.jam_ping_rid", role.getId());
15-
return event.replyEmbeds(Embeds.configEmbed(event, "Jam Ping Role", "Jam Ping Role successfully changed to", null, role.getId(), true, false, true));
14+
return event.replyEmbeds(new Config().configEmbed(
15+
"Jam Ping Role",
16+
role.getAsMention()
17+
));
1618
}
1719
}
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package com.javadiscord.javabot.commands.configuation.config.subcommands;
22

33
import com.javadiscord.javabot.commands.SlashCommandHandler;
4-
import com.javadiscord.javabot.other.Database;
5-
import com.javadiscord.javabot.other.Embeds;
4+
import com.javadiscord.javabot.commands.configuation.config.Config;
65
import net.dv8tion.jda.api.entities.MessageChannel;
76
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
87
import net.dv8tion.jda.api.requests.restaction.interactions.ReplyAction;
@@ -12,6 +11,9 @@ public class SetJamVoteChannel implements SlashCommandHandler {
1211
public ReplyAction handle(SlashCommandEvent event) {
1312
MessageChannel channel = event.getOption("channel").getAsMessageChannel();
1413
//new Database().queryConfig(event.getGuild().getId(), "channels.jam_vote_cid", channel.getId());
15-
return event.replyEmbeds(Embeds.configEmbed(event, "Jam Vote Channel", "Jam Vote Channel successfully changed to", null, channel.getId(), true, true));
14+
return event.replyEmbeds(new Config().configEmbed(
15+
"Jam Vote Channel",
16+
"<#" + channel.getId() + ">"
17+
));
1618
}
1719
}
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package com.javadiscord.javabot.commands.configuation.config.subcommands;
22

33
import com.javadiscord.javabot.commands.SlashCommandHandler;
4-
import com.javadiscord.javabot.other.Database;
5-
import com.javadiscord.javabot.other.Embeds;
4+
import com.javadiscord.javabot.commands.configuation.config.Config;
65
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
76
import net.dv8tion.jda.api.requests.restaction.interactions.ReplyAction;
87

@@ -11,6 +10,9 @@ public class SetLockStatus implements SlashCommandHandler {
1110
public ReplyAction handle(SlashCommandEvent event) {
1211
boolean status = event.getOption("locked").getAsBoolean();
1312
//new Database().queryConfig(event.getGuild().getId(), "other.server_lock.lock_status", status);
14-
return event.replyEmbeds(Embeds.configEmbed(event, "Lock Status changed", "Lock Status successfully changed to ", null, Boolean.toString(status), true));
13+
return event.replyEmbeds(new Config().configEmbed(
14+
"Lock Status",
15+
"`" + status + "`"
16+
));
1517
}
1618
}
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package com.javadiscord.javabot.commands.configuation.config.subcommands;
22

33
import com.javadiscord.javabot.commands.SlashCommandHandler;
4-
import com.javadiscord.javabot.other.Database;
5-
import com.javadiscord.javabot.other.Embeds;
4+
import com.javadiscord.javabot.commands.configuation.config.Config;
65
import net.dv8tion.jda.api.entities.MessageChannel;
76
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
87
import net.dv8tion.jda.api.requests.restaction.interactions.ReplyAction;
@@ -12,6 +11,9 @@ public class SetLogChannel implements SlashCommandHandler {
1211
public ReplyAction handle(SlashCommandEvent event) {
1312
MessageChannel channel = event.getOption("channel").getAsMessageChannel();
1413
//new Database().queryConfig(event.getGuild().getId(), "channels.log_cid", channel.getId());
15-
return event.replyEmbeds(Embeds.configEmbed(event, "Log Channel", "Log Channel successfully changed to", null, channel.getId(), true, true));
14+
return event.replyEmbeds(new Config().configEmbed(
15+
"Log Channel",
16+
"<#" + channel.getId() + ">"
17+
));
1618
}
1719
}
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package com.javadiscord.javabot.commands.configuation.config.subcommands;
22

33
import com.javadiscord.javabot.commands.SlashCommandHandler;
4-
import com.javadiscord.javabot.other.Database;
5-
import com.javadiscord.javabot.other.Embeds;
4+
import com.javadiscord.javabot.commands.configuation.config.Config;
65
import net.dv8tion.jda.api.entities.Role;
76
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
87
import net.dv8tion.jda.api.requests.restaction.interactions.ReplyAction;
@@ -12,6 +11,9 @@ public class SetMuteRole implements SlashCommandHandler {
1211
public ReplyAction handle(SlashCommandEvent event) {
1312
Role role = event.getOption("role").getAsRole();
1413
//new Database().queryConfig(event.getGuild().getId(), "roles.mute_rid", role.getId());
15-
return event.replyEmbeds(Embeds.configEmbed(event, "Mute Role", "Mute Role successfully changed to", null, role.getId(), true, false, true));
14+
return event.replyEmbeds(new Config().configEmbed(
15+
"Mute Role",
16+
role.getAsMention()
17+
));
1618
}
1719
}
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package com.javadiscord.javabot.commands.configuation.config.subcommands;
22

33
import com.javadiscord.javabot.commands.SlashCommandHandler;
4-
import com.javadiscord.javabot.other.Database;
5-
import com.javadiscord.javabot.other.Embeds;
4+
import com.javadiscord.javabot.commands.configuation.config.Config;
65
import net.dv8tion.jda.api.entities.MessageChannel;
76
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
87
import net.dv8tion.jda.api.requests.restaction.interactions.ReplyAction;
@@ -12,6 +11,9 @@ public class SetReportChannel implements SlashCommandHandler {
1211
public ReplyAction handle(SlashCommandEvent event) {
1312
MessageChannel channel = event.getOption("channel").getAsMessageChannel();
1413
//new Database().queryConfig(event.getGuild().getId(), "channels.report_cid", channel.getId());
15-
return event.replyEmbeds(Embeds.configEmbed(event, "Report Channel", "Report Channel successfully changed to", null, channel.getId(), true, true));
14+
return event.replyEmbeds(new Config().configEmbed(
15+
"Report Channel",
16+
"<#" + channel.getId() + ">"
17+
));
1618
}
1719
}

0 commit comments

Comments
 (0)