Async issue in discord bot code; Unexpected Token (
I wanted to start my bot but the console is giving me the SyntaxError : Unexpected token (
.
A few months ago the code worked just fine, now it keeps giving me this error:
bot.on("ready", async () => {
^
SyntaxError: Unexpected token (
I tried removing the async keywords completely in my code but now I get another error:
console.log(` `);
SyntaxError: Unexpected token .
bot.on("ready", async () => {
console.log(` `);
console.log(` `);
console.log(`============================================`);
console.log(` `);
console.log(' The bot is now fully opertational!')
console.log(` `);
console.log(`============================================`);
});
I expect the ouput to be "The bot is now fully operational".
javascript bots discord.js
add a comment |
I wanted to start my bot but the console is giving me the SyntaxError : Unexpected token (
.
A few months ago the code worked just fine, now it keeps giving me this error:
bot.on("ready", async () => {
^
SyntaxError: Unexpected token (
I tried removing the async keywords completely in my code but now I get another error:
console.log(` `);
SyntaxError: Unexpected token .
bot.on("ready", async () => {
console.log(` `);
console.log(` `);
console.log(`============================================`);
console.log(` `);
console.log(' The bot is now fully opertational!')
console.log(` `);
console.log(`============================================`);
});
I expect the ouput to be "The bot is now fully operational".
javascript bots discord.js
add the code into your post.
– basic
Jan 2 at 13:34
1
You don't need theasync
keyword if you're notawait
ing anything inside this function.
– Jeremy Thille
Jan 2 at 13:35
That code is syntactically valid per any online syntax validation tool. Try making sure you are running an up to date version of nodejs (should be V10 or higher). Also not sure why you are printing whitespace in console like that...
– Ronan
Jan 3 at 3:55
Check what version of node.js you are running by running the command node -v, there isn't support for await/async until node 8. Removing the async should work, post the code you are running with the async removed.
– robert
Jan 3 at 4:36
add a comment |
I wanted to start my bot but the console is giving me the SyntaxError : Unexpected token (
.
A few months ago the code worked just fine, now it keeps giving me this error:
bot.on("ready", async () => {
^
SyntaxError: Unexpected token (
I tried removing the async keywords completely in my code but now I get another error:
console.log(` `);
SyntaxError: Unexpected token .
bot.on("ready", async () => {
console.log(` `);
console.log(` `);
console.log(`============================================`);
console.log(` `);
console.log(' The bot is now fully opertational!')
console.log(` `);
console.log(`============================================`);
});
I expect the ouput to be "The bot is now fully operational".
javascript bots discord.js
I wanted to start my bot but the console is giving me the SyntaxError : Unexpected token (
.
A few months ago the code worked just fine, now it keeps giving me this error:
bot.on("ready", async () => {
^
SyntaxError: Unexpected token (
I tried removing the async keywords completely in my code but now I get another error:
console.log(` `);
SyntaxError: Unexpected token .
bot.on("ready", async () => {
console.log(` `);
console.log(` `);
console.log(`============================================`);
console.log(` `);
console.log(' The bot is now fully opertational!')
console.log(` `);
console.log(`============================================`);
});
I expect the ouput to be "The bot is now fully operational".
javascript bots discord.js
javascript bots discord.js
edited Jan 2 at 18:06
Federico Grandi
3,19121230
3,19121230
asked Jan 2 at 13:31
Max KirchhofMax Kirchhof
11
11
add the code into your post.
– basic
Jan 2 at 13:34
1
You don't need theasync
keyword if you're notawait
ing anything inside this function.
– Jeremy Thille
Jan 2 at 13:35
That code is syntactically valid per any online syntax validation tool. Try making sure you are running an up to date version of nodejs (should be V10 or higher). Also not sure why you are printing whitespace in console like that...
– Ronan
Jan 3 at 3:55
Check what version of node.js you are running by running the command node -v, there isn't support for await/async until node 8. Removing the async should work, post the code you are running with the async removed.
– robert
Jan 3 at 4:36
add a comment |
add the code into your post.
– basic
Jan 2 at 13:34
1
You don't need theasync
keyword if you're notawait
ing anything inside this function.
– Jeremy Thille
Jan 2 at 13:35
That code is syntactically valid per any online syntax validation tool. Try making sure you are running an up to date version of nodejs (should be V10 or higher). Also not sure why you are printing whitespace in console like that...
– Ronan
Jan 3 at 3:55
Check what version of node.js you are running by running the command node -v, there isn't support for await/async until node 8. Removing the async should work, post the code you are running with the async removed.
– robert
Jan 3 at 4:36
add the code into your post.
– basic
Jan 2 at 13:34
add the code into your post.
– basic
Jan 2 at 13:34
1
1
You don't need the
async
keyword if you're not await
ing anything inside this function.– Jeremy Thille
Jan 2 at 13:35
You don't need the
async
keyword if you're not await
ing anything inside this function.– Jeremy Thille
Jan 2 at 13:35
That code is syntactically valid per any online syntax validation tool. Try making sure you are running an up to date version of nodejs (should be V10 or higher). Also not sure why you are printing whitespace in console like that...
– Ronan
Jan 3 at 3:55
That code is syntactically valid per any online syntax validation tool. Try making sure you are running an up to date version of nodejs (should be V10 or higher). Also not sure why you are printing whitespace in console like that...
– Ronan
Jan 3 at 3:55
Check what version of node.js you are running by running the command node -v, there isn't support for await/async until node 8. Removing the async should work, post the code you are running with the async removed.
– robert
Jan 3 at 4:36
Check what version of node.js you are running by running the command node -v, there isn't support for await/async until node 8. Removing the async should work, post the code you are running with the async removed.
– robert
Jan 3 at 4:36
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54007285%2fasync-issue-in-discord-bot-code-unexpected-token%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54007285%2fasync-issue-in-discord-bot-code-unexpected-token%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
add the code into your post.
– basic
Jan 2 at 13:34
1
You don't need the
async
keyword if you're notawait
ing anything inside this function.– Jeremy Thille
Jan 2 at 13:35
That code is syntactically valid per any online syntax validation tool. Try making sure you are running an up to date version of nodejs (should be V10 or higher). Also not sure why you are printing whitespace in console like that...
– Ronan
Jan 3 at 3:55
Check what version of node.js you are running by running the command node -v, there isn't support for await/async until node 8. Removing the async should work, post the code you are running with the async removed.
– robert
Jan 3 at 4:36