issue with /core

Its my first time trying core since I want to have a lightbuild gateway helper and I think I do something wrong? This is my current test script
const gateway = new WebSocketManager({
token: '',
intents: GatewayIntentBits.Guilds,
rest: GatewayManager.getRest(),
});

const client = new Client({rest: GatewayManager.getRest(), gateway});

client.once(GatewayDispatchEvents.Ready, this.onReady);
client.on(GatewayDispatchEvents.GuildCreate, this.onGuildCreate);
client.once(GatewayDispatchEvents.GuildDelete, this.onGuildDelete);

await gateway.connect();

const shards = await gateway.getShardIds();
for (const shardId of shards) {
await gateway.send(shardId, {
"op": 3,
"d": {
"activities": [{
"name": "We love casting spells | Memer.gg",
"type": 4
}],
"status": "online",
}
});
}
const gateway = new WebSocketManager({
token: '',
intents: GatewayIntentBits.Guilds,
rest: GatewayManager.getRest(),
});

const client = new Client({rest: GatewayManager.getRest(), gateway});

client.once(GatewayDispatchEvents.Ready, this.onReady);
client.on(GatewayDispatchEvents.GuildCreate, this.onGuildCreate);
client.once(GatewayDispatchEvents.GuildDelete, this.onGuildDelete);

await gateway.connect();

const shards = await gateway.getShardIds();
for (const shardId of shards) {
await gateway.send(shardId, {
"op": 3,
"d": {
"activities": [{
"name": "We love casting spells | Memer.gg",
"type": 4
}],
"status": "online",
}
});
}
The issue I see is that it dont set the status but I thought thats the way to do it? xD
7 Replies
d.js toolkit
d.js toolkit7mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
duck
duck7mo ago
<Client>.updatePresence() exists that being said, GatewayPresenceUpdateData objects should also have a couple more properties that you appear to be missing I'd also recommend still using the ActivityType enum (and the GatewayOpcodes enum if you really intend to continue manually sending payloads) for readability
sean
sean7mo ago
Ohh thanks I didnt found that in the docs sad new dogs is a little bit different Okay I moved that now in the ready event
async onReady({data: payload, api}) {
console.log(`(GATEWAY) => Shard ${payload.shard.join(', ')} is ready`);

if (GatewayManager.client) await GatewayManager.client.updatePresence(payload.shard[0], {
since: 91879201,
activities: [{
name: 'We love casting spells | Memer.gg',
type: ActivityType.Custom,
}],
status: PresenceUpdateStatus.Online,
afk: false
}).then(() => {
console.log(`(GATEWAY) => Shard ${payload.shard[0]} presence updated`);
});
}
async onReady({data: payload, api}) {
console.log(`(GATEWAY) => Shard ${payload.shard.join(', ')} is ready`);

if (GatewayManager.client) await GatewayManager.client.updatePresence(payload.shard[0], {
since: 91879201,
activities: [{
name: 'We love casting spells | Memer.gg',
type: ActivityType.Custom,
}],
status: PresenceUpdateStatus.Online,
afk: false
}).then(() => {
console.log(`(GATEWAY) => Shard ${payload.shard[0]} presence updated`);
});
}
the promise gets resolved but still no status ?
duck
duck7mo ago
just to clarify, when you say status are you referring to a custom status? your activity?
sean
sean7mo ago
I'm referring to the custom bot activity
duck
duck7mo ago
then that's also not the expected payload for a Custom type activity the actual text of the status is determined by the state property the name is required, but not displayed anywhere you may be used to discord.js automatically setting the state to the name if not present /core does not have this functionality
sean
sean7mo ago
I see that explains it thanks mate I try that Now it works, thanks for your help! Working with /core is pretty interesting !