Skip to content

Instantly share code, notes, and snippets.

@TheBITLINK
Created October 27, 2017 02:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheBITLINK/d9c897ee9987aa56faa99fedb94729b6 to your computer and use it in GitHub Desktop.
Save TheBITLINK/d9c897ee9987aa56faa99fedb94729b6 to your computer and use it in GitHub Desktop.
FocaBot module to check the price of the bitcoin
##
# 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
##
# 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