I never made a javascript discord bot and I wanted to make one, so i found a recent good looking tutorial to learn the bascics, but I can't make it work.?
import dotenv from "dotenv";
require("dotenv").config();
import { Client,
GatewayIntentBits,
ButtonBuilder,
ButtonStyle,
ModalBuilder,
TextInputBuilder,
TextInputStyle } from "discord.js";
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.DirectMessages
],
});
client.login(process.env.TOKEN);
I ran these commands before:
touch index.js
npm install discord.js
npm i dotenv
touch .env
then i put this in the .env file:
TOKEN = "discord bot token"
ERROR:
import dotenv from "dotenv";
^^^^^^
SyntaxError: Cannot use import statement outside a module