When I run client.user.setActivity() in the ready script on terminal on my computer it works, but all of a sudden on Glitch it says it’s not a function?
Hi @GlitchMob04, welcome to the Glitch forum!
I’m moving this topic to the Discord Help category under the assumption that the client
you mention is for a Discord bot. If that’s not the case let us know.
As far as your specific issue is concerned, seeing more of your code would be helpful. Ideally you’d share your project name so that folks to take a look.
Yes, it’s a discord bot, and the code is quite simple, it just sets the bot’s ‘game’ when it starts, and here’s the code:
client.on("ready", () => {
console.log(`Bot: Hosting ${client.users.size} users, in ${client.channels.size} channels of ${client.guilds.size} guilds.`);
client.user.setActivity(`Use f!help.`);
});
And the error it gives me is that it’s not a function:
Bot: Hosting 34 users, in 40 channels of 1 guilds.
client.user.setActivity(`Use f!help.`);
^
TypeError: client.user.setActivity is not a function
at Client.client.on (/app/server.js:24:15)
at Client.emit (events.js:187:15)
MOD EDIT: formatting
You can use this
client.on('ready', () => {
console.log('Bot: Hosting ' + `${client.users.size}` + ' users, in ' + `${client.channels.size}` + ' channels of ' + `${client.guilds.size}` + ' guilds.');
client.user.setStatus('online')
client.user.setPresence({
game: {
name: 'Use f!help',
type: "Playing",
url: "https://discordapp.com/"
}
});
});
MOD EDIT: formatting
The following code should be the correct code. @PixelMania They had removed setPresence awhile back, so I do not think it would work unless he was using an earlier version!
client.on("ready", () => {
Use f!help.
client.user.setActivity(`Use f!help.`, {type: "playing"});
});
PixelMania’s code worked, but for some reason it insists that setActivity isn’t a function.
The current documentation seems to agree that setPresence
is current and setActivity
is no longer available.
What “f!help”?
Please explain. I’m just learning, sorry.
me need create bot
Err… that’s just text that appears as the status of the Discord bot. It doesn’t have anything to do with the implementation.
Thank you so much. May I ask another question? =_=
Sure, go ahead!
Very stupid but…
it works for me, but how it doesn’t work (https://www.youtube.com/watch?v=KZ7c0OXzg6k) forgive meее)))
client.on(“ready”, () => {
console.log(I'm online, my name is ${client.user.username}
);
client.user.setActivity("on your face", {
type: "WATCHING",
name: "itt"
});
why “setPresence” not worked?
setPresence
was removed in one of the discord.js updates and replaced with setActivity
I just don’t know where to start learning js and started with a bot. Is it correct or not?
Try Codecademy’s JS course
Useful TIP:
Try use url when are you using the WATCHING type, it will set the link, where you “stream”.
Isnt that for the STREAMING activity
That is for the WATCHING activity only. If you set the URL (example: twitch.tv/randomurl) it will set the WATCHING activity to STREAMING.
false
There is no streaming activity in the streaming activity, this is what i know yet.