✨ Add New Command gt - Game of Thrones Random Quotes
This commit is contained in:
17
.vscode/launch.json
vendored
Normal file
17
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
// Use IntelliSense to learn about possible attributes.
|
||||||
|
// Hover to view descriptions of existing attributes.
|
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"type": "pwa-node",
|
||||||
|
"request": "launch",
|
||||||
|
"name": "Launch Program",
|
||||||
|
"skipFiles": [
|
||||||
|
"<node_internals>/**"
|
||||||
|
],
|
||||||
|
"program": "${workspaceFolder}\\src\\main.js"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
28
src/commands/gt.js
Normal file
28
src/commands/gt.js
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
const axios = require('axios').default;
|
||||||
|
const {MessageEmbed} = require('discord.js');
|
||||||
|
const instance = axios.create({
|
||||||
|
baseURL: 'https://game-of-thrones-quotes.herokuapp.com/v1'
|
||||||
|
});
|
||||||
|
|
||||||
|
async function getRandomQuotes(message, args) {
|
||||||
|
const randomQuotesUrl = "/random";
|
||||||
|
try {
|
||||||
|
const result = await instance.get(randomQuotesUrl);
|
||||||
|
const {sentence, character: {name, house: {name:houseName}}} = result.data;
|
||||||
|
const randomQuoteMessage = new MessageEmbed()
|
||||||
|
.setDescription(sentence)
|
||||||
|
.setFooter(`${name}, ${houseName}`);
|
||||||
|
message.channel.send(randomQuoteMessage);
|
||||||
|
} catch(error) {
|
||||||
|
const errorMessage = new MessageEmbed()
|
||||||
|
.setTitle("Something went wrong: Error getting quotes from Arya Stark")
|
||||||
|
.setColor("RED");
|
||||||
|
message.channel.send(errorMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
execute(client, message, args) {
|
||||||
|
getRandomQuotes(message, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,6 +24,11 @@
|
|||||||
"name": "vaccine",
|
"name": "vaccine",
|
||||||
"description": "Get Vaccine Availability by Pincode",
|
"description": "Get Vaccine Availability by Pincode",
|
||||||
"file": "./commands/vaccine.js"
|
"file": "./commands/vaccine.js"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "gt",
|
||||||
|
"description": "Game of Thrones Quotes",
|
||||||
|
"file": "./commands/gt.js"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user