-
-
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.
Additionally, the user join listener has been added. The welcome and it's listener are now fully functional.
- Loading branch information
1 parent
e5e4502
commit 100d912
Showing
15 changed files
with
459 additions
and
136 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
96 changes: 0 additions & 96 deletions
96
src/main/java/com/beanbeanjuice/cafebot/commands/basic/EmbedCommand.java
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...juice/cafebot/commands/fun/AICommand.java → .../cafebot/commands/settings/AICommand.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
75 changes: 75 additions & 0 deletions
75
src/main/java/com/beanbeanjuice/cafebot/commands/settings/welcome/WelcomeCommand.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,75 @@ | ||
package com.beanbeanjuice.cafebot.commands.settings.welcome; | ||
|
||
import com.beanbeanjuice.cafebot.CafeBot; | ||
import com.beanbeanjuice.cafebot.commands.settings.welcome.channel.WelcomeChannelRemoveSubCommand; | ||
import com.beanbeanjuice.cafebot.commands.settings.welcome.channel.WelcomeChannelSetSubCommand; | ||
import com.beanbeanjuice.cafebot.commands.settings.welcome.message.WelcomeMessageRemoveSubCommand; | ||
import com.beanbeanjuice.cafebot.commands.settings.welcome.message.WelcomeMessageSetSubCommand; | ||
import com.beanbeanjuice.cafebot.utility.commands.*; | ||
import net.dv8tion.jda.api.Permission; | ||
|
||
public class WelcomeCommand extends Command implements ICommand { | ||
|
||
public WelcomeCommand(final CafeBot cafeBot) { | ||
super(cafeBot); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "welcome"; | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return "Edit the welcome settings!"; | ||
} | ||
|
||
@Override | ||
public CommandCategory getCategory() { | ||
return CommandCategory.SETTINGS; | ||
} | ||
|
||
@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 ICommand.super.getSubCommands(); | ||
} | ||
|
||
@Override | ||
public SubCommandGroup[] getSubCommandGroups() { | ||
SubCommandGroup channelGroup = new SubCommandGroup("channel", "Edit the welcome channel."); | ||
channelGroup.addSubCommands(new ISubCommand[] { | ||
new WelcomeChannelSetSubCommand(cafeBot), | ||
new WelcomeChannelRemoveSubCommand(cafeBot) | ||
}); | ||
|
||
SubCommandGroup messageGroup = new SubCommandGroup("message", "Edit the welcome message."); | ||
messageGroup.addSubCommands(new ISubCommand[] { | ||
new WelcomeMessageSetSubCommand(cafeBot), | ||
new WelcomeMessageRemoveSubCommand(cafeBot) | ||
}); | ||
|
||
return new SubCommandGroup[] { channelGroup, messageGroup }; | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...anbeanjuice/cafebot/commands/settings/welcome/channel/WelcomeChannelRemoveSubCommand.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.settings.welcome.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 WelcomeChannelRemoveSubCommand extends Command implements ISubCommand { | ||
|
||
public WelcomeChannelRemoveSubCommand(final CafeBot cafeBot) { | ||
super(cafeBot); | ||
} | ||
|
||
@Override | ||
public void handle(SlashCommandInteractionEvent event) { | ||
cafeBot.getCafeAPI().getGuildsEndpoint().updateGuildInformation(event.getGuild().getId(), GuildInformationType.WELCOME_CHANNEL_ID, "0") | ||
.thenAcceptAsync((ignored) -> { | ||
event.getHook().sendMessageEmbeds(Helper.successEmbed( | ||
"Welcome Channel Removed", | ||
"The welcome channel has been removed!" | ||
)).queue(); | ||
}) | ||
.exceptionallyAsync((e) -> { | ||
event.getHook().sendMessageEmbeds(Helper.errorEmbed( | ||
"Error Removing Welcome Channel", | ||
String.format("There was an error setting the welcome channel: %s", e.getMessage()) | ||
)).queue(); | ||
return null; | ||
}); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "remove"; | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return "Remove the welcome channel."; | ||
} | ||
|
||
} |
60 changes: 60 additions & 0 deletions
60
.../beanbeanjuice/cafebot/commands/settings/welcome/channel/WelcomeChannelSetSubCommand.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.settings.welcome.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 WelcomeChannelSetSubCommand extends Command implements ISubCommand { | ||
|
||
public WelcomeChannelSetSubCommand(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()); | ||
|
||
cafeBot.getCafeAPI().getGuildsEndpoint().updateGuildInformation(event.getGuild().getId(), GuildInformationType.WELCOME_CHANNEL_ID, channel.getId()) | ||
.thenAcceptAsync((ignored) -> { | ||
event.getHook().sendMessageEmbeds(Helper.successEmbed( | ||
"Welcome Channel Set", | ||
String.format("The welcome channel has been set to %s.", channel.getAsMention()) | ||
)).queue(); | ||
}) | ||
.exceptionallyAsync((e) -> { | ||
event.getHook().sendMessageEmbeds(Helper.errorEmbed( | ||
"Error Setting Welcome Channel", | ||
String.format("There was an error setting the welcome channel: %s", e.getMessage()) | ||
)).queue(); | ||
return null; | ||
}); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "set"; | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return "Set the welcome channel!"; | ||
} | ||
|
||
@Override | ||
public OptionData[] getOptions() { | ||
return new OptionData[] { | ||
new OptionData(OptionType.CHANNEL, "channel", "The channel to set the welcome channel to.", false) | ||
}; | ||
} | ||
|
||
} |
Oops, something went wrong.