You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Haha-Yes/commands/admin/tag.js

50 lines
1.4 KiB
JavaScript

const { Command } = require('discord-akairo');
5 years ago
const Tag = require('../../models').Tag;
5 years ago
class TagCommand extends Command {
5 years ago
constructor() {
super('tag', {
aliases: ['tag'],
category: 'admin',
split: 'quoted',
userPermissions: ['MANAGE_MESSAGES'],
5 years ago
args: [
{
id: 'trigger',
5 years ago
type: 'string',
prompt: {
start: 'What word or sentence should trigger it?',
}
5 years ago
},
{
id: 'response',
type: 'string',
5 years ago
match: 'rest',
prompt: {
start: 'What word or sentence should the response be?',
}
5 years ago
}
],
channelRestriction: 'guild',
description: {
content: 'Create custom autoresponse [Click here to see the complete list of "tag"](https://cdn.discordapp.com/attachments/502198809355354133/561043193949585418/unknown.png) (Need "" if the trigger contains spaces)',
5 years ago
usage: '[trigger] [response]',
examples: ['"do you know da wea" Fuck off dead meme', 'hello Hello [author], how are you today?']
5 years ago
}
});
}
5 years ago
5 years ago
async exec(message, args) {
5 years ago
const tag = await Tag.findOne({where: {trigger: args.trigger, serverID: message.guild.id}});
5 years ago
5 years ago
if (!tag) {
const body = {trigger: args.trigger, response: args.response, owner: message.author.id, serverID: message.guild.id};
Tag.create(body);
return message.channel.send(`autoresponse have been set to ${args.trigger} : ${args.response}`);
} else {
return message.channel.send('The tag already exist!');
}
5 years ago
}
}
module.exports = TagCommand;