-2

When I try to run this code I get an error jQuery.get is not a function. According to the documentation it should work but it doesn't seem to run here.

// Run dotenv
const jQuery = require('jquery');
require('dotenv').config();


const Discord = require('discord.js');
const client = new Discord.Client({ intents: [Discord.Intents.FLAGS.GUILDS, Discord.Intents.FLAGS.GUILD_MESSAGES] });

client.on('ready', () => {
    console.log(`Started bot as ${client.user.tag}.`);
});

client.on('messageCreate', msg => {
    if (msg.content.charAt(0) === '?') {
        if (msg.content === '?g') {
            let d = new Date();
            let months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
            msg.reply("On " + d.getDate() + " " + months[d.getMonth()] + "" + Date.now());
            jQuery.get("https://example.com/");
        } else {
            const reply = "Debug";
            msg.reply(reply);
            console.log("Recieved: " + msg.content + "\nReply: " + reply);
        }   
    }
});

client.login(process.env.DISCORD_TOKEN);
  • 1
    If you're bringing in jQuery just to make requests, there are many more specific options like [Axios](https://axios-http.com/) or [Got](https://github.com/sindresorhus/got#readme) – Phil May 30 '22 at 04:54

0 Answers0