Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Part 5 of 7 for inventory command. This is how to update an item from list. Part 6:
- const command5 = {};
- command5.name = 'update';
- command5.description = 'updates an item in the database';
- command5.usage = '<item> <price>';
- command5.category = 'database';
- command5.useDatabase = true;
- command5.useApi = false;
- command5.execute = async(bot, message, args) => {
- if (!message.member.hasPermission('ADMINISTRATOR')) return message.channel.send('You do not have permission to use this command!');
- if (args.length != 2) return message.channel.send('You have not provided the correct amount of arguments!');
- let item = args[0];
- let price = args[1];
- if (isNaN(price)) return message.channel.send('The price is not a number!');
- let query = `UPDATE items SET price = ${price} WHERE item = '${item}'`;
- bot.database.execute(query).then(() => {
- // send a success message
- message.channel.send('The item has been updated!');
- }).catch(() => {
- // send an error message
- message.channel.send('An error has occured!');
- });
- }
Add Comment
Please, Sign In to add comment