#Axios 403

13 messages · Page 1 of 1 (latest)

thorn cove

So im coding a virus checker for my bot with axios and virustotal.com but when i run the command with a link, it console logs a bunch of stuff that says forbidden. the error code is 403

warm timberBOT
  • Consider reading #how-to-get-help to improve your question!
  • Explain what exactly your issue is.
  • Post the full error stack trace, not just the top part!
  • Show your code!
  • Issue solved? Press the button!
  • Marked as resolved by OP
rugged ridge
thorn cove

no in vscode

hold on

const axios = require('axios');

module.exports = {
    name: 'virus-check',
    description: 'Check a Link for viruses',
    // devOnly: Boolean,
    // testOnly: Boolean,
    options: [
        {
            name: 'link',
            description: 'The link you want to scan',
            type: ApplicationCommandOptionType.String,
            required: true,
          },
    ],
    // deleted: Boolean,
   callback: async (client, interaction) => {
      const options = interaction.options;
      const url = options.getString('link');

      await interaction.deferReply({ ephemeral: true});

      async  function sendMessage (message) {
        const embed = new EmbedBuilder()
        .setColor('Navy')
        .setDescription(message);

        await interaction.editReply({ embeds: [embed] });
      }
      async function checkURL (url) {
    try {
        const urlToCheck = encodeURI(url);
        const apiUrl = `https://www.virustotal.com/vtapi/v2/url/report?apiKey=APIKEY&resource=${urlToCheck}`;
        
        const response = await axios.get(apiUrl);
        const data = response.data;```
        
        const scanDate = new Date(data.scan_date);
        const formattedScanDate = `<t:${Math.floor(scanDate.getTime() / 1000)}:F>`;

        var results = ``;
        if (data.positives > 0) results = `> ⚠ **This website contains viruses** `
        else results = `✅ This site is clean and safe to use`;

        const dataObj = {
            url: `> 🔗 Checked URL: \`${url}\``,
            scanDate: `> 📆 Scan Date: ${formattedScanDate}`,
            positives: `> 📮 Positives: \`${data.positives}/${data.total}\``,
            results: results,
            full: `> Click [here](${data.permalink}) to view the full results of this scan.`
        };

        return `🌍 **Your Virus Scan Report:** \n\n${Object.values(dataObj).join('\n')}\n\n *Please note: the scan date is not the time you ran this command-- its the time the virus api most recently checked the website for viruses.*`;
    
    }   catch (error) {
        console.log(error);
    return "An error has occured while checking this URL";
    }

      }

      var output = await checkURL(url);
      await sendMessage(output);
   }
};```

theres the code

@rugged ridge

i somehow got an unknown interaction now

hold on

nah thats messy af

ill just remove the command