This repository has been archived by the owner on Sep 25, 2024. It is now read-only.
forked from Trip-kun/sinon
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(oatmeal): Implements an auto-thread creation feature that is tog… (
#46)
- Loading branch information
Showing
6 changed files
with
88 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
44 changes: 44 additions & 0 deletions
44
src/main/java/wtf/triplapeeck/oatmeal/commands/essential/SetAutoThread.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 wtf.triplapeeck.oatmeal.commands.essential; | ||
|
||
import net.dv8tion.jda.api.entities.User; | ||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent; | ||
import org.jetbrains.annotations.NotNull; | ||
import wtf.triplapeeck.oatmeal.DataCarriage; | ||
import wtf.triplapeeck.oatmeal.commands.Command; | ||
import wtf.triplapeeck.oatmeal.listeners.ThreadManager; | ||
|
||
public class SetAutoThread extends Command { | ||
@Override | ||
public void handler(MessageReceivedEvent event, DataCarriage carriage, ThreadManager listener) { | ||
if (ensureAdministrator(carriage) && ensureFirstArgument(carriage) && ensureThreadable(carriage)) { | ||
String preference = carriage.args[1]; | ||
if (preference.equalsIgnoreCase("enable") || preference.equalsIgnoreCase("disable")) { | ||
carriage.channelStorable.setAutoThread(preference.equalsIgnoreCase("enable")); | ||
carriage.channel.sendMessage("Messages in this channel now have auto-threading " + preference.toLowerCase() + "d.").queue(); | ||
} else { | ||
carriage.channel.sendMessage("You have to choose either enable or disable auto-threading.").queue(); | ||
} | ||
} | ||
} | ||
@NotNull | ||
@Override | ||
public CommandCategory getCategory() { return CommandCategory.ESSENTIAL;} | ||
|
||
@NotNull | ||
@Override | ||
public String getDocumentation() { | ||
return "Used to enable or disable auto-threading for your server" + | ||
"\nAuto threading causes a thread to be made for any message sent within this channel" + | ||
"\nUsage s!autothread [enable/disable]" + | ||
"\nUpdates the channel setting for currency" + | ||
"\nExample: s!autothread enable"; | ||
} | ||
|
||
@Override | ||
public @NotNull String getName() { return "autothread"; } | ||
|
||
@Override | ||
public @NotNull boolean hasPermission(DataCarriage carriage, User user) { | ||
return isAdministrator(carriage) && isThreadable(carriage); | ||
} | ||
} |
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
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