'SyntaxError: Unexpected token 'const' on node.js (discord.js) [closed]
The "const" tag is not working on discord.js for a discord bot.
The code is being refered to this the "aboutembed". I don't know what is wrong with the code.
May someone please help? Thanks.
C:\Users\alext\OneDrive\Documents\Toast\index.js:10
const aboutembed = new Discord.MessageEmbed({
^^^^^
SyntaxError: Unexpected token 'const'
←[90m at Object.compileFunction (node:vm:352:18)←[39m
←[90m at wrapSafe (node:internal/modules/cjs/loader:1033:15)←[39m
←[90m at Module._compile (node:internal/modules/cjs/loader:1069:27)←[39m
←[90m at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)←[39m
←[90m at Module.load (node:internal/modules/cjs/loader:981:32)←[39m
←[90m at Function.Module._load (node:internal/modules/cjs/loader:822:12)←[39m
←[90m at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)←[39m
←[90m at node:internal/main/run_main_module:17:47←[39m
const Discord = require('discord.js');
const request = require('request');
const fetch = require('node-fetch');
require('dotenv-flow').config();
const client = new Discord.Client();
var prefix = !!
const aboutembed = new Discord.MessageEmbed({
title: "Food Bot",
fields: [
{
name: "Author",
value: "This bot is made by **AlexToucanYT#0001** on Discord, copyrighted by AT Products LLC."
},
{
name: "Commands",
value: "https://raw.githubusercontent.com/Alex-Toucan/Food-bot/master/files/commands.txt"
}
],
color: "GREY"
})
client.on('message', msg => {
if(msg.content.toLowerCase() === '${prefix}help') {
msg.reply({ embed: aboutembed });
}
});
Solution 1:[1]
const client = new Discord.Client();
var prefix = '!!';
The issue in the live var prefix = !!
First of all it doesn't have ; at the end, and last but not least !! is invalid sign in JS.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ayzrian |
