How to use @discoin/scambio - 4 common examples

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
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

const SentryCommand = require("../../structures/SentryCommand");
const { MessageEmbed } = require("discord.js");
const logger = require("../../util/logger").scope("command", "discoin rates");
const { stripIndents } = require("common-tags");
const Discoin = require("@discoin/scambio").default;

module.exports = class DiscoinRatesCommand extends SentryCommand {
  constructor(client) {
    super(client, {
      name: "discoin-rates",
      group: "economy",
      memberName: "discoin-rates",
      description: "Lists the conversion rates for Discoin currencies.",
      aliases: ["rates", "conversion-rates", "convert-rates"],
      clientPermissions: ["EMBED_LINKS"],
      throttling: {
        usages: 1,
        duration: 10
      }
    });
  }
github dice-discord / bot / src / commands / economy / convert-oats.js View on Github external
http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

const SentryCommand = require("../../structures/SentryCommand");
const config = require("../../config");
const discoin = require("../../util/discoin");
const logger = require("../../util/logger").scope("command", "convert oats");
const database = require("../../util/database");
const Discoin = require("@discoin/scambio").default;

module.exports = class ConvertOatsCommand extends SentryCommand {
  constructor(client) {
    super(client, {
      name: "convert-oats",
      group: "economy",
      memberName: "convert-oats",
      description: "Converts oats to another bot's currency.",
      details: "Use the `discoin-rates` command to see all currencies",
      aliases: ["convert", "convert-currencies", "exchange-oats", "exchange", "exchange-currencies", "discoin"],
      examples: ["convert-oats 500 dts"],
      clientPermissions: ["EMBED_LINKS"],
      args: [
        {
          key: "amount",
          prompt: "How many oats do you want to convert to another Discoin currency?",
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 3 years ago

Package Health Score

51 / 100
Full package analysis