How to use the @discoin/scambio.default.currencies function in @discoin/scambio

To help you get started, we’ve selected a few @discoin/scambio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dice-discord / bot / src / commands / economy / convert-oats.js View on Github external
try {
      msg.channel.startTyping();

      const authorBalance = await database.balances.get(msg.author.id);

      // Amount checking
      if (amount > authorBalance) {
        return msg.reply(
          `You need to have at least \`${amount.toLocaleString()}\` ${
            config.currency.plural
          }. Your balance is \`${authorBalance}\`.`
        );
      }

      try {
        await Discoin.currencies.getOne(currency);
      } catch (error) {
        return msg.reply("An error occurred. Are you sure that currency exists");
      }

      const transaction = await discoin.transactions
        .create({ to: currency, amount, user: msg.author.id })
        .catch(() => msg.reply("An error occurred. Maybe Discoin is offline? Try checking their support server."));

      // Remove oats from author
      await database.balances.decrease(msg.author.id, amount);

      return msg.replyEmbed({
        title: "Conversion Successful",
        url: `https://dash.discoin.zws.im/#/transactions/${transaction.id}/show`,
        color: 0x4caf50,
        timestamp: transaction.timestamp,
github dice-discord / bot / src / commands / economy / discoin-rates.js View on Github external
async exec(msg) {
    try {
      msg.channel.startTyping();

      const currencies = await Discoin.currencies.getMany();

      const embed = new MessageEmbed({
        title: "Discoin Conversion Rates",
        url: "https://dash.discoin.zws.im/#/currencies"
      });

      const oatsCurrency = currencies.find(currency => currency.id === "OAT");

      currencies.forEach(currency => {
        embed.addField(
          currency.name,
          stripIndents`
            Currency code: ${currency.id}
            Value in Discoin D$: ${currency.value.toLocaleString()}
            Value in oats: ${(currency.value / oatsCurrency.value).toLocaleString()}`
        );

@discoin/scambio

[![npm version](https://img.shields.io/npm/v/@discoin/scambio)](https://www.npmjs.com/package/@discoin/scambio) [![codecov](https://codecov.io/gh/Discoin/scambio/branch/merge/graph/badge.svg)](https://codecov.io/gh/Discoin/scambio) [![MIT license](https:/

MIT
Latest version published 4 years ago

Package Health Score

51 / 100
Full package analysis