Hot Summer Deals are Here!
Celebrate with up to 90% off on 16,300 resources
04
Days
08
Hours
27
Mins
55
Secs

HELP DISCORD BOT

Status
This thread has been locked.

FelixDev

Typical Developer and Designer
Premium
Feedback score
9
Posts
1,113
Reactions
331
Resources
0
Hello, Trying to set a game that the bot is playing. Here is my code :

Code:
// CALLING THE PACKAGE
const Discord = require('discord.js');
const bot = new Discord.Client();

bot.login(')
bot.on('ready', () => {
  console.log('Bot started')
  bot.setGame('Watching L00ting')

});
bot.on('message', message => {
  if(message.content.toLowerCase() === 'hello')
    message.channel.send('Hi there!' + message.author);
    if(message.content.toLowerCase() === 'test2')
      message.channel.send('Hi there!' + message.author);
      if(message.content.toLowerCase() === 'test')
        message.channel.send('Hi there!' + message.author);
});

and here is the error I get,
Code:
 ^

TypeError: bot.setGame is not a function
    at Client.bot.on (C:\Users\Felix\Desktop\DISCORD BOT\app.js:8:7)
    at emitNone (events.js:111:20)
    at Client.emit (events.js:208:7)
    at WebSocketConnection.triggerReady (C:\Users\Felix\Desktop\DISCORD BOT\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:125:17)
    at WebSocketConnection.checkIfReady (C:\Users\Felix\Desktop\DISCORD BOT\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:141:61)
    at GuildCreateHandler.handle (C:\Users\Felix\Desktop\DISCORD BOT\node_modules\discord.js\src\client\websocket\packets\handlers\GuildCreate.js:13:31)
    at WebSocketPacketManager.handle (C:\Users\Felix\Desktop\DISCORD BOT\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:103:65)
    at WebSocketConnection.onPacket (C:\Users\Felix\Desktop\DISCORD BOT\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:333:35)
    at WebSocketConnection.onMessage (C:\Users\Felix\Desktop\DISCORD BOT\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:296:17)
    at WebSocket.onMessage (C:\Users\Felix\Desktop\DISCORD BOT\node_modules\ws\lib\event-target.js:120:16)
 
PebbleHost
High performance, consistent uptime and fast support. Minecraft hosting that just works.

tiehm

Developer
Supreme
Feedback score
7
Posts
688
Reactions
455
Resources
0
Hello, Trying to set a game that the bot is playing. Here is my code :

Code:
// CALLING THE PACKAGE
const Discord = require('discord.js');
const bot = new Discord.Client();

bot.login(')
bot.on('ready', () => {
  console.log('Bot started')
  bot.setGame('Watching L00ting')

});
bot.on('message', message => {
  if(message.content.toLowerCase() === 'hello')
    message.channel.send('Hi there!' + message.author);
    if(message.content.toLowerCase() === 'test2')
      message.channel.send('Hi there!' + message.author);
      if(message.content.toLowerCase() === 'test')
        message.channel.send('Hi there!' + message.author);
});

and here is the error I get,
Code:
 ^

TypeError: bot.setGame is not a function
    at Client.bot.on (C:\Users\Felix\Desktop\DISCORD BOT\app.js:8:7)
    at emitNone (events.js:111:20)
    at Client.emit (events.js:208:7)
    at WebSocketConnection.triggerReady (C:\Users\Felix\Desktop\DISCORD BOT\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:125:17)
    at WebSocketConnection.checkIfReady (C:\Users\Felix\Desktop\DISCORD BOT\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:141:61)
    at GuildCreateHandler.handle (C:\Users\Felix\Desktop\DISCORD BOT\node_modules\discord.js\src\client\websocket\packets\handlers\GuildCreate.js:13:31)
    at WebSocketPacketManager.handle (C:\Users\Felix\Desktop\DISCORD BOT\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:103:65)
    at WebSocketConnection.onPacket (C:\Users\Felix\Desktop\DISCORD BOT\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:333:35)
    at WebSocketConnection.onMessage (C:\Users\Felix\Desktop\DISCORD BOT\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:296:17)
    at WebSocket.onMessage (C:\Users\Felix\Desktop\DISCORD BOT\node_modules\ws\lib\event-target.js:120:16)
Replace .setGame with .setActivity, https://discord.js.org/#/docs/main/stable/class/ClientUser?scrollTo=setActivity
 

FelixDev

Typical Developer and Designer
Premium
Feedback score
9
Posts
1,113
Reactions
331
Resources
0
Thanks, I jsuts taretd program these bots. Appricated bro <233[DOUBLEPOST=1535026020][/DOUBLEPOST]Well,
Tried got the same error.[DOUBLEPOST=1535026041][/DOUBLEPOST]
Code:
bot.setActivity('Watching L00ting')
    ^

TypeError: bot.setActivity is not a function
    at Object.<anonymous> (C:\Users\Felix\Desktop\DISCORD BOT\app.js:4:5)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:191:16)
    at bootstrap_node.js:612:3
 
Last edited:

Cole

Developer
Supreme
Feedback score
19
Posts
944
Reactions
477
Resources
0
bot.user.setGame('game here');

WARNING THIS IS DEPRECATED!
 

undoneacc

Premium
Feedback score
37
Posts
314
Reactions
225
Resources
0
https://discord.js.org/#/docs/main/stable/class/Client -- I would recommend looking through here to find the method to set the game.

As you can see, setActivity and setGame aren't methods. In fact, it's nothing to do with the client object, but the User object within the client.

Look into user#setPresence ;)

EDIT: Cole -> this is the now, none-deprecated way!
 

FelixDev

Typical Developer and Designer
Premium
Feedback score
9
Posts
1,113
Reactions
331
Resources
0
Code:
bot.login(')
bot.on('ready', () => {
  console.log('Bot started')
  bot.user.setActivity(L00ting, {type: "WATCHING"}

});

This should work. The "Watching" status is the type of presence, such as Online and Streaming.
Code:
C:\Users\Felix\Desktop\DISCORD BOT\app.js:7
  bot.user.setActivity(L00ting, {type: "WATCHING"}
                                                 ^

SyntaxError: missing ) after argument list
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:616:28)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:191:16)
    at bootstrap_node.js:612:3
 

Cole

Developer
Supreme
Feedback score
19
Posts
944
Reactions
477
Resources
0
Code:
C:\Users\Felix\Desktop\DISCORD BOT\app.js:7
  bot.user.setActivity(L00ting, {type: "WATCHING"}
                                                 ^

SyntaxError: missing ) after argument list
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:616:28)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:191:16)
    at bootstrap_node.js:612:3


missing ) after argument list
Try to understand the error, you can see it says missing ). So that means there is a missing ). Think English, in English you would use an open bracket AND a closing bracket. Not just an open bracket, so that means you need a extra ) as you never closed it.

Instead of asking, try to understand yourself first
 

FelixDev

Typical Developer and Designer
Premium
Feedback score
9
Posts
1,113
Reactions
331
Resources
0
missing ) after argument list
Try to understand the error, you can see it says missing ). So that means there is a missing ). Think English, in English you would use an open bracket AND a closing bracket. Not just an open bracket, so that means you need a extra ) as you never closed it.

Instead of asking, try to understand yourself first
Sorry I just saw that now, I got another problem tho.
Code:
bot.user.setActivity(L00ting, {type: "WATCHING"})
                       ^

ReferenceError: L00ting is not defined
    at Client.bot.on (C:\Users\Felix\Desktop\DISCORD BOT\app.js:7:24)
    at emitNone (events.js:111:20)
    at Client.emit (events.js:208:7)
    at WebSocketConnection.triggerReady (C:\Users\Felix\Desktop\DISCORD BOT\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:125:17)
    at WebSocketConnection.checkIfReady (C:\Users\Felix\Desktop\DISCORD BOT\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:141:61)
    at GuildCreateHandler.handle (C:\Users\Felix\Desktop\DISCORD BOT\node_modules\discord.js\src\client\websocket\packets\handlers\GuildCreate.js:13:31)
    at WebSocketPacketManager.handle (C:\Users\Felix\Desktop\DISCORD BOT\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:103:65)
    at WebSocketConnection.onPacket (C:\Users\Felix\Desktop\DISCORD BOT\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:333:35)
    at WebSocketConnection.onMessage (C:\Users\Felix\Desktop\DISCORD BOT\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:296:17)
    at WebSocket.onMessage (C:\Users\Felix\Desktop\DISCORD BOT\node_modules\ws\lib\event-target.js:120:16)
 

FelixDev

Typical Developer and Designer
Premium
Feedback score
9
Posts
1,113
Reactions
331
Resources
0

Scarger

Feedback score
9
Posts
68
Reactions
22
Resources
0
Sorry I just saw that now, I got another problem tho.
Code:
bot.user.setActivity(L00ting, {type: "WATCHING"})
                       ^

ReferenceError: L00ting is not defined
    at Client.bot.on (C:\Users\Felix\Desktop\DISCORD BOT\app.js:7:24)
    at emitNone (events.js:111:20)
    at Client.emit (events.js:208:7)
    at WebSocketConnection.triggerReady (C:\Users\Felix\Desktop\DISCORD BOT\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:125:17)
    at WebSocketConnection.checkIfReady (C:\Users\Felix\Desktop\DISCORD BOT\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:141:61)
    at GuildCreateHandler.handle (C:\Users\Felix\Desktop\DISCORD BOT\node_modules\discord.js\src\client\websocket\packets\handlers\GuildCreate.js:13:31)
    at WebSocketPacketManager.handle (C:\Users\Felix\Desktop\DISCORD BOT\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:103:65)
    at WebSocketConnection.onPacket (C:\Users\Felix\Desktop\DISCORD BOT\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:333:35)
    at WebSocketConnection.onMessage (C:\Users\Felix\Desktop\DISCORD BOT\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:296:17)
    at WebSocket.onMessage (C:\Users\Felix\Desktop\DISCORD BOT\node_modules\ws\lib\event-target.js:120:16)
You didn't put it in quotations. It's a string..
 

FelixDev

Typical Developer and Designer
Premium
Feedback score
9
Posts
1,113
Reactions
331
Resources
0
ffs
 

FelixDev

Typical Developer and Designer
Premium
Feedback score
9
Posts
1,113
Reactions
331
Resources
0

FelixDev

Typical Developer and Designer
Premium
Feedback score
9
Posts
1,113
Reactions
331
Resources
0
Status
This thread has been locked.
Top