Update Request.java
This commit is contained in:
parent
26dfc0013c
commit
ddcd1643c2
|
|
@ -19,17 +19,19 @@ import java.awt.*;
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class Request {
|
public class Request {
|
||||||
|
// TODO check if all labels on the modal are max 45 in length
|
||||||
@Getter
|
@Getter
|
||||||
private String id, category, channel, name, title, description, message;
|
private String id, category, channel, name, title, description, message;
|
||||||
|
|
||||||
public Modal modal(Member member) {
|
public Modal modal(Member member) {
|
||||||
TextInput requestTitle = TextInput
|
TextInput requestTitle = TextInput
|
||||||
.create("title", title, TextInputStyle.PARAGRAPH)
|
.create("title", title, TextInputStyle.SHORT)
|
||||||
|
.setPlaceholder(id)
|
||||||
|
.setRequired(false)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
TextInput requestMessage = TextInput
|
TextInput requestMessage = TextInput
|
||||||
.create("request", message.replaceAll("%member%", member.getEffectiveName()).subSequence(0, 45).toString(), TextInputStyle.PARAGRAPH)
|
.create("request", message, TextInputStyle.PARAGRAPH)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
return Modal.create("request:" + id, name)
|
return Modal.create("request:" + id, name)
|
||||||
|
|
@ -40,10 +42,12 @@ public class Request {
|
||||||
|
|
||||||
public void createThread(Member member, String title, String request) {
|
public void createThread(Member member, String title, String request) {
|
||||||
TextChannel channel = AltitudeBot.getInstance().getJDA().getGuildById(RequestConfig.REQUEST_GUILD_ID).getTextChannelById(getChannel());
|
TextChannel channel = AltitudeBot.getInstance().getJDA().getGuildById(RequestConfig.REQUEST_GUILD_ID).getTextChannelById(getChannel());
|
||||||
ThreadChannelAction threadChannelAction = channel.createThreadChannel(title);
|
if (title == null || title.isEmpty()) title = id;
|
||||||
|
String finalTitle = title;
|
||||||
|
ThreadChannelAction threadChannelAction = channel.createThreadChannel(finalTitle);
|
||||||
threadChannelAction.queue(threadChannel -> {
|
threadChannelAction.queue(threadChannel -> {
|
||||||
threadChannel.addThreadMember(member).queue();
|
threadChannel.addThreadMember(member).queue();
|
||||||
sendEmbed(threadChannel, title, request);
|
sendEmbed(threadChannel, finalTitle, request);
|
||||||
channel.deleteMessageById(threadChannel.getId()).queue();
|
channel.deleteMessageById(threadChannel.getId()).queue();
|
||||||
// TODO store the request somewhere so it can be grabbed later
|
// TODO store the request somewhere so it can be grabbed later
|
||||||
});
|
});
|
||||||
|
|
@ -53,7 +57,7 @@ public class Request {
|
||||||
// Pair<EmbedBuilder, ActionRow> pair = getRequestEmbed(channel.getId(), title, request);
|
// Pair<EmbedBuilder, ActionRow> pair = getRequestEmbed(channel.getId(), title, request);
|
||||||
// pairs are not really possible here :(
|
// pairs are not really possible here :(
|
||||||
EmbedBuilder embedBuilder = new EmbedBuilder();
|
EmbedBuilder embedBuilder = new EmbedBuilder();
|
||||||
embedBuilder.setTitle("title")
|
embedBuilder.setTitle(title)
|
||||||
.addField(getName(), request, false)
|
.addField(getName(), request, false)
|
||||||
.setColor(new Color(41, 43, 47));
|
.setColor(new Color(41, 43, 47));
|
||||||
channel.sendMessageEmbeds(embedBuilder.build()).queue(message1 ->
|
channel.sendMessageEmbeds(embedBuilder.build()).queue(message1 ->
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user