Created
April 4, 2016 18:07
-
-
Save langerhans/f89c7cee337ea66172cf4eba85fa81d7 to your computer and use it in GitHub Desktop.
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
package de.langerhans.discord.doge | |
import sx.blah.discord.api.IDiscordClient | |
import sx.blah.discord.handle.impl.events.MessageReceivedEvent | |
import sx.blah.discord.handle.obj.IChannel | |
/** | |
* Created by maxke on 04.04.2016. | |
* Some useful extensions for Discord4J | |
*/ | |
/** | |
* Get a channel on this client by its name | |
* | |
* @param name Channel name | |
* @param includePrivate Include private channels in the search | |
* @return The channel or null if it doesn't exist | |
*/ | |
fun IDiscordClient.getChannelByName(name: String, includePrivate: Boolean): IChannel? { | |
val filtered = this.getChannels(includePrivate).filter { it.name == name } | |
if (filtered.size == 1) { | |
return filtered.first() | |
} | |
return null | |
} | |
/** | |
* Reply to a received message. Basically just sends a message to the channel | |
* that triggered this event. | |
* | |
* @param text The text you want to reply with | |
*/ | |
fun MessageReceivedEvent.reply(text: String) { | |
this.message.channel.sendMessage(text) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment