I'm not very smart

This commit is contained in:
Daniel Odendahl Jr
2018-04-22 03:02:35 +00:00
parent 11ca793181
commit cc27e287aa
7 changed files with 43 additions and 43 deletions
+8 -8
View File
@@ -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}**.`);
}
};
+8 -8
View File
@@ -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}**.`);
}
};
+7 -7
View File
@@ -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);
+7 -7
View File
@@ -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}**.`);
}
};
+6 -6
View File
@@ -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);
}
};
+6 -6
View File
@@ -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);
}
};
+1 -1
View File
@@ -14,7 +14,7 @@ const Tag = Database.db.define('tag', {
type: Sequelize.STRING,
allowNull: false
},
id: {
name: {
type: Sequelize.STRING,
allowNull: false
}