José
José
DIAdiscord.js - Imagine an app
Created by José on 7/10/2023 in #djs-questions
Pass variables into <ShardingManager>.broadcastEval
I have this code:
const params = {
guild_id: "",
channel_id: "",
shard_id: 0
}

// @ts-ignore
const result = await manager.broadcastEval(async (client: CustomClient) => {
const guild = client.guilds.cache.get(params.guild_id)
const channel = guild?.channels.cache.get(params.channel_id);

return channel?.id

}, { shard: params.shard_id });

console.log(result);
const params = {
guild_id: "",
channel_id: "",
shard_id: 0
}

// @ts-ignore
const result = await manager.broadcastEval(async (client: CustomClient) => {
const guild = client.guilds.cache.get(params.guild_id)
const channel = guild?.channels.cache.get(params.channel_id);

return channel?.id

}, { shard: params.shard_id });

console.log(result);
But i get the following error when i run this code:
Error [ReferenceError]: msg is not defined
at eval (eval at _eval (/media/cleiton/Arquivos/Pastas/Documentos/Projetos/bot/api/node_modules/discord.js/src/client/Client.js:482:12), <anonymous>:2:55)
Error [ReferenceError]: msg is not defined
at eval (eval at _eval (/media/cleiton/Arquivos/Pastas/Documentos/Projetos/bot/api/node_modules/discord.js/src/client/Client.js:482:12), <anonymous>:2:55)
So i want to know... How can i pass the variable params to the broadcastEval? With the vanilla javascript eval i can pass the variables into strings, but how can i do in shardingManager?
4 replies
DIAdiscord.js - Imagine an app
Created by José on 5/26/2023 in #djs-questions
Not enough sessions remaining to spawn 1 shards; only 0 remaining;
command: ts-node-dev --respawn --transpile-only main.ts when I start the command I am getting this error when authenticating the bot with discord, with <Client>.login, I searched about this error, and what I saw this happens with those who use shardmanager, but I do not use it... I imagine that maybe it's the ts-node-dev auto-restart, how can I prevent that?
Error: Not enough sessions remaining to spawn 1 shards; only 0 remaining; resets at 2023-05-26T13:00:44.213Z
at WebSocketManager.connect (E:\bot\node_modules\@discordjs\ws\src\ws\WebSocketManager.ts:298:10)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at WebSocketManager.connect (E:\bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:206:5)
at Bot.login (E:\bot\node_modules\discord.js\src\client\Client.js:226:7)
[ERROR] 23:33:14 Error: Not enough sessions remaining to spawn 1 shards; only 0 remaining; resets at 2023-05-26T13:00:44.213Z
Error: Not enough sessions remaining to spawn 1 shards; only 0 remaining; resets at 2023-05-26T13:00:44.213Z
at WebSocketManager.connect (E:\bot\node_modules\@discordjs\ws\src\ws\WebSocketManager.ts:298:10)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at WebSocketManager.connect (E:\bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:206:5)
at Bot.login (E:\bot\node_modules\discord.js\src\client\Client.js:226:7)
[ERROR] 23:33:14 Error: Not enough sessions remaining to spawn 1 shards; only 0 remaining; resets at 2023-05-26T13:00:44.213Z
6 replies
DIAdiscord.js - Imagine an app
Created by José on 5/18/2023 in #djs-questions
shadow reply an interaction
How can I tell discord that the interaction was responded to without actually using the response functions? I have a command that I have to send the message in the person's DM, but later I send it, that message appears that the BOT did not respond... How can I avoid this?
9 replies
DIAdiscord.js - Imagine an app
Created by José on 5/14/2023 in #djs-questions
[TypeScript] - The VS Code alert a ghost error when i inset a ActionRow in message components array
Firstly, the code:
const button = new ButtonBuilder()
.setCustomId("test")
.setStyle(ButtonStyle.Success)
.setLabel("Test")

const row = new ActionRowBuilder().addComponents([button]);

await int.reply({ components: [row] });
const button = new ButtonBuilder()
.setCustomId("test")
.setStyle(ButtonStyle.Success)
.setLabel("Test")

const row = new ActionRowBuilder().addComponents([button]);

await int.reply({ components: [row] });
Well... I'm making a bot with Typescript, but even when i insert a actionrow in the components array the vs code show me this error:
Type 'ActionRowBuilder<AnyComponentBuilder>' cannot be assigned to type 'APIActionRowComponent<APIMessageActionRowComponent> | JSONEncodable<APIActionRowComponent<APIMessageActionRowComponent>> | ActionRowData<...>'.
The 'type' property is absent in type 'ActionRowBuilder<AnyComponentBuilder>', but is required in type 'ActionRowData<MessageActionRowComponentData | MessageActionRowComponentBuilder>'.ts(2322)
Type 'ActionRowBuilder<AnyComponentBuilder>' cannot be assigned to type 'APIActionRowComponent<APIMessageActionRowComponent> | JSONEncodable<APIActionRowComponent<APIMessageActionRowComponent>> | ActionRowData<...>'.
The 'type' property is absent in type 'ActionRowBuilder<AnyComponentBuilder>', but is required in type 'ActionRowData<MessageActionRowComponentData | MessageActionRowComponentBuilder>'.ts(2322)
The command run without problems, but i get this error in vs code... How can i solve this? (Whitout using @ts-ignore. please) discord.js version: 14.11.0 node.js version: 18.3.0
5 replies