mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-26 06:42:50 +02:00
Remove tons of faulty awaits
This commit is contained in:
@@ -25,7 +25,7 @@ module.exports = class BotSearchCommand extends commando.Command {
|
|||||||
console.log(`[Command] ${message.content}`);
|
console.log(`[Command] ${message.content}`);
|
||||||
if (message.mentions.users.size === 1) {
|
if (message.mentions.users.size === 1) {
|
||||||
let botToFind = message.mentions.users.first().id;
|
let botToFind = message.mentions.users.first().id;
|
||||||
await request
|
return request
|
||||||
.get(`https://bots.discord.pw/api/bots/${botToFind}`)
|
.get(`https://bots.discord.pw/api/bots/${botToFind}`)
|
||||||
.set({
|
.set({
|
||||||
'Authorization': config.botskey
|
'Authorization': config.botskey
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ module.exports = class DefineCommand extends commando.Command {
|
|||||||
}
|
}
|
||||||
console.log(`[Command] ${message.content}`);
|
console.log(`[Command] ${message.content}`);
|
||||||
let defineThis = encodeURI(message.content.split(" ").slice(1).join(" "));
|
let defineThis = encodeURI(message.content.split(" ").slice(1).join(" "));
|
||||||
await request
|
return request
|
||||||
.get(`http://api.wordnik.com:80/v4/word.json/${defineThis}/definitions`)
|
.get(`http://api.wordnik.com:80/v4/word.json/${defineThis}/definitions`)
|
||||||
.query({
|
.query({
|
||||||
limit: 1,
|
limit: 1,
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ module.exports = class ForecastCommand extends commando.Command {
|
|||||||
}
|
}
|
||||||
console.log(`[Command] ${message.content}`);
|
console.log(`[Command] ${message.content}`);
|
||||||
let locationToSearch = message.content.split(" ").slice(1).join(" ");
|
let locationToSearch = message.content.split(" ").slice(1).join(" ");
|
||||||
await weather(locationToSearch, 'f').then(info => {
|
return weather(locationToSearch, 'f').then(info => {
|
||||||
const embed = new Discord.RichEmbed()
|
const embed = new Discord.RichEmbed()
|
||||||
.setColor(0x0000FF)
|
.setColor(0x0000FF)
|
||||||
.setAuthor(info.title, 'http://media.idownloadblog.com/wp-content/uploads/2013/12/yahoo-weather-213x220.png')
|
.setAuthor(info.title, 'http://media.idownloadblog.com/wp-content/uploads/2013/12/yahoo-weather-213x220.png')
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ module.exports = class DefineCommand extends commando.Command {
|
|||||||
console.log(`[Command] ${message.content}`);
|
console.log(`[Command] ${message.content}`);
|
||||||
let thingToSearch = encodeURI(message.content.split(" ").slice(1).join(" "));
|
let thingToSearch = encodeURI(message.content.split(" ").slice(1).join(" "));
|
||||||
await message.channel.send('Searching...').then(msg => {
|
await message.channel.send('Searching...').then(msg => {
|
||||||
await request
|
return request
|
||||||
.get(`https://www.google.com/search?q=${thingToSearch}`)
|
.get(`https://www.google.com/search?q=${thingToSearch}`)
|
||||||
.then(function(response) {
|
.then(function(response) {
|
||||||
const $ = cheerio.load(response.text);
|
const $ = cheerio.load(response.text);
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ module.exports = class DefineCommand extends commando.Command {
|
|||||||
console.log(`[Command] ${message.content}`);
|
console.log(`[Command] ${message.content}`);
|
||||||
let thingToSearch = encodeURI(message.content.split(" ").slice(1).join(" "));
|
let thingToSearch = encodeURI(message.content.split(" ").slice(1).join(" "));
|
||||||
await message.channel.send('Searching...').then(msg => {
|
await message.channel.send('Searching...').then(msg => {
|
||||||
await request
|
return request
|
||||||
.get(`https://www.google.com/search?tbm=isch&gs_l=img&q=${encodeURI(thingToSearch)}`)
|
.get(`https://www.google.com/search?tbm=isch&gs_l=img&q=${encodeURI(thingToSearch)}`)
|
||||||
.then(function(response) {
|
.then(function(response) {
|
||||||
const $ = cheerio.load(response.text);
|
const $ = cheerio.load(response.text);
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ module.exports = class OsuCommand extends commando.Command {
|
|||||||
}
|
}
|
||||||
console.log(`[Command] ${message.content}`);
|
console.log(`[Command] ${message.content}`);
|
||||||
let usernameToSearch = message.content.split(" ").slice(1).join(" ");
|
let usernameToSearch = message.content.split(" ").slice(1).join(" ");
|
||||||
await request
|
return request
|
||||||
.get('https://osu.ppy.sh/api/get_user')
|
.get('https://osu.ppy.sh/api/get_user')
|
||||||
.query({
|
.query({
|
||||||
k: config.osukey,
|
k: config.osukey,
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ module.exports = class WattpadCommand extends commando.Command {
|
|||||||
}
|
}
|
||||||
console.log(`[Command] ${message.content}`);
|
console.log(`[Command] ${message.content}`);
|
||||||
let queryBook = message.content.split(" ").slice(1).join(" ");
|
let queryBook = message.content.split(" ").slice(1).join(" ");
|
||||||
await request
|
return request
|
||||||
.get('https://api.wattpad.com:443/v4/stories')
|
.get('https://api.wattpad.com:443/v4/stories')
|
||||||
.set({
|
.set({
|
||||||
'Authorization': `Basic ${config.wattpadkey}`
|
'Authorization': `Basic ${config.wattpadkey}`
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ module.exports = class WeatherCommand extends commando.Command {
|
|||||||
}
|
}
|
||||||
console.log(`[Command] ${message.content}`);
|
console.log(`[Command] ${message.content}`);
|
||||||
let locationToSearch = message.content.split(" ").slice(1).join(" ");
|
let locationToSearch = message.content.split(" ").slice(1).join(" ");
|
||||||
await weather(locationToSearch, 'f').then(info => {
|
return weather(locationToSearch, 'f').then(info => {
|
||||||
const embed = new Discord.RichEmbed()
|
const embed = new Discord.RichEmbed()
|
||||||
.setColor(0x0000FF)
|
.setColor(0x0000FF)
|
||||||
.setAuthor(info.title, 'http://media.idownloadblog.com/wp-content/uploads/2013/12/yahoo-weather-213x220.png')
|
.setAuthor(info.title, 'http://media.idownloadblog.com/wp-content/uploads/2013/12/yahoo-weather-213x220.png')
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ module.exports = class WikipediaCommand extends commando.Command {
|
|||||||
console.log(`[Command] ${message.content}`);
|
console.log(`[Command] ${message.content}`);
|
||||||
let thingToSearch = encodeURI(message.content.split(" ").slice(1).join(" "));
|
let thingToSearch = encodeURI(message.content.split(" ").slice(1).join(" "));
|
||||||
thingToSearch = thingToSearch.split(")").join("%29");
|
thingToSearch = thingToSearch.split(")").join("%29");
|
||||||
await request
|
return request
|
||||||
.get(`https://en.wikipedia.org/w/api.php?action=query&prop=extracts&format=json&titles=${thingToSearch}&exintro=&explaintext=&redirects=&formatversion=2`)
|
.get(`https://en.wikipedia.org/w/api.php?action=query&prop=extracts&format=json&titles=${thingToSearch}&exintro=&explaintext=&redirects=&formatversion=2`)
|
||||||
.then(function(response) {
|
.then(function(response) {
|
||||||
let description = response.body.query.pages[0].extract;
|
let description = response.body.query.pages[0].extract;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ module.exports = class YouTubeCommand extends commando.Command {
|
|||||||
}
|
}
|
||||||
console.log(`[Command] ${message.content}`);
|
console.log(`[Command] ${message.content}`);
|
||||||
let videoToSearch = message.content.split(" ").slice(1).join("-");
|
let videoToSearch = message.content.split(" ").slice(1).join("-");
|
||||||
await request
|
return request
|
||||||
.get('https://www.googleapis.com/youtube/v3/search')
|
.get('https://www.googleapis.com/youtube/v3/search')
|
||||||
.query({
|
.query({
|
||||||
part: 'snippet',
|
part: 'snippet',
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ module.exports = class YuGiOhCommand extends commando.Command {
|
|||||||
}
|
}
|
||||||
console.log(`[Command] ${message.content}`);
|
console.log(`[Command] ${message.content}`);
|
||||||
let cardName = encodeURI(message.content.split(" ").slice(1).join(" "));
|
let cardName = encodeURI(message.content.split(" ").slice(1).join(" "));
|
||||||
await request
|
return request
|
||||||
.get(`http://yugiohprices.com/api/card_data/${cardName}`)
|
.get(`http://yugiohprices.com/api/card_data/${cardName}`)
|
||||||
.then(function(response) {
|
.then(function(response) {
|
||||||
if (response.body.data.card_type === 'monster') {
|
if (response.body.data.card_type === 'monster') {
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ module.exports = class RinSayCommand extends commando.Command {
|
|||||||
}
|
}
|
||||||
console.log(`[Command] ${message.content}`);
|
console.log(`[Command] ${message.content}`);
|
||||||
let rinContent = message.content.split(" ").slice(1).join(" ");
|
let rinContent = message.content.split(" ").slice(1).join(" ");
|
||||||
await request
|
return request
|
||||||
.post(config.webhook)
|
.post(config.webhook)
|
||||||
.send({
|
.send({
|
||||||
content: rinContent
|
content: rinContent
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ module.exports = class TranslateCommand extends commando.Command {
|
|||||||
return message.channel.send(":x: Error! Please keep translations below 200 characters!");
|
return message.channel.send(":x: Error! Please keep translations below 200 characters!");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
await translate(thingToTranslate, {
|
return translate(thingToTranslate, {
|
||||||
to: languageto
|
to: languageto
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
let languagefrom = res.from.language.iso.toLowerCase();
|
let languagefrom = res.from.language.iso.toLowerCase();
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ module.exports = class YodaCommand extends commando.Command {
|
|||||||
return message.channel.send(':x: Error! Nothing to translate!');
|
return message.channel.send(':x: Error! Nothing to translate!');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
await request
|
return request
|
||||||
.get('https://yoda.p.mashape.com/yoda')
|
.get('https://yoda.p.mashape.com/yoda')
|
||||||
.set({
|
.set({
|
||||||
'X-Mashape-Key': config.mashapekey,
|
'X-Mashape-Key': config.mashapekey,
|
||||||
|
|||||||
Reference in New Issue
Block a user