harmony/test/cmds/addemoji.ts

27 lines
823 B
TypeScript
Raw Normal View History

2021-04-04 05:52:47 +00:00
import { Command, CommandContext } from '../../mod.ts'
export default class AddEmojiCommand extends Command {
name = 'addemoji'
2020-12-02 12:29:52 +00:00
aliases = ['ae', 'emojiadd']
args = 2
guildOnly = true
execute(ctx: CommandContext): any {
const name = ctx.args[0]
2020-11-08 11:36:30 +00:00
if (name === undefined) return ctx.message.reply('No name was given!')
const url = ctx.argString.slice(name.length).trim()
2020-11-08 11:36:30 +00:00
if (url === '') return ctx.message.reply('No URL was given!')
2020-12-02 12:29:52 +00:00
ctx.message.guild?.emojis
.create(name, url)
.then((emoji) => {
2020-11-08 11:36:30 +00:00
if (emoji === undefined) throw new Error('Unknown')
2020-12-02 12:29:52 +00:00
ctx.message.reply(
2020-12-28 22:02:43 +00:00
`Successfully added emoji ${emoji.toString()} ${emoji.name}!`
2020-12-02 12:29:52 +00:00
)
})
.catch((e) => {
ctx.message.reply(`Failed to add emoji. Reason: ${e.message}`)
2020-12-02 12:29:52 +00:00
})
}
2020-12-02 12:29:52 +00:00
}