Add random number command
This commit is contained in:
parent
4717de1712
commit
3b75fe165d
2 changed files with 19 additions and 0 deletions
16
commands/random.js
Normal file
16
commands/random.js
Normal 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
3
util/randomNumber.js
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
module.exports = function (min, max) {
|
||||||
|
return Math.floor(Math.random() * (max - min + 1) + min);
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue