Skip to content

Commit

Permalink
Merge pull request #228 from beanbeanjuice/integration
Browse files Browse the repository at this point in the history
Ready for Release v2.4.0
  • Loading branch information
beanbeanjuice committed May 28, 2021
2 parents 3f2d358 + 1378d7c commit 11275ee
Show file tree
Hide file tree
Showing 25 changed files with 958 additions and 136 deletions.
13 changes: 8 additions & 5 deletions README.md
Expand Up @@ -199,6 +199,14 @@ As you can see, this was shown using the command `!!help order`. It shows each p
* `get-twitch-channels` - Get a list of the twitch channels you are currently receiving notifications for.
* `set-live-notifications-role` - Set the role to be mentioned when someone goes live.
##### 8. **MODERATION**
* `set-log-channel` - Sets the log channel for the guild.
* `set-update-channel` - Sets the current channel to the update channel. This means if you have `notify-on-update` set to `Enabled`, you will receive bot updates in this channel.
* `set-counting-channel` - Sets the current channel to the counting channel. This does exactly as it says. Try to count as high as you can without messing up!
* `set-poll-channel` - Sets the current channel to an active poll channel. This is needed if you want to run polls on your server!
* `set-raffle-channel` - Sets the current channel to an active raffle channel. This is needed if you want to run raffles on your server!
* `set-birthday-channel` - Sets the current channel to an active birthday channel. Be notified when one of the members in your server is having a birthday!
* `set-welcome-channel` - Sets the current channel to welcome users when they join!
* `edit-welcome-message` - Edits the welcome message that is sent when users join. (Make sure to check the usage for this command doing `help edit-welcome-message` because this one is a little complicated!)
* `set-moderator-role` - Set the moderator role for the server. This is needed so that users with this role can run commands that require a moderator role.
* `set-muted-role` - Set the muted role for the server. This is needed so that users with this role can be stopped from talking in channels. This requires you to set it this way in each channel. This will not mute them if the role does not have the right permissions.
* `change-prefix` - Change the prefix from the bot to your desired prefix.
Expand All @@ -207,12 +215,7 @@ As you can see, this was shown using the command `!!help order`. It shows each p
* `clear-chat` - Clear the chat. (Only currently works from 2-99 messages).
* `mute` - Mute a specified user.
* `un-mute` - Unmute a specified user.
* `set-update-channel` - Sets the current channel to the update channel. This means if you have `notify-on-update` set to `Enabled`, you will receive bot updates in this channel.
* `notify-on-update` - `Enable` or `Disable` bot notifications. This is `Enabled` by default.
* `set-counting-channel` - Sets the current channel to the counting channel. This does exactly as it says. Try to count as high as you can without messing up!
* `set-poll-channel` - Sets the current channel to an active poll channel. This is needed if you want to run polls on your server!
* `set-raffle-channel` - Sets the current channel to an active raffle channel. This is needed if you want to run raffles on your server!
* `set-birthday-channel` - Sets the current channel to an active birthday channel. Be notified when one of the members in your server is having a birthday!


<!-- ROADMAP -->
Expand Down
4 changes: 3 additions & 1 deletion sql/tables/guild_information.sql
Expand Up @@ -10,4 +10,6 @@ update_channel_id BIGINT DEFAULT 0,
counting_channel_id BIGINT DEFAULT 0,
poll_channel_id BIGINT DEFAULT 0,
raffle_channel_id BIGINT DEFAULT 0,
birthday_channel_id BIGINT DEFAULT 0);
birthday_channel_id BIGINT DEFAULT 0,
welcome_channel_id BIGINT DEFAULT 0,
log_channel_id BIGINT DEFAULT 0);
5 changes: 5 additions & 0 deletions sql/tables/welcome_information.sql
@@ -0,0 +1,5 @@
CREATE TABLE welcome_information
(guild_id BIGINT,
description TEXT null,
thumbnail_url TEXT null,
image_url TEXT null);
Expand Up @@ -6,6 +6,7 @@
import com.beanbeanjuice.utility.command.usage.Usage;
import com.beanbeanjuice.utility.command.usage.categories.CategoryType;
import com.beanbeanjuice.utility.command.usage.types.CommandType;
import com.beanbeanjuice.utility.logger.LogLevel;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.MessageEmbed;
Expand Down Expand Up @@ -57,6 +58,8 @@ public void handle(CommandContext ctx, ArrayList<String> args, User user, GuildM

CafeBot.getGeneralHelper().pmUser(punishee, "You have been banned: " + reason.toString());
event.getChannel().sendMessage(successfulBanWithReasonEmbed(punishee, user, reason.toString())).queue();
CafeBot.getGuildHandler().getCustomGuild(event.getGuild()).log(this, LogLevel.INFO, "User Banned", "`" + punishee.getAsTag() + "` was banned by " +
user.getAsMention() + " for: `" + reason.toString() + "`");
}

@NotNull
Expand Down Expand Up @@ -96,7 +99,7 @@ public String getDescription() {

@Override
public String exampleUsage() {
return "`!!ban @beanbeanjuice 13 you are trash`";
return "`!!ban @beanbeanjuice` or `!!ban @beanbeanjuice you are trash`";
}

@Override
Expand Down
Expand Up @@ -6,6 +6,7 @@
import com.beanbeanjuice.utility.command.usage.Usage;
import com.beanbeanjuice.utility.command.usage.categories.CategoryType;
import com.beanbeanjuice.utility.command.usage.types.CommandType;
import com.beanbeanjuice.utility.logger.LogLevel;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.MessageEmbed;
Expand Down Expand Up @@ -57,6 +58,8 @@ public void handle(CommandContext ctx, ArrayList<String> args, User user, GuildM

CafeBot.getGeneralHelper().pmUser(punishee, "You have been kicked: " + reason.toString());
event.getChannel().sendMessage(successfulKickEmbed(punishee, user, reason.toString())).queue();
CafeBot.getGuildHandler().getCustomGuild(event.getGuild()).log(this, LogLevel.INFO, "User Kicked", "`" + punishee.getAsTag() + "` was kicked by " +
user.getAsMention() + " for: `" + reason.toString() + "`");
}

@NotNull
Expand Down Expand Up @@ -96,14 +99,14 @@ public String getDescription() {

@Override
public String exampleUsage() {
return "`!!kick @beanbeanjuice you're trash`";
return "`!!kick @beanbeanjuice` or `!!kick @beanbeanjuice you're trash`";
}

@Override
public Usage getUsage() {
Usage usage = new Usage();
usage.addUsage(CommandType.USER, "Discord User", true);
usage.addUsage(CommandType.SENTENCE, "Reason", true);
usage.addUsage(CommandType.SENTENCE, "Reason", false);
return usage;
}

Expand Down
Expand Up @@ -5,6 +5,7 @@
import com.beanbeanjuice.utility.command.ICommand;
import com.beanbeanjuice.utility.command.usage.Usage;
import com.beanbeanjuice.utility.command.usage.categories.CategoryType;
import com.beanbeanjuice.utility.command.usage.types.CommandType;
import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;

Expand All @@ -22,10 +23,33 @@ public void handle(CommandContext ctx, ArrayList<String> args, User user, GuildM
if (!CafeBot.getGeneralHelper().isAdministrator(event.getMember(), event)) {
return;
}

if (args.size() == 1) {
String commandTerm = args.get(0);
if (commandTerm.equalsIgnoreCase("remove") || commandTerm.equalsIgnoreCase("disable") || commandTerm.equalsIgnoreCase("0")) {
if (CafeBot.getGuildHandler().getCustomGuild(event.getGuild()).setBirthdayChannelID("0")) {
event.getChannel().sendMessage(CafeBot.getGeneralHelper().successEmbed(
"Removed Birthday Channel",
"The current birthday channel has been unset."
)).queue();
return;
}
event.getChannel().sendMessage(CafeBot.getGeneralHelper().sqlServerError()).queue();
return;
}

event.getChannel().sendMessage(CafeBot.getGeneralHelper().errorEmbed(
"Incorrect Extra Term",
"You can run this command without extra arguments. You had the extra argument `" + commandTerm + "`. " +
"The available command terms for this command are `disable`, `remove`, and `0`."
)).queue();
return;
}

if (CafeBot.getGuildHandler().getCustomGuild(event.getGuild()).setBirthdayChannelID(event.getChannel().getId())) {
event.getChannel().sendMessage(CafeBot.getGeneralHelper().successEmbed(
"Updated Birthday Channel",
"This channel has been set to an active birthday channel. To remove it, simply delete the channel."
"This channel has been set to an active birthday channel."
)).queue();
return;
}
Expand All @@ -51,12 +75,14 @@ public String getDescription() {

@Override
public String exampleUsage() {
return "`!!set-birthday-channel`";
return "`!!set-birthday-channel` or `!!set-birthday-channel 0`";
}

@Override
public Usage getUsage() {
return new Usage();
Usage usage = new Usage();
usage.addUsage(CommandType.TEXT, "disable/remove/0", false);
return usage;
}

@Override
Expand Down
Expand Up @@ -5,6 +5,7 @@
import com.beanbeanjuice.utility.command.ICommand;
import com.beanbeanjuice.utility.command.usage.Usage;
import com.beanbeanjuice.utility.command.usage.categories.CategoryType;
import com.beanbeanjuice.utility.command.usage.types.CommandType;
import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;

Expand All @@ -19,12 +20,33 @@ public class SetCountingChannelCommand implements ICommand {

@Override
public void handle(CommandContext ctx, ArrayList<String> args, User user, GuildMessageReceivedEvent event) {

if (!CafeBot.getGeneralHelper().isAdministrator(event.getMember(), event)) {
return;
}

if (CafeBot.getGuildHandler().getCustomGuild(event.getGuild()).setCountingChannel(event.getChannel())) {
if (args.size() == 1) {
String commandTerm = args.get(0);
if (commandTerm.equalsIgnoreCase("remove") || commandTerm.equalsIgnoreCase("disable") || commandTerm.equalsIgnoreCase("0")) {
if (CafeBot.getGuildHandler().getCustomGuild(event.getGuild()).setCountingChannel("0")) {
event.getChannel().sendMessage(CafeBot.getGeneralHelper().successEmbed(
"Removed Counting Channel",
"Successfully removed the counting channel."
)).queue();
return;
}
event.getChannel().sendMessage(CafeBot.getGeneralHelper().sqlServerError()).queue();
return;
}

event.getChannel().sendMessage(CafeBot.getGeneralHelper().errorEmbed(
"Incorrect Extra Term",
"You can run this command without extra arguments. You had the extra argument `" + commandTerm + "`. " +
"The available command terms for this command are `disable`, `remove`, and `0`."
)).queue();
return;
}

if (CafeBot.getGuildHandler().getCustomGuild(event.getGuild()).setCountingChannel(event.getChannel().getId())) {
event.getChannel().sendMessage(CafeBot.getGeneralHelper().successEmbed(
"Updated Counting Channel",
"Successfully set the counting channel to this channel. " +
Expand All @@ -34,12 +56,7 @@ public void handle(CommandContext ctx, ArrayList<String> args, User user, GuildM
CafeBot.getCountingHelper().createNewRow(event.getGuild());
return;
}

event.getChannel().sendMessage(CafeBot.getGeneralHelper().errorEmbed(
"Error Updating Counting Channel",
"There was an error updating the counting channel. Please try again."
)).queue();

event.getChannel().sendMessage(CafeBot.getGeneralHelper().sqlServerError()).queue();
}

@Override
Expand All @@ -61,12 +78,14 @@ public String getDescription() {

@Override
public String exampleUsage() {
return "`!!setcountingchannel`";
return "`!!setcountingchannel` or `!!set-counting-channel 0`";
}

@Override
public Usage getUsage() {
return new Usage();
Usage usage = new Usage();
usage.addUsage(CommandType.TEXT, "disable/remove/0", false);
return usage;
}

@Override
Expand Down
@@ -0,0 +1,93 @@
package com.beanbeanjuice.command.moderation;

import com.beanbeanjuice.main.CafeBot;
import com.beanbeanjuice.utility.command.CommandContext;
import com.beanbeanjuice.utility.command.ICommand;
import com.beanbeanjuice.utility.command.usage.Usage;
import com.beanbeanjuice.utility.command.usage.categories.CategoryType;
import com.beanbeanjuice.utility.command.usage.types.CommandType;
import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;

import java.util.ArrayList;

/**
* An {@link ICommand} used to set the log {@link net.dv8tion.jda.api.entities.TextChannel TextChannel}.
*
* @author beanbeanjuice
*/
public class SetLogChannelCommand implements ICommand {

@Override
public void handle(CommandContext ctx, ArrayList<String> args, User user, GuildMessageReceivedEvent event) {
if (!CafeBot.getGeneralHelper().isAdministrator(event.getMember(), event)) {
return;
}

if (args.size() == 1) {
String commandTerm = args.get(0);
if (commandTerm.equalsIgnoreCase("remove") || commandTerm.equalsIgnoreCase("disable") || commandTerm.equalsIgnoreCase("0")) {
if (CafeBot.getGuildHandler().getCustomGuild(event.getGuild()).setLogChannelID("0")) {
event.getChannel().sendMessage(CafeBot.getGeneralHelper().successEmbed(
"Removed Log Channel",
"The log channel has been successfully removed."
)).queue();
return;
}
event.getChannel().sendMessage(CafeBot.getGeneralHelper().sqlServerError()).queue();
return;
}

event.getChannel().sendMessage(CafeBot.getGeneralHelper().errorEmbed(
"Incorrect Extra Term",
"You can run this command without extra arguments. You had the extra argument `" + commandTerm + "`. " +
"The available command terms for this command are `disable`, `remove`, and `0`."
)).queue();
return;
}

if (CafeBot.getGuildHandler().getCustomGuild(event.getGuild()).setLogChannelID(event.getChannel().getId())) {
event.getChannel().sendMessage(CafeBot.getGeneralHelper().successEmbed(
"Set Log Channel",
"The current channel has been set to a `log` channel!"
)).queue();
return;
}

event.getChannel().sendMessage(CafeBot.getGeneralHelper().sqlServerError()).queue();
}

@Override
public String getName() {
return "set-log-channel";
}

@Override
public ArrayList<String> getAliases() {
ArrayList<String> arrayList = new ArrayList<>();
arrayList.add("setlogchannel");
return arrayList;
}

@Override
public String getDescription() {
return "Set the log channel for the guild!";
}

@Override
public String exampleUsage() {
return "`!!set-log-channel` or `!!set-log-channel 0`";
}

@Override
public Usage getUsage() {
Usage usage = new Usage();
usage.addUsage(CommandType.TEXT, "disable/remove/0", false);
return usage;
}

@Override
public CategoryType getCategoryType() {
return CategoryType.MODERATION;
}
}
Expand Up @@ -33,6 +33,18 @@ public void handle(CommandContext ctx, ArrayList<String> args, User user, GuildM

Role role = event.getGuild().getRoleById(argument);

if (args.get(0).equals("0")) {
if (CafeBot.getGuildHandler().getCustomGuild(event.getGuild()).setModeratorRoleID("0")) {
event.getChannel().sendMessage(CafeBot.getGeneralHelper().successEmbed(
"Removed Moderator Role",
"Successfully removed the moderator role."
)).queue();
return;
}
event.getChannel().sendMessage(CafeBot.getGeneralHelper().sqlServerError()).queue();
return;
}

if (role == null) {
event.getChannel().sendMessage(unknownRoleEmbed(argument)).queue();
return;
Expand Down Expand Up @@ -85,7 +97,7 @@ public String getDescription() {

@Override
public String exampleUsage() {
return "`!!setmoderatorrole @ModRole`";
return "`!!setmoderatorrole 0` or `!!setmoderatorrole @ModRole`";
}

@Override
Expand Down

0 comments on commit 11275ee

Please sign in to comment.