mirror of
https://github.com/litruv/DAdmin.git
synced 2026-07-24 02:36:11 +10:00
Req from @mikitori
Enjoy
This commit is contained in:
34
commands/redditbattlestations.js
Normal file
34
commands/redditbattlestations.js
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
var request = require('request');
|
||||||
|
var url = "https://www.reddit.com/r/battlestations/hot/.json?limit=100";
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: 'Sloth',
|
||||||
|
alias: ['sloth'],
|
||||||
|
helptext: 'Inserts battlestation from reddit/r/battlestations',
|
||||||
|
helphide: false,
|
||||||
|
permissions: ['READ_MESSAGES'],
|
||||||
|
category: 'general',
|
||||||
|
command: (client, msg) => {
|
||||||
|
request({
|
||||||
|
url: url,
|
||||||
|
json: true
|
||||||
|
}, function (error, response, body) {
|
||||||
|
if (!error && response.statusCode === 200) {
|
||||||
|
var sent = false;
|
||||||
|
while (!sent) {
|
||||||
|
var jokenumber = getRandomInt(1, 25);
|
||||||
|
if (body.data.children[jokenumber].data.url.endsWith(".jpg")) {
|
||||||
|
msg.channel.send({ file: body.data.children[jokenumber].data.url });
|
||||||
|
sent = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getRandomInt(min, max) {
|
||||||
|
min = Math.ceil(min);
|
||||||
|
max = Math.floor(max);
|
||||||
|
return Math.floor(Math.random() * (max - min)) + min;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user