add useragent header to commands contacting APIs
This commit is contained in:
parent
aa2d1a99f6
commit
460fccd543
9 changed files with 29 additions and 8 deletions
|
@ -27,7 +27,7 @@ module.exports = class {
|
||||||
fetch('https://gamecp.apex.to/api/client/servers/1fc76afa-9a4d-497b-983a-a898795ab5b5/power', {
|
fetch('https://gamecp.apex.to/api/client/servers/1fc76afa-9a4d-497b-983a-a898795ab5b5/power', {
|
||||||
method: 'post',
|
method: 'post',
|
||||||
body: JSON.stringify({ 'signal': 'restart' }),
|
body: JSON.stringify({ 'signal': 'restart' }),
|
||||||
headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${client.config.server}` }
|
headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${client.config.server}`, 'User-Agent': client.config.userAgent }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
|
@ -22,7 +22,7 @@ module.exports = class {
|
||||||
let date = 'xxxx';
|
let date = 'xxxx';
|
||||||
if (args[0] && args[0].toLowerCase() === 'daily') date = new Date();
|
if (args[0] && args[0].toLowerCase() === 'daily') date = new Date();
|
||||||
message.channel.sendTyping();
|
message.channel.sendTyping();
|
||||||
fetch('https://garfield-comics.glitch.me/~SRoMG/?date=' + date)
|
fetch('https://garfield-comics.glitch.me/~SRoMG/?date=' + date, { headers: { 'User-Agent': client.config.userAgent }})
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.then(json => {
|
.then(json => {
|
||||||
const embed = new client.RichEmbed()
|
const embed = new client.RichEmbed()
|
||||||
|
|
|
@ -21,7 +21,7 @@ module.exports = class {
|
||||||
run (client, message, args, data) { //eslint-disable-line no-unused-vars
|
run (client, message, args, data) { //eslint-disable-line no-unused-vars
|
||||||
message.channel.sendTyping();
|
message.channel.sendTyping();
|
||||||
try {
|
try {
|
||||||
fetch('http://inspirobot.me/api?generate=true')
|
fetch('http://inspirobot.me/api?generate=true', { headers: { 'User-Agent': client.config.userAgent }})
|
||||||
.then(res => res.text())
|
.then(res => res.text())
|
||||||
.then(body => message.channel.createMessage(body));
|
.then(body => message.channel.createMessage(body));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
|
@ -30,7 +30,8 @@ module.exports = class {
|
||||||
fetch('https://graphqlpokemon.favware.tech/', {
|
fetch('https://graphqlpokemon.favware.tech/', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json',
|
||||||
|
'User-Agent': client.config.userAgent
|
||||||
},
|
},
|
||||||
body: JSON.stringify({ query: `
|
body: JSON.stringify({ query: `
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,7 +32,8 @@ module.exports = class {
|
||||||
const res = await fetch('https://graphqlpokemon.favware.tech/', {
|
const res = await fetch('https://graphqlpokemon.favware.tech/', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json',
|
||||||
|
'User-Agent': client.config.userAgent
|
||||||
},
|
},
|
||||||
body: JSON.stringify({ query: `
|
body: JSON.stringify({ query: `
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,7 +30,8 @@ module.exports = class {
|
||||||
fetch('https://graphqlpokemon.favware.tech/', {
|
fetch('https://graphqlpokemon.favware.tech/', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json',
|
||||||
|
'User-Agent': client.config.userAgent
|
||||||
},
|
},
|
||||||
body: JSON.stringify({ query: `
|
body: JSON.stringify({ query: `
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,7 +31,8 @@ module.exports = class {
|
||||||
fetch('https://graphqlpokemon.favware.tech/', {
|
fetch('https://graphqlpokemon.favware.tech/', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json',
|
||||||
|
'User-Agent': client.config.userAgent
|
||||||
},
|
},
|
||||||
body: JSON.stringify({ query: `
|
body: JSON.stringify({ query: `
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,7 +31,8 @@ module.exports = class {
|
||||||
fetch('https://graphqlpokemon.favware.tech/', {
|
fetch('https://graphqlpokemon.favware.tech/', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json',
|
||||||
|
'User-Agent': client.config.userAgent
|
||||||
},
|
},
|
||||||
body: JSON.stringify({ query: `
|
body: JSON.stringify({ query: `
|
||||||
{
|
{
|
||||||
|
|
|
@ -86,6 +86,22 @@ class Functions {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
epochDifference (difference) {
|
||||||
|
const secondsInMiliseconds = 1000;
|
||||||
|
const minutesInMiliseconds = 60 * secondsInMiliseconds;
|
||||||
|
const hoursInMiliseconds = 60 * minutesInMiliseconds;
|
||||||
|
|
||||||
|
const differenceInHours = difference / hoursInMiliseconds;
|
||||||
|
const differenceInMinutes = differenceInHours % 1 * 60;
|
||||||
|
const differenceInSeconds = differenceInMinutes % 1 * 60;
|
||||||
|
|
||||||
|
return {
|
||||||
|
'h' : Math.floor(differenceInHours),
|
||||||
|
'm' : Math.floor(differenceInMinutes),
|
||||||
|
's' : Math.floor(differenceInSeconds)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
intBetween (min, max) {
|
intBetween (min, max) {
|
||||||
return Math.round((Math.random() * (max - min) + min));
|
return Math.round((Math.random() * (max - min) + min));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue