-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the Custom Channel List Command
- Loading branch information
1 parent
cca3f70
commit 681cb19
Showing
14 changed files
with
402 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
src/main/java/com/beanbeanjuice/cafebot/commands/moderation/polls/PollCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package com.beanbeanjuice.cafebot.commands.moderation.polls; | ||
|
||
import com.beanbeanjuice.cafebot.CafeBot; | ||
import com.beanbeanjuice.cafebot.commands.moderation.polls.channel.PollChannelRemoveSubCommand; | ||
import com.beanbeanjuice.cafebot.commands.moderation.polls.channel.PollChannelSetSubCommand; | ||
import com.beanbeanjuice.cafebot.utility.commands.*; | ||
import net.dv8tion.jda.api.Permission; | ||
|
||
public class PollCommand extends Command implements ICommand { | ||
|
||
public PollCommand(final CafeBot cafeBot) { | ||
super(cafeBot); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "poll"; | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return "Edit the poll channel or create a poll!"; | ||
} | ||
|
||
@Override | ||
public CommandCategory getCategory() { | ||
return CommandCategory.MODERATION; | ||
} | ||
|
||
@Override | ||
public Permission[] getPermissions() { | ||
return new Permission[] { | ||
Permission.MANAGE_SERVER | ||
}; | ||
} | ||
|
||
@Override | ||
public boolean isEphemeral() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean isNSFW() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean allowDM() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public ISubCommand[] getSubCommands() { | ||
return new ISubCommand[] { | ||
new PollCreateSubCommand(cafeBot) | ||
}; | ||
} | ||
|
||
@Override | ||
public SubCommandGroup[] getSubCommandGroups() { | ||
SubCommandGroup channelGroup = new SubCommandGroup("channel", "Edit the poll channel."); | ||
channelGroup.addSubCommands(new ISubCommand[] { | ||
new PollChannelSetSubCommand(cafeBot), | ||
new PollChannelRemoveSubCommand(cafeBot) | ||
}); | ||
|
||
return ICommand.super.getSubCommandGroups(); | ||
} | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
...ain/java/com/beanbeanjuice/cafebot/commands/moderation/polls/PollCreateModalListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.beanbeanjuice.cafebot.commands.moderation.polls; | ||
|
||
import com.beanbeanjuice.cafeapi.wrapper.endpoints.polls.PollsEndpoint; | ||
import com.beanbeanjuice.cafeapi.wrapper.endpoints.welcomes.GuildWelcome; | ||
import com.beanbeanjuice.cafeapi.wrapper.endpoints.welcomes.WelcomesEndpoint; | ||
import com.beanbeanjuice.cafebot.utility.helper.Helper; | ||
import com.beanbeanjuice.cafebot.utility.listeners.WelcomeListener; | ||
import net.dv8tion.jda.api.events.interaction.ModalInteractionEvent; | ||
import net.dv8tion.jda.api.hooks.ListenerAdapter; | ||
|
||
import java.util.Map; | ||
|
||
public class PollCreateModalListener extends ListenerAdapter { | ||
|
||
private final PollsEndpoint pollsEndpoint; | ||
|
||
public PollCreateModalListener(final PollsEndpoint pollsEndpoint) { | ||
this.pollsEndpoint = pollsEndpoint; | ||
} | ||
|
||
@Override | ||
public void onModalInteraction(ModalInteractionEvent event) { | ||
if (!event.getModalId().startsWith("cafeBot:modal:polls:create")) return; | ||
|
||
|
||
} | ||
|
||
} |
74 changes: 74 additions & 0 deletions
74
src/main/java/com/beanbeanjuice/cafebot/commands/moderation/polls/PollCreateSubCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package com.beanbeanjuice.cafebot.commands.moderation.polls; | ||
|
||
import com.beanbeanjuice.cafebot.CafeBot; | ||
import com.beanbeanjuice.cafebot.utility.commands.Command; | ||
import com.beanbeanjuice.cafebot.utility.commands.ISubCommand; | ||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; | ||
import net.dv8tion.jda.api.interactions.components.ActionRow; | ||
import net.dv8tion.jda.api.interactions.components.text.TextInput; | ||
import net.dv8tion.jda.api.interactions.components.text.TextInputStyle; | ||
import net.dv8tion.jda.api.interactions.modals.Modal; | ||
|
||
public class PollCreateSubCommand extends Command implements ISubCommand { | ||
|
||
public PollCreateSubCommand(CafeBot cafeBot) { | ||
super(cafeBot); | ||
} | ||
|
||
@Override | ||
public void handle(SlashCommandInteractionEvent event) { | ||
// TODO: This might not be needed anymore. | ||
// TextInput title = TextInput.create("title", "Title", TextInputStyle.SHORT) | ||
// .setPlaceholder("Welcome to the server, {user}!") | ||
// .setRequired(false) | ||
// .build(); | ||
// | ||
// TextInput description = TextInput.create("description", "Description", TextInputStyle.PARAGRAPH) | ||
// .setPlaceholder("Welcome {user} to the server!\nThese are our rules...") | ||
// .setRequired(false) | ||
// .build(); | ||
// | ||
// TextInput message = TextInput.create("message", "Message", TextInputStyle.PARAGRAPH) | ||
// .setPlaceholder("@SomeRole, {user} just joined!") | ||
// .setRequired(false) | ||
// .build(); | ||
// | ||
// TextInput largeImage = TextInput.create("image-url", "Large Image", TextInputStyle.SHORT) | ||
// .setPlaceholder("https://some.image.url") | ||
// .setRequired(false) | ||
// .build(); | ||
// | ||
// TextInput smallImage = TextInput.create("thumbnail-url", "Small Image", TextInputStyle.SHORT) | ||
// .setPlaceholder("https://some.image.url") | ||
// .setRequired(false) | ||
// .build(); | ||
// | ||
// Modal modal = Modal.create("cafeBot:modal:welcome:message:" + this.getName(), "Edit Welcome Message Content") | ||
// .addComponents( | ||
// ActionRow.of(title), | ||
// ActionRow.of(description), | ||
// ActionRow.of(message), | ||
// ActionRow.of(largeImage), | ||
// ActionRow.of(smallImage) | ||
// ) | ||
// .build(); | ||
// | ||
// event.replyModal(modal).queue(); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "create"; | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return "Create a poll!"; | ||
} | ||
|
||
@Override | ||
public boolean isModal() { | ||
return true; | ||
} | ||
|
||
} |
44 changes: 44 additions & 0 deletions
44
.../beanbeanjuice/cafebot/commands/moderation/polls/channel/PollChannelRemoveSubCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.beanbeanjuice.cafebot.commands.moderation.polls.channel; | ||
|
||
import com.beanbeanjuice.cafeapi.wrapper.endpoints.guilds.GuildInformationType; | ||
import com.beanbeanjuice.cafebot.CafeBot; | ||
import com.beanbeanjuice.cafebot.utility.commands.Command; | ||
import com.beanbeanjuice.cafebot.utility.commands.ISubCommand; | ||
import com.beanbeanjuice.cafebot.utility.helper.Helper; | ||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; | ||
|
||
public class PollChannelRemoveSubCommand extends Command implements ISubCommand { | ||
|
||
public PollChannelRemoveSubCommand(final CafeBot cafeBot) { | ||
super(cafeBot); | ||
} | ||
|
||
@Override | ||
public void handle(SlashCommandInteractionEvent event) { | ||
this.cafeBot.getCafeAPI().getGuildsEndpoint().updateGuildInformation(event.getGuild().getId(), GuildInformationType.POLL_CHANNEL_ID, "0") | ||
.thenAcceptAsync((ignored) -> { | ||
event.getHook().sendMessageEmbeds(Helper.successEmbed( | ||
"Poll Channel Removed", | ||
"The poll channel has been successfully removed." | ||
)).queue(); | ||
}) | ||
.exceptionallyAsync((e) -> { | ||
event.getHook().sendMessageEmbeds(Helper.errorEmbed( | ||
"Error Removing Poll Channel", | ||
String.format("There was an error removing the poll channel: %s", e.getMessage()) | ||
)).queue(); | ||
return null; | ||
}); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "remove"; | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return "Remove the poll channel."; | ||
} | ||
|
||
} |
60 changes: 60 additions & 0 deletions
60
...com/beanbeanjuice/cafebot/commands/moderation/polls/channel/PollChannelSetSubCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.beanbeanjuice.cafebot.commands.moderation.polls.channel; | ||
|
||
import com.beanbeanjuice.cafeapi.wrapper.endpoints.guilds.GuildInformationType; | ||
import com.beanbeanjuice.cafebot.CafeBot; | ||
import com.beanbeanjuice.cafebot.utility.commands.Command; | ||
import com.beanbeanjuice.cafebot.utility.commands.ISubCommand; | ||
import com.beanbeanjuice.cafebot.utility.helper.Helper; | ||
import net.dv8tion.jda.api.entities.channel.unions.GuildChannelUnion; | ||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; | ||
import net.dv8tion.jda.api.interactions.commands.OptionMapping; | ||
import net.dv8tion.jda.api.interactions.commands.OptionType; | ||
import net.dv8tion.jda.api.interactions.commands.build.OptionData; | ||
|
||
import java.util.Optional; | ||
|
||
public class PollChannelSetSubCommand extends Command implements ISubCommand { | ||
|
||
public PollChannelSetSubCommand(final CafeBot cafeBot) { | ||
super(cafeBot); | ||
} | ||
|
||
@Override | ||
public void handle(SlashCommandInteractionEvent event) { | ||
Optional<OptionMapping> channelMapping = Optional.ofNullable(event.getOption("channel")); | ||
GuildChannelUnion channel = channelMapping.map(OptionMapping::getAsChannel).orElse((GuildChannelUnion) event.getChannel()); | ||
|
||
this.cafeBot.getCafeAPI().getGuildsEndpoint().updateGuildInformation(event.getGuild().getId(), GuildInformationType.POLL_CHANNEL_ID, channel.getId()) | ||
.thenAcceptAsync((ignored) -> { | ||
event.getHook().sendMessageEmbeds(Helper.successEmbed( | ||
"Poll Channel Set", | ||
String.format("The poll channel has been set to %s. To create a poll run **/poll create**!", channel.getAsMention()) | ||
)).queue(); | ||
}) | ||
.exceptionallyAsync((e) -> { | ||
event.getHook().sendMessageEmbeds(Helper.errorEmbed( | ||
"Error Setting Poll Channel", | ||
String.format("There was an error setting the poll channel: %s", e.getMessage()) | ||
)).queue(); | ||
return null; | ||
}); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "set"; | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return "Set the poll channel!"; | ||
} | ||
|
||
@Override | ||
public OptionData[] getOptions() { | ||
return new OptionData[] { | ||
new OptionData(OptionType.CHANNEL, "channel", "The channel you want to set the poll channel to.", false) | ||
}; | ||
} | ||
|
||
} |
4 changes: 4 additions & 0 deletions
4
src/main/java/com/beanbeanjuice/cafebot/commands/moderation/raffles/RaffleCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.beanbeanjuice.cafebot.commands.moderation.raffles; | ||
|
||
public class RaffleCommand { | ||
} |
4 changes: 4 additions & 0 deletions
4
...in/java/com/beanbeanjuice/cafebot/commands/moderation/raffles/RaffleCreateSubCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.beanbeanjuice.cafebot.commands.moderation.raffles; | ||
|
||
public class RaffleCreateSubCommand { | ||
} |
4 changes: 4 additions & 0 deletions
4
...nbeanjuice/cafebot/commands/moderation/raffles/channel/RaffleChannelRemoveSubCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.beanbeanjuice.cafebot.commands.moderation.raffles.channel; | ||
|
||
public class RaffleChannelRemoveSubCommand { | ||
} |
4 changes: 4 additions & 0 deletions
4
...beanbeanjuice/cafebot/commands/moderation/raffles/channel/RaffleChannelSetSubCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.beanbeanjuice.cafebot.commands.moderation.raffles.channel; | ||
|
||
public class RaffleChannelSetSubCommand { | ||
} |
Oops, something went wrong.