exchangeratesapi key
This commit is contained in:
parent
a5115537c9
commit
dd39ffc54f
@ -47,7 +47,7 @@
|
||||
},
|
||||
{
|
||||
"name": "utility",
|
||||
"version": "3.1.0"
|
||||
"version": "3.1.1"
|
||||
}
|
||||
],
|
||||
"typescript": true
|
||||
|
@ -2,7 +2,7 @@
|
||||
"main": "plugin.js",
|
||||
"name": "utility",
|
||||
"description": "Utility commands and math operations",
|
||||
"version": "3.1.0",
|
||||
"version": "3.1.1",
|
||||
"tags": ["commands", "tools"],
|
||||
"dependencies": ["simplecommands"],
|
||||
"npmDependencies": [
|
||||
|
@ -656,6 +656,8 @@ function addCommands(plugin: UtilityPlugin, commands: any): void {
|
||||
aliases: ['cv', 'unit']
|
||||
});
|
||||
|
||||
const cexkey = plugin.config.get('currencyAPIKey');
|
||||
if (cexkey) {
|
||||
cmds.push({
|
||||
name: 'currency',
|
||||
execute: async (msg: IMessage, msr: MessageResolver, spec: any, prefix: string, ...simplified: any[]): Promise<boolean> => {
|
||||
@ -663,7 +665,7 @@ function addCommands(plugin: UtilityPlugin, commands: any): void {
|
||||
if (cexCache.expiry < Date.now()) {
|
||||
let fetched;
|
||||
try {
|
||||
const data = await httpGET('https://api.exchangeratesapi.io/latest');
|
||||
const data = await httpGET('http://api.exchangeratesapi.io/latest?access_key=' + cexkey);
|
||||
fetched = JSON.parse(data);
|
||||
logger.log('[utility] Fetched currency exchange rates successfully.');
|
||||
} catch (e) {
|
||||
@ -733,6 +735,7 @@ function addCommands(plugin: UtilityPlugin, commands: any): void {
|
||||
usage: '<number> | [date | list] [<from currency>] [<to currency>]',
|
||||
aliases: ['cex', 'exchange']
|
||||
});
|
||||
}
|
||||
|
||||
cmds.push({
|
||||
name: 'randomnumber',
|
||||
@ -784,6 +787,7 @@ function addCommands(plugin: UtilityPlugin, commands: any): void {
|
||||
|
||||
@Configurable({
|
||||
ipfsGateway: 'https://ipfs.io',
|
||||
currencyAPIKey: '',
|
||||
randomMax: 64
|
||||
})
|
||||
class UtilityPlugin extends Plugin {
|
||||
|
Loading…
Reference in New Issue
Block a user