Last active
July 13, 2019 15:27
-
-
Save Arraying/6c4fd231f08a8f2f612de04eca6aa5c7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| var CHANNEL_ID = "PUT_THE_CHANNEL_ID_HERE"; | |
| var FORMAT = "**User:** %user%\n**Message:** %message%"; | |
| var content = message.getContent(); | |
| var spaceFound = content.indexOf(" "); | |
| if(spaceFound < 0) { | |
| channel.message("Please provide a message."); | |
| return; | |
| } | |
| var toForward = content.substring(spaceFound).trim(); | |
| toForward = FORMAT.replace("%user%", "<@" + user.getID() + ">").replace("%message%", toForward); | |
| if(toForward.length() > 2000) { | |
| toForward = toForward.substring(0, 2000); | |
| } | |
| var target = guild.getTextChannel(CHANNEL_ID); | |
| if(target == null) { | |
| channel.message("Invalid setup. Contact a server administrator."); | |
| return; | |
| } | |
| target.message(toForward); | |
| channel.message("The message has been forwarded."); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment