From cc27e287aaab86a543d708d0055ec6f3b9cdd21c Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Sun, 22 Apr 2018 03:02:35 +0000 Subject: [PATCH] I'm not very smart --- commands/tags/add.js | 16 ++++++++-------- commands/tags/edit.js | 16 ++++++++-------- commands/tags/info.js | 14 +++++++------- commands/tags/remove.js | 14 +++++++------- commands/tags/source.js | 12 ++++++------ commands/tags/tag.js | 12 ++++++------ models/Tag.js | 2 +- 7 files changed, 43 insertions(+), 43 deletions(-) diff --git a/commands/tags/add.js b/commands/tags/add.js index 3971d05d..699a43a9 100644 --- a/commands/tags/add.js +++ b/commands/tags/add.js @@ -12,11 +12,11 @@ module.exports = class TagAddCommand extends Command { guildOnly: true, args: [ { - key: 'id', - prompt: 'What should the ID of the tag be?', + key: 'name', + prompt: 'What should the name of the tag be?', type: 'string', max: 50, - parse: id => id.toLowerCase() + parse: name => name.toLowerCase() }, { key: 'text', @@ -28,15 +28,15 @@ module.exports = class TagAddCommand extends Command { }); } - async run(msg, { id, text }) { - const tag = await Tag.findOne({ where: { id, guildID: msg.guild.id } }); - if (tag) return msg.reply(`A tag with the ID **${id}** already exists.`); + async run(msg, { name, text }) { + const tag = await Tag.findOne({ where: { name, guildID: msg.guild.id } }); + if (tag) return msg.reply(`A tag with the name **${name}** already exists.`); await Tag.create({ userID: msg.author.id, guildID: msg.guild.id, - id, + name, text }); - return msg.reply(`Added the tag **${id}**.`); + return msg.reply(`Added **${name}**.`); } }; diff --git a/commands/tags/edit.js b/commands/tags/edit.js index b7dae808..34b65451 100644 --- a/commands/tags/edit.js +++ b/commands/tags/edit.js @@ -12,11 +12,11 @@ module.exports = class TagEditCommand extends Command { guildOnly: true, args: [ { - key: 'id', - prompt: 'What is the ID of the tag you want to edit?', + key: 'name', + prompt: 'What is the name of the tag you want to edit?', type: 'string', max: 50, - parse: id => id.toLowerCase() + parse: name => name.toLowerCase() }, { key: 'text', @@ -28,13 +28,13 @@ module.exports = class TagEditCommand extends Command { }); } - async run(msg, { id, text }) { - const tag = await Tag.findOne({ where: { id, guildID: msg.guild.id } }); - if (!tag) return msg.reply(`A tag with the ID **${id}** doesn't exist.`); + async run(msg, { name, text }) { + const tag = await Tag.findOne({ where: { name, guildID: msg.guild.id } }); + if (!tag) return msg.reply(`A tag with the name **${name}** doesn't exist.`); if (!msg.channel.permissionsFor(msg.author).has('MANAGE_MESSAGES') && tag.userID !== msg.author.id) { return msg.reply('You can only edit your own tags.'); } - await Tag.update({ text }, { where: { id, guild: msg.guild.id } }); - return msg.reply(`Edited the tag **${id}**.`); + await Tag.update({ text }, { where: { name, guild: msg.guild.id } }); + return msg.reply(`Edited **${name}**.`); } }; diff --git a/commands/tags/info.js b/commands/tags/info.js index bc7d8bd3..30dcc7b0 100644 --- a/commands/tags/info.js +++ b/commands/tags/info.js @@ -13,19 +13,19 @@ module.exports = class TagInfoCommand extends Command { clientPermissions: ['EMBED_LINKS'], args: [ { - key: 'id', - prompt: 'What is the ID of the tag you want to get information on?', + key: 'name', + prompt: 'What is the name of the tag you want to get information on?', type: 'string', max: 50, - parse: id => id.toLowerCase() + parse: name => name.toLowerCase() } ] }); } - async run(msg, { id }) { - const tag = await Tag.findOne({ where: { id, guildID: msg.guild.id } }); - if (!tag) return msg.reply(`A tag with the ID **${id}** doesn't exist.`); + async run(msg, { name }) { + const tag = await Tag.findOne({ where: { name, guildID: msg.guild.id } }); + if (!tag) return msg.reply(`A tag with the name **${name}** doesn't exist.`); let author; try { const authorUser = await this.client.users.fetch(tag.userID); @@ -36,7 +36,7 @@ module.exports = class TagInfoCommand extends Command { const embed = new MessageEmbed() .setColor(0x00AE86) .setThumbnail(msg.guild.iconURL()) - .addField('❯ ID', tag.id, true) + .addField('❯ name', tag.name, true) .addField('❯ Author', author, true) .addField('❯ Created On', new Date(tag.createdAt).toDateString(), true) .addField('❯ Modified On', new Date(tag.updatedAt).toDateString(), true); diff --git a/commands/tags/remove.js b/commands/tags/remove.js index 7fd21ee6..243f7f3e 100644 --- a/commands/tags/remove.js +++ b/commands/tags/remove.js @@ -12,23 +12,23 @@ module.exports = class TagRemoveCommand extends Command { guildOnly: true, args: [ { - key: 'id', - prompt: 'What is the ID of the tag you want to remove?', + key: 'name', + prompt: 'What is the name of the tag you want to remove?', type: 'string', max: 50, - parse: id => id.toLowerCase() + parse: name => name.toLowerCase() } ] }); } - async run(msg, { id }) { - const tag = await Tag.findOne({ where: { id, guildID: msg.guild.id } }); - if (!tag) return msg.reply(`A tag with the ID **${id}** doesn't exist.`); + async run(msg, { name }) { + const tag = await Tag.findOne({ where: { name, guildID: msg.guild.id } }); + if (!tag) return msg.reply(`A tag with the name **${name}** doesn't exist.`); if (!msg.channel.permissionsFor(msg.author).has('MANAGE_MESSAGES') && tag.userID !== msg.author.id) { return msg.reply('You can only delete your own tags.'); } await tag.destroy(); - return msg.reply(`Removed the tag **${id}**.`); + return msg.reply(`Removed **${name}**.`); } }; diff --git a/commands/tags/source.js b/commands/tags/source.js index 299b0280..b8d06bab 100644 --- a/commands/tags/source.js +++ b/commands/tags/source.js @@ -11,19 +11,19 @@ module.exports = class TagSourceCommand extends Command { guildOnly: true, args: [ { - key: 'id', - prompt: 'What is the ID of the tag you want view the source of?', + key: 'name', + prompt: 'What is the name of the tag you want view the source of?', type: 'string', max: 50, - parse: id => id.toLowerCase() + parse: name => name.toLowerCase() } ] }); } - async run(msg, { id }) { - const tag = await Tag.findOne({ where: { id, guildID: msg.guild.id } }); - if (!tag) return msg.reply(`A tag with the ID **${id}** doesn't exist.`); + async run(msg, { name }) { + const tag = await Tag.findOne({ where: { name, guildID: msg.guild.id } }); + if (!tag) return msg.reply(`A tag with the name **${name}** doesn't exist.`); return msg.code('md', tag.text); } }; diff --git a/commands/tags/tag.js b/commands/tags/tag.js index 3497fa5a..af6bfb4b 100644 --- a/commands/tags/tag.js +++ b/commands/tags/tag.js @@ -11,19 +11,19 @@ module.exports = class TagCommand extends Command { guildOnly: true, args: [ { - key: 'id', - prompt: 'What is the ID of the tag you want view?', + key: 'name', + prompt: 'What is the name of the tag you want view?', type: 'string', max: 50, - parse: id => id.toLowerCase() + parse: name => name.toLowerCase() } ] }); } - async run(msg, { id }) { - const tag = await Tag.findOne({ where: { id, guildID: msg.guild.id } }); - if (!tag) return msg.reply(`A tag with the ID **${id}** doesn't exist.`); + async run(msg, { name }) { + const tag = await Tag.findOne({ where: { name, guildID: msg.guild.id } }); + if (!tag) return msg.reply(`A tag with the name **${name}** doesn't exist.`); return msg.say(tag.text); } }; diff --git a/models/Tag.js b/models/Tag.js index c405a7e3..fd40ea13 100644 --- a/models/Tag.js +++ b/models/Tag.js @@ -14,7 +14,7 @@ const Tag = Database.db.define('tag', { type: Sequelize.STRING, allowNull: false }, - id: { + name: { type: Sequelize.STRING, allowNull: false }