Hi i have dev a little code for setup a activity for my bot so he dosen’t realy work how i want :
client.on("ready", () => {
var word = ["'the world', { type: 'WATCHING'}", "'with a cat', {type: 'PLAYING'}"];
let i = 0;
client.user.setActivity(word[0]);
i++;
setInterval(() => {
if (i >= word.length + 1) {
i = 0;
}
client.user.setActivity(word[i]);
i++;
}, 1000 * 15); // 30 = 30s || 1000 * 1 = 1s
});
the problem is on the bot he display “the world’, { type: ‘WATCHING’}” and not just “the world” and somme times he display nothing and the last thing :
if i add “client.user.setStatus(“dnd”);” nothing change on the status
Thanks a lot for your answers and sorry for my bad english.
var word = ["'the world', { type: 'WATCHING'}", "'with a cat', {type: 'PLAYING'}"];
Here, 'the world', { type: 'WATCHING'} is treated as on item of the array because you’ve surrounded both of these in double quotes, which results in both the items 'the world', { type: 'WATCHING'} being treated as one item.
the problem if i write this : var word = ['the world', { type: 'WATCHING'} , 'with a cat', {type: 'PLAYING'}];
witohout the double quotes he keep the playing he don’t change to watching so somme times is “playing the world”
im sorry i’m verry bad with JS
(and same somme time he show nothing, and the dnd whas fixed)
the tuto i see on guithub set the WATCHING in quotes :
but yeah a see what you whant to say,
I have set double quotes because I mean the problem whas the “comma”(sorry i don’t know if is this word for say “,”) : var word = ['the world', { type: 'WATCHING'} , 'with a cat', {type: 'PLAYING'}]; because you have 3 : 2 in the var and the midle comma for separate the 2 differents variables
I’m realy sorry to disturb you, but i’m verry bad with js i have add your code in mine :
i have a error at else :
else if (word[i] === “with a cat”) {
^^^^
SyntaxError: Unexpected token else
at Module._compile (internal/modules/cjs/loader.js:703:23)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:770:10)
at Module.load (internal/modules/cjs/loader.js:628:32)
at Function.Module._load (internal/modules/cjs/loader.js:555:12)
at Function.Module.runMain (internal/modules/cjs/loader.js:826:10)
at internal/main/run_main_module.js:17:11
this is clearly not m’y level in development is pretty hard for me
Okay so a lot of error :
last line : “}, 1000 * 15); // 30 = 30s || 1000 * 1 = 1s” need one more } after the first (my bad is on my code not on your but i have copy paste your code so is okay)
the two args need to be remplaced by “word” ?
after do this two thing :
{ type: ‘PLAYING’ }
^
SyntaxError: Unexpected token t in JSON at position 2
at JSON.parse (anonymous)
at Timeout._onTimeout (/app/server.js:37:42)
at listOnTimeout (internal/timers.js:531:17)
at processTimers (internal/timers.js:475:7)