|
| 1 | +console.log() |
| 2 | + |
| 3 | +const nodeogram = require('nodeogram'), |
| 4 | +bot = new nodeogram.Bot('TOKEN'); |
| 5 | + |
| 6 | +bot.init(); |
| 7 | + |
| 8 | +bot.command('start', 'Start', false, (args, message, markup) => { |
| 9 | + message.reply("Hi, i am simple calculator bot. send me /help to view a list of commands!"); |
| 10 | +}); |
| 11 | + |
| 12 | +bot.command('random', 'Generates a random number. Usage /random', false, (args, message) => { |
| 13 | + message.reply(Math.floor((Math.random() * 100) + 1)); |
| 14 | +}); |
| 15 | + |
| 16 | +bot.command('log', 'Returns the base 10 logarithm of a number. Usage /log [num]', false, (args, message) => { |
| 17 | + message.reply(Math.log10(args[0])); |
| 18 | +}); |
| 19 | + |
| 20 | +bot.command('root', 'Return the square root of a number. Usage /root [num]', false, (args, message) => { |
| 21 | + message.reply(Math.sqrt(args[0])); |
| 22 | +}); |
| 23 | + |
| 24 | +bot.command('tan', 'Returns the tangent of an angle. Usage /tan [num]', false, (args, message) => { |
| 25 | + message.reply(Math.tan(args[0]/180*Math.PI)); |
| 26 | +}); |
| 27 | + |
| 28 | +bot.command('sin', 'Returns the sine of an angle. Usage /sin [num]', false, (args, message) => { |
| 29 | + message.reply(Math.sin(args[0]/180*Math.PI)); |
| 30 | +}); |
| 31 | + |
| 32 | +bot.command('cos', 'Returns the cosine of an angle. Usage /cos [num]', false, (args, message) => { |
| 33 | + message.reply(Math.cos(args[0]/180*Math.PI)); |
| 34 | +}); |
| 35 | + |
| 36 | +bot.command('round', 'Rounds the number to the nearest integer. Usage /round [num]', false, (args, message) => { |
| 37 | + message.reply(Math.round(args[0])); |
| 38 | +}); |
| 39 | + |
| 40 | +bot.command('power', 'Returns the power of a number to the other. Usage /power [num1] [num2]', false, (args, message) => { |
| 41 | + message.reply(Math.pow(args[0], args[1])); |
| 42 | +}); |
| 43 | + |
| 44 | +bot.command('antilog', 'Returns a number to the power of ten. Usage /antilog [num]', false, (args, message) => { |
| 45 | + message.reply(Math.pow(10, args[0])); |
| 46 | +}); |
| 47 | + |
| 48 | +bot.command('add', 'Simple addition. Usage /add [num1] [num2]', false, (args, message) => { |
| 49 | + message.reply(parseFloat(args[0]) + parseFloat(args[1])); |
| 50 | +}); |
| 51 | + |
| 52 | +bot.command('subtract', 'Simple subtraction. Usage /subtract [num1] [num2]', false, (args, message) => { |
| 53 | + message.reply(parseFloat(args[0]) - parseFloat(args[1])); |
| 54 | +}); |
| 55 | + |
| 56 | +bot.command('multiply', 'Simple multiplication. usage /multiply [num1] [num2]', false, (args, message) => { |
| 57 | + message.reply(parseFloat(args[0]) * parseFloat(args[1])); |
| 58 | +}); |
| 59 | + |
| 60 | +bot.command('divide', 'Simple division. Usage /divide [num1] [num2]', false, (args, message) => { |
| 61 | + message.reply(parseFloat(args[0]) / parseFloat(args[1])); |
| 62 | +}); |
| 63 | + |
| 64 | +bot.command('square', 'Returns the square of the number. Usage /square [num]', false, (args, message) => { |
| 65 | + message.reply(parseInt(args[0]) * parseInt(args[0])); |
| 66 | +}); |
| 67 | + |
| 68 | +bot.command('pi', 'Returns the value of Pi. Usage /pi', false, (args, message) => { |
| 69 | + message.reply(Math.PI); |
| 70 | +}); |
| 71 | + |
0 commit comments