Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
86 lines (79 sloc) 3.07 KB
#! ========================================
#! Emote
execRegex = /^(emote|emoji)(\s+|$)/i
handler = (msg, match, Haruka) ->
args = match.input.replace(execRegex, '')
#! Create / Delete
args = args.split(/\s+/gi)
switch args[0]
when "create"
#! Create emote
name = args[1]
image = msg.attachments.array()?[0]?.url or args[2]
#! Break if no image
if (not name?) or (not image?)
return msg.reply "Attachment or URL wasn't provided.
Use `-h help emote` for help with this command."
msg.guild.createEmoji(image, name, null,
"Haruka: Created emote as asked by
#{} in Message<#{}>"
.then ->
e = msg.guild.emojis.find((e) -> is name) "Emote created: `:#{name}:`"
.then (sent) -> sent.react e
.catch (err) -> "An error occurred: \n```\n#{err}\n```"
when "delete"
#! Delete emote
name = args[1]
if (not name?)
return "
An emote name wasn't provided.
Please provide an emote name. Use `-h help emote`
for help with this command."
e = msg.guild.emojis.find((e) -> is name)
if e?
"Haruka: Deleted emote as asked by
#{} in Message<#{}>"
.then -> "Successfully deleted emote `:#{name}:`"
.catch (err) -> "An error occurred: \n```\n#{err}\n```"
msg.reply [
"That emote (`:#{name}:`) doesn’t exist."
"I can’t delete an emote that doesn’t exist!"
"That emote isn’t from this server."
msg.reply "Expected command to be either `create`
or `delete`, was instead `#{args[0] or "empty"}`.
Use `-h help emote` for help with this command."
module.exports = {
name: "Emote"
regex: execRegex
handler: handler
short: "-h emote <...> ::
Manages emotes."
long: """
=== Help for Emote ===
*Aliases*: emote, emoji
-h emote create <name> ::
Creates an emote. This requires an image to be attached.
-h emote create <name> <url> ::
Creates an emote with the image located at the URL.
-h emote delete <name> ::
Deletes an emote.
-h emote create sayori_hmm
-h emote delete sayori_hmm
Note: When using `create`, attachments take precedence.
You can’t perform that action at this time.