Add random number command

This commit is contained in:
SileNce5k 2021-03-13 04:04:02 +01:00
parent 4717de1712
commit 3b75fe165d
No known key found for this signature in database
GPG key ID: C507260E7F2583AD
2 changed files with 19 additions and 0 deletions

16
commands/random.js Normal file
View file

@ -0,0 +1,16 @@
const randomNumber = require('../util/randomNumber')
module.exports = {
name: 'random',
description: 'Returns a value between two numbers (default = 1-10)',
execute({ message, args }) {
let min = 1
let max = 10
if (args[0] && args[1]) {
min = parseInt(args[0])
max = parseInt(args[1])
}
let randNumber= randomNumber(min,max)
message.channel.send(randNumber)
}
};

3
util/randomNumber.js Normal file
View file

@ -0,0 +1,3 @@
module.exports = function (min, max) {
return Math.floor(Math.random() * (max - min + 1) + min);
}