{"size": 1013, "ext": "js", "max_stars_repo_path": "commands/Tags/create.js", "max_stars_repo_name": "oxy-devs/oxygen", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "commands/Tags/create.js", "max_issues_repo_name": "oxy-devs/oxygen", "max_issues_repo_issues_event_min_datetime": "2021-09-02T09:34:29.000Z", "max_issues_repo_issues_event_max_datetime": "2021-09-02T09:34:29.000Z", "max_forks_repo_path": "commands/Tags/create.js", "max_forks_repo_name": "oxy-devs/oxygen", "max_forks_repo_forks_event_min_datetime": "2020-05-22T14:34:10.000Z", "max_forks_repo_forks_event_max_datetime": "2020-05-22T14:34:10.000Z"}
{"max_stars_count": null, "max_issues_count": 1, "max_forks_count": 1, "avg_line_length": 36.1785714286, "max_line_length": 94, "alphanum_fraction": 0.532082922}
module.exports = {
	name: 'create',
	description: 'Create a tag',
	useage: '<name - one word> <content>',
	isCommand: true,
	async execute(message, args) {
        if(args.length < 2) return message.reply('please specify a name and content!');
        const tagName = args.shift();
        const tagContent = args.join(' ');
        try {
            // equivalent to: INSERT INTO tags (name, description, username) values (?, ?, ?);
            const tag = await global.Tags.create({
                guild: message.guild.id,
                name: tagName,
                content: tagContent,
                creator: message.author.tag,
            });
            return message.reply(`tag \`${tag.name}\` added.`);
        }
        catch (e) {
            if (e.name === 'SequelizeUniqueConstraintError') {
                return message.reply('that tag already exists.');
            }
            console.log(e);
            return message.reply('something went wrong with adding a tag.');
        }
	},
};