How to use snekfetch - 10 common examples

To help you get started, we’ve selected a few snekfetch 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 DS-Development / delet / commands / Misc / google.js View on Github external
async run(message, args, level) { // eslint-disable-line no-unused-vars
        const searchMessage = await message.channel.send("Searching Google...");
        const searchURL = `https://www.google.com/search?q=${encodeURIComponent(message.content)}`;

        return snekfetch.get(searchURL).then((result) => {

            const $ = cheerio.load(result.text);
            let googleData = $(".r").first().find("a").first().attr("href");

            googleData = querystring.parse(googleData.replace("/url?", ""));
            searchMessage.edit(`Result found!\n${googleData.q}`);

        }).catch((err) => {
            searchMessage.edit(`${texts.error}\`\`\`${err}\`\`\``);
        });
    }
}
github NotAWeebDev / Misaki / commands / fun / yomomma.js View on Github external
async run(message, args, level) { // eslint-disable-line no-unused-vars
    try {

      if (message.settings.socialSystem === "true") {
        if (!(await this.cmdPay(message, message.author.id, this.help.cost))) return;
      }

      const { text } = await snekfetch.get("http://api.yomomma.info/");
      message.channel.send(`_${JSON.parse(text).joke}_`);
    } catch (error) {
      this.client.logger.error(error);
    }
  }
}
github NotAWeebDev / Misaki / commands / fun / gif.js View on Github external
async run(message, args, level) { // eslint-disable-line no-unused-vars
    const list = await get("http://replygif.net/api/tags?api-key=39YAprx5Yi");
    const tag = list.body.random();
    const giflist = await get(`http://replygif.net/api/gifs?tag=${tag.title}&api-key=39YAprx5Yi`);
    message.channel.send({
      "embed": {
        "image": {
          "url": giflist.body.random().file
        },
        "footer": {
          "icon_url": message.author.displayAvatarURL({ format: "png", size: 32 }),
          "text": `Requested by ${message.author.tag} | Powered by ReplyGif.net`
        }
      }
    });
  }
}
github NotAWeebDev / Misaki / commands / fun / lovecalc.js View on Github external
async run(message, args, level) { // eslint-disable-line no-unused-vars
    if (!message.mentions.members.size) return message.response(undefined, "Ba-Baka! How will I tell you, how much you love someone. If I don't know who!"); //Response Can Be Refined 😂
    const data = await get(`https://love-calculator.p.mashape.com/getPercentage?fname=${message.member.displayName}&sname=${message.mentions.members.first().displayName}`).set("X-Mashape-Key", process.env.MASHAPE);
    const embed = new MessageEmbed()
      .setThumbnail("http://images6.fanpop.com/image/answers/3317000/3317487_1375024940496.53res_300_202.jpg")
      .addField("Lover", data.body.fname)
      .addField("Crush", data.body.sname)
      .addField("Love Percent", data.body.percentage)
      .setFooter(data.body.result)
      .setColor(0xFF0000);
      
    message.channel.send({ embed });
  }
}
github NotAWeebDev / Misaki / commands / social / upvote.js View on Github external
async run(message, args, level) { // eslint-disable-line no-unused-vars
    if (message.guild.id !== "396331425621868554") return message.reply(`This command can only be used in Okami Academy, run ${message.settings.prefix}invite to get the invite link.`);
    const { body } = await get(`https://discordbots.org/api/bots/${this.client.user.id}/check?userId=${message.author.id}`).set("Authorization", process.env.DBLTOKEN);
    if (Boolean(body.voted)) { // eslint-disable-line no-extra-boolean-cast
      if (message.member.roles.has(upvoterRole)) return message.channel.send("You have the role already.");
      message.member.roles.add(upvoterRole)
        .then(() => message.reply("You have been awarded the `Updooter` role, thank you for your support.\nDon't forget to revote next month!"))
        .catch((error) => {
          this.client.logger.error(error);
          message.channel.send("Something went wrong, please try again later.");
        });
    } else {
      message.channel.send(`To claim the \`Updooter\` to show your support, please go upvote ${this.client.user.username} at , then after voting return and run the command again to claim your role reward.`);
    }
  }
}
github NotAWeebDev / Misaki / commands / owner / dblstats.js View on Github external
async run(message, args, level) { // eslint-disable-line no-unused-vars
    const { body } = await get(`https://discordbots.org/api/bots/${this.client.user.id}/votes?onlyids=true`).set("Authorization", this.client.config.dblToken);
    await message.buildEmbed()
      .setColor(message.guild.me.roles.highest.color || 5198940)
      .setThumbnail(this.client.user.displayAvatarURL({format: "png"}))
      .setTitle("Discord Bot List Upvoters")
      .setDescription(`Voter(s) <@${body.join(">, <@")}>`)
      .addField("Voter Count", body.length, true)
      .setTimestamp()
      .send();
  }
}
github NotAWeebDev / Misaki / commands / animals / shiba.js View on Github external
async run(message, args, level, loadingMessage) {
    const { body } = await get("http://shibe.online/api/shibes");
    await loadingMessage.edit({
      embed: {
        "title": "Click here if the image failed to load.",
        "url": body[0],
        "color": 6192321,
        "image": {
          "url": body[0]
        }
      }
    });
  }
}
github NotAWeebDev / Misaki / commands / fun / pun.js View on Github external
async run(message, args, level, loadingMessage) {
    const { text } = await get("https://getpuns.herokuapp.com/api/random");
    const embed = new MessageEmbed()
      .setThumbnail("https://cdn.discordapp.com/emojis/257279894885498890.png")
      .setDescription(`_${JSON.parse(text).Pun}_`)
      .setColor(6192321);

    await loadingMessage.edit({ embed });
  }
}
github NotAWeebDev / Misaki / commands / animals / bird.js View on Github external
async run(message, args, level, loadingMessage) { 
    const { body } = await get("http://random.birb.pw/tweet/");
    return loadingMessage.edit({
      embed: {
        "title": "Click here if the image failed to load.",
        "url": `https://random.birb.pw/img/${body}`,
        "color": 6192321,
        "image": {
          "url": `https://random.birb.pw/img/${body}`
        }
      }
    });
  }
}
github NotAWeebDev / Misaki / commands / fun / joke.js View on Github external
async run(message, args, level, loadingMessage) {
    const { body } = await get("https://dashboard.typicalbot.com/api/v1/joke").set("Authorization", process.env.TYPICAL);
    const embed = new MessageEmbed()
      .setThumbnail("https://cdn.discordapp.com/emojis/397910503013220354.png")
      .setDescription(`_${body.data}_`)
      .setColor(6192321)
      .setFooter("Powered by TypicalBot API.");
    await loadingMessage.edit({ embed });
  }
}

snekfetch

Just do http requests without all that weird nastiness from other libs

MIT
Latest version published 6 years ago

Package Health Score

53 / 100
Full package analysis

Popular snekfetch functions