Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async fetchToken() {
const { body } = await snekfetch
.post("https://api.twitter.com/oauth2/token")
.set({
Authorization: `Basic ${base64(`${TWITTER_API_KEY}:${TWITTER_SECRET}`)}`,
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8"
})
.send("grant_type=client_credentials");
this.token = body.access_token;
return body;
}
}
async fetchToken() {
const { body } = await snekfetch
.post("https://api.twitter.com/oauth2/token")
.set({
Authorization: `Basic ${base64(`${TWITTER_API_KEY}:${TWITTER_SECRET}`)}`,
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8"
})
.send("grant_type=client_credentials");
this.token = body.access_token;
return body;
}
}
async run(input, extension = "js") {
return post("https://hastebin.com/documents")
.send(input)
.then(res => `https://hastebin.com/${res.body.key}.${extension}`);
}
async run(msg, [Question, ...Options]) {
if (Options.length < 2) return msg.sendMessage("<:penguError:435712890884849664> ***Less than two options are not allowed.***");
if (Options.length > 30) return msg.sendMessage("<:penguError:435712890884849664> ***I only allow 30 or less options.***");
try {
const { body } = await post("https://www.strawpoll.me/api/v2/polls")
.send({ title: Question, options: Options })
.catch(e => {
Error.captureStackTrace(e);
return e;
});
return msg.sendMessage(`<:penguSuccess:435712876506775553> ***Here's the poll you requested:*** https://www.strawpoll.me/${body.id}`);
} catch (e) {
return msg.sendMessage("<:penguError:435712890884849664> ***There was an error trying to create this poll, please try again.***");
}
}