Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
67 lines (62 sloc) 2.61 KB
#! ========================================
#! Someone
handler = (msg, match, Haruka) ->
#! Choose a random member
if not msg.guild? then return msg.reply [
"You have to be in a server to use this command."
"This command only works in servers, not DMs or GroupDMs."
"It doesn’t look like you’re in a server, so I can’t run that command."
].choose()
if not msg.member.hasPermission 'MENTION_EVERYONE'
return msg.reply [
"Sorry, you can’t (ab)use that command."
"You’re not allowed to use that command."
"You must be able to mention everyone before using that command."
].choose()
args = match.input.tokenize()[1]
members = msg.channel?.members
lucky = switch args
when "online"
members?.filter((m) -> m?.presence.status is 'online')
when "offline"
members?.filter((m) -> m?.presence.status is 'offline')
when "dnd"
members?.filter((m) -> m?.presence.status is 'dnd')
when "idle"
members?.filter((m) -> m?.presence.status is 'idle')
else
members?.filter((m) -> m?.presence.status in ['online', 'idle'])
if lucky = lucky.random()
msg.channel.send [
"#{lucky}, you’re the chosen one."
"#{lucky}, you’ve been summoned."
"#{lucky}, consider yourself lucky."
].choose()
else
msg.reply [
"Hmm, I couldn’t choose a random user who’s `#{args ? 'online'}`."
"I can’t seem to find someone with those criteria."
"I didn’t find anyone who’s `#{args ? 'online'}`."
].choose() + " See `-h h someone` for details on this command."
module.exports = {
name: "Someone"
regex: /^@?(someone|somebody)(\s+|$)/i
handler: handler
help:
short: "-h someone [p] ::
Mentions a random user."
long: """
```asciidoc
=== Help for Someone ===
*Aliases*: @someone, @somebody, someone, somebody
-h someone :: Mentions a random user that’s online.
-h someone online :: Mentions a random user that’s online.
-h someone offline :: Mentions a random user that’s offline.
-h someone idle :: Mentions a random user that’s idle.
-h someone dnd :: Mentions a random user that’s \
in Do Not Disturb.
*Note*: This function only works in servers, not DMs or GroupDMs.
*Note*: You must be able to use @everyone before using this command.
```
"""
}
You can’t perform that action at this time.