Created
October 27, 2017 02:11
-
-
Save TheBITLINK/d9c897ee9987aa56faa99fedb94729b6 to your computer and use it in GitHub Desktop.
FocaBot module to check the price of the bitcoin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# FocaBot 1.x / Azarasi | |
## | |
btcAverage = require('request-promise').defaults { | |
baseUrl: 'https://apiv2.bitcoinaverage.com' | |
json: true | |
simple: true | |
} | |
class BtcConvert extends BotModule | |
init: -> | |
@registerCommand 'btcusd', { allowDM: true }, ({ msg, args })=> | |
amount = parseInt(args) or 1 | |
rq = await btcAverage.get('convert/global', { qs: { from: 'BTC', to: 'USD', amount } }) | |
price = rq.price | |
msg.channel.sendMessage "", embed: { | |
color: 0xFFB251 | |
fields: [ | |
{ name: 'BTC', value: amount.toString(), inline: true } | |
{ name: 'USD', value: price.toString(), inline: true } | |
] | |
} | |
@registerCommand 'usdbtc', { allowDM: true }, ({ msg, args })=> | |
amount = parseInt(args) or 1 | |
rq = await btcAverage.get('convert/global', { qs: { from: 'USD', to: 'BTC', amount } }) | |
price = rq.price | |
msg.channel.send "", embed: { | |
color: 0x5A9F4F | |
fields: [ | |
{ name: 'USD', value: amount.toString(), inline: true } | |
{ name: 'BTC', value: price.toString(), inline: true } | |
] | |
} | |
module.exports = BtcConvert |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# FocaBot 0.x / FocaBotCore | |
## | |
btcAverage = require('request-promise').defaults { | |
baseUrl: 'https://apiv2.bitcoinaverage.com' | |
json: true | |
simple: true | |
} | |
class BtcConvert extends BotModule | |
init: -> | |
@registerCommand 'btcusd', { allowDM: true }, (msg, args)=> | |
amount = parseInt(args) or 1 | |
rq = await btcAverage.get('convert/global', { qs: { from: 'BTC', to: 'USD', amount } }) | |
price = rq.price | |
msg.channel.sendMessage "", false, { | |
color: 0xFFB251 | |
fields: [ | |
{ name: 'BTC', value: amount.toString(), inline: true } | |
{ name: 'USD', value: price.toString(), inline: true } | |
] | |
} | |
@registerCommand 'usdbtc', { allowDM: true }, (msg, args)=> | |
amount = parseInt(args) or 1 | |
rq = await btcAverage.get('convert/global', { qs: { from: 'USD', to: 'BTC', amount } }) | |
price = rq.price | |
msg.channel.sendMessage "", false, { | |
color: 0x5A9F4F | |
fields: [ | |
{ name: 'USD', value: amount.toString(), inline: true } | |
{ name: 'BTC', value: price.toString(), inline: true } | |
] | |
} | |
module.exports = BtcConvert |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment