#i need discord bot activity code
43 messages · Page 1 of 1 (latest)
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?
a server for what?
http
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
Discord.js is a powerful node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend.
that doesnt help at all to explain what you want
a http server that does what?
why does your bot need a http server
var http = require('http'); http.createServer(function (req, res) { res.write("I'm alive"); res.end(); }).listen(8080);
what purpose do you have for needing a http server on your bot?
shouldnt it be a separate thing from your bot
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
what is uptimebot and why do you need it?
import http from "http"
http.createServer((req, res) => {
res.write("I'm alive")
res.end()
}).listen(8080)
that code should look more like this
but "not working" could mean any number of things are wrong, such as how you're trying to run that code, etc
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!);
if you want the playing activity to be set when the bot starts up, then yes it goes inside there
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)
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
ok
this.client.on("ready", () => {
console.log(${this.client.user!.username} ready!)
client.user?.setActivity("stuff", { type: ActivityType.Playing })
})
something like that
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
ok