Skip to content

Commit 94de6fe

Browse files
author
amar
committed
get pretester role slash command
1 parent c26e580 commit 94de6fe

4 files changed

Lines changed: 68 additions & 4 deletions

File tree

deploy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ cd "$BOT_DIR" || exit 1
3434
git pull
3535

3636
run_bot
37-
echo "Deploy finished"
37+
echo "Deploy finished"

src/main/java/net/amar/oreojava/Oreo.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.jagrosh.jdautilities.examples.command.PingCommand;
66

77
import net.amar.oreojava.commands.slash.general.GetEmoji;
8+
import net.amar.oreojava.commands.slash.general.GetPretesterRole;
89
import net.amar.oreojava.commands.slash.owner.SetBotActivity;
910
import net.amar.oreojava.commands.slash.staff.*;
1011
import net.amar.oreojava.commands.text.general.CallEmbedTag;
@@ -98,7 +99,8 @@ public Oreo() throws InterruptedException, SQLException {
9899
new MuteSlash(),
99100
new SupportbanSlash(),
100101
new GetModCases(),
101-
new UnmuteSlash()
102+
new UnmuteSlash(),
103+
new GetPretesterRole()
102104
);
103105

104106
jda = JDABuilder.createLight(Util.botToken())
@@ -159,4 +161,10 @@ public static Role getSupportbanRole() {
159161
if (id == null) return null;
160162
return jda.getRoleById(id);
161163
}
164+
165+
public static Role getPretesterRole() {
166+
String id = DBGetter.getData(connection, "pretester");
167+
if (id == null) return null;
168+
return jda.getRoleById(id);
169+
}
162170
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package net.amar.oreojava.commands.slash.general;
2+
3+
import com.jagrosh.jdautilities.command.SlashCommand;
4+
import com.jagrosh.jdautilities.command.SlashCommandEvent;
5+
6+
import net.amar.oreojava.Oreo;
7+
import net.dv8tion.jda.api.components.actionrow.ActionRow;
8+
import net.dv8tion.jda.api.components.buttons.Button;
9+
import net.dv8tion.jda.api.entities.emoji.Emoji;
10+
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
11+
import net.dv8tion.jda.api.interactions.InteractionContextType;
12+
import net.dv8tion.jda.api.entities.Member;
13+
import net.dv8tion.jda.api.entities.Role;
14+
15+
public class GetPretesterRole extends SlashCommand{
16+
17+
public GetPretesterRole() {
18+
this.name = "get-pretester";
19+
this.help = "grants you pretester role";
20+
this.contexts = new InteractionContextType[] {
21+
InteractionContextType.GUILD
22+
};
23+
}
24+
25+
@Override
26+
protected void execute(SlashCommandEvent event) {
27+
event.reply("""
28+
By clicking the button below you agree to follow these rules:
29+
1. You agree to not go offtopic in the channel.
30+
2. You agree to only text there when the dev's ping the role.
31+
Any violation to those points will immediately result in a 7d timeout.
32+
""").addComponents(
33+
ActionRow.of(Button.success("ver", Emoji.fromUnicode("✅")))
34+
).setEphemeral(true)
35+
.queue((s) -> {
36+
Oreo.getWaiter()
37+
.waitForEvent(ButtonInteractionEvent.class,
38+
condition -> event.getUser().getIdLong()==condition.getUser().getIdLong(),
39+
action -> {
40+
if (action.getComponentId().equals("ver")) {
41+
Member m = action.getMember();
42+
Role r = Oreo.getPretesterRole();
43+
event.getGuild().addRoleToMember(m, r).queue(
44+
ss ->
45+
event.getHook()
46+
.sendMessage("success!")
47+
.setEphemeral(true)
48+
.queue(),
49+
ff ->
50+
event.getHook()
51+
.sendMessage("failure!! [%s]".formatted(ff))
52+
);
53+
}
54+
});
55+
});
56+
}
57+
}

src/main/java/net/amar/oreojava/commands/slash/owner/SetBotActivity.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import com.jagrosh.jdautilities.command.SlashCommand;
44
import com.jagrosh.jdautilities.command.SlashCommandEvent;
55
import net.amar.oreojava.Oreo;
6-
import net.amar.oreojava.commands.Categories;
76
import net.dv8tion.jda.api.entities.Activity;
87
import net.dv8tion.jda.api.interactions.InteractionContextType;
98
import net.dv8tion.jda.api.interactions.commands.OptionType;
@@ -62,4 +61,4 @@ protected void execute(@NotNull SlashCommandEvent event) {
6261
""").setEphemeral(true).queue();
6362
}
6463
}
65-
}
64+
}

0 commit comments

Comments
 (0)