#i need discord bot activity code

43 messages · Page 1 of 1 (latest)

versed scarab
#

can anyone provide me discord bot activity code and localhost code

tame elbow
#

what do you mean by activity code and localhost code? that doesn't really tell me what you want at all. are you using the discord.js library and want to achieve something specific using it?

versed scarab
#

i want playing activity on my bot

#

and a server

tame elbow
#

a server for what?

versed scarab
#

http

tame elbow
#

if you're using discord.js for your bot you can set the activity/playing status with client.user.setActivity("stuff", { type: ActivityType.Playing })

https://old.discordjs.dev/#/docs/discord.js/main/class/ClientUser?scrollTo=setActivity

tame elbow
#

a http server that does what?

#

why does your bot need a http server

versed scarab
#

var http = require('http'); http.createServer(function (req, res) { res.write("I'm alive"); res.end(); }).listen(8080);

tame elbow
#

what purpose do you have for needing a http server on your bot?

#

shouldnt it be a separate thing from your bot

versed scarab
#

to host 24 7 using uptimebot

#

var http = require('http'); http.createServer(function (req, res) { res.write("I'm alive"); res.end(); }).listen(8080); this is not working

#

in ts

tame elbow
#

what is uptimebot and why do you need it?

tame elbow
#

but "not working" could mean any number of things are wrong, such as how you're trying to run that code, etc

versed scarab
#

worked

#

where to add activity code in this this.client.on("ready", () => {
console.log(${this.client.user!.username} ready!);

#

this.client.on("ready", () => {
console.log(${this.client.user!.username} ready!);

tame elbow
#

if you want the playing activity to be set when the bot starts up, then yes it goes inside there

versed scarab
#

can you help i am not a coder

#

i am using someone else code

#

😅

tame elbow
#

in the line after the console.log you showed above, put this

#

client.user.setActivity("stuff", { type: ActivityType.Playing })

#

change stuff to whatever you want it to say in the status

#

if it complains that user might be undefined, then you'll need this instead:
client.user?.setActivity("stuff", { type: ActivityType.Playing })
(just an added question mark)

versed scarab
#

public constructor(public readonly client: Client) {
this.client.login(config.TOKEN);

this.client.on("ready", () => {
  console.log(// Set the client user's presence

client.user?.setActivity("stuff", { type: ActivityType.Playing })

#

error

#

not working

tame elbow
#

why did you delete the console.log

#

I said after the console.log

versed scarab
#

ok

tame elbow
#
this.client.on("ready", () => {
    console.log(${this.client.user!.username} ready!)
    client.user?.setActivity("stuff", { type: ActivityType.Playing })
})
#

something like that

versed scarab
#

thanks

#

@tame elbow

#

keep it up

tame elbow
#

any reason you're trying to modify this bot when you dont understand the basics of the typescript language yet btw? seems like if you want to learn programming you should start from the basics, not someone elses discord bot

versed scarab
#

ok